Esempio n. 1
0
 public static FactoryDao CreateInstance(String connectionString)
 {
     if (instance != null)
     {
         throw new Exception("already allocaion!");
     }
     instance = new FactoryDao(connectionString);
     return(instance);
 }
Esempio n. 2
0
        public void AllocResource(object obj)
        {
            var fields = from field in obj.GetType().GetFields(BindingFlags.Public | BindingFlags.NonPublic | BindingFlags.Instance)
                         let attrs = field.GetCustomAttributes()
                                     from attr in attrs
                                     where attr is ResourceDao
                                     select field;

            Parallel.ForEach(fields, field =>
            {
                ImplementDao impl = field.ReflectedType.GetCustomAttribute(typeof(ImplementDao)) as ImplementDao;
                field.SetValue(obj, FactoryDao.GetInstance().GetDao(impl.ClassName));
            });
        }
Esempio n. 3
0
        public Allocation()
        {
            var fields = from field in this.GetType().GetFields(BindingFlags.Public | BindingFlags.NonPublic | BindingFlags.Instance)
                         let attrs = field.GetCustomAttributes()
                                     from attr in attrs
                                     where attr is ResourceDao
                                     select field;

            foreach (var field in fields)
            {
                ImplementDao impl = field.FieldType.GetCustomAttribute(typeof(ImplementDao)) as ImplementDao;
                field.SetValue(this, FactoryDao.GetInstance().GetDao(impl.ClassName));
            }
        }