Beispiel #1
0
        public void プロパティと属性に対応したMasterInfoが生成される()
        {
            PropertyFactory factory = new PropertyFactory();
            var             builder = new MasterLoader(factory);
            var             info    = typeof(Hoge).GetMember(nameof(Hoge.Fugas))[0] as PropertyInfo;
            var             attr    = new PwMasterAttribute("ふが", "Fugas");

            var master = builder.AsDynamic().GetMasterinfo((info, attr)) as MasterInfo;

            master.Key.Is("Fugas");
            master.Property.Is(info);
            var collection = master.Master.IsInstanceOf <ComplicateCollectionProperty>();

            collection.ElementType.Is(typeof(Fuga));
            collection.Count.Value.Is(0);
            collection.Title.Value.Is("ふが");
            collection.ValueType.Is(typeof(Fuga[]));
        }
Beispiel #2
0
        public void マスタープロパティを列挙できる()
        {
            PropertyFactory factory = new PropertyFactory();
            var             builder = new MasterLoader(factory);
            var             members = typeof(Hoge).GetMembers();

            var masters = builder.AsDynamic()
                          .GetMastersProperties(members) as IEnumerable <(PropertyInfo info, PwMasterAttribute attr)>;

            var dic = masters.ToDictionary(x => x.info.Name, x => x);

            dic.ContainsKey(nameof(Hoge.Fugas)).IsTrue();
            dic.ContainsKey(nameof(Hoge.Fuga)).IsTrue();
            dic.ContainsKey(nameof(Hoge.NotMember)).IsFalse();
            dic.ContainsKey(nameof(Hoge.Run)).IsFalse();
            dic[nameof(Hoge.Fugas)].attr.Name.Is("ふが");
            dic[nameof(Hoge.Fuga)].attr.Name.IsNull();
            dic[nameof(Hoge.Fugas)].attr.Key.Is("Fugas");
            dic[nameof(Hoge.Fuga)].attr.Key.IsNull();
        }
Beispiel #3
0
        public void MasterInfoをもとに参照情報を生成できる()
        {
            PropertyFactory factory = new PropertyFactory();
            var             builder = new MasterLoader(factory);
            var             info    = new MasterInfo[]
            {
                new MasterInfo("Fugas",
                               typeof(Hoge).GetMember(nameof(Hoge.Fugas))[0] as PropertyInfo,
                               new ComplicateCollectionProperty(typeof(Fuga[]), factory)),
                new MasterInfo("Fuga",
                               typeof(Hoge).GetMember(nameof(Hoge.Fuga))[0] as PropertyInfo,
                               new ClassProperty(typeof(Fuga), factory))
            };

            var repo = builder.AsDynamic()
                       .GetReferencableMasters(info as IEnumerable <MasterInfo>) as MasterRepository;

            repo.ContainsKey("Fugas").IsTrue();
            repo["Fugas"].Type.Is(typeof(Fuga));
            repo.ContainsKey("Fuga").IsFalse();
        }
Beispiel #4
0
        public void サブクラス情報をロードできる()
        {
            PropertyFactory factory = new PropertyFactory();
            var             builder = new MasterLoader(factory);
            var             domain  = new Type[]
            {
                typeof(Subtyping),
                typeof(Subtype1),
                typeof(Subtype2),
                typeof(Hoge),
                typeof(Fuga),
            };

            var subtypes = builder.AsDynamic().GetSubtypes(domain) as Dictionary <Type, Type[]>;

            subtypes.ContainsKey(typeof(Subtyping)).IsTrue();
            subtypes[typeof(Subtyping)].Contains(typeof(Subtype1)).IsTrue();
            subtypes[typeof(Subtyping)].Contains(typeof(Subtype2)).IsTrue();
            subtypes.ContainsKey(typeof(Hoge)).IsFalse();
            subtypes.ContainsKey(typeof(Fuga)).IsFalse();
        }