Beispiel #1
0
        public void Initialize(ExtensionConfigContext extensionConfigContext)
        {
            _log?.LogInformation("Availability Monitoring Extension is initializing:"
                                 + " {{Version=\"{Version}\"}}",
                                 this.GetType().Assembly.GetName().Version);

            Validate.NotNull(extensionConfigContext, nameof(extensionConfigContext));

            // A Coded Availablity Test is defined as such by returning a value that is bound by AvailabilityTestResult-Attribute.
            // A paramater bound by AvailabilityTestInfo-Attribute is optional.
            // Such parameter can be used to programmatically get information about the current availablity test, or it can be omitted.

            // FluentBindingRule<T> is marked as Obsolete, yet it is the type returned from AddBindingRule(..)
            // We could use "var", but one should NEVER use "var" except in Lync expressions
            // or when the type is clear from the *same* line to an unfamiliar reader.
            // Neither is the case, so we use the type explicitly and work around the obsolete-warning by disabling it.
#pragma warning disable CS0618
            FluentBindingRule <AvailabilityTestResultAttribute> testResultRule = extensionConfigContext.AddBindingRule <AvailabilityTestResultAttribute>();
            FluentBindingRule <AvailabilityTestInfoAttribute>   testInfoRule   = extensionConfigContext.AddBindingRule <AvailabilityTestInfoAttribute>();
#pragma warning restore CS0618

            // This binding is used to get and process the return value of the function:
            testResultRule.BindToCollector <AvailabilityTestResultAttribute, AvailabilityTelemetry>(CreateAvailabilityTelemetryAsyncCollector);
            testResultRule.BindToCollector <AvailabilityTestResultAttribute, bool>(CreateBoolAsyncCollector);
            extensionConfigContext.AddConverter <string, AvailabilityTelemetry>(Convert.StringToAvailabilityTelemetry);

            // This is an optional In-parameter that allows user code to get runtime info about the availablity test:
            testInfoRule.BindToInput <AvailabilityTestInfo>(CreateAvailabilityTestInfo);
            extensionConfigContext.AddConverter <AvailabilityTestInfo, string>(Convert.AvailabilityTestInfoToString);
        }
Beispiel #2
0
        /// <summary>
        /// Initializes the SQL binding rules
        /// </summary>
        /// <param name="context"> The config context </param>
        /// <exception cref="ArgumentNullException">
        /// Thrown if context is null
        /// </exception>
        public void Initialize(ExtensionConfigContext context)
        {
            if (context == null)
            {
                throw new ArgumentNullException(nameof(context));
            }
            ILogger logger = this._loggerFactory.CreateLogger(LogCategories.Bindings);

            TelemetryInstance.Initialize(this._configuration, logger);
#pragma warning disable CS0618 // Fine to use this for our stuff
            FluentBindingRule <SqlAttribute> inputOutputRule = context.AddBindingRule <SqlAttribute>();
            var converter = new SqlConverter(this._configuration);
            inputOutputRule.BindToInput(converter);
            inputOutputRule.BindToInput <string>(typeof(SqlGenericsConverter <string>), this._configuration, logger);
            inputOutputRule.BindToCollector <OpenType>(typeof(SqlAsyncCollectorBuilder <>), this._configuration, logger);
            inputOutputRule.BindToInput <OpenType>(typeof(SqlGenericsConverter <>), this._configuration, logger);
        }
Beispiel #3
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);
        }