The Labs \ Source Viewer \ SSCLI \ System.ComponentModel.Design.Serialization \ IDesignerSerializationManager

  1. //------------------------------------------------------------------------------
  2. // <copyright file="IDesignerSerializationManager.cs" company="Microsoft">
  3. //
  4. // Copyright (c) 2006 Microsoft Corporation. All rights reserved.
  5. //
  6. // The use and distribution terms for this software are contained in the file
  7. // named license.txt, which can be found in the root of this distribution.
  8. // By using this software in any fashion, you are agreeing to be bound by the
  9. // terms of this license.
  10. //
  11. // You must not remove this notice, or any other, from this software.
  12. //
  13. // </copyright>
  14. //------------------------------------------------------------------------------
  15. namespace System.ComponentModel.Design.Serialization
  16. {
  17.    
  18.     using System;
  19.     using System.Collections;
  20.     using System.ComponentModel;
  21.    
  22.     /// <devdoc>
  23.     /// This interface is passed to a designer serializer to provide
  24.     /// assistance in the serialization process.
  25.     /// </devdoc>
  26.     public interface IDesignerSerializationManager : IServiceProvider
  27.     {
  28.        
  29.         /// <devdoc>
  30.         /// The Context property provides a user-defined storage area
  31.         /// implemented as a stack. This storage area is a useful way
  32.         /// to provide communication across serializers, as serialization
  33.         /// is a generally hierarchial process.
  34.         /// </devdoc>
  35.         ContextStack Context {
  36.             get;
  37.         }
  38.        
  39.         /// <devdoc>
  40.         /// The Properties property provides a set of custom properties
  41.         /// the serialization manager may surface. The set of properties
  42.         /// exposed here is defined by the implementor of
  43.         /// IDesignerSerializationManager.
  44.         /// </devdoc>
  45.         PropertyDescriptorCollection Properties {
  46.             get;
  47.         }
  48.        
  49.         /// <devdoc>
  50.         /// ResolveName event. This event
  51.         /// is raised when GetName is called, but the name is not found
  52.         /// in the serialization manager's name table. It provides a
  53.         /// way for a serializer to demand-create an object so the serializer
  54.         /// does not have to order object creation by dependency. This
  55.         /// delegate is cleared immediately after serialization or deserialization
  56.         /// is complete.
  57.         /// </devdoc>
  58.         event ResolveNameEventHandler ResolveName;
  59.        
  60.         /// <devdoc>
  61.         /// This event is raised when serialization or deserialization
  62.         /// has been completed. Generally, serialization code should
  63.         /// be written to be stateless. Should some sort of state
  64.         /// be necessary to maintain, a serializer can listen to
  65.         /// this event to know when that state should be cleared.
  66.         /// An example of this is if a serializer needs to write
  67.         /// to another file, such as a resource file. In this case
  68.         /// it would be inefficient to design the serializer
  69.         /// to close the file when finished because serialization of
  70.         /// an object graph generally requires several serializers.
  71.         /// The resource file would be opened and closed many times.
  72.         /// Instead, the resource file could be accessed through
  73.         /// an object that listened to the SerializationComplete
  74.         /// event, and that object could close the resource file
  75.         /// at the end of serialization.
  76.         /// </devdoc>
  77.         event EventHandler SerializationComplete;
  78.        
  79.         /// <devdoc>
  80.         /// This method adds a custom serialization provider to the
  81.         /// serialization manager. A custom serialization provider will
  82.         /// get the opportunity to return a serializer for a data type
  83.         /// before the serialization manager looks in the type's
  84.         /// metadata.
  85.         /// </devdoc>
  86.         void AddSerializationProvider(IDesignerSerializationProvider provider);
  87.        
  88.         /// <devdoc>
  89.         /// Creates an instance of the given type and adds it to a collection
  90.         /// of named instances. Objects that implement IComponent will be
  91.         /// added to the design time container if addToContainer is true.
  92.         /// </devdoc>
  93.         object CreateInstance(Type type, ICollection arguments, string name, bool addToContainer);
  94.        
  95.         /// <devdoc>
  96.         /// Retrieves an instance of a created object of the given name, or
  97.         /// null if that object does not exist.
  98.         /// </devdoc>
  99.         object GetInstance(string name);
  100.        
  101.         /// <devdoc>
  102.         /// Retrieves a name for the specified object, or null if the object
  103.         /// has no name.
  104.         /// </devdoc>
  105.         string GetName(object value);
  106.        
  107.         /// <devdoc>
  108.         /// Retrieves a serializer of the requested type for the given
  109.         /// object type.
  110.         /// </devdoc>
  111.         object GetSerializer(Type objectType, Type serializerType);
  112.        
  113.         /// <devdoc>
  114.         /// Retrieves a type of the given name.
  115.         /// </devdoc>
  116.         Type GetType(string typeName);
  117.        
  118.         /// <devdoc>
  119.         /// Removes a previously added serialization provider.
  120.         /// </devdoc>
  121.         void RemoveSerializationProvider(IDesignerSerializationProvider provider);
  122.        
  123.         /// <devdoc>
  124.         /// Reports a non-fatal error in serialization. The serialization
  125.         /// manager may implement a logging scheme to alert the caller
  126.         /// to all non-fatal errors at once. If it doesn't, it should
  127.         /// immediately throw in this method, which should abort
  128.         /// serialization.
  129.         /// Serialization may continue after calling this function.
  130.         /// </devdoc>
  131.         void ReportError(object errorInformation);
  132.        
  133.         /// <devdoc>
  134.         /// Provides a way to set the name of an existing object.
  135.         /// This is useful when it is necessary to create an
  136.         /// instance of an object without going through CreateInstance.
  137.         /// An exception will be thrown if you try to rename an existing
  138.         /// object or if you try to give a new object a name that
  139.         /// is already taken.
  140.         /// </devdoc>
  141.         void SetName(object instance, string name);
  142.     }
  143. }

Developer Fusion