/// <summary> /// Initializes the extension configuration provider. /// </summary> /// <param name="context">The extension configuration context.</param> public void Initialize(ExtensionConfigContext context) { var mqttAttributeBindingRule = context?.AddBindingRule <MqttAttribute>() ?? throw new ArgumentNullException(nameof(context)); mqttAttributeBindingRule.BindToCollector((attr) => { return(new MqttMessageCollector(_mqttConnectionFactory.GetMqttConnection(attr))); }); var bindingProvider = new MqttTriggerAttributeBindingProvider(_mqttConnectionFactory, _loggerFactory, _nameResolver); context.AddBindingRule <MqttTriggerAttribute>() .BindToTrigger(bindingProvider); }
public void BasicRules() { ConverterManager cm = new ConverterManager(); INameResolver nr = new FakeNameResolver(); var ctx = new ExtensionConfigContext(_config, nr, cm, null, null); // Simulates extension initialization scope. { var binding = ctx.AddBindingRule <TestAttribute>(); binding.WhenIsNull("Mode"). BindToInput <int>(attr => attr.Value); binding.WhenIsNotNull("Mode"). BindToInput <string>(attr => attr.ToString()); StringWriter sw = new StringWriter(); binding.DebugDumpGraph(sw); AssertStringEqual( @"[TestAttribute] -->[filter: (Mode == null)]-->Int32 [TestAttribute] -->[filter: (Mode != null)]-->String", sw.ToString()); } }
public void Initialize(ExtensionConfigContext context) { context.AddBindingRule <SwashBuckleClientAttribute>() .Bind(new SwashBuckleClientBindingProvider(this)); var services = new ServiceCollection(); services.AddSingleton <IApiDescriptionGroupCollectionProvider>(_apiDescriptionGroupCollectionProvider); services.AddSwaggerGen(options => { if (_option.Documents.Length == 0) { var defaultDocument = new OptionDocument(); AddSwaggerDocument(options, defaultDocument); } else { foreach (var optionDocument in _option.Documents) { AddSwaggerDocument(options, optionDocument); } } options.DescribeAllEnumsAsStrings(); if (!string.IsNullOrWhiteSpace(_xmlPath)) { options.IncludeXmlComments(_xmlPath); } options.OperationFilter <FunctionsOperationFilter>(); options.OperationFilter <QueryStringParameterAttributeFilter>(); options.OperationFilter <GenerateOperationIdFilter>(); }); _serviceProvider = services.BuildServiceProvider(true); }
public void Initialize(ExtensionConfigContext context) { if (context == null) { throw new ArgumentNullException(nameof(context)); } context.ApplyConfig(this, "firebaseCloudMessaging"); var nameResolver = context.Config.GetService <INameResolver>(); var extensions = context.Config.GetService <IExtensionRegistry>(); var converterManager = context.Config.GetService <IConverterManager>(); var triggerBindingProvider = new FirebaseCloudMessageTriggerAttributeBindingProvider( nameResolver, converterManager, this, context.Config.LoggerFactory ); extensions.RegisterExtension <ITriggerBindingProvider>(triggerBindingProvider); context.AddBindingRule <FirebaseCloudMessagingTriggerAttribute>() .BindToTrigger(triggerBindingProvider); }
public void Converters() { ConverterManager cm = new ConverterManager(); var ctx = new ExtensionConfigContext(_config, null, cm, null, null); // Simulates extension initialization scope. { ctx.AddBindingRule <TestAttribute>().AddConverter <int, string>(val => "specific"); // specific ctx.AddConverter <int, string>(val => "general"); // general } ctx.ApplyRules(); { var generalConverter = cm.GetSyncConverter <int, string, Attribute>(); var result = generalConverter(12, null, null); Assert.Equal("general", result); } { var specificConverter = cm.GetSyncConverter <int, string, TestAttribute>(); var result = specificConverter(12, null, null); Assert.Equal("specific", result); } }
public void Initialize(ExtensionConfigContext context) { var rule = context.AddBindingRule <SimpleNotificationAttribute>(); rule.BindToCollector(BuildCollector); }
public void Initialize(ExtensionConfigContext context) { var rule = context.AddBindingRule <BindVotingConfigAttribute>(); rule.BindToInput(BuildItemFromAttr); }
public void Initialize(ExtensionConfigContext context) { var rule = context .AddBindingRule <InjectAttribute>() .Bind(_injectBindingProvider); }
public void Initialize(ExtensionConfigContext context) { context .AddBindingRule <InjectAttribute>() .Bind(new InjectBindingProvider()); }
public void Initialize(ExtensionConfigContext context) { var rule = context.AddBindingRule <SimpleServiceNotifiactionAttribute>(); rule.BindToInput(a => $"Hello from Simple Service {a.PushNotificationMessage}"); }
public void Initialize(ExtensionConfigContext context) { context .AddBindingRule <InjectAttribute>() .BindToInput <dynamic>(i => _typeImplementationMap[i.Type]); }
public void Initialize(ExtensionConfigContext context) { var rule = context.AddBindingRule <AzureAdTokenAttribute>(); rule.BindToInput(GetAzureAdTokenAsync); }
public void Initialize(ExtensionConfigContext context) { var provider = new AccessTokenBindingProvider(); var rule = context.AddBindingRule <AccessTokenAttribute>().Bind(provider); }
public void Initialize(ExtensionConfigContext context) { context.AddBindingRule <TestStreamAttribute>(). BindToStream(this, FileAccess.ReadWrite); }
public void Initialize(ExtensionConfigContext context) { context.AddBindingRule <DungeonInjectAttribute>().BindToInput(atr => serviceProvider); }
public void Initialize(ExtensionConfigContext context) { var rule = context.AddBindingRule <Test6Attribute>(); rule.BindToInput <OpenType>(typeof(GeneralBuilder <>)); }
public void Initialize(ExtensionConfigContext context) { var rule = context.AddBindingRule <Test6Attribute>(); rule.BindToInput <AlphaType>(typeof(AlphaBuilder)); }
/// <summary>Registers the validaiton binding.</summary> /// <param name="context">An object that represents an extension config context.</param> public void Initialize(ExtensionConfigContext context) => context.AddBindingRule <ValidationAttribute>() .Bind(new ValidationBindingProvider());
public void Initialize(ExtensionConfigContext context) { context .AddBindingRule <InjectAttribute>() .BindToInput <dynamic>(i => _serviceProvider.GetRequiredService(i.Type)); }
public void Initialize(ExtensionConfigContext context) { var rule = context.AddBindingRule <ActionableMessageValidatorAttribute>(); rule.Bind(new ActionableMessageValidatorBindingProvider()); }
public void Initialize(ExtensionConfigContext context) { if (context == null) { throw new ArgumentNullException(nameof(context)); } _logger = _loggerFactory.CreateLogger(LogCategories.CreateTriggerCategory("EventGrid")); #pragma warning disable 618 Uri url = context.GetWebhookHandler(); #pragma warning restore 618 _logger.LogInformation($"registered EventGrid Endpoint = {url?.GetLeftPart(UriPartial.Path)}"); // Register our extension binding providers // use converterManager as a hashTable // also take benefit of identity converter context .AddBindingRule <EventGridTriggerAttribute>() // following converters are for EventGridTriggerAttribute only .AddConverter <JToken, string>(jtoken => jtoken.ToString(Formatting.Indented)) .AddConverter <JToken, string[]>(jarray => jarray.Select(ar => ar.ToString(Formatting.Indented)).ToArray()) .AddConverter <JToken, DirectInvokeString>(jtoken => new DirectInvokeString(null)) .AddConverter <JToken, EventGridEvent>(jobject => EventGridEvent.Parse(new BinaryData(jobject.ToString()))) // surface the type to function runtime .AddConverter <JToken, EventGridEvent[]>(jobject => EventGridEvent.ParseMany(new BinaryData(jobject.ToString()))) .AddConverter <JToken, CloudEvent>(jobject => CloudEvent.Parse(new BinaryData(jobject.ToString()))) .AddConverter <JToken, CloudEvent[]>(jobject => CloudEvent.ParseMany(new BinaryData(jobject.ToString()))) .AddOpenConverter <JToken, OpenType.Poco>(typeof(JTokenToPocoConverter <>)) .AddOpenConverter <JToken, OpenType.Poco[]>(typeof(JTokenToPocoConverter <>)) .BindToTrigger <JToken>(new EventGridTriggerAttributeBindingProvider(this)); // Register the output binding var rule = context .AddBindingRule <EventGridAttribute>() //TODO - add binding for BinaryData? .AddConverter <string, object>(str => { // first attempt to parse as EventGridEvent, then fallback to CloudEvent try { return(EventGridEvent.Parse(new BinaryData(str))); } catch (ArgumentException) { return(CloudEvent.Parse(new BinaryData(str))); } }) .AddConverter <JObject, object>(jobject => { try { return(EventGridEvent.Parse(new BinaryData(jobject.ToString()))); } catch (ArgumentException) { return(CloudEvent.Parse(new BinaryData(jobject.ToString()))); } }); rule.BindToCollector(_converter); rule.AddValidator((a, t) => { // if app setting is missing, it will be caught by runtime // this logic tries to validate the practicality of attribute properties if (string.IsNullOrWhiteSpace(a.TopicKeySetting)) { throw new InvalidOperationException($"The '{nameof(EventGridAttribute.TopicKeySetting)}' property must be the name of an application setting containing the Topic Key"); } if (!Uri.IsWellFormedUriString(a.TopicEndpointUri, UriKind.Absolute)) { throw new InvalidOperationException($"The '{nameof(EventGridAttribute.TopicEndpointUri)}' property must be a valid absolute Uri"); } }); }
public void Initialize(ExtensionConfigContext context) { context.AddBindingRule <MyCustomTriggerAttribute>().BindToTrigger <string>(_provider); context.AddBindingRule <MyCustomBindingAttribute>().BindToCollector(attr => new MyAsyncCollector(attr)); }
public void Initialize(ExtensionConfigContext context) => context .AddBindingRule <GenesysAttribute>() .Bind(_bindingProvider);
public void Initialize(ExtensionConfigContext context) { context.AddBindingRule <DependencyInjectionAttribute>() .BindToInput <dynamic>((a, c) => ServiceBuilder(a, c)); }
public void Initialize(ExtensionConfigContext context) { context.AddBindingRule <ResourceDeploymentAttribute>().BindToCollector(attr => new ResourceDeploymentCollector(attr, this)); }
void IExtensionConfigProvider.Initialize(ExtensionConfigContext context) { var rule = context.AddBindingRule <FakeItemAttribute>(); rule.BindToValueProvider(BuildFromAttribute); }
public void Initialize(ExtensionConfigContext context) { // Creates a rule that links the attribute to the binding var provider = new AccessTokenBindingProvider(); var rule = context.AddBindingRule <AccessTokenAttribute>().Bind(provider); }
public void Initialize(ExtensionConfigContext context) { context.AddBindingRule <TwitterTriggerAttribute>().BindToTrigger(_provider); }
public void Initialize(ExtensionConfigContext context) { context.AddBindingRule <BindingDataAttribute>(). BindToInput <string>(attr => attr.ToBeAutoResolve); }
/// <summary> /// Internal initialization call from the WebJobs host. /// </summary> /// <param name="context">Extension context provided by WebJobs.</param> void IExtensionConfigProvider.Initialize(ExtensionConfigContext context) { ConfigureLoaderHooks(); // Functions V1 has it's configuration initialized at startup time (now). // For Functions V2 (and for some unit tests) configuration happens earlier in the pipeline. if (!this.isOptionsConfigured) { this.InitializeForFunctionsV1(context); } if (this.nameResolver.TryResolveWholeString(this.Options.HubName, out string taskHubName)) { // use the resolved task hub name this.Options.HubName = taskHubName; } // Throw if any of the configured options are invalid this.Options.Validate(); // For 202 support if (this.Options.NotificationUrl == null) { #pragma warning disable CS0618 // Type or member is obsolete this.Options.NotificationUrl = context.GetWebhookHandler(); #pragma warning restore CS0618 // Type or member is obsolete } this.TraceConfigurationSettings(); var bindings = new BindingHelper(this, this.TraceHelper); // Note that the order of the rules is important var rule = context.AddBindingRule <DurableClientAttribute>() .AddConverter <string, StartOrchestrationArgs>(bindings.StringToStartOrchestrationArgs) .AddConverter <JObject, StartOrchestrationArgs>(bindings.JObjectToStartOrchestrationArgs) .AddConverter <IDurableClient, string>(bindings.DurableOrchestrationClientToString); rule.BindToCollector <StartOrchestrationArgs>(bindings.CreateAsyncCollector); rule.BindToInput <IDurableOrchestrationClient>(this.GetClient); rule.BindToInput <IDurableEntityClient>(this.GetClient); rule.BindToInput <IDurableClient>(this.GetClient); string storageConnectionString = null; var providerFactory = this.durabilityProviderFactory as AzureStorageDurabilityProviderFactory; if (providerFactory != null) { storageConnectionString = providerFactory.GetDefaultStorageConnectionString(); } context.AddBindingRule <OrchestrationTriggerAttribute>() .BindToTrigger(new OrchestrationTriggerAttributeBindingProvider(this, context, storageConnectionString, this.TraceHelper)); context.AddBindingRule <ActivityTriggerAttribute>() .BindToTrigger(new ActivityTriggerAttributeBindingProvider(this, context, storageConnectionString, this.TraceHelper)); context.AddBindingRule <EntityTriggerAttribute>() .BindToTrigger(new EntityTriggerAttributeBindingProvider(this, context, storageConnectionString, this.TraceHelper)); this.taskHubWorker = new TaskHubWorker(this.defaultDurabilityProvider, this, this); this.taskHubWorker.AddOrchestrationDispatcherMiddleware(this.EntityMiddleware); this.taskHubWorker.AddOrchestrationDispatcherMiddleware(this.OrchestrationMiddleware); }