public XafApplication Build() { try { var typesInfo = _buildTypesInfoSystem.Invoke(_moduleName); ReflectionHelper.AddResolvePath(_assemblyPath); var assembly = ReflectionHelper.GetAssembly(Path.GetFileNameWithoutExtension(_moduleName), _assemblyPath); var assemblyInfo = typesInfo.FindAssemblyInfo(assembly); typesInfo.LoadTypes(assembly); var findTypeInfo = typesInfo.FindTypeInfo(typeof(XafApplication)); var findTypeDescendants = ReflectionHelper.FindTypeDescendants(assemblyInfo, findTypeInfo, false); var instance = SecuritySystem.Instance; var info = XafTypesInfo.Instance; typesInfo.AssignAsInstance(); var xafApplication = ((XafApplication)Enumerator.GetFirst(findTypeDescendants).CreateInstance(new object[0])); SecuritySystem.SetInstance(instance); SetConnectionString(xafApplication); if (!_withOutObjectSpaceProvider) { var objectSpaceProviders = ((IList <IObjectSpaceProvider>)xafApplication.GetFieldValue("objectSpaceProviders")); objectSpaceProviders.Add(new MyClass(xafApplication)); } info.AssignAsInstance(); return(xafApplication); } finally { ReflectionHelper.RemoveResolvePath(_assemblyPath); } }
public ApplicationModulesManager CreateApplicationModulesManager(XafApplication application, string configFileName, string assembliesPath, ITypesInfo typesInfo) { if (!string.IsNullOrEmpty(configFileName)) { bool isWebApplicationModel = String.Compare(Path.GetFileNameWithoutExtension(configFileName), "web", StringComparison.OrdinalIgnoreCase) == 0; if (string.IsNullOrEmpty(assembliesPath)) { assembliesPath = Path.GetDirectoryName(configFileName); if (isWebApplicationModel) { assembliesPath = Path.Combine(assembliesPath + "", "Bin"); } } } ReflectionHelper.AddResolvePath(assembliesPath); try { var result = new ApplicationModulesManager(new ControllersManager(), assembliesPath); foreach (ModuleBase module in application.Modules) { result.AddModule(module); } result.Security = application.Security; if (GetModulesFromConfig(application) != null) { result.AddModuleFromAssemblies(GetModulesFromConfig(application)); } return(result); } finally { ReflectionHelper.RemoveResolvePath(assembliesPath); } }
private XafApplication GetApplication(string executableName, TypesInfo typesInfo) { string assemblyPath = AppDomain.CurrentDomain.SetupInformation.ApplicationBase; try { ReflectionHelper.AddResolvePath(assemblyPath); var assembly = ReflectionHelper.GetAssembly(Path.GetFileNameWithoutExtension(executableName), assemblyPath); var assemblyInfo = typesInfo.FindAssemblyInfo(assembly); ((ITypesInfo)typesInfo).LoadTypes(assembly); var findTypeInfo = typesInfo.FindTypeInfo(typeof(XafApplication)); var findTypeDescendants = ReflectionHelper.FindTypeDescendants(assemblyInfo, findTypeInfo, false); return(Enumerator.GetFirst(findTypeDescendants).CreateInstance(new object[0]) as XafApplication); } finally { ReflectionHelper.RemoveResolvePath(assemblyPath); } }
XpandApplicationModulesManager CreateModulesManager(XafApplication application, string configFileName, string assembliesPath, ITypesInfo typesInfo) { if (!string.IsNullOrEmpty(configFileName)) { bool isWebApplicationModel = String.Compare(Path.GetFileNameWithoutExtension(configFileName), "web", StringComparison.OrdinalIgnoreCase) == 0; if (string.IsNullOrEmpty(assembliesPath)) { assembliesPath = Path.GetDirectoryName(configFileName); if (isWebApplicationModel) { assembliesPath = Path.Combine(assembliesPath + "", "Bin"); } } } ReflectionHelper.AddResolvePath(assembliesPath); ITypesInfo synchronizeTypesInfo = null; try { var applicationModulesManager = new XpandApplicationModulesManager(new ControllersManager(), assembliesPath); if (application != null) { foreach (ModuleBase module in application.Modules) { applicationModulesManager.AddModule(module); } applicationModulesManager.Security = application.Security; applicationModulesManager.AddAdditionalModules(application); } if (!string.IsNullOrEmpty(configFileName)) { applicationModulesManager.AddModuleFromAssemblies(GetModulesFromConfig(application)); } var loadTypesInfo = typesInfo != XafTypesInfo.Instance; synchronizeTypesInfo = XafTypesInfo.Instance; typesInfo.AssignAsInstance(); applicationModulesManager.TypesInfo = typesInfo; var runtimeMode = InterfaceBuilder.RuntimeMode; InterfaceBuilder.RuntimeMode = false; applicationModulesManager.Load(typesInfo, loadTypesInfo); InterfaceBuilder.RuntimeMode = runtimeMode; return(applicationModulesManager); } finally { synchronizeTypesInfo.AssignAsInstance(); ReflectionHelper.RemoveResolvePath(assembliesPath); } }
ApplicationModulesManager CreateModulesManager(XafApplication application, string configFileName, string assembliesPath, ITypesInfo typesInfo) { if (!string.IsNullOrEmpty(configFileName)) { bool isWebApplicationModel = String.Compare(Path.GetFileNameWithoutExtension(configFileName), "web", StringComparison.OrdinalIgnoreCase) == 0; if (string.IsNullOrEmpty(assembliesPath)) { assembliesPath = Path.GetDirectoryName(configFileName); if (isWebApplicationModel) { assembliesPath = Path.Combine(assembliesPath + "", "Bin"); } } } ReflectionHelper.AddResolvePath(assembliesPath); try { var result = new ApplicationModulesManager(new ControllersManager(), assembliesPath); if (application != null) { foreach (ModuleBase module in application.Modules) { result.AddModule(module); } result.Security = application.Security; } if (!string.IsNullOrEmpty(configFileName)) { result.AddModuleFromAssemblies(GetModulesFromConfig(application)); } var info = typesInfo as TypesInfoBuilder.TypesInfo; if (info != null) { XpandModuleBase.Dictiorary = (info).Source.XPDictionary; } XpandModuleBase.TypesInfo = typesInfo; result.Load(typesInfo, typesInfo != XafTypesInfo.Instance); return(result); } finally { XpandModuleBase.Dictiorary = XpoTypesInfoHelper.GetXpoTypeInfoSource().XPDictionary; XpandModuleBase.TypesInfo = XafTypesInfo.Instance; ReflectionHelper.RemoveResolvePath(assembliesPath); } }
public XafApplication Build() { try { var typesInfo = _buildTypesInfoSystem.Invoke(_moduleName); ReflectionHelper.AddResolvePath(_assemblyPath); var assembly = ReflectionHelper.GetAssembly(Path.GetFileNameWithoutExtension(_moduleName), _assemblyPath); var assemblyInfo = typesInfo.FindAssemblyInfo(assembly); typesInfo.LoadTypes(assembly); var findTypeInfo = typesInfo.FindTypeInfo(typeof(XafApplication)); var findTypeDescendants = ReflectionHelper.FindTypeDescendants(assemblyInfo, findTypeInfo, false); var instance = SecuritySystem.Instance; var xafApplication = ((XafApplication)Enumerator.GetFirst(findTypeDescendants).CreateInstance(new object[0])); SecuritySystem.SetInstance(instance); if (ConfigurationManager.ConnectionStrings["ConnectionString"] != null) { ((ISupportFullConnectionString)xafApplication).ConnectionString = ConfigurationManager.ConnectionStrings["ConnectionString"].ConnectionString; } return(xafApplication); } finally { ReflectionHelper.RemoveResolvePath(_assemblyPath); } }