public static void DataProxyDelink(this IDataExtracter target, params int[] dataNames) { IDataProxy proxy; DataWarehouse datas = Framework.Instance.GetUnit <DataWarehouse>(Framework.UNIT_DATA); int max = dataNames == default ? 0 : dataNames.Length; for (int i = 0; i < max; i++) { proxy = datas.GetData <IDataProxy>(dataNames[i]); proxy.Unregister(target); } }
public void CommitRelate() { int name; int max = (ComponentNames != default) ? ComponentNames.Length : 0; if (max > 0) { if (mCompCached == default) { mCompCached = new KeyValueList <int, IShipDockComponent>(); } var components = ShipDockECS.Instance.Context; for (int i = 0; i < max; i++) { name = ComponentNames[i]; mCompCached[name] = components.RefComponentByName(name); } } max = (DataNames != default) ? DataNames.Length : 0; if (max > 0) { if (mDataCached == default) { mDataCached = new KeyValueList <int, IDataProxy>(); } DataWarehouse datas = Framework.Instance.GetUnit <DataWarehouse>(Framework.UNIT_DATA); for (int i = 0; i < max; i++) { name = DataNames[i]; mDataCached[name] = datas.GetData <IDataProxy>(name); } } max = (ServerNames != default) ? ServerNames.Length : 0; if (max > 0) { if (mServerCached == default) { mServerCached = new KeyValueList <string, IServer>(); } string serverName; Servers servers = Framework.Instance.GetUnit <Servers>(Framework.UNIT_IOC); for (int i = 0; i < max; i++) { serverName = ServerNames[i]; mServerCached[serverName] = servers.GetServer <IServer>(serverName); } } }
public static KeyValueList <int, IDataProxy> DataProxyLink(this IDataExtracter target, params int[] dataNames) { IDataProxy proxy; int name; int max = dataNames != default ? dataNames.Length : 0; DataWarehouse datas = Framework.Instance.GetUnit <DataWarehouse>(Framework.UNIT_DATA); KeyValueList <int, IDataProxy> result = new KeyValueList <int, IDataProxy>(); for (int i = 0; i < max; i++) { name = dataNames[i]; proxy = datas.GetData <IDataProxy>(name); proxy.Register(target); result[name] = proxy; } return(result); }
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 }
public static T GetData <T>(this int target) where T : IDataProxy { DataWarehouse datas = Framework.Instance.GetUnit <DataWarehouse>(Framework.UNIT_DATA); return(datas.GetData <T>(target)); }
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 }