public override Collection <Attribute> GetAttributes() { Collection <Attribute> attributes = new Collection <Attribute>(); string schedule = Context.GetMetadataValue <string>("schedule"); bool runOnStartup = Context.GetMetadataValue <bool>("runOnStartup"); if (Utility.IsDynamic) { // pre-resolve app setting specifiers var resolver = new DefaultNameResolver(); schedule = resolver.ResolveWholeString(schedule); var options = new CrontabSchedule.ParseOptions() { IncludingSeconds = true }; if (CrontabSchedule.TryParse(schedule, options) == null) { throw new ArgumentException(string.Format("'{0}' is not a valid CRON expression.", schedule)); } } attributes.Add(new TimerTriggerAttribute(schedule) { RunOnStartup = runOnStartup }); return(attributes); }
private IQuery <TModel> CreateQuery <TModel>(SelectQueryData data) { var resolver = new DefaultNameResolver(); var factory = new DefaultQueryDataFactory(resolver); return(new SelectQuery <TModel>(data, factory)); }
/// <summary> /// Validates the current configuration against the original configuration. If any values for a trigger /// do not match, they are returned via the return value. /// </summary> /// <param name="originalConfig">The original configuration</param> /// <returns>A dictionary mapping function name to a list of the invalid values for that function.</returns> public IDictionary <string, IEnumerable <string> > Validate(IConfigurationRoot originalConfig) { if (originalConfig == null) { throw new ArgumentNullException(nameof(originalConfig)); } INameResolver originalNameResolver = new DefaultNameResolver(originalConfig); IDictionary <string, IEnumerable <string> > invalidValues = new Dictionary <string, IEnumerable <string> >(); var functions = _metadataManager.GetFunctionMetadata(); foreach (var function in functions) { // Only a single trigger per function is supported. For our purposes here we just take // the first. If multiple are defined, that error will be handled on indexing. var trigger = function.Bindings.FirstOrDefault(b => b.IsTrigger); if (trigger == null) { continue; } IList <string> invalidValuesForFunction = new List <string>(); // make sure none of the resolved values have changed for the trigger. foreach (KeyValuePair <string, JToken> property in trigger.Raw) { string lookup = property.Value?.ToString(); if (lookup != null) { string originalValue = originalConfig[lookup]; string newValue = _config[lookup]; if (originalValue != newValue) { invalidValuesForFunction.Add(lookup); } else { // It may be a binding expression like "%lookup%" originalNameResolver.TryResolveWholeString(lookup, out originalValue); _nameResolver.TryResolveWholeString(lookup, out newValue); if (originalValue != newValue) { invalidValuesForFunction.Add(lookup); } } } } if (invalidValuesForFunction.Any()) { invalidValues[function.Name] = invalidValuesForFunction; } } return(invalidValues); }
public async Task TestBlobStorageProvider_ConnectionNameWithResolver() { var resolver = new DefaultNameResolver(_configuration); var client = _blobServiceClientProvider.Create(StorageConnection, resolver, _configuration); await VerifyServiceAvailable(client); }
private SelectQueryData CreateQueryData <TModel>() { var resolver = new DefaultNameResolver(); return(new SelectQueryData( new SqlCommandBuilder(resolver), new ModelQuerySource(typeof(TModel), resolver))); }
// [Fact] public void TestSrvResolverWithSingleRecord() { var dnsEndPoint = new System.Net.DnsEndPoint("xmpp.ag-software.net", 5222); var ep = new DefaultNameResolver().ResolveAsync(dnsEndPoint).GetAwaiter().GetResult(); var resolver = new SrvNameResolver(); var ep2 = resolver.ResolveAsync(new System.Net.DnsEndPoint("ag-software.net", 80)).GetAwaiter().GetResult(); // assert resolver.DirectTls.ShouldBe(false); ep2.ToString().ShouldBe(ep.ToString()); }
public WebPubSubTriggerBindingProviderTests() { _configuration = new ConfigurationBuilder() .AddEnvironmentVariables() .AddInMemoryCollection() .Build(); _configuration["testhub"] = TestHub; var resolver = new DefaultNameResolver(_configuration); var mockDispater = new Mock <IWebPubSubTriggerDispatcher>(MockBehavior.Strict); var config = new WebPubSubFunctionsOptions(); _provider = new WebPubSubTriggerBindingProvider(mockDispater.Object, resolver, config, null); }
public ErrorNotifier(SendGridConfiguration sendGridConfig) { if (sendGridConfig == null) { throw new ArgumentNullException(nameof(sendGridConfig)); } _sendGridConfig = sendGridConfig; _sendGrid = new SendGridClient(sendGridConfig.ApiKey); // pull our IFTTT notification URL from app settings (since it contains a secret key) var nameResolver = new DefaultNameResolver(); _webNotificationUri = nameResolver.Resolve(NotificationUriSettingName); }
public void Resolve_WithNullOrEmptyNameParameter_ReturnsNull() { var configuration = new ConfigurationBuilder().Build(); var resolver = new DefaultNameResolver(configuration); // Assert we null returns null string result = resolver.Resolve(null); Assert.Null(result); // Assert empty returns null result = resolver.Resolve(string.Empty); Assert.Null(result); }
public static TokenOptions GetValidSettingsForTests() { IConfiguration config = new ConfigurationBuilder() .SetBasePath(Directory.GetCurrentDirectory()) .AddJsonFile("appsettings.json") .Build(); if (string.IsNullOrEmpty(config[Constants.ClientSecretName])) { config[Constants.ClientSecretName] = GetClientSecret(); } var resolver = new DefaultNameResolver(config); var options = new TokenOptions(); options.SetAppSettings(resolver); return(options); }
public ExternalConfigurationStartupValidator(IConfiguration config, IFunctionMetadataManager metadataManager) { _config = config ?? throw new ArgumentNullException(nameof(config)); _metadataManager = metadataManager ?? throw new ArgumentNullException(nameof(metadataManager)); _nameResolver = new DefaultNameResolver(config); }
/// <summary> /// Constructs a new instance. /// </summary> public SendGridConfiguration() { var nameResolver = new DefaultNameResolver(); ApiKey = nameResolver.Resolve(AzureWebJobsSendGridApiKeyName); }