private Dictionary <string, ServiceClient> _clients; // key: connection string public void Initialize(ExtensionConfigContext context) { _clients = new Dictionary <string, ServiceClient>(); // This allows a user to bind to IAsyncCollector<string>, and the sdk // will convert that to IAsyncCollector<IoTCloudToDeviceItem> context.AddConverter <string, IoTCloudToDeviceItem>(ConvertToItem); // This is useful on input. context.AddConverter <IoTCloudToDeviceItem, string>(ConvertToString); // Create 2 binding rules for the Sample attribute. var rule = context.AddBindingRule <IoTCloudToDeviceAttribute>(); rule.BindToCollector <IoTCloudToDeviceItem>(BuildCollector); }
public void Initialize(ExtensionConfigContext context) { if (context == null) { throw new ArgumentNullException("context"); } if (string.IsNullOrEmpty(options.ConnectionString)) { options.ConnectionString = nameResolver.Resolve(AzureSignalRConnectionStringName); } context.AddConverter <string, JObject>(JObject.FromObject) .AddConverter <SignalRConnectionInfo, JObject>(JObject.FromObject) .AddConverter <JObject, SignalRMessage>(input => input.ToObject <SignalRMessage>()) .AddConverter <JObject, SignalRGroupAction>(input => input.ToObject <SignalRGroupAction>()); var signalRConnectionInfoAttributeRule = context.AddBindingRule <SignalRConnectionInfoAttribute>(); signalRConnectionInfoAttributeRule.AddValidator(ValidateSignalRConnectionInfoAttributeBinding); signalRConnectionInfoAttributeRule.BindToInput <SignalRConnectionInfo>(GetClientConnectionInfo); var signalRAttributeRule = context.AddBindingRule <SignalRAttribute>(); signalRAttributeRule.AddValidator(ValidateSignalRAttributeBinding); signalRAttributeRule.BindToCollector <SignalROpenType>(typeof(SignalRCollectorBuilder <>), this); logger.LogInformation("SignalRService binding initialized"); }
void IExtensionConfigProvider.Initialize(ExtensionConfigContext context) { if (context == null) { throw new ArgumentNullException("context"); } // apply at eventProcessorOptions level (maxBatchSize, prefetchCount) context.ApplyConfig(_options, "eventHub"); // apply at config level (batchCheckpointFrequency) context.ApplyConfig(this, "eventHub"); _defaultStorageString = context.Config.StorageConnectionString; context .AddConverter <string, EventData>(ConvertString2EventData) .AddConverter <EventData, string>(ConvertEventData2String) .AddConverter <byte[], EventData>(ConvertBytes2EventData) .AddConverter <EventData, byte[]>(ConvertEventData2Bytes); // register our trigger binding provider INameResolver nameResolver = context.Config.NameResolver; IConverterManager cm = context.Config.GetService <IConverterManager>(); var triggerBindingProvider = new EventHubTriggerAttributeBindingProvider(nameResolver, cm, this); context.AddBindingRule <EventHubTriggerAttribute>() .BindToTrigger(triggerBindingProvider); // register our binding provider context.AddBindingRule <EventHubAttribute>() .BindToCollector(BuildFromAttribute); }
public void Initialize(ExtensionConfigContext context) { context.AddConverter <bool, VSTSContext>(input => new VSTSContext { QueueBuild = input }); context.AddBindingRule <VSTSAttribute>().BindToCollector <VSTSContext>(attr => new VSTSCollector(attr)); }
public void Converters() { var config = new JobHostConfiguration(); var ctx = new ExtensionConfigContext { Config = config }; // Simulates extension initialization scope. { ctx.AddBindingRule <TestAttribute>().AddConverter <int, string>(val => "specific"); // specific ctx.AddConverter <int, string>(val => "general"); // general } ctx.ApplyRules(); var cm = config.ConverterManager; { 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, QueueServiceClientProvider queueServiceClientProvider, IContextGetter <IMessageEnqueuedWatcher> contextGetter) { _queueServiceClientProvider = queueServiceClientProvider; _messageEnqueuedWatcherGetter = contextGetter; // TODO: FACAVAL replace this with queue options. This should no longer be needed. //context.ApplyConfig(context.Config.Queues, "queues"); // IStorageQueueMessage is the core testing interface var binding = context.AddBindingRule <QueueAttribute>(); binding .AddConverter <byte[], QueueMessage>(ConvertByteArrayToCloudQueueMessage) .AddConverter <string, QueueMessage>(ConvertStringToCloudQueueMessage) .AddOpenConverter <OpenType.Poco, QueueMessage>(ConvertPocoToCloudQueueMessage); context // global converters, apply to multiple attributes. .AddConverter <QueueMessage, byte[]>(ConvertCloudQueueMessageToByteArray) .AddConverter <QueueMessage, string>(ConvertCloudQueueMessageToString); var builder = new QueueBuilder(this); binding.AddValidator(ValidateQueueAttribute); binding.BindToCollector <QueueMessage>(this); binding.BindToInput <QueueClient>(builder); binding.BindToInput <QueueClient>(builder); }
public void Initialize( ExtensionConfigContext context, QueueServiceClientProvider queueServiceClientProvider, IContextGetter <IMessageEnqueuedWatcher> contextGetter, QueueCausalityManager queueCausalityManager) { _queueServiceClientProvider = queueServiceClientProvider; _messageEnqueuedWatcherGetter = contextGetter; _queueCausalityManager = queueCausalityManager; // IStorageQueueMessage is the core testing interface var binding = context.AddBindingRule <QueueAttribute>(); binding .AddConverter <byte[], QueueMessage>(ConvertByteArrayToCloudQueueMessage) .AddConverter <string, QueueMessage>(ConvertStringToCloudQueueMessage) .AddConverter <BinaryData, QueueMessage>(ConvertBinaryDataToCloudQueueMessage) .AddOpenConverter <OpenType.Poco, QueueMessage>(ConvertPocoToCloudQueueMessage); context // global converters, apply to multiple attributes. .AddConverter <QueueMessage, byte[]>(ConvertCloudQueueMessageToByteArray) .AddConverter <QueueMessage, string>(ConvertCloudQueueMessageToString) .AddConverter <QueueMessage, BinaryData>(ConvertCloudQueueMessageToBinaryData); var builder = new QueueBuilder(this); binding.AddValidator(ValidateQueueAttribute); binding.BindToCollector <QueueMessage>(this); binding.BindToInput <QueueClient>(builder); binding.BindToInput <QueueClient>(builder); }
public void Initialize(ExtensionConfigContext context) { context.AddConverter <JObject, SlackMessage>(ConvertSlackMessage); var rule = context.AddBindingRule <SlackAttribute>(); rule.AddValidator(ValidateBinding); rule.BindToCollector <SlackMessage>(attribute => { var apiKey = Utility.FirstOrDefault(attribute.ApiKey, _options.ApiKey); var webHookUrl = Utility.FirstOrDefault(attribute.WebHookUrl, _options.WebHookUrl); var iconUrl = attribute.IconUrl; var iconEmoji = attribute.IconEmoji; var userName = attribute.Username; var slackContext = new SlackContext { ApiKey = apiKey, WebHookUrl = webHookUrl, Channel = attribute.Channel, IconUrl = iconUrl, IconEmoji = iconEmoji, UserName = userName }; return(new SlackMessageAsyncCollector(slackContext, _slackHttpClient, _slackLogger)); }); }
public void Initialize(ExtensionConfigContext context) { context.AddConverter <JObject, SqlInput>(input => { return(ConvertFromJObject(input)); }); context.AddConverter <JArray, SqlInput>(input => { return(ConvertFromJArray(input)); }); context.AddOpenConverter <OpenType, SqlInput>(typeof(OpenTypeToSqlInputConverter <>)); var rule = context.AddBindingRule <DapperAttribute>(); rule.BindToCollector <SqlInput>(attr => new ExecuteSqlAsyncCollector(attr, _appRoot)); rule.BindToInput <OpenType>(typeof(DapperAttributeToExecuteQueryAsyncConverter <>), _appRoot); }
/// <inheritdoc /> public void Initialize(ExtensionConfigContext context) { if (context == null) { throw new ArgumentNullException(nameof(context)); } // Set the default exception handler for background exceptions // coming from MessageReceivers. Options.ExceptionHandler = (e) => { LogExceptionReceivedEvent(e, _loggerFactory); return(Task.CompletedTask); }; context .AddConverter(new MessageToStringConverter()) .AddConverter(new MessageToByteArrayConverter()) .AddOpenConverter <ServiceBusReceivedMessage, OpenType.Poco>(typeof(MessageToPocoConverter <>), _options.JsonSerializerSettings); // register our trigger binding provider ServiceBusTriggerAttributeBindingProvider triggerBindingProvider = new ServiceBusTriggerAttributeBindingProvider(_nameResolver, _options, _messagingProvider, _loggerFactory, _converterManager, _clientFactory); context.AddBindingRule <ServiceBusTriggerAttribute>() .BindToTrigger(triggerBindingProvider); // register our binding provider ServiceBusAttributeBindingProvider bindingProvider = new ServiceBusAttributeBindingProvider(_nameResolver, _messagingProvider, _clientFactory); context.AddBindingRule <ServiceBusAttribute>().Bind(bindingProvider); }
/// <inheritdoc /> public void Initialize(ExtensionConfigContext context) { if (context == null) { throw new ArgumentNullException("context"); } var metadata = new ConfigMetadata(); context.ApplyConfig(metadata, "sendgrid"); this.ToAddress = SendGridHelpers.Apply(this.ToAddress, metadata.To); this.FromAddress = SendGridHelpers.Apply(this.FromAddress, metadata.From); if (string.IsNullOrEmpty(this.ApiKey)) { INameResolver nameResolver = context.Config.NameResolver; this.ApiKey = nameResolver.Resolve(AzureWebJobsSendGridApiKeyName); } context .AddConverter <string, SendGridMessage>(SendGridHelpers.CreateMessage) .AddConverter <JObject, SendGridMessage>(SendGridHelpers.CreateMessage) .AddBindingRule <SendGridAttribute>() .AddValidator(ValidateBinding) .BindToCollector <SendGridMessage>(CreateCollector); }
public void Initialize(ExtensionConfigContext context) { if (context == null) { throw new ArgumentNullException(nameof(context)); } context .AddConverter <MqttMessage, byte[]>(ConvertMqttMessageToByteArray) .AddConverter <MqttMessage, string>(ConvertMqttMessageToString) .AddConverter <MqttMessage, string>(ConvertMqttMessageToString); // Register our binding provider. var binding = context.AddBindingRule <MqttAttribute>(); binding .AddConverter <byte[], MqttMessage>(ConvertByteArrayToMqttMessage) .AddConverter <string, MqttMessage>(ConvertStringToMqttMessage) .AddConverter <JObject, MqttMessage>(ConvertJObjectToMqttMessage) .AddOpenConverter <OpenType.Poco, MqttMessage>(ConvertPocoToMqttMessage); binding.AddValidator(ValidateMqttAttribute); binding.BindToInput <MqttMessage>(BuildMessageFromAttribute); binding.BindToCollector <MqttMessage>(BuildCollectorFromAttribute); // Register our trigger binding provider. var triggerBindingProvider = new MqttTriggerAttributeBindingProvider(this); context.AddBindingRule <MqttTriggerAttribute>() .BindToTrigger(triggerBindingProvider); }
public void Initialize(ExtensionConfigContext context) { if (context == null) { throw new ArgumentNullException("context"); } StaticServiceHubContextStore.ServiceManagerStore = serviceManagerStore; Exception webhookException = null; try { var url = context.GetWebhookHandler(); logger.LogInformation($"Registered SignalR trigger Endpoint = {url?.GetLeftPart(UriPartial.Path)}"); } catch (Exception ex) { webhookException = ex; } JsonConvert.DefaultSettings = () => new JsonSerializerSettings() { Converters = new List <JsonConverter>() { new ServiceEndpointJsonConverter() } }; context.AddConverter <string, JObject>(JObject.FromObject) .AddConverter <SignalRConnectionInfo, JObject>(JObject.FromObject) .AddConverter <JObject, SignalRMessage>(input => input.ToObject <SignalRMessage>()) .AddConverter <JObject, SignalRGroupAction>(input => input.ToObject <SignalRGroupAction>()); // Trigger binding rule var triggerBindingRule = context.AddBindingRule <SignalRTriggerAttribute>(); triggerBindingRule.AddConverter <InvocationContext, JObject>(JObject.FromObject); triggerBindingRule.BindToTrigger <InvocationContext>(new SignalRTriggerBindingProvider(_dispatcher, nameResolver, serviceManagerStore, webhookException)); // Non-trigger binding rule var signalRConnectionInfoAttributeRule = context.AddBindingRule <SignalRConnectionInfoAttribute>(); signalRConnectionInfoAttributeRule.Bind(inputBindingProvider); var securityTokenValidationAttributeRule = context.AddBindingRule <SecurityTokenValidationAttribute>(); securityTokenValidationAttributeRule.Bind(inputBindingProvider); _ = context.AddBindingRule <SignalREndpointsAttribute>() .AddConverter <ServiceEndpoint[], JArray>(JArray.FromObject) .BindToInput(new SignalREndpointsAsyncConverter()); var signalRAttributeRule = context.AddBindingRule <SignalRAttribute>(); signalRAttributeRule.BindToCollector <SignalROpenType>(typeof(SignalRCollectorBuilder <>)); logger.LogInformation("SignalRService binding initialized"); }
private static ExtensionConfigContext AddByteArrayToConverter(this ExtensionConfigContext context, Microsoft.Extensions.Logging.ILogger logger) => context.AddConverter <byte[], CreateSecretData>((value, attr) => { var config = (KeyVaultSecretAttribute)attr; return(new CreateSecretData { SecretName = config.SecretName, Value = Convert.ToBase64String(value), ContentType = config.ContentType, IsEnabled = config.IsEnabled, ExpiresAt = config.ExpiresAt, StartsAt = config.StartsAt }); });
public void Initialize(ExtensionConfigContext context) { if (context == null) { throw new ArgumentNullException("context"); } context.AddConverter <string, JObject>(JObject.FromObject); context.AddConverter <JObject, ResolvedEvent?>(input => input.ToObject <ResolvedEvent?>()); context.AddConverter <JObject, IList <ResolvedEvent> >(input => input.ToObject <IList <ResolvedEvent> >()); context.AddAllConverters(_logger); var eventStoreAttributeRule = context.AddBindingRule <EventStoreStreamsAttribute>(); eventStoreAttributeRule.BindToInput <IList <ResolvedEvent> >(new EventStoreInputAsyncConverter(_logger)); eventStoreAttributeRule.BindToCollector <EventStoreData>(config => new EventStoreDataAsyncCollector(config, _logger)); }
public void Initialize(ExtensionConfigContext context) { // Add [Test] support var rule = context.AddBindingRule <TestAttribute>(); rule.BindToInput <string>(typeof(FakeExtClient), _nameResolver, _converterManager); // Add [FakeQueueTrigger] support. context.AddConverter <string, FakeQueueData>(x => new FakeQueueData { Message = x }); context.AddConverter <FakeQueueData, string>(msg => msg.Message); var triggerBindingProvider = new FakeQueueTriggerBindingProvider(new FakeQueueClient(_nameResolver, _converterManager), _converterManager); context.AddBindingRule <FakeQueueTriggerAttribute>().BindToTrigger(triggerBindingProvider); }
public void Initialize(ExtensionConfigContext context) { // Allows user to bind to IAsyncCollector<JObject>, and the sdk will convert that to IAsyncCollector<HttpCallRequest> context.AddConverter <JObject, HttpCallMessage>(input => input.ToObject <HttpCallMessage>()); context.AddBindingRule <HttpCallAttribute>() .BindToCollector <HttpCallMessage>(attr => new HttpCallMessageAsyncCollector(this, attr)); }
public void Initialize(ExtensionConfigContext context) { context.AddConverter <AlphaType, BetaType>(ConvertAlpha2Beta); // The AlphaType restriction here means that although we have a GeneralBuilder<> that *could* // directly build a BetaType, we can only use it to build AlphaTypes, and so we must invoke the converter. context.AddBindingRule <Test6Attribute>().BindToInput <AlphaType>(typeof(GeneralBuilder <>)); }
public void Initialize(ExtensionConfigContext context) { _counter++; context.AddBindingRule <Test9Attribute>(). BindToInput <Widget>(Builder); context.AddConverter <Widget, JObject>(widget => JObject.FromObject(widget)); }
private Dictionary <string, RegistryManager> _manager; // key: connection string public void Initialize(ExtensionConfigContext context) { _manager = new Dictionary <string, RegistryManager>(); // This allows a user to bind to IAsyncCollector<string>, and the sdk // will convert that to IAsyncCollector<IoTCloudToDeviceItem> context.AddConverter <string, IoTSetDeviceTwinItem>(ConvertToItem); // This is useful on input. context.AddConverter <IoTSetDeviceTwinItem, string>(ConvertToString); // Create 2 binding rules for the Sample attribute. var rule = context.AddBindingRule <IoTSetDeviceTwinAttribute>(); //rule.BindToInput<IoTSetDeviceTwinItem>(BuildItemFromAttr); rule.BindToCollector <IoTSetDeviceTwinItem>(BuildCollector); }
public void Initialize(ExtensionConfigContext context) { if (context == null) { throw new ArgumentNullException("context"); } if (string.IsNullOrEmpty(options.ConnectionString)) { options.ConnectionString = nameResolver.Resolve(Constants.AzureSignalRConnectionStringName); } var serviceTransportTypeStr = nameResolver.Resolve(Constants.ServiceTransportTypeName); if (Enum.TryParse <ServiceTransportType>(serviceTransportTypeStr, out var transport)) { options.AzureSignalRServiceTransportType = transport; } else { logger.LogWarning($"Unsupported service transport type: {serviceTransportTypeStr}. Use default {options.AzureSignalRServiceTransportType} instead."); } StaticServiceHubContextStore.ServiceManagerStore = new ServiceManagerStore(options.AzureSignalRServiceTransportType, configuration, loggerFactory); var url = context.GetWebhookHandler(); logger.LogInformation($"Registered SignalR trigger Endpoint = {url?.GetLeftPart(UriPartial.Path)}"); context.AddConverter <string, JObject>(JObject.FromObject) .AddConverter <SignalRConnectionInfo, JObject>(JObject.FromObject) .AddConverter <JObject, SignalRMessage>(input => input.ToObject <SignalRMessage>()) .AddConverter <JObject, SignalRGroupAction>(input => input.ToObject <SignalRGroupAction>()); // Trigger binding rule var triggerBindingRule = context.AddBindingRule <SignalRTriggerAttribute>(); triggerBindingRule.AddConverter <InvocationContext, JObject>(JObject.FromObject); triggerBindingRule.BindToTrigger <InvocationContext>(new SignalRTriggerBindingProvider(_dispatcher, nameResolver, options)); // Non-trigger binding rule var signalRConnectionInfoAttributeRule = context.AddBindingRule <SignalRConnectionInfoAttribute>(); signalRConnectionInfoAttributeRule.AddValidator(ValidateSignalRConnectionInfoAttributeBinding); signalRConnectionInfoAttributeRule.Bind(inputBindingProvider); var securityTokenValidationAttributeRule = context.AddBindingRule <SecurityTokenValidationAttribute>(); securityTokenValidationAttributeRule.Bind(inputBindingProvider); var signalRAttributeRule = context.AddBindingRule <SignalRAttribute>(); signalRAttributeRule.AddValidator(ValidateSignalRAttributeBinding); signalRAttributeRule.BindToCollector <SignalROpenType>(typeof(SignalRCollectorBuilder <>), options); logger.LogInformation("SignalRService binding initialized"); }
/// <summary> /// Initializes attributes, configuration and async collector /// </summary> /// <param name="context"></param> public void Initialize(ExtensionConfigContext context) { // Converts json to RedisItem context.AddConverter <JObject, RedisItem>(input => input.ToObject <RedisItem>()); // Use RedisItemAsyncCollector to send items to Redis context.AddBindingRule <RedisAttribute>() .BindToCollector <RedisItem>(attr => new RedisItemAsyncCollector(this, attr)); }
public void Initialize(ExtensionConfigContext context) { context.AddConverter <string, TweetMessage>(input => new TweetMessage() { Message = input }); context.AddBindingRule <TweetAttribute>().BindToCollector <TweetMessage>(attr => new TweetAsyncCollector(attr)); }
/// <summary> /// This callback is invoked by the WebJobs framework before the host starts execution. /// It should add the binding rules and converters for our new <see cref="SampleAttribute"/> /// </summary> /// <param name="context"></param> public void Initialize(ExtensionConfigContext context) { // Register converters. These help convert between the user's parameter type // and the type specified by the binding rules. // This allows a user to bind to IAsyncCollector<string>, and the sdk // will convert that to IAsyncCollector<SampleItem> context.AddConverter <string, SampleItem>(ConvertToItem); // This is useful on input. context.AddConverter <SampleItem, string>(ConvertToString); // Create 2 binding rules for the Sample attribute. var rule = context.AddBindingRule <SampleAttribute>(); rule.BindToInput <SampleItem>(BuildItemFromAttr); rule.BindToCollector <SampleItem>(BuildCollector); }
public void Initialize(ExtensionConfigContext context) { if (context == null) { throw new ArgumentNullException(nameof(context)); } if (string.IsNullOrEmpty(_options.ConnectionString)) { _options.ConnectionString = _nameResolver.Resolve(Constants.WebPubSubConnectionStringName); AddSettings(_options.ConnectionString); } if (string.IsNullOrEmpty(_options.Hub)) { _options.Hub = _nameResolver.Resolve(Constants.HubNameStringName); } Exception webhookException = null; try { #pragma warning disable CS0618 // Type or member is obsolete var url = context.GetWebhookHandler(); #pragma warning restore CS0618 // Type or member is obsolete _logger.LogInformation($"Registered Web PubSub negotiate Endpoint = {url?.GetLeftPart(UriPartial.Path)}"); } catch (Exception ex) { // disable trigger. webhookException = ex; } // register JsonConverters RegisterJsonConverter(); // bindings context .AddConverter <WebPubSubConnection, JObject>(JObject.FromObject) .AddConverter <JObject, WebPubSubOperation>(ConvertToWebPubSubOperation) .AddConverter <JArray, WebPubSubOperation[]>(ConvertToWebPubSubOperationArray); // Trigger binding context.AddBindingRule <WebPubSubTriggerAttribute>() .BindToTrigger(new WebPubSubTriggerBindingProvider(_dispatcher, _options, webhookException)); var webpubsubConnectionAttributeRule = context.AddBindingRule <WebPubSubConnectionAttribute>(); webpubsubConnectionAttributeRule.AddValidator(ValidateWebPubSubConnectionAttributeBinding); webpubsubConnectionAttributeRule.BindToInput(GetClientConnection); var webPubSubAttributeRule = context.AddBindingRule <WebPubSubAttribute>(); webPubSubAttributeRule.AddValidator(ValidateWebPubSubAttributeBinding); webPubSubAttributeRule.BindToCollector(CreateCollector); _logger.LogInformation("Azure Web PubSub binding initialized"); }
public void Initialize(ExtensionConfigContext context) { // Register converters. These help convert between the user's parameter type // and the type specified by the binding rules. // This allows a user to bind to IAsyncCollector<string>, and the sdk // will convert that to IAsyncCollector<SampleItem> context.AddConverter <string, FileContent>(ConvertToItem); // This is useful on input binding. context.AddConverter <FileContent, string>(ConvertToString); // Create 2 binding rules for the Sample attribute. var rule = context.AddBindingRule <FileAccessAttribute>(); //On input binding to read from the file rule.BindToInput <FileContent>(BuildItemFromAttr); //on output binding to make call to AddAsync method in IAyncCollector<FileContent> rule.BindToCollector <FileContent>(BuildCollector); }
public void Initialize(ExtensionConfigContext context) { // add converter between JObject and SlackMessage // Allows a user to bind to IAsyncCollector<JObject>, and the sdk will convert that to IAsyncCollector<SlackMessage> context.AddConverter <JObject, TeamsMessage>(input => input.ToObject <TeamsMessage>()); // Add a binding rule for Collector context.AddBindingRule <TeamsAttribute>() .BindToCollector <TeamsMessage>(attr => new TeamsAsyncCollector(this, attr)); }
public void Initialize(ExtensionConfigContext context) { // add converter between JObject and SlackMessage // Allows a user to bind to IAsyncCollector<JObject>, and the sdk will convert that to IAsyncCollector<SlackMessage> context.AddConverter <JObject, Container>(input => input.ToObject <Container>()); context.AddConverter <JObject, ContainerGroupDelete>(input => input.ToObject <ContainerGroupDelete>()); // Add a binding rule for Collector context.AddBindingRule <ContainerGroupAttribute>() .BindToCollector <Container>(attr => new ContainerCreateAsyncCollector(this, attr)); // Add a binding rule for Collector context.AddBindingRule <ContainerGroupWithPrivateRegistryAttribute>() .BindToCollector <Container>(attr => new ContainerCreateAsyncCollector(this, attr)); // Add a binding rule for Collector context.AddBindingRule <DeleteContainerGroupAttribute>() .BindToCollector <ContainerGroupDelete>(attr => new ContainerGroupDeleteAsyncCollector(this, attr)); }
public void Initialize(ExtensionConfigContext context) { context.AddBindingRule <TestStreamAttribute>(). BindToStream(this, FileAccess.ReadWrite); // Override the Stream --> String converter context.AddConverter <Stream, string>(stream => ReadTag); context.AddConverter <ApplyConversion <string, Stream>, object>((pair) => { var val = pair.Value; var stream = pair.Existing; using (var sr = new StreamWriter(stream)) { sr.Write("yy"); // custom sr.Write(val); } return(null); }); }
public void Initialize(ExtensionConfigContext context) { context.Trace.Info($"In {nameof(MyMessageExtensionConfigProvider)}.{nameof(Initialize)}"); context.AddConverter <string, MyMessage>(s => new MyMessage { Name = "Custom-binding (string): " + s } ); context.AddConverter <EventData, MyMessage>(s => { //var body = Encoding.UTF8.GetString(s.GetBytes()); //return new MyMessage { Name = "Custom-binding (EventData): " + body }; return(new MyMessage { Name = "Custom-binding (EventData): " + s.ToString() }); } ); }