Initial commit
[mono.git] / mcs / class / referencesource / System / compmod / system / componentmodel / design / serialization / DesignerLoader.cs
1 //------------------------------------------------------------------------------
2 // <copyright file="DesignerLoader.cs" company="Microsoft">
3 //     Copyright (c) Microsoft Corporation.  All rights reserved.
4 // </copyright>                                                                
5 //------------------------------------------------------------------------------
6
7 namespace System.ComponentModel.Design.Serialization {
8
9     using System;
10     using System.Reflection;
11     using System.Security.Permissions;
12
13     /// <devdoc>
14     ///     DesignerLoader.  This class is responsible for loading a designer document.  
15     ///     Where and how this load occurs is a private matter for the designer loader.
16     ///     The designer loader will be handed to an IDesignerHost instance.  This instance, 
17     ///     when it is ready to load the document, will call BeginLoad, passing an instance
18     ///     of IDesignerLoaderHost.  The designer loader will load up the design surface
19     ///     using the host interface, and call EndLoad on the interface when it is done.
20     ///     The error collection passed into EndLoad should be empty or null to indicate a
21     ///     successful load, or it should contain a collection of exceptions that 
22     ///     describe the error.
23     ///
24     ///     Once a document is loaded, the designer loader is also responsible for
25     ///     writing any changes made to the document back whatever storage the
26     ///     loader used when loading the document.  
27     /// </devdoc>
28     [HostProtection(SharedState = true)]
29     [System.Security.Permissions.PermissionSetAttribute(System.Security.Permissions.SecurityAction.InheritanceDemand, Name = "FullTrust")]
30     [System.Runtime.InteropServices.ComVisible(true)]
31     public abstract class DesignerLoader {
32
33         /// <devdoc>
34         ///     Returns true when the designer is in the process of loading.  Clients that are
35         ///     sinking notifications from the designer often want to ignore them while the desingner is loading
36         ///     and only respond to them if they result from user interatcions.
37         /// </devdoc>
38         public virtual bool Loading {
39             get {
40                 return false;
41             }
42         }
43     
44         /// <devdoc>
45         ///     Called by the designer host to begin the loading process.  The designer
46         ///     host passes in an instance of a designer loader host (which is typically
47         ///     the same object as the designer host.  This loader host allows
48         ///     the designer loader to reload the design document and also allows
49         ///     the designer loader to indicate that it has finished loading the
50         ///     design document.
51         /// </devdoc>
52         public abstract void BeginLoad(IDesignerLoaderHost host);
53         
54         /// <devdoc>
55         ///     Disposes this designer loader.  The designer host will call this method
56         ///     when the design document itself is being destroyed.  Once called, the
57         ///     designer loader will never be called again.
58         /// </devdoc>
59         public abstract void Dispose();
60         
61         /// <devdoc>
62         ///     The designer host will call this periodically when it wants to
63         ///     ensure that any changes that have been made to the document
64         ///     have been saved by the designer loader.  This method allows
65         ///     designer loaders to implement a lazy-write scheme to improve
66         ///     performance.  The default implementation does nothing.
67         /// </devdoc>
68         public virtual void Flush() {}
69     }
70 }
71