Exemplo n.º 1
0
        private IRegisteredEventsPluginHandler ThreadSafeGetOrCreateHandler()
        {
            if (_handler != null)
            {
                return(_handler);
            }

            if (_isIntialized)
            {
                return(_handler);
            }

            lock (_handlerLock)
            {
                if (_isIntialized)
                {
                    return(_handler);
                }

                var local = GetPluginHandler();
                local.SetConfigValues(UnsecureConfig, SecureConfig);
                local.RegisterEvents();
                _handler      = local;
                _isIntialized = true;
            }
            return(_handler);
        }
        /// <summary>
        /// Initializes the plugin properties.
        /// </summary>
        /// <param name="context">The context.</param>
        /// <param name="plugin">The plugin.</param>
        private void InitializePluginProperties(IPluginExecutionContext context, IRegisteredEventsPluginHandler plugin)
        {
            // Iterate over all of the expected registered events to ensure that the plugin
            // has been invoked by an expected event
            // For any given plug-in event at an instance in time, we would expect at most 1 result to match.
            Event = plugin.RegisteredEvents.FirstOrDefault(a =>
                                                           (int)a.Stage == context.Stage &&
                                                           a.MessageName == context.MessageName &&
                                                           (string.IsNullOrWhiteSpace(a.EntityLogicalName) || a.EntityLogicalName == context.PrimaryEntityName)
                                                           );

            PluginTypeName = plugin.GetType().FullName;
        }
        /// <summary>
        /// Initializes a new instance of the <see cref="DLaBExtendedPluginContextBase"/> class.
        /// </summary>
        /// <param name="serviceProvider">The service provider.</param>
        /// <param name="plugin">The plugin.</param>
        /// <exception cref="System.ArgumentNullException">
        /// serviceProvider
        /// or
        /// plugin
        /// </exception>
        public DLaBExtendedPluginContextBase(IServiceProvider serviceProvider, IRegisteredEventsPluginHandler plugin)
        {
            if (serviceProvider == null)
            {
                throw new ArgumentNullException(nameof(serviceProvider));
            }

            if (plugin == null)
            {
                throw new ArgumentNullException(nameof(plugin));
            }

            InitializeServiceProviderProperties(serviceProvider);
            InitializePluginProperties(PluginExecutionContext, plugin);
        }
        /// <summary>
        /// Initializes a new instance of the <see cref="LocalPluginContextBase"/> class.
        /// </summary>
        /// <param name="serviceProvider">The service provider.</param>
        /// <param name="plugin">The plugin.</param>
        /// <exception cref="System.ArgumentNullException">
        /// serviceProvider
        /// or
        /// plugin
        /// </exception>
        protected LocalPluginContextBase(IServiceProvider serviceProvider, IRegisteredEventsPluginHandler plugin)
        {
            if (serviceProvider == null)
            {
                throw new ArgumentNullException("serviceProvider");
            }

            if (plugin == null)
            {
                throw new ArgumentNullException("plugin");
            }

            InitializeServiceProviderProperties(serviceProvider);
            InitializePluginProperties(PluginExecutionContext, plugin);
        }
 public LocalPluginContext(IServiceProvider serviceProvider, IRegisteredEventsPluginHandler plugin)
     : base(serviceProvider, plugin)
 {
 }
 /// <summary>
 /// Initializes the plugin properties.
 /// </summary>
 /// <param name="context">The context.</param>
 /// <param name="plugin">The plugin.</param>
 private void InitializePluginProperties(IPluginExecutionContext context, IRegisteredEventsPluginHandler plugin)
 {
     Event          = context.GetEvent(plugin.RegisteredEvents);
     IsolationMode  = (IsolationMode)context.IsolationMode;
     PluginTypeName = plugin.GetType().FullName;
 }
Exemplo n.º 7
0
 public LocalPluginContext(IServiceProvider serviceProvider, IRegisteredEventsPluginHandler plugin) : base(serviceProvider, plugin)
 {
 }