Microsoft.Web.Administration.ConfigurationElement.ConfigurationElement C# (CSharp) Method

ConfigurationElement() private method

private ConfigurationElement ( ConfigurationElement element, string name, ConfigurationElementSchema schema, ConfigurationElement parent, System.Xml.Linq.XElement entity, FileContext core ) : System
element ConfigurationElement
name string
schema ConfigurationElementSchema
parent ConfigurationElement
entity System.Xml.Linq.XElement
core FileContext
return System
        internal ConfigurationElement(ConfigurationElement element, string name, ConfigurationElementSchema schema, ConfigurationElement parent, XElement entity, FileContext core)
        {
            Methods = new ConfigurationMethodCollection();
            this.FileContext = parent?.FileContext ?? element?.FileContext ?? core;
            Section = parent?.Section;
            this.InnerEntity = entity ?? element?.InnerEntity;
            if (element == null)
            {
                if (name == null)
                {
                    throw new ArgumentException("empty name");
                }

                ElementTagName = name;
                Attributes = new ConfigurationAttributeCollection(this);
                ChildElements = new ConfigurationChildElementCollection(this);
                Collections = new List<ConfigurationElementCollection>();
                RawAttributes = new Dictionary<string, string>();
                ParentElement = parent;
                if (parent == null)
                {
                    if (schema == null)
                    {
                        throw new ArgumentException();
                    }

                    Schema = schema;
                    IsLocallyStored = true;
                }
                else
                {
                    IsLocallyStored = !parent.Section.IsLocked;
                    var collection = parent.Schema.CollectionSchema;
                    if (collection == null)
                    {
                        Schema = parent.Schema.ChildElementSchemas[name];
                    }
                    else
                    {
                        Schema = parent.Schema.CollectionSchema.GetElementSchema(name) ?? parent.Schema.ChildElementSchemas[name];
                    }

                    if (Schema == null)
                    {
                        throw new ArgumentException("empty schema");
                    }
                }

                ParseAttributes();
            }
            else
            {
                IsLocallyStored = element.IsLocallyStored;
                ElementTagName = element.ElementTagName;
                Attributes = element.Attributes;
                ChildElements = element.ChildElements;
                Collections = element.Collections;
                RawAttributes = element.RawAttributes;
                Schema = element.Schema;
                ParentElement = parent ?? element.ParentElement;
                if (schema != null)
                {
                    // TODO: here we ignore second schema
                    //throw new ArgumentException();
                }
            }
        }