public static Hashtable Init( MetaList metaList ) { logger.Info( "cacheFactory..." ); Hashtable factoryList = cacheFactory( metaList ); logger.Info( "cacheAccessor..." ); cacheAccessor( metaList ); return factoryList; }
public static IPropertyAccessor GetAccessor( String typeFullName, String propertyName, MetaList mapping ) { switch (DbConfig.Instance.OptimizeMode) { case OptimizeMode.CodeDom: return CodeDomPropertyAccessor.GetAccessor( typeFullName, propertyName, mapping ); case OptimizeMode.IL: return ILPropertyAccessor.GetAccessor( typeFullName, propertyName ); } return null; }
private static Hashtable cacheFactory( MetaList metas ) { if( DbConfig.Instance.OptimizeMode == OptimizeMode.CodeDom ) { CodeDomPropertyAccessor.Init( metas ); return CodeDomPropertyAccessor.GetFactoryList(); } else if( DbConfig.Instance.OptimizeMode == OptimizeMode.IL ) { ILPropertyAccessor.Init(); return null; } return null; }
private static void cacheAccessor( MetaList metas ) { foreach (KeyValuePair<String, EntityInfo> kv in metas.ClassList) { String str = kv.Key; EntityInfo info = kv.Value; foreach (EntityPropertyInfo ep in info.PropertyListAll) { ep.PropertyAccessor = GetAccessor( info.Type.FullName, ep.Name, metas ); if (ep.PropertyAccessor == null) { throw new Exception( "PropertyAccessor can not be null : [type name]" + info.Type.FullName + ", [property name]" + ep.Name ); } } } }
private static void cacheAccessor( MetaList metas ) { foreach (DictionaryEntry entry in metas.ClassList) { String str = entry.Key.ToString(); EntityInfo info = entry.Value as EntityInfo; foreach (EntityPropertyInfo ep in info.PropertyListAll) { ep.PropertyAccessor = GetAccessor( info.Type.FullName, ep.Name, metas ); if (ep.PropertyAccessor == null) { throw new Exception( "PropertyAccessor can not be null : [type name]" + info.Type.FullName + ", [property name]" + ep.Name ); } } } }
public static IDictionary GetAccessorList( MetaList metaList ) { if (_accessorList == null) { Dictionary<String, EntityInfo> classList = metaList.ClassList; Dictionary<String, Assembly> asmList = metaList.AssemblyList; Assembly assembly = CodeDomHelper.CompileCode( GetAccessorCode( classList ), asmList, null ); _accessorList = (assembly.CreateInstance( "wojilu.Reflection.CodeDomAccessorUtil" ) as IAccessorUtil).GetAccessorList(); foreach (KeyValuePair<String, EntityInfo> kv in classList) { String typeFullName = kv.Key; IConcreteFactory factory = assembly.CreateInstance( getConcreteFactoryName( typeFullName ) ) as IConcreteFactory; _concreteFactoryList[typeFullName] = factory; } } return _accessorList; }
public static MappingClass loadByReflection() { logger.Info("loadByReflection"); IList asmList = DbConfig.Instance.AssemblyList; MappingClass map = new MappingClass(); for (int i = 0; i < asmList.Count; i++) { Assembly assembly = ObjectContext.LoadAssembly(asmList[i].ToString()); map.AssemblyList[asmList[i].ToString()] = assembly; Type[] typeArray = ObjectContext.FindTypes(asmList[i].ToString()); foreach (Type type in typeArray) { ResolveOneType(map, type); } logger.Info("loaded assembly: " + assembly.FullName); } logger.Info("FinishPropertyInfo"); FinishPropertyInfo(map.ClassList); logger.Info("cacheInterceptor"); cacheInterceptor(map); logger.Info("AccessorUtil.Init"); MetaList list = new MetaList(map.AssemblyList, map.ClassList); map.FactoryList = AccessorUtil.Init(list); checkMultiDB(map); return(map); }
public static MappingClass loadByReflection() { logger.Info( "loadByReflection" ); IList asmList = DbConfig.Instance.AssemblyList; MappingClass map = new MappingClass(); for (int i = 0; i < asmList.Count; i++) { Assembly assembly = ObjectContext.LoadAssembly( asmList[i].ToString() ); map.AssemblyList[asmList[i].ToString()] = assembly; Type[] typeArray = ObjectContext.FindTypes( asmList[i].ToString() ); foreach (Type type in typeArray) { ResolveOneType( map, type ); } logger.Info( "loaded assembly: " + assembly.FullName ); } logger.Info( "FinishPropertyInfo" ); FinishPropertyInfo( map.ClassList ); logger.Info( "cacheInterceptor" ); cacheInterceptor( map ); logger.Info( "AccessorUtil.Init" ); MetaList list = new MetaList( map.AssemblyList, map.ClassList ); map.FactoryList = AccessorUtil.Init( list ); checkMultiDB( map ); return map; }
public static IPropertyAccessor GetAccessor( String typeFullName, String propertyName, MetaList metaList ) { return (GetAccessorList( metaList )[getAccessorName( typeFullName, propertyName )] as IPropertyAccessor); }
public static void Init( MetaList metaList ) { GetAccessorList( metaList ); }
public static IDictionary GetAccessorList( MetaList metaList ) { if (_accessorList == null) { IDictionary classList = metaList.ClassList; IDictionary asmList = metaList.AssemblyList; Assembly assembly = CompileCode( GetAccessorCode( classList ), asmList ); _accessorList = (assembly.CreateInstance( "wojilu.Reflection.CodeDomAccessorUtil" ) as IAccessorUtil).GetAccessorList(); foreach (DictionaryEntry entry in classList) { String typeFullName = entry.Key.ToString(); IConcreteFactory factory = assembly.CreateInstance( getConcreteFactoryName( typeFullName ) ) as IConcreteFactory; _concreteFactoryList[typeFullName] = factory; } } return _accessorList; }