public When_setting_property()
        {
            dynamicObject = new DynamicObjectTest { { StringProperty, OldValue } };

            dynamicObject.PropertyChangingCount.ShouldBe(0);
            dynamicObject.PropertyChangedCount.ShouldBe(0);
            dynamicObject.OnPropertyChangingCount.ShouldBe(0);
            dynamicObject.OnPropertyChangedCount.ShouldBe(0);
        }
        public When_setting_property()
        {
            dynamicObject = new DynamicObjectTest
            {
                Properties = new PropertySet
                {
                    { StringProperty, OldValue },
                },
            };

            dynamicObject.PropertyChangingCount.ShouldBe(0);
            dynamicObject.PropertyChangedCount.ShouldBe(0);
            dynamicObject.OnPropertyChangingCount.ShouldBe(0);
            dynamicObject.OnPropertyChangedCount.ShouldBe(0);
        }
Beispiel #3
0
        static void Main(string[] args)
        {
            Derived d = new Derived();

            Console.Read();

            for (int i = 0; i < 100000; i++)
            {
                T2 t2 = new T2 {
                    ID = i, T2Name = "fasdfasd" + i
                };
                t2.Insert();
                LocalDBTest lt = new LocalDBTest {
                    Age = 10, ID = 1, Name = "zhoulin" + i, T2S = new List <T2> {
                        t2
                    }
                };
                lt.Insert();
                Thread.Sleep(100);
            }


            //List<LocalDBTest> lts = LocalDB.Select<LocalDBTest>();
            //if (lts == null || !lts.Any())
            //{
            //    T2 t2 = new T2 { ID = 23, T2Name = "fasdfasd" };
            //    t2.Insert();
            //    LocalDBTest lt = new LocalDBTest { Age = 10, ID = 1, Name = "zhoulin", T2S = new List<T2> { t2 } };
            //    lt.Insert();
            //}
            //else
            //{
            //    LocalDBTest lt = lts.First();
            //    if (lt.remark == null)
            //    {
            //        lt.remark = new List<string>();
            //    }
            //    if (lt.T2S == null)
            //    {
            //        lt.T2S = new List<T2> { new T2 { ID = 23, T2Name = "fasdfasd" } };
            //    }
            //    lt.remark.Add(new Random().Next().ToString());
            //    lt.Update();

            //    lt = new LocalDBTest { Age = 10, ID = 1, Name = "zhoulin_" + new Random().Next() };
            //    lt.Insert();
            //}

            Person pson = new Person {
                id = "1", Name = "zl"
            };

            Thread.Sleep(10000 * 323);
            string rrr = SerializerHelper.JsonSerializer(pson);

            pson = SerializerHelper.JsonDeserialize <Person>("{\"id\":\"1\",\"Int_id\":3,\"Name\":\"zl\"}");

            DataBufferPool <int> dp = new DataBufferPool <int>(tls =>
            {
                Console.WriteLine(tls.Count + "|" + string.Join(",", tls));
            }, 2000);

            Random r = new Random();

            for (int i = 0; i < 10000000; i++)
            {
                dp.AddItem(i % 10);
                Thread.Sleep(r.Next(10, 300));
            }

            Console.ReadLine();
            Parallel.Invoke(
                () => ExecCrawler(30, 16),
                () => ExecCrawler(31, 16),
                () => ExecCrawler(32, 16),
                () => ExecCrawler(33, 16),
                () => ExecCrawler(30, 4),
                () => ExecCrawler(31, 4),

                () => ExecCrawler(32, 4),
                () => ExecCrawler(33, 4)
                );
            Console.WriteLine("done");
            //DataBufferPool<int> dp = new DataBufferPool<int>(Console.WriteLine);
            //int iu = 0;
            //while (iu < 20)
            //{
            //    iu++;
            //    dp.AddItem(iu);
            //}
            //Console.ReadLine();

            #region 引用类型测试

            RTest  rt = new RTest();
            InnerC ic = new InnerC();
            ic.T(rt);
            Console.WriteLine(rt.i);

            ic.T(ref rt);
            Console.WriteLine(rt.i);
            Console.ReadLine();
            #endregion

            #region 动态类型测试

            dynamic dynamicobj = new LocalCacheContainer();
            dynamicobj.Name = "Learning Hard";
            dynamicobj.Age  = "24";
            var res = dynamicobj.Age;
            Console.WriteLine("fsadf");

            DynamicObjectTest dot = new DynamicObjectTest();

            dot.LocalCache.Person = new Person
            {
                id   = "1",
                Name = "zl"
            };

            dot.LocalCache.OtherInfo = "234";

            Person p1 = dot.LocalCache.Person1 as Person;

            Console.WriteLine(dot.LocalCache.Person.Name);
            Console.WriteLine(dot.LocalCache.OtherInfo);


            Console.ReadLine();
            #endregion

            #region 反射输出对象属性测试
            Group gp = new Group
            {
                GroupID   = 1,
                GroupName = "TestGroupName",
                PS        = new List <Person>
                {
                    new Person {
                        id = "1", Name = "n1"
                    },
                    new Person {
                        id = "2", Name = "n2"
                    },
                    new Person {
                        id = "3", Name = "n3"
                    }
                },
                Mark = "这是一个测试组"
            };

            foreach (string str in gp.GetReflectPropsValue().Split('|'))
            {
                Console.WriteLine(str);
            }
            Console.ReadLine();
            #endregion

            #region 随机数测试

            TestRandomNum();

            #endregion

            #region 反射对象属性测试
            Person p = new Person();
            TestReflectProps(p);
            Console.ReadLine();
            #endregion

            #region 数据缓存仓库测试

            //key
            const string key    = "GetCurrDateKey";
            const string key_Dt = "GetDatatableKey";

            //初始化仓库
            DataWarehouse <string> .InitDataItem(key, GetCurrDate, 1);

            DataWarehouse <DataTable> .InitDataItem(key_Dt, GetDataTable, 1);

            //根据key获取值
            Console.WriteLine(DataWarehouse <string> .GetData(key));
            //Console.WriteLine(DataWarehouse<string>.GetData(key));
            ////休眠 等待过期
            //Thread.Sleep(1000 * 61);
            ////再次根据key获取值
            //Console.WriteLine(DataWarehouse<string>.GetData(key));

            //Console.ReadLine();

            #endregion

            #region DataTable测试

            DataTable dt = DataWarehouse <DataTable> .GetData(key_Dt);

            List <Person> ps = dt.GetEntityListByTable <Person>();
            Stopwatch     s  = new Stopwatch();
            s.Start();
            foreach (DataRow dr in dt.Rows)
            {
            }
            s.Stop();
            Console.WriteLine(s.ElapsedMilliseconds);
            Console.ReadLine();

            #endregion
        }
Beispiel #4
0
        static void Main(string[] args)
        {
            //DataBufferPool<int> dp = new DataBufferPool<int>(Console.WriteLine);
            //int iu = 0;
            //while (iu < 20)
            //{
            //    iu++;
            //    dp.AddItem(iu);
            //}
            //Console.ReadLine();

            #region 引用类型测试

            RTest  rt = new RTest();
            InnerC ic = new InnerC();
            ic.T(rt);
            Console.WriteLine(rt.i);

            ic.T(ref rt);
            Console.WriteLine(rt.i);
            Console.ReadLine();
            #endregion

            #region 动态类型测试

            dynamic dynamicobj = new LocalCacheContainer();
            dynamicobj.Name = "Learning Hard";
            dynamicobj.Age  = "24";
            var res = dynamicobj.Age;
            Console.WriteLine("fsadf");

            DynamicObjectTest dot = new DynamicObjectTest();

            dot.LocalCache.Person = new Person
            {
                id   = "1",
                Name = "zl"
            };

            dot.LocalCache.OtherInfo = "234";

            Person p1 = dot.LocalCache.Person1 as Person;

            Console.WriteLine(dot.LocalCache.Person.Name);
            Console.WriteLine(dot.LocalCache.OtherInfo);


            Console.ReadLine();
            #endregion

            #region 反射输出对象属性测试
            Group gp = new Group
            {
                GroupID   = 1,
                GroupName = "TestGroupName",
                PS        = new List <Person>
                {
                    new Person {
                        id = "1", Name = "n1"
                    },
                    new Person {
                        id = "2", Name = "n2"
                    },
                    new Person {
                        id = "3", Name = "n3"
                    }
                },
                Mark = "这是一个测试组"
            };

            foreach (string str in gp.GetReflectPropsValue().Split('|'))
            {
                Console.WriteLine(str);
            }
            Console.ReadLine();
            #endregion

            #region 随机数测试

            TestRandomNum();

            #endregion

            #region 反射对象属性测试
            Person p = new Person();
            TestReflectProps(p);
            Console.ReadLine();
            #endregion

            #region 过滤器测试

            //初始化过滤器
            ComplexFilterCore <string, DemoStringEnumType> demoStrFilterCore = new ComplexFilterCore <string, DemoStringEnumType>();

            //初始化 HasOne 2 LongLen 1
            demoStrFilterCore.SetMinGetCount(DemoStringEnumType.LongLen, 1);
            demoStrFilterCore.SetMinGetCount(DemoStringEnumType.HasOne, 2);

            //注册类型识别器 识别特性 DemoStringEnumType
            demoStrFilterCore.RegistEnumTypeIdentifier(new IdentifyDemoString());

            //添加过滤器 过滤掉不是整数的字符串
            demoStrFilterCore.AddFilter(new DemoStringContentFilter());

            //初始化数据源
            var ls = new List <string> {
                "123", "246", "b", "15", "16", "a32"
            };

            //执行过滤
            var result = demoStrFilterCore.GetFilteredResult(ls);

            //打印结果
            Console.WriteLine(string.Join(",", result.Keys));


            Console.ReadKey();

            #endregion

            #region 数据缓存仓库测试

            //key
            const string key    = "GetCurrDateKey";
            const string key_Dt = "GetDatatableKey";

            //初始化仓库
            DataWarehouse <string> .InitDataItem(key, GetCurrDate, 1);

            DataWarehouse <DataTable> .InitDataItem(key_Dt, GetDataTable, 1);

            //根据key获取值
            Console.WriteLine(DataWarehouse <string> .GetData(key));
            //Console.WriteLine(DataWarehouse<string>.GetData(key));
            ////休眠 等待过期
            //Thread.Sleep(1000 * 61);
            ////再次根据key获取值
            //Console.WriteLine(DataWarehouse<string>.GetData(key));

            //Console.ReadLine();

            #endregion

            #region DataTable测试

            DataTable dt = DataWarehouse <DataTable> .GetData(key_Dt);

            List <Person> ps = dt.GetEntityListByTable <Person>();
            Stopwatch     s  = new Stopwatch();
            s.Start();
            foreach (DataRow dr in dt.Rows)
            {
            }
            s.Stop();
            Console.WriteLine(s.ElapsedMilliseconds);
            Console.ReadLine();

            #endregion
        }