示例#1
0
 public void TestInitailize()
 {
     scope       = AutofacContainer.GetLifetimeScope().Resolve <IServiceScope>();
     target      = scope.Resolve <IBaseObject>();
     target.ID   = Id;
     target.Name = Name;
     resolver    = scope.Resolve <FatClientContractResolver>();
 }
示例#2
0
        public void TestInitailize()
        {
            scope       = AutofacContainer.GetLifetimeScope().Resolve <IServiceScope>();
            target      = scope.Resolve <IValidateObjectList>();
            target.ID   = Id;
            target.Name = Name;
            resolver    = scope.Resolve <FatClientContractResolver>();

            child      = scope.Resolve <IValidateObject>();
            child.ID   = Guid.NewGuid();
            child.Name = Guid.NewGuid().ToString();
            target.Add(child);
        }
示例#3
0
 private string Serialize(object target)
 {
     return(JsonConvert.SerializeObject(target, new JsonSerializerSettings()
     {
         ContractResolver = resolver,
         TypeNameHandling = TypeNameHandling.All,
         PreserveReferencesHandling = PreserveReferencesHandling.All,
         Converters = new List <JsonConverter>()
         {
             scope.Resolve <ListBaseCollectionConverter>()
         },
         Formatting = Formatting.Indented
     }));
 }
示例#4
0
        public void FatClientEdit_Deserialize_Child()
        {
            var child = target.Child = scope.Resolve <IEditObject>();

            child.ID   = Guid.NewGuid();
            child.Name = Guid.NewGuid().ToString();

            var json = Serialize(target);

            var newTarget = Deserialize(json);

            Assert.IsNotNull(newTarget.Child);
            Assert.AreEqual(child.ID, newTarget.Child.ID);
            Assert.AreEqual(child.Name, newTarget.Child.Name);
        }
示例#5
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));
        }
示例#6
0
        public override async ValueTask OnFeature(IServiceScope scope, FeatureContext ctxt, Func <IServiceScope, FeatureContext, ValueTask> nextHandler)
        {
            // Create a browser.
            var browser = scope.Resolve <Browser>();

            browser.Initialise();

            await nextHandler(scope, ctxt);
        }
        public PortalOperationManager(IServiceScope scope)
        {
#if DEBUG
            if (typeof(T).IsInterface)
            {
                throw new Exception($"PortalOperationManager should be service type not interface. {typeof(T).FullName}");
            }
#endif
            RegisterPortalOperations();
            Scope = scope;
            AuthorizationRuleManager = scope.Resolve <IAuthorizationRuleManager <T> >();
        }
示例#8
0
        public void WebClientTests_Serialize_Child()
        {
            var child = target.Child = scope.Resolve <IBaseObject>();

            child.ID   = Guid.NewGuid();
            child.Name = Guid.NewGuid().ToString();

            var json = Serialize(target);

            Assert.IsTrue(json.Contains(child.ID.ToString()));
            Assert.IsTrue(json.Contains(child.Name));
        }
        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));
        }
 public static Browser Browser(this IServiceScope scope)
 {
     return(scope.Resolve <Browser>());
 }
示例#11
0
 protected T Resolve <T>()
 {
     return(_testScope.Resolve <T>());
 }