public void Process(IClassBuilder builder, Type typeToParse) { //This is so inefficient. We do this so often, thankfully it's technically cached. //Anyway, we need the member types again. IEnumerable <MemberInfo> parsedInfos = typeParser.Parse(System.Reflection.MemberTypes.Property | System.Reflection.MemberTypes.Field, typeToParse); //Should now be a collection of only Action fields IEnumerable <MemberInfo> actionInfoTypes = parsedInfos.Where(x => actionMapper.isActionType(x.Type())); foreach (MemberInfo mi in actionInfoTypes) { //this class can't handle generic events if (actionMapper.isGenericActionType(mi.Type())) { //get a new class name that is shared across all events of the same sig string newClassName = actionMapper.GetSharedGenericEventTypeName(mi.Type().GetGenericArguments()); eventTracker.Register(newClassName, mi.Type().GetGenericArguments()); //register info about the generic event to be tracked //we can add the field to the class now builder.AddClassField(new UnitySerializedFieldImplementationProvider(mi.Name, newClassName, new Common.Unity3D.WiredToAttribute(mi.MemberType, mi.Name, mi.Type()))); } else { //action mapper can resolve Action/TestityEvent types //Non-generic events require no messing with builder.AddClassField(new UnitySerializedFieldImplementationProvider(mi.Name, actionMapper.ResolveMappedType(mi.Type()), new Common.Unity3D.WiredToAttribute(mi.MemberType, mi.Name, mi.Type()))); } } }
public void Process(IClassBuilder builder, Type typeToParse) { //This is so inefficient. We do this so often, thankfully it's technically cached. //Anyway, we need the member types again. IEnumerable<MemberInfo> parsedInfos = typeParser.Parse(System.Reflection.MemberTypes.Property | System.Reflection.MemberTypes.Field, typeToParse); //Should now be a collection of only Action fields IEnumerable<MemberInfo> actionInfoTypes = parsedInfos.Where(x => actionMapper.isActionType(x.Type())); foreach(MemberInfo mi in actionInfoTypes) { //this class can't handle generic events if (actionMapper.isGenericActionType(mi.Type())) { //get a new class name that is shared across all events of the same sig string newClassName = actionMapper.GetSharedGenericEventTypeName(mi.Type().GetGenericArguments()); eventTracker.Register(newClassName, mi.Type().GetGenericArguments()); //register info about the generic event to be tracked //we can add the field to the class now builder.AddClassField(new UnitySerializedFieldImplementationProvider(mi.Name, newClassName, new Common.Unity3D.WiredToAttribute(mi.MemberType, mi.Name, mi.Type()))); } else //action mapper can resolve Action/TestityEvent types //Non-generic events require no messing with builder.AddClassField(new UnitySerializedFieldImplementationProvider(mi.Name, actionMapper.ResolveMappedType(mi.Type()), new Common.Unity3D.WiredToAttribute(mi.MemberType, mi.Name, mi.Type()))); } }
public void Process(IClassBuilder builder, Type typeToParse) { //This can be done in a way that preserves order but that is not important in the first Testity build. //We can improve on that later //handle serialized fields and properties foreach (MemberInfo mi in typeParser.Parse(MemberTypes.Field | MemberTypes.Property, typeToParse)) { //Some types are no serialized or are serialized in later steps if (typesNotToSerialize.isExcluded(mi.Type())) continue; builder.AddClassField(new UnitySerializedFieldImplementationProvider(mi.Name, typeResolver.ResolveMappedType(mi.Type()), new Common.Unity3D.WiredToAttribute(mi.MemberType, mi.Name, mi.Type()))); } }
public void Process(IClassBuilder builder, Type typeToParse) { //This can be done in a way that preserves order but that is not important in the first Testity build. //We can improve on that later //handle serialized fields and properties foreach (MemberInfo mi in typeParser.Parse(MemberTypes.Field | MemberTypes.Property, typeToParse)) { //Some types are no serialized or are serialized in later steps if (typesNotToSerialize.isExcluded(mi.Type())) { continue; } builder.AddClassField(new UnitySerializedFieldImplementationProvider(mi.Name, typeResolver.ResolveMappedType(mi.Type()), new Common.Unity3D.WiredToAttribute(mi.MemberType, mi.Name, mi.Type()))); } }