コード例 #1
0
        private void ParseAttribute(XAttribute attribute)
        {
            if (attribute.Name.NamespaceName == "http://www.w3.org/2000/xmlns/")
            {
                return;
            }

            var name = attribute.Name.LocalName;

            switch (name)
            {
            case "lockAllAttributesExcept":
                LockAllAttributesExcept.SetFromList(attribute.Value);
                return;

            case "lockAllElementsExcept":
                LockAllElementsExcept.SetFromList(attribute.Value);
                return;

            case "lockAttributes":
                LockAttributes.SetFromList(attribute.Value);
                return;

            case "lockElements":
                LockElements.SetFromList(attribute.Value);
                return;

            case "lockItem":
                IsLocked = attribute.Value;
                return;
            }

            RawAttributes.Add(name, attribute.Value);
            var child = Schema.AttributeSchemas[name];

            if (child == null && !Schema.AllowUnrecognizedAttributes)
            {
                throw new ArgumentException(String.Format("Unrecognized attribute '{0}'", name));
            }

            var item = new ConfigurationAttribute(name, child, attribute.Value, this);

            Attributes.Add(item);
        }
        private void ParseAttribute(XAttribute attribute)
        {
            var name = attribute.Name.LocalName;
            switch (name)
            {
                case "lockAllAttributesExcept":
                    LockAllAttributesExcept.SetFromList(attribute.Value);
                    return;
                case "lockAllElementsExcept":
                    LockAllElementsExcept.SetFromList(attribute.Value);
                    return;
                case "lockAttributes":
                    LockAttributes.SetFromList(attribute.Value);
                    return;
                case "lockElements":
                    LockElements.SetFromList(attribute.Value);
                    return;
                case "lockItem":
                    IsLocked = attribute.Value;
                    return;
            }

            RawAttributes.Add(name, attribute.Value);
            var child = Schema.AttributeSchemas[name];
            if (child == null && !Schema.AllowUnrecognizedAttributes)
            {
                throw new ArgumentException(String.Format("Unrecognized attribute '{0}'", name));
            }

            var item = new ConfigurationAttribute(name, child, attribute.Value, this);
            Attributes.Add(item);
        }