public override List <Bundle> ParseConfigs()
        {
            if (!Directory.Exists(ProjectPath))
            {
                throw new DirectoryNotFoundException($"Could not find project directory '{ProjectPath}'.");
            }

            FindConfigs();

            var loader = new ConfigLoader(
                FilePaths,
                new ExceptionThrowingLogger(),
                new ConfigLoaderOptions {
                ProcessBundles = true
            });

            Configuration = loader.Get();

            var bundles = Configuration.AutoBundles.Bundles
                          .Select(autoBundle => createBundleOf(autoBundle))
                          .ToList();

            this.WriteOverrideConfigs(bundles);

            return(bundles);
        }
Beispiel #2
0
 internal void ApplyConfiguration(PeerCustomResolverSettings settings)
 {
     if (settings == null)
     {
         throw DiagnosticUtility.ExceptionUtility.ThrowHelperArgumentNull("settings");
     }
     if (this.Address != null)
     {
         settings.Address = new EndpointAddress(this.Address, ConfigLoader.LoadIdentity(this.Identity), this.Headers.Headers);
     }
     settings.BindingSection       = this.Binding;
     settings.BindingConfiguration = this.BindingConfiguration;
     if (!string.IsNullOrEmpty(this.Binding) && !string.IsNullOrEmpty(this.BindingConfiguration))
     {
         settings.Binding = ConfigLoader.LookupBinding(this.Binding, this.BindingConfiguration);
     }
     if (!string.IsNullOrEmpty(this.ResolverType))
     {
         Type type = Type.GetType(this.ResolverType, false);
         if (type == null)
         {
             throw DiagnosticUtility.ExceptionUtility.ThrowHelperError(new ConfigurationErrorsException(System.ServiceModel.SR.GetString("PeerResolverInvalid", new object[] { this.ResolverType })));
         }
         settings.Resolver = Activator.CreateInstance(type) as PeerResolver;
     }
 }
 public CustomPrinterSetting()
 {
     InitializeComponent();
     FormHelper.InitHabitToForm(this);
     this.cbPrintModel.SelectedIndex = 0;
     loader = new ConfigLoader<GlobalPrintSetting>(this);
 }
 public CatcherConfigForm()
 {
     InitializeComponent();
     loader = new ConfigLoader<CatcherConfig>(this);
     FormHelper.InitHabitToForm(this);
     this.cbParaType.SelectedIndex = 0;
 }
Beispiel #5
0
        /// <summary>
        /// Loads the settings for the given file path
        /// </summary>
        internal void LoadSettings(string path)
        {
            ClearMessage();
            _settings = null;

            // Prevent parsing of internet-located documents,
            // or documents that do not have proper paths.
            if (path.StartsWith("http:", StringComparison.OrdinalIgnoreCase) ||
                path.Equals("Temp.txt"))
            {
                return;
            }

            try
            {
                if (!ConfigLoader.TryLoad(path, out _settings))
                {
                    return;
                }

                _localSettings = new LocalSettings(_view, Settings);
                _localSettings.Apply();
            }
            catch (Exception e)
            {
                ShowError(path, "EditorConfig core error: " + e.Message);
            }
        }
Beispiel #6
0
        public void Log(ApiRequest request)
        {
            if (request.Result.StartsWith("<!DOCTYPE html>") || request.URI.StartsWith("/swagger"))
            {
                return;
            }

            var config = ConfigLoader.LoadConfig <LoggingMiddleWareConfig>();

            if (config == null)
            {
                if (request.ElapsedTime > 1000)
                {
                    _logger.InsertRequestLog("requestLog", request.ToJson());
                }
            }
            else
            {
                if (config.IncludePath.Any(p => request.URI.Contains(p)))
                {
                    _logger.InsertRequestLog("requestLog", request.ToJson());
                    return;
                }

                if (!config.IgnorePath.Any(p => request.URI.Contains(p)) && config.Overtime <= request.ElapsedTime)
                {
                    _logger.InsertRequestLog("requestLog", request.ToJson());
                    return;
                }
            }
        }
Beispiel #7
0
        /// <summary>
        /// For a given collection of Mod IDs, returns all mod IDs which
        /// have actual corresponding mods.
        /// </summary>
        /// <param name="appIds">List of App IDs.</param>
        public static List <string> FilterNonexistingAppIds(IEnumerable <string> appIds)
        {
            try
            {
                // Get a set of all apps.
                IConfigLoader <ApplicationConfig> configLoader = new ConfigLoader <ApplicationConfig>();
                var allApps = configLoader.ReadConfigurations(
                    new LoaderConfigReader().ReadConfiguration().ApplicationConfigDirectory,
                    ApplicationConfig.ConfigFileName);
                var allAppSet = BuildSet(allApps.Select(tuple => tuple.Object.AppId));

                // Remove nonexisting apps.
                List <string> newAppList = new List <string>(appIds.Count());
                foreach (var appId in appIds)
                {
                    if (allAppSet.Contains(appId))
                    {
                        newAppList.Add(appId);
                    }
                }

                return(newAppList);
            }
            catch (FileNotFoundException ex) // Unit Testing: Config does not exist.
            {
                return(new List <string>());
            }
        }
Beispiel #8
0
    static public void Reload()
    {
        Datas.Clear();
        TextAsset ta = Resources.Load <TextAsset>("all_config");

        ConfigLoader.LoadFromJson(JsonMapper.ToObject(ta.text));
    }
Beispiel #9
0
 void EmptyLinesMixed()
 {
     using (var loader = new ConfigLoader("EmptyLinesMixed.cfg", "EmptyLinesMixed.Good.cfg")) {
         Config.Save();
         Assert.Equal(loader.GoodText, File.ReadAllText(loader.FileName));
     }
 }
Beispiel #10
0
 void CommentsOnly()
 {
     using (var loader = new ConfigLoader("CommentsOnly.cfg")) {
         Config.Save();
         Assert.Equal(BitConverter.ToString(loader.Bytes), BitConverter.ToString(File.ReadAllBytes(loader.FileName)));
     }
 }
Beispiel #11
0
 void EmptyLinesCR()
 {
     using (var loader = new ConfigLoader("EmptyLinesCR.cfg")) {
         Config.Save();
         Assert.Equal(BitConverter.ToString(loader.Bytes), BitConverter.ToString(File.ReadAllBytes(loader.FileName)));
     }
 }
Beispiel #12
0
 public CatcherConfigForm()
 {
     InitializeComponent();
     loader = new ConfigLoader <CatcherConfig>(this);
     FormHelper.InitHabitToForm(this);
     this.cbParaType.SelectedIndex = 0;
 }
Beispiel #13
0
        static void Main(string[] args)
        {
            var configLoader = new ConfigLoader();

            var downloader = new InvoiceDownloader(
                configLoader.imapServiceSettings(),
                configLoader.credentialsSettings(),
                configLoader.imapFolderSettings().SourceFolder,
                new AttachmentProcessorBuilder()
                .PermitAttachmentType(CommonContentTypes.PDF_NORMAL)
                .PermitAttachmentType(CommonContentTypes.PDF_GENERAL)
                .IgnoringAttachments((contentType, fileName) => fileName
                                     .Contains("detalhe") || fileName
                                     .EndsWith(".zip")
                                     )
                .NameDownloadsByFolder(FileNamers.FolderBasedName)
                .DownloadTo(configLoader.fileSystemExportSettings().ExportDirectory)
                .IncludeMessageHeaders(
                    MessageSummaryItems.UniqueId |
                    MessageSummaryItems.Envelope |
                    MessageSummaryItems.GMailLabels |
                    MessageSummaryItems.BodyStructure |
                    MessageSummaryItems.Size |
                    MessageSummaryItems.ModSeq
                    )
                .Build()
                );

            downloader.TryRun(downloader.RunImplementation);
        }
Beispiel #14
0
        public static ContainerBuilder RegisterTypes(string testProjectPath, string stubsFilePath)
        {
            ContainerBuilder cb = new ContainerBuilder();

            string            configFilePath = Path.Combine(Path.GetDirectoryName(testProjectPath), "SimpleStubs.json");
            SimpleStubsConfig config         = new ConfigLoader().LoadConfig(configFilePath);

            cb.RegisterInstance(config);

            cb.Register((c) =>
            {
                IInterfaceStubber interfaceStubber = new InterfaceStubber(new IMethodStubber[]
                {
                    new OrdinaryMethodStubber(),
                    new EventStubber(),
                    new StubbingDelegateGenerator()
                },
                                                                          new IPropertyStubber[]
                {
                    new PropertyStubber()
                });
                return(interfaceStubber);
            }).As <IInterfaceStubber>().SingleInstance();

            cb.RegisterType <ProjectStubber>().As <IProjectStubber>().SingleInstance();
            cb.RegisterType <SimpleStubsGenerator>().AsSelf();

            return(cb);
        }
Beispiel #15
0
        /// <summary>
        /// For a given collection of Mod IDs, returns all mod IDs which
        /// have actual corresponding mods.
        /// </summary>
        /// <param name="modIds">List of Mod IDs.</param>
        public static List <string> FilterNonexistingModIds(IEnumerable <string> modIds)
        {
            try
            {
                // Get a set of all mods.
                IConfigLoader <ModConfig> configLoader = new ConfigLoader <ModConfig>();
                var allMods   = configLoader.ReadConfigurations(new LoaderConfigReader().ReadConfiguration().ModConfigDirectory, ModConfig.ConfigFileName);
                var allModSet = BuildSet(allMods.Select(tuple => tuple.Object.ModId));

                // Remove nonexisting mods.
                List <string> newModList = new List <string>(modIds.Count());
                foreach (var modId in modIds)
                {
                    if (allModSet.Contains(modId))
                    {
                        newModList.Add(modId);
                    }
                }

                return(newModList);
            }
            catch (FileNotFoundException ex) // Unit Testing: Config does not exist.
            {
                return(new List <string>());
            }
        }
Beispiel #16
0
        public FinacialBuilderTests()
        {
            _config        = ConfigLoader.InitConfiguration();
            ESSENTIALS_KEY = _config["Keys:ESSENTIALS_KEY"];

            SetSubscriptionKeys();
        }
Beispiel #17
0
        public void LoadMigration_MinVersionOfYml_ShouldSetValidProviderAndConnectionString()
        {
            var migration = ConfigLoader.LoadMigration(GetConfigPath("min.yml").Some <string, Error>());

            migration.MatchSome(x => x.Provider.Should().Be(Provider.SqlServer));
            migration.MatchSome(x => x.ConnectionString.Should().Be(@"(localdb)\dbup;Initial Catalog=DbUpTest;Integrated Security=True"));
        }
        public Crypto()
        {
            var thumbprint = ConfigLoader.Get <CryptographicServiceThumbprintConfig>().ThumbPrint;

            _enabled = !string.IsNullOrWhiteSpace(thumbprint);
            if (!_enabled)
            {
                return;
            }

            var cert = GetCertificate(thumbprint);

            var config = ConfigLoader.Get <CryptographicServiceConfig>();

            var dict = new Dictionary <string, string>(StringComparer.InvariantCultureIgnoreCase)
            {
                { "key", config.AesKey },
                { "initVector", config.AesInitVector },
                { "salt", config.AesSalt }
            };

            dict.Keys.ToList().ForEach(key => { dict[key] = Decrypt(cert, dict[key]); });

            _aesSettings = new AesSettings(dict["key"], dict["initVector"], dict["salt"]);
        }
        public static void ConvertToXml(string filename)
        {
            var configLoader   = new ConfigLoader();
            var withoutExt     = Path.GetFileNameWithoutExtension(filename);
            var xmlName        = $"{withoutExt}.xml";
            var mapDescription = configLoader.LoadMapDescription(filename);
            var graph          = mapDescription.GetGraph();

            using (var sw = new StreamWriter($"D:\\Trash\\LevelSyn-1.1\\data\\Thesis\\{xmlName}"))
            {
                sw.WriteLine("<?xml version=\"1.0\" standalone=\"yes\" ?>");
                sw.WriteLine("<Graph>");

                foreach (var vertex in graph.Vertices)
                {
                    sw.WriteLine($"  <Node name=\"{vertex}\" />");
                }

                foreach (var edge in graph.Edges)
                {
                    sw.WriteLine($"  <Edge node0=\"{edge.From}\" node1=\"{edge.To}\" />");
                }

                sw.WriteLine("</Graph>");
            }
        }
Beispiel #20
0
 private void ApplyConfiguration(string configurationName, System.Configuration.Configuration configuration)
 {
     if (this.Endpoint == null)
     {
         throw DiagnosticUtility.ExceptionUtility.ThrowHelperError(new InvalidOperationException(System.ServiceModel.SR.GetString("SFxChannelFactoryCannotApplyConfigurationWithoutEndpoint")));
     }
     if (!this.Endpoint.IsFullyConfigured)
     {
         ConfigLoader loader;
         if (configuration != null)
         {
             loader = new ConfigLoader(configuration.EvaluationContext);
         }
         else
         {
             loader = new ConfigLoader();
         }
         if (configurationName == null)
         {
             loader.LoadCommonClientBehaviors(this.Endpoint);
         }
         else
         {
             loader.LoadChannelBehaviors(this.Endpoint, configurationName);
         }
     }
 }
        /// <summary>
        /// Runs one of the example presented in the Tutorial.
        /// </summary>
        public static void RunExample()
        {
            var configLoader    = new ConfigLoader();
            var layoutGenerator = LayoutGeneratorFactory.GetDefaultChainBasedGenerator <int>();

            // var layoutGenerator = LayoutGeneratorFactory.GetChainBasedGeneratorWithCorridors<int>(new List<int>() {1});
            layoutGenerator.InjectRandomGenerator(new Random(0));

            // var mapDescription = new BasicsExample().GetMapDescription();
            // var mapDescription = configLoader.LoadMapDescription("Resources/Maps/tutorial_basicDescription.yml");

            // var mapDescription = new DifferentShapesExample().GetMapDescription();
            // var mapDescription = configLoader.LoadMapDescription("Resources/Maps/tutorial_differentShapes.yml");

            // var mapDescription = new DIfferentProbabilitiesExample().GetMapDescription();
            var mapDescription = configLoader.LoadMapDescription("Resources/Maps/tutorial_differentProbabilities.yml");

            // var mapDescription = new CorridorsExample().GetMapDescription();
            // var mapDescription = configLoader.LoadMapDescription("Resources/Maps/tutorial_corridors.yml");

            var settings = new GeneratorSettings
            {
                MapDescription  = mapDescription,
                LayoutGenerator = layoutGenerator,

                NumberOfLayouts = 10,

                ShowPartialValidLayouts     = false,
                ShowPartialValidLayoutsTime = 500,
            };

            Application.Run(new GeneratorWindow(settings));
        }
Beispiel #22
0
        public void Setup()
        {
            if (String.IsNullOrEmpty(ConfigPath))
            {
                ConfigPath = Consts.DEFAULT_SMARTSQL_CONFIG_PATH;
            }
            if (String.IsNullOrEmpty(Alias))
            {
                Alias = ConfigPath;
            }
            if (LoggerFactory == null)
            {
                LoggerFactory = NoneLoggerFactory.Instance;
            }

            if (ConfigLoader == null)
            {
                ConfigLoader = new LocalFileConfigLoader(ConfigPath, LoggerFactory);
            }
            var sqlMapConfig = ConfigLoader.Load();

            SmartSqlContext = new SmartSqlContext(LoggerFactory.CreateLogger <SmartSqlContext>(), sqlMapConfig);
            if (DbSessionStore == null)
            {
                DbSessionStore = new DbConnectionSessionStore(LoggerFactory, SmartSqlContext.DbProvider.Factory);
            }
            if (DataSourceFilter == null)
            {
                DataSourceFilter = new DataSourceFilter(LoggerFactory.CreateLogger <DataSourceFilter>(), DbSessionStore, SmartSqlContext);
            }
            if (SqlBuilder == null)
            {
                SqlBuilder = new SqlBuilder(LoggerFactory.CreateLogger <SqlBuilder>(), SmartSqlContext, ConfigLoader);
            }

            if (PreparedCommand == null)
            {
                PreparedCommand = new PreparedCommand(LoggerFactory.CreateLogger <PreparedCommand>(), SmartSqlContext);
            }
            if (CommandExecuter == null)
            {
                CommandExecuter = new CommandExecuter(LoggerFactory.CreateLogger <CommandExecuter>(), PreparedCommand);
            }
            if (DataReaderDeserializerFactory == null)
            {
                DataReaderDeserializerFactory = new EmitDataReaderDeserializerFactory();
            }
            if (CacheManager == null)
            {
                if (SmartSqlContext.IsCacheEnabled)
                {
                    CacheManager = new CacheManager(LoggerFactory.CreateLogger <CacheManager>(), SmartSqlContext, DbSessionStore);
                }
                else
                {
                    CacheManager = new NoneCacheManager();
                }
            }
            ConfigLoader.OnChanged += ConfigLoader_OnChanged;
        }
 void Load(IEnumerable <ILump> contents, [CallerMemberName] string?name = null)
 {
     ConfigLoader
     .Load()
     .CreateECWolfLauncher()
     .CreateAndLoadWad(contents, Path.Combine(_dirInfo.FullName, (name ?? "demo") + ".wad"));
 }
Beispiel #24
0
        public void LoadMigration_ShouldReturnNoneWithError_InCaseOfSyntacticError()
        {
            var migrationOrNone = ConfigLoader.LoadMigration(GetConfigPath("syntax-error.yml").Some <string, Error>());

            migrationOrNone.Match(
                some: m => Assert.Fail("Migration should not be loaded in case of syntactic error"),
                none: e => e.Should().NotBeNull());
        }
Beispiel #25
0
        public static void AddConfigurationProvider(this IServiceCollection services, IConfiguration configuration)
        {
            IConfigLoader loader = new ConfigLoader();

            configProvider = loader.GetConfigProvider(configuration);

            services.AddSingleton <IConfigProvider>(configProvider);
        }
Beispiel #26
0
        public void RemoveMulti()
        {
            using var loader = new ConfigLoader("RemoveMulti.cfg", "RemoveMulti.Good.cfg");
            Config.Delete("Key2");
            Config.Save();

            Assert.Equal(loader.GoodText, File.ReadAllText(loader.FileName));
        }
Beispiel #27
0
        private static void InternalInit(LogConfig config)
        {
            Config = config;    // 注意:这里不克隆参数对应,直接引用它

            ConfigLoader loader = new ConfigLoader();

            loader.Load(config, s_writerTable);
        }
Beispiel #28
0
 public void EmptySave()
 {
     using var loader = new ConfigLoader("Empty.cfg");
     Assert.True(Config.Load(), "File should exist before load.");
     Assert.True(Config.Save(), "Save should succeed.");
     Assert.Equal(BitConverter.ToString(loader.Bytes), BitConverter.ToString(File.ReadAllBytes(loader.FileName)));
     Assert.False(Config.IsAssumedInstalled);
 }
Beispiel #29
0
 public void SaveAndReplaceConfig(int configId)
 {
     config.Id = configId;
     ConfigLoader.SerializeConfig(config, configId.ToString());
     GameManager.Instance.GameConfig = config;
     GameManager.Instance.fader.LoadSceneFading("configChoice");
     ConfigChooser.selectedConfigName = config.Name;
 }
Beispiel #30
0
        private static Context GetValidatedContext()
        {
            var context = ConfigLoader.FromConfigFile();

            context.Validate();

            return(context);
        }
Beispiel #31
0
 public void ReadMultiFromOverrideNotFound()
 {
     using (var loader = new ConfigLoader("ReplaceOnlyLast.Good.cfg", resourceOverrideFileName: "RemoveMulti.cfg")) {
         var list = new List <string>(Config.Read("Key3"));
         Assert.Equal(1, list.Count);
         Assert.Equal("Value 3", list[0]);
     }
 }
Beispiel #32
0
 public void CommentsWithValues()
 {
     using (var loader = new ConfigLoader("CommentsWithValues.cfg")) {
         Config.Save();
         Assert.Equal(Encoding.UTF8.GetString(loader.Bytes), Encoding.UTF8.GetString(File.ReadAllBytes(loader.FileName)));
         Assert.Equal(BitConverter.ToString(loader.Bytes), BitConverter.ToString(File.ReadAllBytes(loader.FileName)));
     }
 }
Beispiel #33
0
        public void LoadConfigTest()
        {
            ConfigLoader _testloader = new ConfigLoader();

            _testloader.Load();

            Assert.IsNotNull(_testloader.classConfigResult);

            Console.WriteLine(_testloader.classConfigResult.add[0].key);
        }
Beispiel #34
0
        public void JSONConvertTest()
        {
            ConfigLoader _testloader = new ConfigLoader();
            _testloader.Load();

            DataDownloader _testDownloader = new DataDownloader(_testloader.classConfigResult);
            _testDownloader.DataDownload();

            List<Dictionary<string, object>> _output = JsonConvert.DeserializeObject<List<Dictionary<string, object>>>(_testDownloader.strDownloadData);

            Console.WriteLine(_output[253]["經度Lng"] == null);

            Assert.IsNull(_output[253]["經度Lng"]);
        }
Beispiel #35
0
        public void DataDownloadTest()
        {
            ConfigLoader _testloader = new ConfigLoader();

            _testloader.Load();

            DataDownloader _testDownloader = new DataDownloader(_testloader.classConfigResult);

            _testDownloader.DataDownload();

            Assert.IsNotNull(_testDownloader.strDownloadData);

            Console.WriteLine(_testDownloader.strDownloadData);
        }
Beispiel #36
0
        public void LoadCSVTest()
        {
            ConfigLoader _testloader = new ConfigLoader();

            _testloader.Load();

            DataDownloader _testDownloader = new DataDownloader(_testloader.classConfigResult);
            _testDownloader.DataDownload();

            List<Dictionary<string, object>> output = CSVReader.Read(_testDownloader.strDownloadData);

            Assert.IsTrue(output[5]["經度Lng"].ToString() == "");

            Console.WriteLine(output[5]["經度Lng"]);
        }
        public CapturePhotoSetting()
        {
            InitializeComponent();
            FormHelper.InitHabitToForm(this);
            loader = new ConfigLoader<CapturePhotoSet>(this);
            CapturePhotoSet set= StaticCacheManager.GetConfig<CapturePhotoSet>();
            try
            {
                this.lbBgColor.BackColor =
                    Color.FromArgb(set.BgRgbR,set.BgRgbG,set.BgRgbB);
            }
            catch (System.Exception ex)
            {

            }
        }
Beispiel #38
0
        public void CSVConvertTest()
        {
            ConfigLoader _testloader = new ConfigLoader();
            _testloader.Load();

            DataDownloader _testDownloader = new DataDownloader(_testloader.classConfigResult);
            _testDownloader.DataDownload();

            ProcessorFactory _testFactory = new ProcessorFactory(_testloader.classConfigResult);
            CSVProcessor _processor = _testFactory.GetYourProcessor() as CSVProcessor;

            Way _way = _processor.Process(_testDownloader.strDownloadData , _testloader.classConfigResult);

            Console.WriteLine(_way.Nodes.Count);

            Assert.IsNotNull(_way.Nodes);
        }
        public ServiceEndpoint GenerateServiceEndpoint(ServiceHostBase serviceHost, Uri baseAddress)
        {
            Fx.Assert(serviceHost != null, "The 'serviceHost' parameter should not be null.");
            Fx.Assert(baseAddress != null, "The 'baseAddress' parameter should not be null.");

            AuthenticationSchemes supportedSchemes = GetAuthenticationSchemes(baseAddress);
            Type contractType = this.GetSingleImplementedContract();
            ConfigLoader configLoader = new ConfigLoader(serviceHost.GetContractResolver(this.implementedContracts));
            ServiceEndpointElement serviceEndpointElement = new ServiceEndpointElement();
            
            serviceEndpointElement.Contract = contractType.FullName;
            this.SetBindingConfiguration(baseAddress.Scheme, serviceEndpointElement);
            serviceEndpointElement.Kind = this.standardEndpointKind;

            ServiceEndpoint serviceEndpoint = configLoader.LookupEndpoint(serviceEndpointElement, null, serviceHost, serviceHost.Description, true);
            this.ConfigureBinding(serviceEndpoint.Binding, baseAddress.Scheme, supportedSchemes, AspNetEnvironment.Enabled);

            // Setting the Endpoint address and listenUri now that we've set the binding security
            ConfigLoader.ConfigureEndpointAddress(serviceEndpointElement, serviceHost, serviceEndpoint);
            ConfigLoader.ConfigureEndpointListenUri(serviceEndpointElement, serviceHost, serviceEndpoint);

            return serviceEndpoint;
        }
 public ComPlusServiceLoader(ServiceInfo info)
 {
     this.info = info;
     this.typeLoader = new ComPlusTypeLoader(info);
     this.configLoader = new ConfigLoader(this.typeLoader);
 }
        // This method adds automatic endpoints at the base addresses, 1 per site binding (http or https). It only configures
        // the security on the binding. It does not add any behaviors.
        // If there are no base addresses, or if endpoints have been configured explicitly, it does not add any
        // automatic endpoints.
        // If it adds automatic endpoints, it validates that the service implements a single contract
        internal static void AddAutomaticWebHttpBindingEndpoints(ServiceHost host, IDictionary<string, ContractDescription> implementedContracts,  string multipleContractsErrorMessage, string noContractErrorMessage, string standardEndpointKind)
        {
            bool enableAutoEndpointCompat = AppSettings.EnableAutomaticEndpointsCompatibility;
            // We do not add an automatic endpoint if an explicit endpoint has been configured unless
            // the user has specifically opted into compat mode.  See CSDMain bugs 176157 & 262728 for history
            if (host.Description.Endpoints != null 
                && host.Description.Endpoints.Count > 0
                && !enableAutoEndpointCompat)
            {
                return;
            }

            AuthenticationSchemes supportedSchemes = AuthenticationSchemes.None;
            if (host.BaseAddresses.Count > 0)
            {
                supportedSchemes = AspNetEnvironment.Current.GetAuthenticationSchemes(host.BaseAddresses[0]);

                if (AspNetEnvironment.Current.IsSimpleApplicationHost)
                {
                    // Cassini always reports the auth scheme as anonymous or Ntlm. Map this to Ntlm, except when forms auth
                    // is requested
                    if (supportedSchemes == (AuthenticationSchemes.Anonymous | AuthenticationSchemes.Ntlm))
                    {
                        if (AspNetEnvironment.Current.IsWindowsAuthenticationConfigured())
                        {
                            supportedSchemes = AuthenticationSchemes.Ntlm;
                        }
                        else
                        {
                            supportedSchemes = AuthenticationSchemes.Anonymous;
                        }
                    }
                }
            }
            Type contractType = null;
            // add an endpoint with the contract at each base address
            foreach (Uri baseAddress in host.BaseAddresses)
            {
                string uriScheme = baseAddress.Scheme;
                
                // HTTP and HTTPs are only supported schemes
                if (Object.ReferenceEquals(uriScheme, Uri.UriSchemeHttp) || Object.ReferenceEquals(uriScheme, Uri.UriSchemeHttps))
                {
                    // bypass adding the automatic endpoint if there's already one at the base address
                    bool isExplicitEndpointConfigured = false;
                    foreach (ServiceEndpoint endpoint in host.Description.Endpoints)
                    {
                        if (endpoint.Address != null && EndpointAddress.UriEquals(endpoint.Address.Uri, baseAddress, true, false))
                        {
                            isExplicitEndpointConfigured = true;
                            break;
                        }
                    }
                    if (isExplicitEndpointConfigured)
                    {
                        continue;
                    }

                    if (contractType == null)
                    {
                        if (implementedContracts.Count > 1)
                        {
                            throw DiagnosticUtility.ExceptionUtility.ThrowHelperError(new InvalidOperationException(multipleContractsErrorMessage));
                        }
                        else if (implementedContracts.Count == 0)
                        {
                            throw DiagnosticUtility.ExceptionUtility.ThrowHelperError(new InvalidOperationException(noContractErrorMessage));
                        }
                        foreach (ContractDescription contract in implementedContracts.Values)
                        {
                            contractType = contract.ContractType;
                            break;
                        }
                    }
                    
                    // Get the default web endpoint
                    ConfigLoader configLoader = new ConfigLoader(host.GetContractResolver(implementedContracts));
                    ServiceEndpointElement serviceEndpointElement = new ServiceEndpointElement();
                    serviceEndpointElement.Contract = contractType.FullName;
                    // Check for a protocol mapping
                    ProtocolMappingItem protocolMappingItem = ConfigLoader.LookupProtocolMapping(baseAddress.Scheme);
                    if (protocolMappingItem != null &&
                        string.Equals(protocolMappingItem.Binding, WebHttpBinding.WebHttpBindingConfigurationStrings.WebHttpBindingCollectionElementName, StringComparison.Ordinal))
                    {
                        serviceEndpointElement.BindingConfiguration = protocolMappingItem.BindingConfiguration;
                    }
                    serviceEndpointElement.Kind = standardEndpointKind;

                    // LookupEndpoint will not set the Endpoint address and listenUri
                    // because omitSettingEndpointAddress is set to true.
                    // We will set them after setting the binding security
                    ServiceEndpoint automaticEndpoint = configLoader.LookupEndpoint(serviceEndpointElement, null, host, host.Description, true /*omitSettingEndpointAddress*/);
                    WebHttpBinding binding = automaticEndpoint.Binding as WebHttpBinding;
                                    
                    bool automaticallyConfigureSecurity = !binding.Security.IsModeSet;
                    if (automaticallyConfigureSecurity)
                    {
                        if (Object.ReferenceEquals(uriScheme, Uri.UriSchemeHttps))
                        {
                            binding.Security.Mode = WebHttpSecurityMode.Transport;
                        }
                        else if (supportedSchemes != AuthenticationSchemes.None && supportedSchemes != AuthenticationSchemes.Anonymous)
                        {
                            binding.Security.Mode = WebHttpSecurityMode.TransportCredentialOnly;
                        }
                        else
                        {
                            binding.Security.Mode = WebHttpSecurityMode.None;
                        }
                    }
                    
                    if (automaticallyConfigureSecurity && AspNetEnvironment.Enabled)
                    {
                        SetBindingCredentialBasedOnHostedEnvironment(automaticEndpoint, supportedSchemes);
                    }

                    // Setting the Endpoint address and listenUri now that we've set the binding security
                    ConfigLoader.ConfigureEndpointAddress(serviceEndpointElement, host, automaticEndpoint);
                    ConfigLoader.ConfigureEndpointListenUri(serviceEndpointElement, host, automaticEndpoint);

                    host.AddServiceEndpoint(automaticEndpoint);
                }
            }
        }
Beispiel #42
0
 public SetWindowEnv()
 {
     InitializeComponent();
     FormHelper.InitHabitToForm(this);
     loader = new ConfigLoader<SystemEnvConfig>(this);
 }
Beispiel #43
0
 public SimpleRegister()
 {
     InitializeComponent();
     FormHelper.InitHabitToForm(this);
     loader = new ConfigLoader<ProgramRegConfig>(this);
 }
Beispiel #44
0
 public ExamPolicySetting()
 {
     InitializeComponent();
     FormHelper.InitHabitToForm(this);
     loader = new ConfigLoader<ExamPolicy>(this);
 }
Beispiel #45
0
 public SystemConfig()
 {
     InitializeComponent();
     FormHelper.InitHabitToForm(this);
     loader = new ConfigLoader<MonitorConfig>(this);
 }
Beispiel #46
0
        public void XMLConvertTest()
        {
            ConfigLoader _testloader = new ConfigLoader();
            _testloader.Load();

            DataDownloader _testDownloader = new DataDownloader(_testloader.classConfigResult);
            _testDownloader.DataDownload();

            XmlDocument _document = new XmlDocument();
            _document.LoadXml(_testDownloader.strDownloadData);

            if(_document.FirstChild.NodeType == XmlNodeType.XmlDeclaration)
                _document.RemoveChild(_document.FirstChild);

            string json = JsonConvert.SerializeXmlNode(_document.FirstChild , Newtonsoft.Json.Formatting.None , true);

            Console.WriteLine(json);
        }
Beispiel #47
0
        public void ProcessorFactoryTest()
        {
            ConfigLoader _testloader = new ConfigLoader();

            _testloader.Load();

            ProcessorFactory _testFactory = new ProcessorFactory(_testloader.classConfigResult);

            Assert.IsNotNull(_testFactory.GetYourProcessor());
        }
Beispiel #48
0
        public void MakeXMLTest()
        {
            ConfigLoader _testloader = new ConfigLoader();

            _testloader.Load();

            OSMXMLMaker _testMaker = new OSMXMLMaker();

            #region Make Mock Data

            CommonAttributes _tAttr = new CommonAttributes();

            List<Tag> _tTags = new List<Tag>();

            for(int i = 0; i < 2; ++i)
            {
                Tag _t = new Tag("key" + i.ToString(), "value" + i.ToString());

                _tTags.Add(_t);
            }

            Node _tNode = new Node(_tAttr,"0.1","0.2",_tTags);

            List<Node> _tNodes = new List<Node>();
            _tNodes.Add(_tNode);

            Way _tWay = new Way(_tAttr, _tNodes, _tTags);

            #endregion

            _testMaker.MakeXMLFile(_tWay , _testloader.classConfigResult);
        }
 public BarReaderConfigForm()
 {
     InitializeComponent();
     FormHelper.InitHabitToForm(this);
     loader = new ConfigLoader<BarReaderConfig>(this);
 }
Beispiel #50
0
 public SimpleCompany()
 {
     InitializeComponent();
     FormHelper.InitHabitToForm(this);
     loader = new ConfigLoader<CompanyInfo>(this);
 }
 public StudentSystemConfigForm()
 {
     InitializeComponent();
     FormHelper.InitHabitToForm(this);
     loader = new ConfigLoader<StudentSystemConfig>(this);
 }
        private ServiceEndpoint CreateServiceEndpoint()
        {
            TypeLoader loader = new TypeLoader();
            ContractDescription contractDescription = loader.LoadContractDescription(contractType);

            ServiceEndpoint endpoint = new ServiceEndpoint(contractDescription);
            if (address != null)
                endpoint.Address = new EndpointAddress(new Uri(address), identity);
            if (binding != null)
                endpoint.Binding = binding;

            if (configurationName != null)
            {
                ConfigLoader configLoader = new ConfigLoader();
                configLoader.LoadChannelBehaviors(endpoint, configurationName);
            }

            ComPlusTypedChannelBuilderTrace.Trace(TraceEventType.Verbose, TraceCode.ComIntegrationTypedChannelBuilderLoaded,
                SR.TraceCodeComIntegrationTypedChannelBuilderLoaded, contractType, binding);

            return endpoint;
        }
Beispiel #53
0
 public Setting()
 {
     InitializeComponent();
     FormHelper.InitHabitToForm(this);
     loader = new ConfigLoader<CarStartSetting>(this);
 }
 public DbAutoBakConfigForm()
 {
     InitializeComponent();
     FormHelper.InitHabitToForm(this);
     loader = new ConfigLoader<DbAutoBakConfig>(this);
 }