/// <inheritdoc />
 public void Configure(IConfigSection configSection)
 {
     _dataDirectory = configSection.GetString(@"data/elevation/local", null);
     _srtmSchemaPath = configSection.GetString(@"data/elevation/remote.schema", null);
     _srtmServer = configSection.GetString(@"data/elevation/remote.server", @"http://dds.cr.usgs.gov/srtm/version2_1/SRTM3");
     _downloader = new SrtmDownloader(_srtmServer, _srtmSchemaPath, _fileSystemService, _trace);
 }
Example #2
0
 private static string GetFileName(IConfigSection section)
 {
     var ext = section.FileExtension;
     if (ext.StartsWith("."))
         ext = ext.Remove(0, 1);
     if (0 == ext.Length) throw new InvalidOperationException("The specified configuration section does not have a valid file extension");
     return string.Format("{0}.{1}", TargetPath, ext);
 }
Example #3
0
 private void SerializeProperties(IConfigSection section, XElement xmlSection)
 {
     foreach (var item in section.GetType().GetProperties())
     {
         if (PropertyIsRelevant(item, section))
         {
             SerializeProperty(xmlSection, item, section);
         }
     }
 }
Example #4
0
 public void SetDeserializedConfigs(XDocument xmlConfig, IConfigSection[] configs)
 {
     foreach (var section in xmlConfig.Root.Elements())
     {
         var config = GetConfigSection(configs, section);
         if (config != null)
         {
             GetConfigValuesFromXml(section, config);
         }
     }
 }
        private void AddSection(IConfigSection configSection)
        {
            var displayNameAttribute = (NameAttribute)Attribute.GetCustomAttribute(configSection.GetType(), typeof(NameAttribute));
            if (displayNameAttribute != null)
            {
                var configSectionControl = new ConfigSectionControl(_localController, _configController.GetConfigSection<ICoreConfigSection>(), _allExporters, _buildController);
                configSectionControl.SectionHeader = _localController.GetLocalString(displayNameAttribute.LocalType, displayNameAttribute.DisplayName);
                configSectionControl.ConfigSection = configSection;

                configPanel.Children.Add(configSectionControl);
            }
        }
Example #6
0
        private static void MapList(IConfigSection section, Object model, PropertyInfo pi, IConfigProvider provider)
        {
            var elementType = pi.PropertyType.GetElementTypeEx();

            // 实例化列表
            if (pi.GetValue(model, null) is not IList list)
            {
                var obj = !pi.PropertyType.IsInterface ?
                          pi.PropertyType.CreateInstance() :
                          typeof(List <>).MakeGenericType(elementType).CreateInstance();

                list = obj as IList;
                if (list == null)
                {
                    return;
                }

                pi.SetValue(model, list, null);
            }

            // 逐个映射
            for (var i = 0; i < section.Childs.Count; i++)
            {
                var val = elementType.CreateInstance();
                if (elementType.GetTypeCode() != TypeCode.Object)
                {
                    val = section.Childs[i].Value;
                }
                else
                {
                    MapTo(section.Childs[i], val, provider);
                    //list[i] = val;
                }
                list.Add(val);
            }
        }
Example #7
0
        private void SerializeProperty(XElement xmlSection, PropertyInfo item, IConfigSection section)
        {
            if (item.PropertyType.Name == "ObservableCollection`1")
            {
                var xmlProperty = new XElement("item", new XAttribute("key", item.Name));
                var list        = (IEnumerable <string>)item.GetValue(section, null);
                AddValueToProperty(xmlProperty, string.Join(";", list));
                xmlSection.Add(xmlProperty);
            }
            else if (item.PropertyType.Name == "SDPath")
            {
                var path = item.GetValue(section, null) as SDPath;
                if (path != null)
                {
                    path.UpdatePath();

                    var xmlProperty = new XElement(item.Name);
                    xmlProperty.Add(new XElement("Relative")
                    {
                        Value = path.RelativePath
                    });
                    xmlProperty.Add(new XElement("Full")
                    {
                        Value = path.FullPath
                    });

                    xmlSection.Add(xmlProperty);
                }
            }
            else
            {
                var xmlProperty = new XElement("item", new XAttribute("key", item.Name));
                AddValueToProperty(xmlProperty, item.GetValue(section, null).ToString());
                xmlSection.Add(xmlProperty);
            }
        }
Example #8
0
        private void SerializeProperty(XElement xmlSection, PropertyInfo item, IConfigSection section)
        {
            if (item.PropertyType.Name == "ObservableCollection`1")
            {
                var xmlProperty = new XElement("item", new XAttribute("key", item.Name));
                var list = (IEnumerable<string>)item.GetValue(section, null);
                AddValueToProperty(xmlProperty, string.Join(";", list));
                xmlSection.Add(xmlProperty);
            }
            else if (item.PropertyType.Name == "SDPath")
            {
                var path = item.GetValue(section, null) as SDPath;
                if (path != null)
                {
                    path.UpdatePath();

                    var xmlProperty = new XElement(item.Name);
                    xmlProperty.Add(new XElement("Relative")
                    {
                        Value = path.RelativePath
                    });
                    xmlProperty.Add(new XElement("Full")
                    {
                        Value = path.FullPath
                    });

                    xmlSection.Add(xmlProperty);
                }
            }
            else
            {
                var xmlProperty = new XElement("item", new XAttribute("key", item.Name));
                AddValueToProperty(xmlProperty, item.GetValue(section, null).ToString());
                xmlSection.Add(xmlProperty);
            }
        }
Example #9
0
        /// <summary>映射配置树到实例公有属性</summary>
        /// <param name="section">数据源</param>
        /// <param name="model">模型</param>
        internal static void MapTo(this IConfigSection section, Object model)
        {
            if (section == null || section.Childs == null || section.Childs.Count == 0 || model == null)
            {
                return;
            }

            // 反射公有实例属性
            foreach (var pi in model.GetType().GetProperties(true))
            {
                if (!pi.CanRead || !pi.CanWrite)
                {
                    continue;
                }
                //if (pi.GetIndexParameters().Length > 0) continue;
                //if (pi.GetCustomAttribute<IgnoreDataMemberAttribute>(false) != null) continue;
                //if (pi.GetCustomAttribute<XmlIgnoreAttribute>() != null) continue;

                var name = SerialHelper.GetName(pi);
                if (name.EqualIgnoreCase("ConfigFile", "IsNew"))
                {
                    continue;
                }

                var cfg = section.Childs?.FirstOrDefault(e => e.Key.EqualIgnoreCase(name));
                if (cfg == null)
                {
                    continue;
                }

                // 分别处理基本类型、数组类型、复杂类型
                if (pi.PropertyType.GetTypeCode() != TypeCode.Object)
                {
                    pi.SetValue(model, cfg.Value.ChangeType(pi.PropertyType), null);
                }
                else if (cfg.Childs != null)
                {
                    if (pi.PropertyType.As <IList>())
                    {
                        if (pi.PropertyType.IsArray)
                        {
                            MapArray(cfg, model, pi);
                        }
                        else
                        {
                            MapList(cfg, model, pi);
                        }
                    }
                    else
                    {
                        // 复杂类型需要递归处理
                        var val = pi.GetValue(model, null);
                        if (val == null)
                        {
                            // 如果有无参构造函数,则实例化一个
                            var ctor = pi.PropertyType.GetConstructor(new Type[0]);
                            if (ctor != null)
                            {
                                val = ctor.Invoke(null);
                                pi.SetValue(model, val, null);
                            }
                        }

                        // 递归映射
                        if (val != null)
                        {
                            MapTo(cfg, val);
                        }
                    }
                }
            }
        }
Example #10
0
 public abstract void Configure(IConfigSection configSection);
Example #11
0
 /// <inheritdoc />
 public void Configure(IConfigSection configSection)
 {
     MapDataAdapter.UseTrace(_trace);
 }
Example #12
0
 /// <inheritdoc />
 public void Configure(IConfigSection configSection)
 {
     _osmMapDataProvider.Configure(configSection);
     _mapzenMapDataProvider.Configure(configSection);
 }
Example #13
0
 private bool PropertyIsRelevant(PropertyInfo item, IConfigSection section)
 {
     return(item.GetValue(section, null) != null && !item.Name.Equals("Guid") && !item.Name.Equals("IsSaved"));
 }
Example #14
0
 /// <inheritdoc />
 public void Configure(IConfigSection configSection)
 {
     _mapDataLibrary.Configure(configSection.GetString("data/index"));
     _mapDataStorageType = MapDataStorageType.Persistent;
 }
Example #15
0
 private bool PropertyIsRelevant(PropertyInfo item, IConfigSection section)
 {
     return item.GetValue(section, null) != null && !item.Name.Equals("Guid") && !item.Name.Equals("IsSaved");
 }
 public MatchYourSkillsToCareerConfigurationSetup(ScenarioContext context)
 {
     _context       = context;
     _configSection = context.Get <IConfigSection>();
     _objectContext = context.Get <ObjectContext>();
 }
 /// <summary>
 /// Adds the specific configuration section to the .git/config file.
 /// </summary>
 /// <param name="configSection">The configuration section.</param>
 public void AddConfigSection(IConfigSection configSection)
 {
     SettingsCache.AddConfigSection(configSection);
 }
Example #18
0
        private void ReadNode(XmlReader reader, IConfigSection section)
        {
            while (true)
            {
                var remark = "";
                if (reader.NodeType == XmlNodeType.Comment)
                {
                    remark = reader.Value;
                }
                while (reader.NodeType == XmlNodeType.Comment || reader.NodeType == XmlNodeType.Whitespace)
                {
                    reader.Skip();
                }
                if (reader.NodeType != XmlNodeType.Element)
                {
                    break;
                }

                var name = reader.Name;
                var cfg  = section.AddChild(name);
                // 前一行是注释
                if (!remark.IsNullOrEmpty())
                {
                    cfg.Comment = remark;
                }

                // 读取属性值
                if (reader.HasAttributes)
                {
                    var dic = new Dictionary <String, String>();
                    reader.MoveToFirstAttribute();
                    do
                    {
                        //var cfg2 = cfg.AddChild(reader.Name);
                        //cfg2.Value = reader.Value;
                        dic[reader.Name] = reader.Value;
                    } while (reader.MoveToNextAttribute());

                    // 如果只有一个Value属性,可能是基元类型数组
                    if (dic.Count == 1 && dic.TryGetValue("Value", out var val))
                    {
                        cfg.Value = val;
                    }
                    else
                    {
                        foreach (var item in dic)
                        {
                            var cfg2 = cfg.AddChild(item.Key);
                            cfg2.Value = item.Value;
                        }
                    }
                }
                else
                {
                    reader.ReadStartElement();
                }
                while (reader.NodeType == XmlNodeType.Whitespace)
                {
                    reader.Skip();
                }

                // 遇到下一层节点
                if (reader.NodeType == XmlNodeType.Element || reader.NodeType == XmlNodeType.Comment)
                {
                    ReadNode(reader, cfg);
                }
                else if (reader.NodeType == XmlNodeType.Text)
                {
                    cfg.Value = reader.ReadContentAsString();
                }

                if (reader.NodeType == XmlNodeType.Attribute)
                {
                    reader.Read();
                }
                if (reader.NodeType == XmlNodeType.EndElement)
                {
                    reader.ReadEndElement();
                }
                while (reader.NodeType == XmlNodeType.Whitespace)
                {
                    reader.Skip();
                }
            }
        }
 public HomepageConfigurationSetup(ScenarioContext context)
 {
     _context       = context;
     _configSection = context.Get <IConfigSection>();
     _objectContext = context.Get <ObjectContext>();
 }
        public void Initialize()
        {
            var config = TestHelper.GetJsonConfig(TestHelper.ConfigTestRootFile);

            _stubSection = config.GetSection("stubs");
        }
Example #21
0
 /// <inheritdoc />
 public void Configure(IConfigSection configSection)
 {
     _eleDataType = (ElevationDataType)configSection.GetInt("data/elevation/type", 0);
 }
Example #22
0
 private void NewSection()
 {
     _section = new ConfigSection(token.ToString(), false);
     _configFile.ConfigSections.Add(_section);
     token.Clear();
 }
Example #23
0
 public static void SetUp(Func<IConfigSection> configSectionBuilder)
 {
     builder = configSectionBuilder;
     configurableValuesSection = null;
 }
Example #24
0
 /// <summary> Sets configuration section associated with this component. </summary>
 /// <param name="configSection">Config section.</param>
 /// <returns>Component.</returns>
 public Component SetConfig(IConfigSection configSection)
 {
     ConfigSection = configSection;
     return(this);
 }
Example #25
0
 public void RemoveSection(IConfigSection section)
 {
     m_sections.Remove(section.Name);
 }
Example #26
0
 /// <summary>获取字符串形式</summary>
 /// <param name="section">配置段</param>
 /// <returns></returns>
 public virtual String GetString(IConfigSection section = null) => null;
 /// <inheritdoc />
 public void Configure(IConfigSection configSection)
 {
     _cachePath = configSection.GetString(@"data/cache", null);
 }
 public FindACourseConfigurationSetup(ScenarioContext context)
 {
     _context       = context;
     _configSection = context.Get <IConfigSection>();
     _objectContext = context.Get <ObjectContext>();
 }
Example #29
0
 private void GetAndSetConfigValue(IConfigSection config, XElement item)
 {
     var property = config.GetType().GetProperty(item.Attribute("key").Value);
     if (property != null)
     {
         if(property.PropertyType.Name == "Boolean")
         {
             property.SetValue(config, item.Attribute("value").Value.ToLower() == "true", null);
         }
         else if (property.PropertyType.Name == "ObservableCollection`1")
         {
             property.SetValue(config, new ObservableCollection<string>(item.Attribute("value").Value.Split(';').ToList()), null);
         }
         else
         {
             property.SetValue(config, item.Attribute("value").Value, null);
         }
     }
 }
 /// <inheritdoc />
 public void Configure(IConfigSection configSection)
 {
     _moveSensitivity = configSection.GetFloat("sensitivity", 30);
     _offsetRatio = configSection.GetFloat("offset", 10); // percentage of tile size
 }
Example #31
0
 private IConfigSection?FindConfigSection(IConfigSection configSectionToFind)
 {
     return(ConfigSections.FirstOrDefault(configSectionToFind.Equals));
 }
 public RoleInstanceHealthWatchdogFactory(IConfigSection configSection, IHealthClient healthClient)
 {
     this.configSection = configSection.Validate("configSection");
     this.healthClient  = healthClient.Validate("healthClient");
 }
Example #33
0
 /// <summary> Creates instance of <see cref="CompositionRoot"/>. </summary>
 /// <param name="container"> Dependency injection container. </param>
 /// <param name="configSection"> Application configuration. </param>
 public CompositionRoot(IContainer container, IConfigSection configSection)
 {
     _container           = container;
     _configSection       = configSection;
     _bootstrapperActions = new List <Action <IContainer, IConfigSection> >();
 }
Example #34
0
        // Does repairTask represent a VendorRepair, via action/target match?
        public static bool MatchesVendorRepairJobByActionAndTarget(this IRepairTask repairTask, RepairActionProvider repairActionProvider, IConfigSection configSection, ITenantJob tenantJob)
        {
            repairTask.Validate("repairTask");
            tenantJob.Validate("tenantJob");

            // 1. check action
            RepairActionTypeEnum?actionFromRepairTask = repairActionProvider.GetRepairAction(repairTask.Action);

            if (!actionFromRepairTask.HasValue || RepairActionTypeEnum.Heal != actionFromRepairTask.Value)
            {
                return(false);
            }

            // 2. check targets (nodes)
            // TODO should this be RoleInstancesToBeImpacted or JobStep.CurrentlyImpactedRoleInstances?
            if (tenantJob.RoleInstancesToBeImpacted == null || tenantJob.RoleInstancesToBeImpacted.Count != 1)
            {
                Constants.TraceType.WriteInfo(
                    "Task '{0}' does not match VendorRepair job {1} since RoleInstancesToBeImpacted does not have exactly one instance: {2}",
                    repairTask.TaskId,
                    tenantJob.Id,
                    tenantJob.ToJson());
                return(false);
            }

            var nodeNames = repairTask.GetTargetNodeNames();

            if (nodeNames == null || nodeNames.Count != 1)
            {
                Constants.TraceType.WriteInfo(
                    "Task '{0}' does not match VendorRepair job {1} since task target does not have exactly one node: {2}",
                    repairTask.TaskId,
                    tenantJob.Id,
                    nodeNames.ToJson());
                return(false);
            }

            var repairTaskTargetRoleInstance = nodeNames[0].TranslateNodeNameToRoleInstance();
            var jobRoleInstance = tenantJob.RoleInstancesToBeImpacted[0];

            bool targetsMatch = string.Equals(repairTaskTargetRoleInstance, jobRoleInstance, StringComparison.OrdinalIgnoreCase);

            return(targetsMatch);
        }
 /// <inheritdoc />
 public void Configure(IConfigSection configSection)
 {
     _path       = configSection.GetString(PathKey, null);
     _isSandbox  = configSection.GetBool(SandboxKey, false);
     _stylesheet = null;
 }
Example #36
0
 public static bool DoesJobRequirePreparingHealthCheck(this ITenantJob tenantJob, IConfigSection configSection)
 {
     return(DoesJobRequireHealthCheck(
                tenantJob,
                configSection,
                Constants.ConfigKeys.EnablePreparingHealthCheckFormat,
                false));
 }
Example #37
0
 /// <summary>读取配置文件</summary>
 /// <param name="fileName">文件名</param>
 /// <param name="section">配置段</param>
 protected abstract void OnRead(String fileName, IConfigSection section);
Example #38
0
 public static bool DoesJobRequireRestoringHealthCheck(this ITenantJob tenantJob, IConfigSection configSection)
 {
     return(DoesJobRequireHealthCheck(
                tenantJob,
                configSection,
                Constants.ConfigKeys.EnableRestoringHealthCheckFormat,
                tenantJob.IsUpdateJobType()));
 }
        private void ConfigSectionChanged(IConfigSection configSection)
        {
            configItemPanel.Children.Clear();
            foreach (var configItem in configSection.GetType().GetProperties())
            {
                var displayNameAttribute = (NameAttribute)Attribute.GetCustomAttribute(configItem, typeof(NameAttribute));
                if(displayNameAttribute != null)
                {
                    var b = new Binding(configItem.Name);
                    b.Source = configSection;
                    b.Mode = BindingMode.TwoWay;
                    b.UpdateSourceTrigger = UpdateSourceTrigger.PropertyChanged;

                    var requiredAttribute = (RequiredAttribute)Attribute.GetCustomAttribute(configItem, typeof(RequiredAttribute));
                    var editorTypeAttribute = (ConfigEditorAttribute)Attribute.GetCustomAttribute(configItem, typeof(ConfigEditorAttribute));

                    if (ConfigSection.Guid == new Guid("FEACBCE2-8290-4D90-BB05-373B9D7DBBFC") && configItem.Name == "ExcludedIdentifiers")
                    {
                        CreateVisibilityControl(displayNameAttribute);
                    }
                    else if (editorTypeAttribute != null && editorTypeAttribute.Editor == EditorType.CheckBoxList && ConfigSection.Guid == new Guid("FEACBCE2-8290-4D90-BB05-373B9D7DBBFC") && configItem.Name == "ActivatedExporters")
                    {
                        var exporterList = new CheckBoxList();
                        foreach (var exporter in _allExporters)
                        {
                            exporterList.Add(exporter.ExporterName);
                        }

                        CreateCheckboxListControl(displayNameAttribute, exporterList, b);
                    }
                    else if (editorTypeAttribute != null && editorTypeAttribute.Editor == EditorType.CheckBoxList && editorTypeAttribute.SourceListType != null)
                    {
                        CreateCheckboxListControl(displayNameAttribute, (CheckBoxList)Activator.CreateInstance(editorTypeAttribute.SourceListType) ,b);
                    }
                    else if(editorTypeAttribute != null && editorTypeAttribute.Editor == EditorType.Markdown)
                    {
                        CreateMarkdownControl(displayNameAttribute, requiredAttribute, b);
                    }
                    else if(editorTypeAttribute == null && configItem.PropertyType == typeof(string))
                    {
                        CreateTextboxControl(displayNameAttribute, requiredAttribute, b);
                    }
                    else if (editorTypeAttribute == null && configItem.PropertyType == typeof(bool))
                    {
                        CreateCheckboxControl(displayNameAttribute, b);
                    }
                    else if (editorTypeAttribute != null && editorTypeAttribute.Editor == EditorType.ComboBox && editorTypeAttribute.SourceListType != null)
                    {
                        CreateComboboxControl(displayNameAttribute, requiredAttribute, editorTypeAttribute, b);
                    }
                    else if (editorTypeAttribute != null && editorTypeAttribute.Editor == EditorType.Colorpicker)
                    {
                        CreateColorpickerControl(displayNameAttribute, b);
                    }
                    else if (editorTypeAttribute != null && (editorTypeAttribute.Editor == EditorType.Filepicker || editorTypeAttribute.Editor == EditorType.Folderpicker))
                    {
                        CreateFilesystemControl(displayNameAttribute, requiredAttribute, editorTypeAttribute, b);
                    }
                }
            }
        }
Example #40
0
 public static void AddSection(string name, IConfigSection section)
 {
     ConfigSections.Add(name, section);
 }
Example #41
0
 public void Configure(IConfigSection config)
 {
     ConfigSection = config;
 }
Example #42
0
        /// <inheritdoc />
        public void Configure(IConfigSection configSection)
        {
            _mapDataServerUri = configSection.GetString(@"data/remote/server", null);
            _mapDataServerQuery = configSection.GetString(@"data/remote/query", null);
            _mapDataFormatExtension = "." + configSection.GetString(@"data/remote/format", "xml");
            _cachePath = configSection.GetString(@"data/cache", null);

            var stringPath = _pathResolver.Resolve(configSection.GetString("data/index/strings"));
            var mapDataPath = _pathResolver.Resolve(configSection.GetString("data/index/spatial"));
            var elePath = _pathResolver.Resolve(configSection.GetString("data/elevation/local"));

            string errorMsg = null;
            CoreLibrary.Configure(stringPath, mapDataPath, elePath, error => errorMsg = error);
            if (errorMsg != null)
                throw new MapDataException(errorMsg);
        }
 /// <inheritdoc />
 public void Configure(IConfigSection configSection)
 {
     _searchPath = configSection.GetString("geocoding", DefaultServer);
 }
Example #44
0
 private void GetConfigValuesFromXml(XElement section, IConfigSection config)
 {
     foreach (var item in section.Elements())
     {
         GetAndSetConfigValue(config, item);
     }
 }
Example #45
0
        private void ReadNode(XmlReader reader, IConfigSection section)
        {
            while (true)
            {
                var remark = "";
                if (reader.NodeType == XmlNodeType.Comment)
                {
                    remark = reader.Value;
                }
                while (reader.NodeType == XmlNodeType.Comment || reader.NodeType == XmlNodeType.Whitespace)
                {
                    reader.Skip();
                }
                if (reader.NodeType != XmlNodeType.Element)
                {
                    break;
                }

                var name = reader.Name;
                var cfg  = section.AddChild(name);
                // 前一行是注释
                if (!remark.IsNullOrEmpty())
                {
                    cfg.Comment = remark;
                }

                // 读取属性值
                if (reader.HasAttributes)
                {
                    reader.MoveToFirstAttribute();
                    do
                    {
                        var cfg2 = cfg.AddChild(reader.Name);
                        cfg2.Value = reader.Value;
                    } while (reader.MoveToNextAttribute());
                }
                else
                {
                    reader.ReadStartElement();
                }
                while (reader.NodeType == XmlNodeType.Whitespace)
                {
                    reader.Skip();
                }

                // 遇到下一层节点
                if (reader.NodeType == XmlNodeType.Element || reader.NodeType == XmlNodeType.Comment)
                {
                    ReadNode(reader, cfg);
                }
                else if (reader.NodeType == XmlNodeType.Text)
                {
                    cfg.Value = reader.ReadContentAsString();
                }

                if (reader.NodeType == XmlNodeType.Attribute)
                {
                    reader.Read();
                }
                if (reader.NodeType == XmlNodeType.EndElement)
                {
                    reader.ReadEndElement();
                }
                while (reader.NodeType == XmlNodeType.Whitespace)
                {
                    reader.Skip();
                }
            }
        }
Example #46
0
        private void GetAndSetConfigValue(IConfigSection config, XElement item)
        {
            var propertyName = string.Empty;

            var keyAttribute = item.Attribute("key");
            if (keyAttribute != null)
            {
                propertyName = keyAttribute.Value;
            }
            else
            {
                propertyName = item.Name.LocalName;
            }
            
            var property = config.GetType().GetProperty(propertyName);
            if (property != null)
            {
                var excludeAttribute = (ExcludeAttribute)Attribute.GetCustomAttribute(property, typeof(ExcludeAttribute));
                if (excludeAttribute == null)
                {
                    if (property.PropertyType.Name == "Boolean")
                    {
                        property.SetValue(config, item.Attribute("value").Value.ToLower() == "true", null);
                    }
                    else if (property.PropertyType.Name == "ObservableCollection`1")
                    {
                        property.SetValue(config, new ObservableCollection<string>(item.Attribute("value").Value.Split(new [] { ';' }, StringSplitOptions.RemoveEmptyEntries).ToList()), null);
                    }
                    else if (property.PropertyType == typeof(SDPath) && item.Element("Full") != null)
                    {
                        var fullPath = item.Element("Full").Value;
                        var relativePath = item.Element("Relative").Value;

                        var path = new SDPath(fullPath, relativePath);
                        property.SetValue(config, path, null);
                    }
                    else if (property.PropertyType == typeof(SDPath))
                    {
                        // Backwards compatibility code
                        var fullPath = item.Attribute("value").Value;

                        var path = new SDPath(fullPath);
                        property.SetValue(config, path, null);
                    }
                    else
                    {
                        property.SetValue(config, item.Attribute("value").Value, null);
                    }
                }
            }
        }
Example #47
0
 private static IConfigSection GetConfigurableValueSection()
 {
     if (null != configurableValuesSection) return configurableValuesSection;
     configurableValuesSection = Load();
     return configurableValuesSection;
 }
Example #48
0
 public XDocument GetSerializedConfigs(IConfigSection[] configs)
 {
     var configXml = new XDocument(new XDeclaration("1.0", "utf-8", "yes"), new XElement("SDConfig"));
     SerializeConfigSections(configs, configXml);
     return configXml;
 }
Example #49
0
 public static void SetValueAsBool(this IConfigSection section, string name, bool value)
 {
     section.SetValue(name, value.ToString());
 }
 /// <inheritdoc />
 public void Configure(IConfigSection configSection)
 {
     _searchPath = configSection.GetString("geocoding", DefaultServer);
 }
Example #51
-1
 private void SerializeProperty(XElement xmlSection, PropertyInfo item, IConfigSection section)
 {
     if (item.PropertyType.Name == "ObservableCollection`1")
     {
         var xmlProperty = new XElement("item", new XAttribute("key", item.Name));
         var list = (IEnumerable<string>)item.GetValue(section, null);
         AddValueToProperty(xmlProperty, string.Join(";", list));
         xmlSection.Add(xmlProperty);
     }
     else
     {
         var xmlProperty = new XElement("item", new XAttribute("key", item.Name));
         AddValueToProperty(xmlProperty, item.GetValue(section, null).ToString());
         xmlSection.Add(xmlProperty);
     }
 }