public static SerializerDescriptor CreateFromFactoryInstance(ISerializerFactory factoryInstance)
        {
            Contract.Ensures(!string.IsNullOrEmpty(factoryInstance.GetType().FullName));
            Contract.Ensures(Contract.Result <System.Windows.Documents.Serialization.SerializerDescriptor>() != null);
            Contract.Ensures(factoryInstance.GetType().Assembly != null);
            Contract.Ensures(factoryInstance.GetType().Assembly.FullName != null);
            Contract.Ensures(factoryInstance.GetType().Assembly.GetName() != null);
            Contract.Ensures(factoryInstance.GetType().Assembly.Location != null);

            return(default(SerializerDescriptor));
        }
    public static SerializerDescriptor CreateFromFactoryInstance(ISerializerFactory factoryInstance)
    {
      Contract.Ensures(!string.IsNullOrEmpty(factoryInstance.GetType().FullName));
      Contract.Ensures(Contract.Result<System.Windows.Documents.Serialization.SerializerDescriptor>() != null);
      Contract.Ensures(factoryInstance.GetType().Assembly != null);
      Contract.Ensures(factoryInstance.GetType().Assembly.FullName != null);
      Contract.Ensures(factoryInstance.GetType().Assembly.GetName() != null);
      Contract.Ensures(factoryInstance.GetType().Assembly.Location != null);

      return default(SerializerDescriptor);
    }
示例#3
0
        public static SerializerDescriptor CreateFromFactoryInstance(
            ISerializerFactory factoryInstance
            )
        {
            SecurityHelper.DemandPlugInSerializerPermissions();

            if (factoryInstance == null)
            {
                throw new ArgumentNullException("factoryInstance");
            }
            if (factoryInstance.DisplayName == null)
            {
                throw new ArgumentException(SR.Get(SRID.SerializerProviderDisplayNameNull));
            }
            if (factoryInstance.ManufacturerName == null)
            {
                throw new ArgumentException(SR.Get(SRID.SerializerProviderManufacturerNameNull));
            }
            if (factoryInstance.ManufacturerWebsite == null)
            {
                throw new ArgumentException(SR.Get(SRID.SerializerProviderManufacturerWebsiteNull));
            }
            if (factoryInstance.DefaultFileExtension == null)
            {
                throw new ArgumentException(SR.Get(SRID.SerializerProviderDefaultFileExtensionNull));
            }

            SerializerDescriptor sd = new SerializerDescriptor();

            sd._displayName          = factoryInstance.DisplayName;
            sd._manufacturerName     = factoryInstance.ManufacturerName;
            sd._manufacturerWebsite  = factoryInstance.ManufacturerWebsite;
            sd._defaultFileExtension = factoryInstance.DefaultFileExtension;

            // When this is called with an instantiated factory object, it must be loadable
            sd._isLoadable = true;

            Type factoryType = factoryInstance.GetType();

            sd._assemblyName         = factoryType.Assembly.FullName;
            sd._assemblyPath         = factoryType.Assembly.Location;
            sd._assemblyVersion      = factoryType.Assembly.GetName().Version;
            sd._factoryInterfaceName = factoryType.FullName;
            sd._winFXVersion         = typeof(System.Windows.Controls.Button).Assembly.GetName().Version;

            return(sd);
        }
        public static SerializerDescriptor CreateFromFactoryInstance(ISerializerFactory factoryInstance)
        {
            SecurityHelper.DemandPlugInSerializerPermissions();
            if (factoryInstance == null)
            {
                throw new ArgumentNullException("factoryInstance");
            }
            if (factoryInstance.DisplayName == null)
            {
                throw new ArgumentException(SR.Get("SerializerProviderDisplayNameNull"));
            }
            if (factoryInstance.ManufacturerName == null)
            {
                throw new ArgumentException(SR.Get("SerializerProviderManufacturerNameNull"));
            }
            if (factoryInstance.ManufacturerWebsite == null)
            {
                throw new ArgumentException(SR.Get("SerializerProviderManufacturerWebsiteNull"));
            }
            if (factoryInstance.DefaultFileExtension == null)
            {
                throw new ArgumentException(SR.Get("SerializerProviderDefaultFileExtensionNull"));
            }
            SerializerDescriptor serializerDescriptor = new SerializerDescriptor();

            serializerDescriptor._displayName          = factoryInstance.DisplayName;
            serializerDescriptor._manufacturerName     = factoryInstance.ManufacturerName;
            serializerDescriptor._manufacturerWebsite  = factoryInstance.ManufacturerWebsite;
            serializerDescriptor._defaultFileExtension = factoryInstance.DefaultFileExtension;
            serializerDescriptor._isLoadable           = true;
            Type type = factoryInstance.GetType();

            serializerDescriptor._assemblyName         = type.Assembly.FullName;
            serializerDescriptor._assemblyPath         = type.Assembly.Location;
            serializerDescriptor._assemblyVersion      = type.Assembly.GetName().Version;
            serializerDescriptor._factoryInterfaceName = type.FullName;
            serializerDescriptor._winFXVersion         = typeof(Button).Assembly.GetName().Version;
            return(serializerDescriptor);
        }
        /// <summary>
        /// Creates a SerializerDescriptor. The interface must be defined in the calling assembly 
        /// The WinFX version, and assembly name, and version are initialized by reflecting on the calling assembly 
        /// </summary>
        /// <remarks> 
        ///     Create a SerializerDescriptor from a ISerializerFactory instance
        ///
        ///     This method currently requires full trust to run.
        /// </remarks> 
        ///<SecurityNote>
        ///  The DemandPlugInSerializerPermissions() ensures that this method only works in full trust. 
        ///  Full trust is required, so that partial trust applications do not load or use potentially 
        ///  unsafe serializer plug ins
        ///</SecurityNote> 
        public static SerializerDescriptor CreateFromFactoryInstance(
            ISerializerFactory  factoryInstance
            )
        { 
            SecurityHelper.DemandPlugInSerializerPermissions();
 
            if (factoryInstance == null) 
            {
                throw new ArgumentNullException("factoryInstance"); 
            }
            if (factoryInstance.DisplayName == null)
            {
                throw new ArgumentException(SR.Get(SRID.SerializerProviderDisplayNameNull)); 
            }
            if (factoryInstance.ManufacturerName == null) 
            { 
                throw new ArgumentException(SR.Get(SRID.SerializerProviderManufacturerNameNull));
            } 
            if (factoryInstance.ManufacturerWebsite == null)
            {
                throw new ArgumentException(SR.Get(SRID.SerializerProviderManufacturerWebsiteNull));
            } 
            if (factoryInstance.DefaultFileExtension == null)
            { 
                throw new ArgumentException(SR.Get(SRID.SerializerProviderDefaultFileExtensionNull)); 
            }
 
            SerializerDescriptor sd = new SerializerDescriptor();

            sd._displayName = factoryInstance.DisplayName;
            sd._manufacturerName = factoryInstance.ManufacturerName; 
            sd._manufacturerWebsite = factoryInstance.ManufacturerWebsite;
            sd._defaultFileExtension = factoryInstance.DefaultFileExtension; 
 
            // When this is called with an instantiated factory object, it must be loadable
            sd._isLoadable = true; 

            Type factoryType = factoryInstance.GetType();
            sd._assemblyName = factoryType.Assembly.FullName;
            sd._assemblyPath = factoryType.Assembly.Location; 
            sd._assemblyVersion = factoryType.Assembly.GetName().Version;
            sd._factoryInterfaceName = factoryType.FullName; 
            sd._winFXVersion = typeof(System.Windows.Controls.Button).Assembly.GetName().Version; 

            return sd; 
        }