Пример #1
0
        //------------------------------------------------------------------------------
        public static object GetPluginHelper(Type pluginInterfaceType, IPluginContext context)
        {
            var pluginObjectType = InternalConfiguration.Plugins[pluginInterfaceType];

            SettingsBasePlugin pluginObject = (SettingsBasePlugin)Activator.CreateInstance(pluginObjectType);

            pluginObject.Context = context;

            return(pluginObject);
        }
Пример #2
0
        //------------------------------------------------------------------------------
        public static PLUGIN_INTERFACE_TYPE GetPluginHelper <PLUGIN_INTERFACE_TYPE>(IPluginContext context)
        {
            var pluginInterfaceType = typeof(PLUGIN_INTERFACE_TYPE);
            var pluginObjectType    = InternalConfiguration.Plugins[pluginInterfaceType];

            SettingsBasePlugin pluginObject = (SettingsBasePlugin)Activator.CreateInstance(pluginObjectType);

            pluginObject.Context = context;

            return((PLUGIN_INTERFACE_TYPE)(object)pluginObject);
        }
Пример #3
0
        //------------------------------------------------------------------------------
        void ProcessDynamicSettingsFromContext(SettingsBasePlugin sourcePlugin, IForegroundSerializerNotificationSink sink, Action <IDynamicSettingsPlugin> pluginAction)
        {
            var localDynamicSettings = GetObjectPlugin <Advexp.LocalDynamicSettings.Plugin.ILocalDynamicSettingsPlugin>();

            if (sink != null)
            {
                sink.OnStartDynamicSettingsSerialization(localDynamicSettings as SettingsBasePlugin);
            }

            pluginAction.Invoke(localDynamicSettings);

            if (sink != null)
            {
                sink.OnEndDynamicSettingsSerialization();
            }

            foreach (var pluginInterfaceType in EnumeratePluginTypes())
            {
                var internalPlugin        = GetPluginInternally(pluginInterfaceType);
                var dynamicSettingsPlugin = internalPlugin as IDynamicSettingsPlugin;
                if (dynamicSettingsPlugin != null)
                {
                    if (internalPlugin != sourcePlugin && internalPlugin != localDynamicSettings)
                    {
                        if (sink != null)
                        {
                            sink.OnStartDynamicSettingsPluginSerialization(internalPlugin as SettingsBasePlugin);
                        }

                        pluginAction.Invoke(dynamicSettingsPlugin);

                        if (sink != null)
                        {
                            sink.OnEndDynamicSettingsPluginSerialization();
                        }
                    }
                }
            }
        }
Пример #4
0
        //------------------------------------------------------------------------------
        void IPluginContext.DeleteSettings(ISettingsSerializer pluginForegroundSerializer, SettingsBasePlugin sourcePlugin)
        {
            try
            {
                SetForegroundSerializer(pluginForegroundSerializer);

                var sink = pluginForegroundSerializer as IForegroundSerializerNotificationSink;

                if (sink != null)
                {
                    sink.OnStartStaticSettingsSerialization(this);
                }

                DeleteObjectSettings();

                if (sink != null)
                {
                    sink.OnEndStaticSettingsSerialization();
                }

                ProcessDynamicSettingsFromContext(sourcePlugin, sink, (IDynamicSettingsPlugin plugin) => { plugin.DeleteSettings(); });
            }
            finally
            {
                SetForegroundSerializer(null);
            }
        }