Generic,reflection
来源:互联网 发布:linux建立用户组 编辑:程序博客网 时间:2024/04/28 22:31
protected BaseInstagramWriter<Posts> postWriter = new BaseInstagramWriter<Posts>();
postWriter.AddItemToWriteQueue(new Post);
public class BaseInstagramWriter<T>
{
BlockingCollection<T> _queue1;
BlockingCollection<T> _queue2;
BlockingCollection<T>[] _queues;
List<string> _keyNames;
List<PropertyInfo> _keys;
EntityCompare<T> _entityCompare;
public BaseInstagramWriter()
{
_queue1 = new BlockingCollection<T>();
_queue2 = new BlockingCollection<T>();
_queues = new BlockingCollection<T>[2];
_queues[0] = _queue1;
_queues[1] = _queue2;
_keyNames = new List<string>();
//setup here
TableAttribute tableAttribute = (TableAttribute)Attribute.GetCustomAttribute(typeof(T), typeof(TableAttribute));
//get the specified table name or use the name of the class
_tableName = tableAttribute != null ? tableAttribute.Name : typeof(T).Name;
_connectionString = System.Configuration.ConfigurationManager.ConnectionStrings["InstagramV3DB"].ConnectionString;
_columns = typeof(T).GetProperties();
foreach (var col in _columns)
{
Type propType = col.PropertyType;
if (Attribute.GetCustomAttribute(col, typeof(KeyAttribute)) != null)
{
_keyNames.Add(col.Name);
}
}
_keys = _columns.Where(i => _keyNames.Contains(i.Name)).ToList();
_entityCompare = new EntityCompare<T>(_keys, true);
//single threaded;
Task.Run(() => this.WriterThread());
}
}
- Generic Reflection
- Generic,reflection
- Singleton, Generic Singleton and Silverlight Reflection 限制
- Reflection
- Reflection
- Reflection
- Reflection
- Reflection
- Reflection
- Reflection
- Reflection
- Generic
- Generic
- generic
- Java Reflection
- Introducing reflection
- Reflection & Attributes
- Java Reflection
- samba实现与window共享文件夹
- priority_queue(优先队列)
- HDU-1394-Minimum Inversion Number-线段树+逆序数
- 安卓开发数据库篇
- Linux进程使用内存的基本流程---Linux用户进程是如何释放内存的
- Generic,reflection
- iOS UI第一周总结
- Linux的文件权限与目录配置
- ahu 350 分解因式
- 音视频同步-时间戳
- JavaMail开发出现com/sun/mail/util/LineInputStream异常
- 魅族 MEIZU MX4 连接电脑,Eclipse DDMS不能发现设备,识别不了手机的问题
- DoTween(HOTween V2) 教程
- 字符串排序