2 using System.Collections.Generic;
 
    5 using System.Configuration;
 
    6 using System.Collections.ObjectModel;
 
    7 using System.Reflection;
 
    8 using System.ComponentModel;
 
   11 using SiliconStudio.Presentation.ViewModel;
 
   13 namespace SiliconStudio.
Paradox.ConfigEditor.ViewModels
 
   17         public Assembly Assembly { 
get; 
private set; }
 
   18         public Type Section { 
get; 
private set; }
 
   21         private readonly List<PropertyViewModel> workingProperties = 
new List<PropertyViewModel>();
 
   26                 throw new ArgumentNullException(
"assembly");
 
   28                 throw new ArgumentNullException(
"section");
 
   32             Name = Section.DeclaringType != null ? Section.DeclaringType.Name : 
"";
 
   33             Properties = 
new ReadOnlyCollection<PropertyViewModel>(workingProperties);
 
   38             if (property.
Parent != 
this)
 
   39                 throw new InvalidOperationException(
"Bad parent");
 
   40             workingProperties.Add(property);
 
   42             property.PropertyChanged += OnPropertyViewModelPropertyChanged;
 
   47             if (e.PropertyName == 
"IsUsed")
 
   48                 IsUsed = workingProperties.Any(p => p.IsUsed);
 
   54             get { 
return isUsed; }
 
   55             set { SetValue(ref isUsed, value, 
"IsUsed"); }
 
   58         public string TypeName { 
get { 
return Section.FullName; } }
 
   66                 if (SetValue(ref name, value, 
"Name"))
 
   67                     IsValidName = !string.IsNullOrWhiteSpace(name);
 
   71         private bool isValidName;
 
   72         public bool IsValidName
 
   74             get { 
return isValidName; }
 
   75             set { SetValue(ref isValidName, value, 
"IsValidName"); }
 
   78         public bool CreateXmlNodes(XmlDocument doc, out XmlNode sectionNode, out XmlNode definitionNode)
 
   81             definitionNode = null;
 
   83             if (IsUsed == 
false || 
string.IsNullOrWhiteSpace(Name))
 
   89                 var localSectionNode = doc.CreateElement(
"section");
 
   91                 var attr = doc.CreateAttribute(
"name");
 
   93                 localSectionNode.Attributes.Append(attr);
 
   95                 attr = doc.CreateAttribute(
"type");
 
   96                 attr.Value = Section.AssemblyQualifiedName;
 
   97                 localSectionNode.Attributes.Append(attr);
 
  101                 var localDefinitionNode = doc.CreateElement(Name);
 
  102                 foreach (var property 
in workingProperties)
 
  104                     if (property.IsUsed == 
false)
 
  106                     attr = doc.CreateAttribute(property.Attribute.Name);
 
  107                     attr.Value = property.Value != null ? property.Value.ToString() : 
"";
 
  108                     localDefinitionNode.Attributes.Append(attr);
 
  112                 sectionNode = localSectionNode;
 
  113                 definitionNode = localDefinitionNode;
 
bool CreateXmlNodes(XmlDocument doc, out XmlNode sectionNode, out XmlNode definitionNode)
 
This abstract class represents a basic view model, implementing INotifyPropertyChanging and INotifyPr...
 
void AddProperty(PropertyViewModel property)
 
SectionViewModel(Assembly assembly, Type section)