コード例 #1
0
 public void ThrowOnNoSuchAttribute(AcmaSchemaAttribute attribute)
 {
     if (!this.Attributes.Contains(attribute))
     {
         throw new NoSuchAttributeInObjectTypeException(attribute.Name);
     }
 }
コード例 #2
0
        public AcmaSchemaAttribute GetAttribute(string name)
        {
            AcmaSchemaAttribute attribute = this.Attributes.FirstOrDefault(t => t.Name == name);

            if (attribute == null)
            {
                throw new NoSuchAttributeInObjectTypeException(attribute.Name);
            }

            return(attribute);
        }
コード例 #3
0
        public bool HasAttribute(string name)
        {
            AcmaSchemaAttribute attribute = this.Attributes.FirstOrDefault(t => t.Name == name);

            if (attribute == null)
            {
                return(false);
            }
            else
            {
                return(true);
            }
        }
コード例 #4
0
        private static AcmaSchemaAttribute GetSubstituteAttribute(string attributeName)
        {
            if (string.IsNullOrWhiteSpace(attributeName))
            {
                return(null);
            }
            else if (AcmaSchemaAttribute.MissingAttributeEvent != null)
            {
                MissingAttributeEventArgs args = new MissingAttributeEventArgs(attributeName);
                AcmaSchemaAttribute.MissingAttributeEvent(args);

                return(args.ReplacementAttribute);
            }

            return(null);
        }
コード例 #5
0
        public static AcmaSchemaAttribute FindAttributeOrSubstitute(string attributeName)
        {
            if (lostAndFound == null)
            {
                lostAndFound = new Dictionary <string, AcmaSchemaAttribute>();
            }

            if (lostAndFound.ContainsKey(attributeName))
            {
                return(lostAndFound[attributeName]);
            }

            AcmaSchemaAttribute attribute;

            try
            {
                attribute = ActiveConfig.DB.GetAttribute(attributeName);
            }
            catch (NoSuchAttributeException)
            {
                attribute = AcmaSchemaAttribute.GetSubstituteAttribute(attributeName);

                if (attribute == null)
                {
                    throw;
                }

                lostAndFound.Add(attributeName, attribute);
            }
            catch (NoSuchAttributeInObjectTypeException)
            {
                attribute = AcmaSchemaAttribute.GetSubstituteAttribute(attributeName);

                if (attribute == null)
                {
                    throw;
                }

                lostAndFound.Add(attributeName, attribute);
            }

            return(attribute);
        }
コード例 #6
0
        public override bool Equals(object obj)
        {
            if (obj == null)
            {
                return(false);
            }

            if (obj is AcmaSchemaAttribute)
            {
                AcmaSchemaAttribute otherAttribute = (AcmaSchemaAttribute)obj;

                if (this.ID == otherAttribute.ID)
                {
                    return(true);
                }
            }

            return(base.Equals(obj));
        }
コード例 #7
0
        public bool CanInheritFrom(AcmaSchemaAttribute inheritFromAttribute)
        {
            if (!this.CanInherit)
            {
                return(false);
            }

            if (this.Type != inheritFromAttribute.Type)
            {
                return(false);
            }

            if (this.IsMultivalued != inheritFromAttribute.IsMultivalued)
            {
                return(false);
            }

            return(true);
        }
コード例 #8
0
 public object GetRealObject(StreamingContext context)
 {
     return(AcmaSchemaAttribute.FindAttributeOrSubstitute(this.serializationName));
 }