Beispiel #1
0
        public void Initialize(ExtensionConfigContext context)
        {
            if (context == null)
            {
                throw new ArgumentNullException(nameof(context));
            }

            var bindingProvider = new EdgeHubTriggerBindingProvider();
            var rule            = context.AddBindingRule <EdgeHubTriggerAttribute>();

            rule.AddConverter <Message, string>(ConvertMessageToString);
            rule.AddConverter <Message, byte[]>(ConvertMessageToBytes);
            rule.BindToTrigger <Message>(bindingProvider);

            var rule2 = context.AddBindingRule <EdgeHubAttribute>();

            rule2.BindToCollector <Message>(typeof(EdgeHubCollectorBuilder));
            rule2.AddConverter <string, Message>(ConvertStringToMessage);
            rule2.AddConverter <byte[], Message>(ConvertBytesToMessage);
            rule2.AddOpenConverter <OpenType.Poco, Message>(ConvertPocoToMessage);
        }
Beispiel #2
0
        public void Initialize(ExtensionConfigContext context)
        {
            if (context == null)
            {
                throw new ArgumentNullException(nameof(context));
            }

            var extensions = context.Config.GetService <IExtensionRegistry>();

            // register trigger binding provider
            var triggerBindingProvider = new EdgeHubTriggerBindingProvider();

            extensions.RegisterExtension <ITriggerBindingProvider>(triggerBindingProvider);

            extensions.RegisterBindingRules <EdgeHubAttribute>();
            FluentBindingRule <EdgeHubAttribute> rule = context.AddBindingRule <EdgeHubAttribute>();

            rule.BindToCollector <Message>(typeof(EdgeHubCollectorBuilder));

            context.AddConverter <Message, string>(this.MessageConverter);
            context.AddConverter <string, Message>(this.ConvertToMessage);
        }