コード例 #1
0
 public static FieldDescription Create(string name, int id, TypeDescription underlyingEnumTypeDescription)
 {
     return(new FieldDescription(underlyingEnumTypeDescription, name, null, id));
 }
コード例 #2
0
        public static FieldDescription Create(MemberInfo member, TypeDescription typeDescription, int memberId)
        {
            var name = GetName(member);

            return(new FieldDescription(typeDescription, name, member, memberId));
        }
コード例 #3
0
        private void AddSubTypeTo(TypeDescription baseType, TypeDescription typeDescription)
        {
            var baseMetaType = _metaTypes[baseType.ResolvedType];

            baseMetaType.AddSubType(typeDescription.TypeId, typeDescription.ResolvedType);
        }
コード例 #4
0
        private void ThrowOnBreakingChanges(TypeDescription otherDescription)
        {
            if (Classification != otherDescription.Classification)
            {
                throw new BreakingChangeException();
            }

            foreach (var field in _fields)
            {
                var otherField = otherDescription._fields.FirstOrDefault(x => Equals(x.Name, field.Name));
                if (otherField != null)
                {
                    field.ThrowOnBreakingChanges(otherField);
                }
            }

            var otherUnderlyingType = otherDescription.UnderlyingEnumTypeDescription;

            if (UnderlyingEnumTypeDescription == null && otherUnderlyingType != null)
            {
                throw new BreakingChangeException();
            }
            if (UnderlyingEnumTypeDescription != null && otherUnderlyingType == null)
            {
                throw new BreakingChangeException();
            }
            if (UnderlyingEnumTypeDescription != null && otherUnderlyingType != null)
            {
                if (!AreSameType(UnderlyingEnumTypeDescription, otherUnderlyingType))
                {
                    throw new BreakingChangeException();
                }
            }

            var otherBaseType = otherDescription.BaseType;

            if (BaseType == null && otherBaseType != null)
            {
                throw new BreakingChangeException(string.Format("The base class of the type '{0}' has been changed from 'null' to '{1}': This is a breaking change!",
                                                                FullTypeName,
                                                                otherBaseType.FullTypeName));
            }
            if (BaseType != null && otherBaseType == null)
            {
                throw new BreakingChangeException(string.Format("The base class of the type '{0}' has been changed from '{1}' to '{0}': This is a breaking change!",
                                                                FullTypeName,
                                                                BaseType.FullTypeName));
            }

            if (BaseType != null && otherBaseType != null)
            {
                if (!AreSameType(BaseType, otherBaseType))
                {
                    throw new
                          BreakingChangeException(string.Format("The base class of the type '{0}' has been changed from '{1}' to '{2}': This is a breaking change!",
                                                                FullTypeName,
                                                                BaseType.FullTypeName,
                                                                otherBaseType.FullTypeName));
                }

                BaseType.ThrowOnBreakingChanges(otherDescription.BaseType);
            }
        }
コード例 #5
0
 private static bool AreSameType(TypeDescription type, TypeDescription otherType)
 {
     return(string.Equals(type.FullTypeName, otherType.FullTypeName));
 }
コード例 #6
0
        private int?GetUnderlyingEnumTypeId(TypeDescription typeDescription)
        {
            var surrogateType = typeDescription.UnderlyingEnumTypeDescription;

            return(surrogateType?.TypeId);
        }
コード例 #7
0
        private int?GetSurrogateTypeId(TypeDescription typeDescription)
        {
            var surrogateType = typeDescription.SurrogateType;

            return(surrogateType?.TypeId);
        }