Inheritance: System.Attribute
Exemple #1
0
        private static DispatchCommand CreateCommandRunner(
            MethodInfo method, YarnCommandAttribute metadata, ref Dictionary <string, Injector> injectorCache)
        {
            var methodType = method.DeclaringType;

            if (methodType == null)
            {
                throw new ArgumentException($"Method {method.Name} does not have a type...somehow.");
            }

            Injector injector = null;

            if (!method.IsStatic)
            {
                injector = GetInjectorForMethod(methodType, metadata)
                           ?? GetInjectorForType(methodType, ref injectorCache)
                           ?? GetDefaultMonoBehaviourInjector(methodType, metadata.Name);
            }

            var converters = CreateConverters(method);

            return(new DispatchCommand()
            {
                Method = method,
                Injector = injector,
                Converters = converters
            });
        }
Exemple #2
0
        private static Injector GetInjectorForMethod(Type injectorType, YarnCommandAttribute metadata)
        {
            var injectorFunction = metadata.Injector == null
                ? null
                : injectorType.GetMethod(metadata.Injector, AllStaticMembers);

            if (IsInjector(injectorType, injectorFunction))
            {
                return((Injector)injectorFunction.CreateDelegate(typeof(Injector)));
            }
            return(null);
        }