Beispiel #1
0
        static Settings Create()
        {
            IConfiguration configuration = new ConfigurationBuilder()
                                           .SetBasePath(Directory.GetCurrentDirectory())
                                           .AddJsonFile("config/settings.json")
                                           .AddEnvironmentVariables()
                                           .Build();

            var frequencies = new List <Frequency>();

            configuration.GetSection(FrequencyPropertyName).Bind(frequencies);

            string         runProfileName     = configuration.GetValue <string>(NetworkControllerRunProfilePropertyName);
            NetworkProfile runProfileSettings = configuration.GetSection($"{DefaultProfilesPropertyName}:{runProfileName}").Get <NetworkProfile>();

            if (runProfileSettings == null)
            {
                runProfileSettings = NetworkProfile.Online;
            }

            return(new Settings(
                       configuration.GetValue <TimeSpan>(StartAfterPropertyName),
                       configuration.GetValue <string>(DockerUriPropertyName),
                       configuration.GetValue <string>(NetworkIdPropertyName),
                       frequencies,
                       runProfileSettings,
                       configuration.GetValue <Uri>(TestResultCoordinatorEndpointPropertyName),
                       configuration.GetValue <string>(TrackingIdPropertyName),
                       configuration.GetValue <string>(ModuleIdPropertyName),
                       configuration.GetValue <string>(IotHubHostnamePropertyName)));
        }
Beispiel #2
0
 Settings(
     TimeSpan startAfter,
     string dockerUri,
     string networkId,
     IList <Frequency> frequencies,
     NetworkProfile runProfileSettings,
     Uri testResultCoordinatorEndpoint,
     string trackingId,
     string moduleId,
     string iothubHostname)
 {
     this.StartAfter  = startAfter;
     this.Frequencies = frequencies;
     this.DockerUri   = Preconditions.CheckNonWhiteSpace(dockerUri, nameof(dockerUri));
     this.NetworkId   = Preconditions.CheckNonWhiteSpace(networkId, nameof(networkId));
     this.TestResultCoordinatorEndpoint = Preconditions.CheckNotNull(testResultCoordinatorEndpoint, nameof(testResultCoordinatorEndpoint));
     this.NetworkRunProfile             = Preconditions.CheckNotNull(runProfileSettings, nameof(runProfileSettings));
     Preconditions.CheckRange <uint>(this.NetworkRunProfile.ProfileSetting.PackageLoss, 0, 101, nameof(this.NetworkRunProfile));
     this.TrackingId     = Preconditions.CheckNonWhiteSpace(trackingId, nameof(trackingId));
     this.ModuleId       = Preconditions.CheckNonWhiteSpace(moduleId, nameof(moduleId));
     this.IotHubHostname = Preconditions.CheckNonWhiteSpace(iothubHostname, nameof(iothubHostname));
 }