Ejemplo n.º 1
0
        private void RegisterInstance(MethodInfo method, object instance, string alias)
        {
            var registration = new MethodRegistration
            {
                RegisteredName = alias ?? method.Name,
                MethodInfo     = method
            };

            if (!method.IsStatic)
            {
                registration.Activator = () => instance;
            }

            _registry.Add(registration.RegisteredName, registration);
        }
Ejemplo n.º 2
0
        private void RegisterActivator(Type type, MethodInfo method, ConstructorInfo defaultConstructor, string alias)
        {
            if (!method.IsStatic && defaultConstructor == null)
            {
                throw new RpcRegistrationException($"Failed to register a non static method on a type without a default constructor. Either provide a public default constructor on type '{type.FullName}' or register an instance of the type instead.");
            }
            var registration = new MethodRegistration
            {
                RegisteredName = alias ?? method.Name,
                MethodInfo     = method
            };

            if (!method.IsStatic)
            {
                registration.Activator = () => defaultConstructor.Invoke(null);
            }

            _registry.Add(registration.RegisteredName, registration);
        }