Пример #1
0
        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)
                {
                    Binding 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 && 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);
                    }
                }
            }
        }
Пример #2
0
 private void SerializeProperties(IConfigSection section, XElement xmlSection)
 {
     foreach (var item in section.GetType().GetProperties())
     {
         if (PropertyIsRelevant(item, section))
         {
             SerializeProperty(xmlSection, item, section);
         }
     }
 }
Пример #3
0
 private void SerializeProperties(IConfigSection section, XElement xmlSection)
 {
     foreach (var item in section.GetType().GetProperties())
     {
         if (PropertyIsRelevant(item, section))
         {
             SerializeProperty(xmlSection, item, section);
         }
     }
 }
Пример #4
0
        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);
            }
        }
Пример #5
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);
                    }
                }
            }
        }
Пример #6
0
        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);
            }
        }
Пример #7
0
 private void ResetAllProperties(IConfigSection config)
 {
     foreach (var property in config.GetType().GetProperties())
     {
         var excludeAttribute = (ExcludeAttribute)Attribute.GetCustomAttribute(property, typeof(ExcludeAttribute));
         if (property.CanWrite && excludeAttribute == null)
         {
             if (property.PropertyType.Name == "ObservableCollection`1")
             {
                 property.SetValue(config, new ObservableCollection <string>(), null);
             }
             else
             {
                 property.SetValue(config, null, null);
             }
         }
     }
 }
Пример #8
0
        private void GetAndSetConfigValue(IConfigSection config, XElement item)
        {
            var property = config.GetType().GetProperty(item.Attribute("key").Value);

            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 char[] { ';' }, StringSplitOptions.RemoveEmptyEntries).ToList()), null);
                    }
                    else
                    {
                        property.SetValue(config, item.Attribute("value").Value, null);
                    }
                }
            }
        }
Пример #9
0
        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);
                    }
                }
            }
        }
Пример #10
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);
                    }
                }
            }
        }
Пример #11
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);
         }
     }
 }