예제 #1
0
        /// <summary>
        /// Loads the state of the plugin and initializes the the programs. In most hosts, this will
        /// be called when the plugin first loads.
        /// </summary>
        /// <param name="stream">
        /// Stream containing an object graph which contains the state of the program. The root of
        /// this object graph should have the same type specified by SerializableRootType
        /// </param>
        /// <param name="programs">This collection must be populated with new VstPrograms unless it
        /// is null.</param>
        public void ReadPrograms(Stream stream, VstProgramCollection programs)
        {
            Control mainThreadHandel = getMainThreadHandel();

            if (mainThreadHandel != null && mainThreadHandel.InvokeRequired)
            {
                mainThreadHandel.Invoke(new Action <Stream, VstProgramCollection>(ReadPrograms), stream, programs);
                return;
            }

            if (BeforePluginDeserialized != null)
            {
                BeforePluginDeserialized();
            }

            SerializableRootType deserializedRoot;

            deserializedRoot = ContractSerializer.Deserialize <SerializableRootType>(stream);

            if (programs != null)
            {
                programs.AddRange(this.pluginPrograms.CreatePrograms());
            }

            if (PluginDeserialized != null)
            {
                PluginDeserialized(deserializedRoot);
            }

            Logger.Info(21, string.Format("Finished loading new program: {0}", deserializedRoot.ToString()));
        }
        protected override void LoadSettingsFromFileStream(System.IO.FileStream fs)
        {
            IBaseGraphableMappingManager activeMappingManager = activeMappingInfo.GetActiveGraphableEntryManager();

            activeMappingManager.RunFuncOnMappingEntry(activeMappingInfo.ActiveGraphableEntryId, (mappingEntry) =>
                                                       mappingEntry.CurveShapeInfo = ContractSerializer.Deserialize <CurveShapeInfo>(fs));
        }
예제 #3
0
        public void ReadFromDisk(string in_filename)
        {
            Type type = typeof(SerializableDictionary <string, EntityCollection>);

            // not sure if this behavior is good - we read file if it exists, otherwise we
            // don't worry about it.
            if (File.Exists(in_filename))
            {
                FileStream fs = new FileStream(in_filename, FileMode.Open, FileAccess.Read);
                try {
                    Microsoft.Xrm.Sdk.KnownTypesResolver resolver = new Microsoft.Xrm.Sdk.KnownTypesResolver();
                    data = (SerializableDictionary <string, EntityCollection>)ContractSerializer.Deserialize(type, fs, resolver);
                }
                finally { fs.Close(); }
            }
        }