public static Growl.Destinations.DestinationSettingsPanel GetSettingsPanel(Subscription s)
        {
            ISubscriptionHandler handler = GetHandler(s);

            Growl.Destinations.DestinationSettingsPanel panel = handler.GetSettingsPanel(s);
            return(panel);
        }
Ejemplo n.º 2
0
        private static void LoadFolder(string folder)

        {
            try

            {
                if (!loadedPlugins.ContainsKey(folder))

                {
                    PluginFinder pf = new PluginFinder();

                    ISubscriptionHandler plugin = pf.Search <ISubscriptionHandler>(folder, CheckType, ignoreList);

                    if (plugin != null)

                    {
                        Type type = plugin.GetType();

                        PluginInfo pi = new PluginInfo(folder, type);



                        LoadPlugin(pi, plugin);
                    }
                }
            }

            catch (Exception ex)

            {
                // suppress any per-plugin loading exceptions

                Utility.WriteDebugInfo(String.Format("Plugin failed to load: '{0}' - {1} - {2}", folder, ex.Message, ex.StackTrace));
            }
        }
Ejemplo n.º 3
0
        public IEnumerable <ISubscriptionHandler> GetHandlers(ModifiedFileModel modifiedFile)
        {
            List <ISubscriptionHandler> subscriptionHandlers = new List <ISubscriptionHandler>();
            HandlerResolver             resolver             = new HandlerResolver(this);

            foreach (Subscription subscription in GetSubscriptions(modifiedFile))
            {
                try
                {
                    var parameterSubstitutions = new Dictionary <string, string>
                    {
                        { "<trigger-repo>", modifiedFile.RepoName },
                        { "<trigger-branch>", modifiedFile.BranchName },
                        { "<trigger-path>", modifiedFile.FullPath },
                        { "<trigger-commit>", modifiedFile.CommitId }
                    };

                    ISubscriptionHandler subscriptionHandler = resolver.Resolve(subscription, parameterSubstitutions);
                    subscriptionHandlers.Add(subscriptionHandler);
                }
                catch (Exception e)
                {
                    Trace.TraceError(e.Message);
                }
            }

            return(subscriptionHandlers);
        }
 private static void LoadBuiltIn(ISubscriptionHandler sh)
 {
     if (sh != null)
     {
         string path = Path.Combine(userSubscriberDirectory, Growl.CoreLibrary.PathUtility.GetSafeFolderName(sh.Name));
         LoadInternal(sh, null, path);
     }
 }
Ejemplo n.º 5
0
 public SubscriptionInfo(Type pSubType, Type pUnSubType, Type pNotifyType, ISubscriptionHandler pHandler)
 {
     SubType     = pSubType;
     UnSubType   = pUnSubType;
     NotifyType  = pNotifyType;
     HandlerType = pHandler.GetType();
     Handler     = pHandler;
 }
Ejemplo n.º 6
0
        public IThreadSubscriptionBuilder <TPayload> Invoke(ISubscriptionHandler <TPayload> handler)
        {
            Assert.ArgumentNotNull(handler, nameof(handler));

            ValidateDoesNotHaveAction();
            _actionReference = new SubscriptionHandlerActionReference <TPayload>(handler);
            return(this);
        }
Ejemplo n.º 7
0
 /// <summary>
 /// Create a new DeviceHandlerBase
 /// </summary>
 /// <param name="deviceDescriptor">The descriptor describing the device</param>
 /// <param name="deviceEmptyHandler">An eventhandler to fire when the device can be removed</param>
 /// <param name="bindModeHandler">The event handler to fire when there is a Bind Mode event</param>
 protected DeviceHandlerBase(DeviceDescriptor deviceDescriptor, EventHandler <DeviceDescriptor> deviceEmptyHandler, EventHandler <BindModeUpdate> bindModeHandler)
 {
     _processUpdates     = ProcessSubscriptionModeUpdates;
     BindModeUpdate      = bindModeHandler;
     DeviceDescriptor    = deviceDescriptor;
     _deviceEmptyHandler = deviceEmptyHandler;
     SubHandler          = new SubscriptionHandler(deviceDescriptor, OnDeviceEmpty, CallbackHandler);
 }
 public NodeRepublishSubscriptionHandler(ISubscriptionHandler <TPayload> inner, IPubSubBus messageBus, string nodeKey, string outputTopic, string errorTopic)
 {
     _inner       = inner;
     _messageBus  = messageBus;
     _nodeKey     = nodeKey;
     _outputTopic = outputTopic;
     _errorTopic  = errorTopic;
 }
 public PiCalcMessageSubscriber(
     IBusClient busClient,
     IPiCalcService piCalcService,
     ISubscriptionHandler subscriptionHandler) : base(busClient)
 {
     this.busClient           = busClient;
     this.piCalcService       = piCalcService;
     this.subscriptionHandler = subscriptionHandler;
 }
Ejemplo n.º 10
0
        private static void LoadInternal(ISubscriptionHandler ish, string installPath, string settingsPath)

        {
            string name = null;

            try

            {
                if (ish != null)

                {
                    name = ish.Name;



                    loadedHandlersList.Add(ish);



                    List <Type> list = ish.Register();

                    foreach (Type type in list)

                    {
                        if (typeof(Subscription).IsAssignableFrom(type))

                        {
                            if (!loadedTypes.ContainsKey(type))

                            {
                                lock (loadedTypes)

                                {
                                    if (!loadedTypes.ContainsKey(type))

                                    {
                                        loadedTypes.Add(type, ish);
                                    }
                                }
                            }
                        }
                    }



                    Utility.WriteDebugInfo(String.Format("Subscriber '{0}' was loaded successfully", name));
                }
            }

            catch (Exception ex)

            {
                // suppress any per-plugin loading exceptions

                Utility.WriteDebugInfo(String.Format("Subscriber failed to load: '{0}' - {1} - {2}", name, ex.Message, ex.StackTrace));
            }
        }
Ejemplo n.º 11
0
        public T GetSubscriptionHandler <T>()
        {
            var objInfo = SubscriptionHandlers.FirstOrDefault(s => s.HandlerType.Equals(typeof(T)));
            ISubscriptionHandler objHandler = null;

            if (objInfo != null)
            {
                objHandler = objInfo.Handler;
            }
            return((T)objHandler);
        }
Ejemplo n.º 12
0
        public SubscriptionHelper(DeviceDescriptor?deviceDescriptor = null)
        {
            if (deviceDescriptor == null)
            {
                deviceDescriptor = new DeviceDescriptor {
                    DeviceHandle = "Test Device"
                };
            }

            Device     = (DeviceDescriptor)deviceDescriptor;
            SubHandler = new Hidwizards.IOWrapper.Libraries.SubscriptionHandlers.SubscriptionHandler(Device, EmptyHandler, CallbackHandler);
            ClearCallbacks();
            DeviceEmptyResults = new List <DeviceDescriptor>();
        }
        public async Task Handle <TCommand>(TCommand command)
        {
            this.logger.LogInformation("Message Received: {@Message}", command);
            using var scope = this.serviceProvider.CreateScope();

            ISubscriptionHandler <TCommand> handler = scope.ServiceProvider.GetRequiredService <ISubscriptionHandler <TCommand> >();

            try
            {
                await handler.Handle(command).ConfigureAwait(false);
            }
            catch (Exception e)
            {
                this.logger.LogError(e, "Message handler failed");
            }
        }
Ejemplo n.º 14
0
            public IEnumerable <ISubscriptionHandler> GetHandlers(ModifiedFileModel modifiedFile)
            {
                List <ISubscriptionHandler> subscriptionHandlers = new List <ISubscriptionHandler>();
                HandlerResolver             resolver             = new HandlerResolver(this);

                foreach (HandlerObject handlerObject in GetHandlerObjects(modifiedFile))
                {
                    ISubscriptionHandler subscriptionHandler = resolver.Resolve(handlerObject);
                    if (subscriptionHandler != null)
                    {
                        subscriptionHandlers.Add(subscriptionHandler);
                    }
                }

                return(subscriptionHandlers);
            }
        private static void LoadPlugin(PluginInfo pi, ISubscriptionHandler ish)
        {
            try
            {
                // load if not already loaded
                if (ish == null)
                {
                    PluginFinder pf = new PluginFinder();
                    ish = pf.Load <ISubscriptionHandler>(pi, ignoreList);
                }

                if (ish != null)
                {
                    // for the 'path' value, we still want to use the userprofile directory no matter where the plugin was loaded from
                    // the reason is that the 'path' is where plugin settings will be saved, so it needs to be user writable and user-specific
                    string path = Path.Combine(userSubscriberDirectory, Growl.CoreLibrary.PathUtility.GetSafeFolderName(ish.Name));

                    // check to make sure this plugin was not loaded from another directory already
                    if (!loadedPlugins.ContainsKey(path))
                    {
                        loadedPlugins.Add(pi.FolderPath, pi);
                        if (!loadedPlugins.ContainsKey(path))
                        {
                            loadedPlugins.Add(path, pi);                                   // link by the settings path as well so we can detect duplicate plugins in other folders
                        }
                        loadedPluginsList.Add(pi);

                        LoadInternal(ish, pi.FolderPath, path);
                    }
                    else
                    {
                        // plugin was not valid
                        Utility.WriteDebugInfo(String.Format("Subscriber not loaded: '{0}' - Duplicate plugin was already loaded from another folder", pi.FolderPath));
                    }
                }
                else
                {
                    // plugin was not valid
                    Utility.WriteDebugInfo(String.Format("Subscriber not loaded: '{0}' - Does not implement ISubscriptionHandler interface", pi.FolderPath));
                }
            }
            catch (Exception ex)
            {
                // suppress any per-plugin loading exceptions
                Utility.WriteDebugInfo(String.Format("Subscriber failed to load: '{0}' - {1} - {2}", pi.FolderPath, ex.Message, ex.StackTrace));
            }
        }
Ejemplo n.º 16
0
        public ISubscriptionHandler Resolve(Subscription subscription)
        {
            JObject action = _subscriptionsModel.Actions.GetAction(subscription.Action);

            if (action == null)
            {
                throw new Exception($"Could not find a valid action with name '{subscription.Action}'.");
            }

            ISubscriptionHandler result = VsoBuildHandler.TryCreate(action, subscription);

            if (result == null)
            {
                throw new Exception($"Could not resolve a Handler for Subscription '{JsonConvert.SerializeObject(subscription)}'.");
            }
            return(result);
        }
Ejemplo n.º 17
0
        // This function will get triggered/executed when a new message is written
        // on the DelayedMessage.QueueName Azure Queue.
        public static async Task ProcessQueueMessage(
            [QueueTrigger(DelayedMessage.QueueName)] DelayedMessage message,
            TextWriter log)
        {
            await log.WriteLineAsync("Starting " + message);

            await log.WriteLineAsync($"Deserializing {message.HandlerType}");

            Type handlerType = Type.GetType(message.HandlerType);

            if (handlerType == null)
            {
                await log.WriteLineAsync($"Could not find type '{message.HandlerType}'. Skipping message '{message.HandlerData}'.");

                return;
            }

            ISubscriptionHandler handler = (ISubscriptionHandler)JsonConvert.DeserializeObject(message.HandlerData, handlerType);
            await handler.Execute();
        }
Ejemplo n.º 18
0
        public IEnumerable <ISubscriptionHandler> GetHandlers(ModifiedFileModel modifiedFile)
        {
            List <ISubscriptionHandler> subscriptionHandlers = new List <ISubscriptionHandler>();
            HandlerResolver             resolver             = new HandlerResolver(this);

            foreach (Subscription subscription in GetSubscriptions(modifiedFile))
            {
                try
                {
                    ISubscriptionHandler subscriptionHandler = resolver.Resolve(subscription);
                    subscriptionHandlers.Add(subscriptionHandler);
                }
                catch (Exception e)
                {
                    Trace.TraceError(e.Message);
                }
            }

            return(subscriptionHandlers);
        }
Ejemplo n.º 19
0
 public DeleteSubscriptionToNotifications(ISubscriptionHandler subscriptionHandler)
 {
     _subscriptionHandler = subscriptionHandler;
 }
Ejemplo n.º 20
0
 public StopMessageSubscriber(
     ISubscriptionHandler subscriptionHandler,
     IBusClient busClient) : base(busClient)
 {
     this.subscriptionHandler = subscriptionHandler;
 }
Ejemplo n.º 21
0
 public bool TryGetValue(string key, out ISubscriptionHandler value) => _handlers.TryGetValue(key, out value);
Ejemplo n.º 22
0
 public SubscriptionHandlerActionReference(ISubscriptionHandler <TPayload> handler)
 {
     Assert.ArgumentNotNull(handler, nameof(handler));
     _handler = handler;
 }
        private static void LoadInternal(ISubscriptionHandler ish, string installPath, string settingsPath)
        {
            string name = null;
            try
            {
                if (ish != null)
                {
                    name = ish.Name;

                    loadedHandlersList.Add(ish);

                    List<Type> list = ish.Register();
                    foreach (Type type in list)
                    {
                        if (typeof(Subscription).IsAssignableFrom(type))
                        {
                            if (!loadedTypes.ContainsKey(type))
                            {
                                lock (loadedTypes)
                                {
                                    if (!loadedTypes.ContainsKey(type))
                                    {
                                        loadedTypes.Add(type, ish);
                                    }
                                }
                            }
                        }
                    }

                    Utility.WriteDebugInfo(String.Format("Subscriber '{0}' was loaded successfully", name));
                }
            }
            catch (Exception ex)
            {
                // suppress any per-plugin loading exceptions
                Utility.WriteDebugInfo(String.Format("Subscriber failed to load: '{0}' - {1} - {2}", name, ex.Message, ex.StackTrace));
            }
        }
 private static void LoadBuiltIn(ISubscriptionHandler sh)
 {
     if (sh != null)
     {
         string path = Path.Combine(userSubscriberDirectory, Growl.CoreLibrary.PathUtility.GetSafeFolderName(sh.Name));
         LoadInternal(sh, null, path);
     }
 }
        private static void LoadPlugin(PluginInfo pi, ISubscriptionHandler ish)
        {
            try
            {
                // load if not already loaded
                if (ish == null)
                {
                    PluginFinder pf = new PluginFinder();
                    ish = pf.Load<ISubscriptionHandler>(pi, ignoreList);
                }

                if (ish != null)
                {
                    // for the 'path' value, we still want to use the userprofile directory no matter where the plugin was loaded from
                    // the reason is that the 'path' is where plugin settings will be saved, so it needs to be user writable and user-specific
                    string path = Path.Combine(userSubscriberDirectory, Growl.CoreLibrary.PathUtility.GetSafeFolderName(ish.Name));

                    // check to make sure this plugin was not loaded from another directory already
                    if (!loadedPlugins.ContainsKey(path))
                    {
                        loadedPlugins.Add(pi.FolderPath, pi);
                        if (!loadedPlugins.ContainsKey(path)) loadedPlugins.Add(path, pi); // link by the settings path as well so we can detect duplicate plugins in other folders
                        loadedPluginsList.Add(pi);

                        LoadInternal(ish, pi.FolderPath, path);
                    }
                    else
                    {
                        // plugin was not valid
                        Utility.WriteDebugInfo(String.Format("Subscriber not loaded: '{0}' - Duplicate plugin was already loaded from another folder", pi.FolderPath));
                    }
                }
                else
                {
                    // plugin was not valid
                    Utility.WriteDebugInfo(String.Format("Subscriber not loaded: '{0}' - Does not implement ISubscriptionHandler interface", pi.FolderPath));
                }
            }
            catch (Exception ex)
            {
                // suppress any per-plugin loading exceptions
                Utility.WriteDebugInfo(String.Format("Subscriber failed to load: '{0}' - {1} - {2}", pi.FolderPath, ex.Message, ex.StackTrace));
            }
        }
Ejemplo n.º 26
0
 public Transport(int port, ISubscriptionHandler aggregationEngine)
 {
     _serverPort        = port;
     _isShutdown        = true;
     _aggregationEngine = aggregationEngine;
 }
Ejemplo n.º 27
0
 public SubscriptionListItem(string text, Image image, ISubscriptionHandler ish)
     : base(text, image, ish)
 {
 }
 public SubscribeToNotifications(ISubscriptionHandler subscriptionHandler)
 {
     _subscriptionHandler = subscriptionHandler;
 }
 public SubscriptionListItem(string text, Image image, ISubscriptionHandler ish)
     : base(text, image, ish)
 {
 }