Exemplo n.º 1
0
        public ObjectPortalBase(IServiceScope scope)
        {
            Scope = scope;

            // To find the static method this needs to be the concrete type
            var concreteType = scope.ConcreteType <T>() ?? throw new Exception($"Type {typeof(T).FullName} is not registered");

            OperationManager = (IPortalOperationManager)scope.Resolve(typeof(IPortalOperationManager <>).MakeGenericType(concreteType));
        }
Exemplo n.º 2
0
        protected override JsonObjectContract CreateObjectContract(Type objectType)
        {
            // use Autofac to create types that have been registered with it
            if (_container.IsRegistered(objectType))
            {
                JsonObjectContract contract = base.CreateObjectContract(_container.ConcreteType(objectType));
                contract.DefaultCreator = () => _container.Resolve(objectType);

                return(contract);
            }

            return(base.CreateObjectContract(objectType));
        }