public static TypeBase TypeBase(TypeSerializationModel typeSerializationModel) { TypeBase typeBase = new TypeBase() { Name = typeSerializationModel.Name }; _typeDictionary.Add(typeBase.Name, typeBase); typeBase.NamespaceName = typeSerializationModel.NamespaceName; typeBase.Type = typeSerializationModel.Type; typeBase.BaseType = GetOrAdd(typeSerializationModel.BaseType); typeBase.DeclaringType = GetOrAdd(typeSerializationModel.DeclaringType); typeBase.IsAbstract = typeSerializationModel.IsAbstract; typeBase.Accessibility = typeSerializationModel.Accessibility; typeBase.IsSealed = typeSerializationModel.IsSealed; typeBase.IsStatic = typeSerializationModel.IsStatic; typeBase.Constructors = typeSerializationModel.Constructors?.Select(MethodBase).ToList(); typeBase.Fields = typeSerializationModel.Fields?.Select(FieldBase).ToList(); typeBase.GenericArguments = typeSerializationModel.GenericArguments?.Select(GetOrAdd).ToList(); typeBase.ImplementedInterfaces = typeSerializationModel.ImplementedInterfaces?.Select(GetOrAdd).ToList(); typeBase.Methods = typeSerializationModel.Methods?.Select(MethodBase).ToList(); typeBase.NestedTypes = typeSerializationModel.NestedTypes?.Select(GetOrAdd).ToList(); typeBase.Properties = typeSerializationModel.Properties?.Select(PropertyBase).ToList(); return(typeBase); }
public static TypeBase GetOrAdd(TypeSerializationModel baseType) { if (baseType != null) { if (_typeDictionary.ContainsKey(baseType.Name)) { return(_typeDictionary[baseType.Name]); } else { return(TypeBase(baseType)); } } else { return(null); } }
private static TypeBase ToBase(TypeSerializationModel metadata) { if (metadata == null) { return(null); } if (typeDictonary.ContainsKey(metadata.Name)) { return(typeDictonary[metadata.Name]); } TypeBase type = new TypeBase() { typeName = metadata.Name, namespaceName = metadata.NamespaceName, typeKind = metadata.TypeKind, baseType = ToBase(metadata.BaseType), declaringType = ToBase(metadata.DeclaringType), modifiers = new Tuple <DTGBase.Enums.AccessLevelEnum, DTGBase.Enums.SealedEnum, DTGBase.Enums.AbstractEnum>(metadata.Modifiers.Item1, metadata.Modifiers.Item2, metadata.Modifiers.Item3), constructors = metadata.Constructors?.Select(ToBase), fields = metadata.Fields?.Select(ToBase), genericArguments = metadata.GenericArguments?.Select(ToBase), implementedInterfaces = metadata.ImplementedInterfaces?.Select(ToBase), methods = metadata.Methods?.Select(ToBase), nestedTypes = metadata.NestedTypes?.Select(ToBase), properties = metadata.Properties?.Select(ToBase) }; typeDictonary.Add(type.typeName, type); return(type); }
public FieldSerializationModel(FieldBase baseParameter) { this.Name = baseParameter.Name; this.Type = TypeSerializationModel.GetOrAdd(baseParameter.Type); }
public FieldSerializationModel(FieldModel model) : base(model) { TypeModel = TypeSerializationModel.EmitTypeSerializationModel(model.TypeModel); }