Ejemplo n.º 1
0
 public NamedAnalysis()
 {
     type               = typeof(StudentClass);
     nameTransfer       = IdentityMapNameTransfer.FromTypeAttributes(type);
     objectNamedCreator = new ObjectNamedCreator(type, nameTransfer,
                                                 IdentityNamedCreator.Instance, ReflectionPropertyVisitor.Instance);
 }
Ejemplo n.º 2
0
        public NamedBuild()
        {
            var type         = typeof(StudentClass);
            var nameTransfer = IdentityMapNameTransfer.FromTypeAttributes(type);
            var builder      = new ConfigurationBuilder();
            var map          = new Dictionary <string, string>
            {
                ["Name0"] = "1",
                ["Name1"] = "2",
                ["Name2"] = "3",
                ["Name3"] = "4",
                ["Name4"] = "5"
            };

            for (int i = 1; i < 5; i++)
            {
                for (int j = 0; j < 4; j++)
                {
                    map[$"Student" + i + ":" + "Student" + j] = (i * j + j).ToString();
                }
            }
            builder.AddInMemoryCollection(map);
            config = builder.BuildSavable();

            objectNamedCreatorRef = new ObjectNamedCreator(type, nameTransfer,
                                                           IdentityNamedCreator.Instance, ReflectionPropertyVisitor.Instance);
            valueReflection = objectNamedCreatorRef.Build(config);
            valueReflection = objectNamedCreatorRef.Build(valueReflection, config);

            objectNamedCreatorCom = new ObjectNamedCreator(type, nameTransfer,
                                                           IdentityNamedCreator.Instance, CompilePropertyVisitor.Instance);
            valueCompiled = objectNamedCreatorCom.Build(config);
            valueCompiled = objectNamedCreatorCom.Build(valueCompiled, config);
        }
Ejemplo n.º 3
0
        public void EnsureCreateProx_MustCreated()
        {
            var root  = ConfigHelper.CreateEmptyRoot();
            var proxy = ProxyUtil.CreateProx();
            var val   = proxy.EnsureCreateProx <NullClass>(root, IdentityMapNameTransfer.FromTypeAttributes(typeof(NullClass)));

            Assert.IsTrue(proxy.ProxMap.ContainsKey(typeof(NullClass)));
            Assert.IsNotNull(val);
        }
Ejemplo n.º 4
0
 protected override void OnBind()
 {
     if (Mode != ConfigBindMode.OneTime)
     {
         var type = BindSettings.Value.GetType();
         objectNamedCreator = new ObjectNamedCreator(type,
                                                     NameTransfer ?? IdentityMapNameTransfer.FromTypeAttributes(type),
                                                     NamedCreator ?? IdentityNamedCreator.Instance,
                                                     CompilePropertyVisitor.Instance);
         objectNamedCreator.Analysis();
     }
 }
Ejemplo n.º 5
0
        public void CreateProxType_MustOk()
        {
            var root     = ConfigHelper.CreateEmptyRoot();
            var proxType = ProxyUtil.CreateProx();
            var res      = proxType.BuildProx(typeof(Setting1));

            Assert.IsTrue(res);
            var newType = proxType.CreateProxy(typeof(Setting1), root, IdentityMapNameTransfer.FromTypeAttributes(typeof(Setting1)));

            Assert.IsNotNull(newType);
            Assert.IsInstanceOfType(newType, typeof(Setting1));
        }
Ejemplo n.º 6
0
        public void UsingClassPath_MustCombineWithIt()
        {
            var t = IdentityMapNameTransfer.FromTypeAttributes("A", typeof(Class1), true);

            Assert.AreEqual("A:Cl", t.BasePath);
        }