private static SerializableType GetBaseType(MonoManager manager, TypeReference type, IReadOnlyDictionary <GenericParameter, TypeReference> arguments) { TypeDefinition definition = type.Resolve(); if (IsObject(definition.BaseType)) { return(null); } if (definition.BaseType.IsGenericInstance) { Dictionary <GenericParameter, TypeReference> templateArguments = new Dictionary <GenericParameter, TypeReference>(); GenericInstanceType instance = (GenericInstanceType)definition.BaseType; TypeDefinition template = instance.ElementType.Resolve(); for (int i = 0; i < instance.GenericArguments.Count; i++) { GenericParameter parameter = template.GenericParameters[i]; TypeReference argument = instance.GenericArguments[i]; if (argument.ContainsGenericParameter) { argument = MonoUtils.ResolveGenericParameter(argument, arguments); } templateArguments.Add(parameter, argument); } return(manager.GetSerializableType(instance, templateArguments)); } else { TypeDefinition baseDefinition = definition.BaseType.Resolve(); return(manager.GetSerializableType(baseDefinition, s_emptyArguments)); } }
private static SerializableType GetBaseType(MonoManager manager, MonoTypeContext context) { MonoTypeContext baseContext = context.GetBase(); MonoTypeContext resolvedContext = baseContext.Resolve(); TypeDefinition baseDefinition = resolvedContext.Type.Resolve(); if (IsObject(baseDefinition)) { return(null); } return(manager.GetSerializableType(resolvedContext)); }
private static Field[] CreateFields(MonoManager manager, TypeReference type, IReadOnlyDictionary <GenericParameter, TypeReference> arguments) { TypeDefinition definition = type.Resolve(); List <Field> fields = new List <Field>(); foreach (FieldDefinition field in definition.Fields) { if (MonoField.IsSerializable(field, arguments)) { TypeReference fieldType = GetSerializedElementType(field.FieldType, arguments); SerializableType scriptType = manager.GetSerializableType(fieldType, arguments); bool isArray = IsSerializableArray(field.FieldType, arguments); Field fieldStruc = new Field(scriptType, isArray, field.Name); fields.Add(fieldStruc); } } return(fields.ToArray()); }
private static Field[] CreateFields(MonoManager manager, MonoTypeContext context) { List <Field> fields = new List <Field>(); TypeDefinition definition = context.Type.Resolve(); IReadOnlyDictionary <GenericParameter, TypeReference> arguments = context.GetContextArguments(); foreach (FieldDefinition field in definition.Fields) { if (MonoField.IsSerializable(field, arguments)) { MonoTypeContext fieldContext = new MonoTypeContext(field.FieldType, arguments); MonoTypeContext resolvedContext = fieldContext.Resolve(); MonoTypeContext serFieldContext = GetSerializedElementContext(resolvedContext); SerializableType scriptType = manager.GetSerializableType(serFieldContext); bool isArray = MonoField.IsSerializableArray(resolvedContext.Type); Field fieldStruc = new Field(scriptType, isArray, field.Name); fields.Add(fieldStruc); } } return(fields.ToArray()); }
internal MonoField(MonoManager manager, FieldDefinition field, IReadOnlyDictionary <GenericParameter, TypeReference> arguments) : base(manager.GetSerializableType(GetSerializedElementType(field.FieldType, arguments), arguments), IsSerializableArray(field.FieldType, arguments), field.Name) { }