private static TypeParser GetParser(MelonPreferences_Entry.TypeEnum type) { TypeParser parser = null; if (type == MelonPreferences_Entry.TypeEnum.UNKNOWN) { return(parser); } lock (TypeParserDict_TypeEnum) { if (TypeParserDict_TypeEnum.TryGetValue(type, out TypeParser nparser)) { parser = nparser; } else { var args = new TypeParser.ResolveEventArgs { TypeEnum = type }; ResolveEvents?.Invoke(null, args); //if (args.TypeParser == null) // throw new NullReferenceException("No Parser for Type " + MelonPreferences.TypeEnumToTypeName(type)); if ((args.TypeParser != null) && (args.TypeParser.GetTypeEnum() == type)) { parser = TypeParserDict_TypeEnum[type] = args.TypeParser; } } } return(parser); }
private static TypeParser GetParser(Type type) { TypeParser parser = null; lock (TypeParserDict_ReflectedType) { if (TypeParserDict_ReflectedType.TryGetValue(type, out TypeParser nparser)) { parser = nparser; } else { var args = new TypeParser.ResolveEventArgs { ReflectedType = type }; ResolveEvents?.Invoke(null, args); //if (args.TypeParser == null) // throw new NullReferenceException("No Parser for Type " + type.Name); if ((args.TypeParser != null) && (args.TypeParser.GetReflectedType() == type)) { parser = TypeParserDict_ReflectedType[type] = args.TypeParser; } } } return(parser); }