Пример #1
0
        public virtual void FromXml(XElement element, Profile parent)
        {
            Initialize();

            if (element.Attribute("name") != null)
            {
                this.Name = element.Attribute("name").Value;
            }

            if (element.Attribute("symbol") != null)
            {
                this.Symbol = element.Attribute("symbol").Value;
            }

            if (element.Attribute("guid") != null)
            {
                this.Guid = Guid.Parse(element.Attribute("guid").Value);
            }

            if (element.Attribute("alias") != null)
            {
                this.Alias = element.Attribute("alias").Value;
            }
            else
            {
                this.Alias = this.Symbol;
            }

            if (element.Element("Example") != null)
            {
                this.Example = element.Element("Example").Value;
            }

            if (element.Attribute("hidden") != null && Convert.ToBoolean(element.Attribute("hidden").Value) == true)
            {
                this.Hidden = true;
            }

            //
            // Inherit.
            //

            this.Parent                = parent;
            this.HasProperties         = new HashSet <string>();
            this.DefaultPropertyValues = new Dictionary <string, string>();

            if (parent != null)
            {
                this.HasProperties         = new HashSet <string>(this.HasProperties.Union(parent.HasProperties));
                this.DefaultPropertyValues = new Dictionary <string, string>(parent.DefaultPropertyValues);
            }

            this.HasProperties = new HashSet <string>(this.HasProperties.Union(
                                                          from XElement e in element.Elements("HasProperty")
                                                          select e.Value
                                                          ));

            foreach (KeyValuePair <string, string> defaultPropertyValue in this.DefaultPropertyValues)
            {
                this.SetPropertyValue(defaultPropertyValue.Key, defaultPropertyValue.Value, null);
            }

            //
            // Child flaws/violations.
            //

            foreach (XElement propertyCandidate in element.Elements())
            {
                if (SetPropertyValue(propertyCandidate.Name.ToString(), propertyCandidate.Value, propertyCandidate))
                {
                    this.DefaultPropertyValues[propertyCandidate.Name.ToString()] = propertyCandidate.Value;
                }
            }
        }
Пример #2
0
 internal ProfilePropertyInfo(Profile profile, PropertyInfo propertyInfo, string dictionaryKey = null)
 {
     this.Profile       = profile;
     this.PropertyInfo  = propertyInfo;
     this.DictionaryKey = dictionaryKey;
 }
Пример #3
0
 public Profile(XElement element, Profile parent)
     : this()
 {
     FromXml(element, parent);
 }
Пример #4
0
 public bool HasParent(Profile p)
 {
     return(this == p || (this.Parent != null && this.Parent.HasParent(p)));
 }