static MethodInvoker() { Cache = new HashcodeDictionary <Type, MethodInfo[]>(); MethodInfoCache = new HashcodeDictionary <MethodInfo, Action <object, object> >(); //TODO: clean // with like a reflection helper class // or something var dict = new Dictionary <Type, List <MethodInfo> >(); foreach (var i in _tclassType.GetMethods().Where(x => AttributeCache <DeserializedHandlerAttribute> .HasAttribute(x))) { if (dict.TryGetValue(i.GetParameters()[0].ParameterType, out var val)) { val.Add(i); } else { dict[i.GetParameters()[0].ParameterType] = new List <MethodInfo> { i } } } ; foreach (var i in dict) { Cache.TryAdd(i.Key, i.Value.ToArray()); } }
static MessageManager() { Definitions = new HashcodeDictionary <Type, MessageDefinition>(); foreach (var i in AppDomain.CurrentDomain.GetAssemblies() .Select(assembly => assembly.GetTypes()) .SelectMany(type => type) .Where(type => type.IsDefined(typeof(MessageAttribute), true))) { GetDefinitionForType(i); } }