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)); }
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)); }