Exemple #1
0
        ApplicationModulesManager CreateModulesManager(XafApplication application, string configFileName, string assembliesPath, ITypesInfo typesInfo) {
            if (!string.IsNullOrEmpty(configFileName)) {
                bool isWebApplicationModel = string.Compare(Path.GetFileNameWithoutExtension(configFileName), "web", true) == 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));
                }
                if (typesInfo is TypesInfo)
                    XpandModuleBase.Dictiorary = ((TypesInfo)typesInfo).Source.XPDictionary;

                result.Load(typesInfo);
                return result;
            } finally {
                XpandModuleBase.Dictiorary = XafTypesInfo.XpoTypeInfoSource.XPDictionary;
                ReflectionHelper.RemoveResolvePath(assembliesPath);
            }

        }
 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);
     }
 }
 IModelApplication GetModelApplication(XafApplication application, ApplicationModulesManager modulesManager) {
     var modelApplicationCreator = XpandModuleBase.ModelApplicationCreator;
     XpandModuleBase.ModelApplicationCreator = null;
     var modelApplication = new DesignerModelFactory().CreateApplicationModel(application, modulesManager, null, null);
     AddAfterSetupLayer(modelApplication);
     XpandModuleBase.ModelApplicationCreator = modelApplicationCreator;
     return modelApplication;
 }
 ModelApplicationBase GetModelApplication(XafApplication application, ApplicationModulesManager modulesManager) {
     var modelApplicationCreator = XpandModuleBase.ModelApplicationCreator;
     XpandModuleBase.ModelApplicationCreator = null;
     var modelApplication = new DesignerModelFactory().CreateApplicationModel(application, modulesManager, null, null);
     // ReSharper disable SuspiciousTypeConversion.Global
     var modelApplicationBase = (ModelApplicationBase)modelApplication;
     // ReSharper restore SuspiciousTypeConversion.Global
     AddAfterSetupLayer(modelApplicationBase);
     XpandModuleBase.ModelApplicationCreator = modelApplicationCreator;
     return modelApplicationBase;
 }
Exemple #5
0
 public ModelApplicationBase Build(bool rebuild) {
     string config = GetConfigPath();
     if (!rebuild)
         _modulesManager = CreateModulesManager(_application, config, _assembliesPath, _typesInfo);
     return BuildModel(_application, config, _modulesManager);
 }
Exemple #6
0
 ModelApplicationBase BuildModel(XafApplication application, string configFileName, ApplicationModulesManager applicationModulesManager) {
     ModelApplicationBase modelApplication = ModelApplicationHelper.CreateModel(XpandModuleBase.TypesInfo, applicationModulesManager.DomainComponents, applicationModulesManager.Modules,
                                                                                applicationModulesManager.ControllersManager, application.ResourcesExportedToModel, GetAspects(configFileName), null, null);
     var modelApplicationBase = modelApplication.CreatorInstance.CreateModelApplication();
     modelApplicationBase.Id = "After Setup";
     ModelApplicationHelper.AddLayer(modelApplication, modelApplicationBase);
     return modelApplication;
 }
Exemple #7
0
 ModelApplicationBase BuildModel(XafApplication application, string configFileName, ApplicationModulesManager applicationModulesManager) {
     XpandModuleBase.CallMonitor.Clear();
     var ruleBaseDescantans = RemoveRuntimeTypeFromIModelRuleBaseDescantans();
     var modelAssemblyFile = typeof(XafApplication).Invoke(application, "GetModelAssemblyFilePath") as string;
     var modelApplication = ModelApplicationHelper.CreateModel(applicationModulesManager.TypesInfo, applicationModulesManager.DomainComponents, applicationModulesManager.Modules,
                                                                                applicationModulesManager.ControllersManager, application.ResourcesExportedToModel, GetAspects(configFileName), modelAssemblyFile, null);
     ((ITypesInfoProvider)modelApplication).TypesInfo = applicationModulesManager.TypesInfo; 
     var modelApplicationBase = modelApplication.CreatorInstance.CreateModelApplication();
     modelApplicationBase.Id = "After Setup";
     ModelApplicationHelper.AddLayer(modelApplication, modelApplicationBase);
     AddRuntimeTypesToIModelRuleBaseDescenants(ruleBaseDescantans);
     return modelApplication;
 }
Exemple #8
0
 ModelApplicationBase BuildModel(XafApplication application, string configFileName, ApplicationModulesManager applicationModulesManager) {
     var modelsManager = new ApplicationModelsManager(applicationModulesManager.Modules, applicationModulesManager.ControllersManager, applicationModulesManager.DomainComponents, application.ResourcesExportedToModel, GetAspects(configFileName));
     var modelApplication = (ModelApplicationBase)modelsManager.CreateModel(modelsManager.CreateApplicationCreator(), null, false);
     var modelApplicationBase = modelApplication.CreatorInstance.CreateModelApplication();
     modelApplicationBase.Id = "After Setup";
     modelApplication.AddLayer(modelApplicationBase);
     return modelApplication;
 }
Exemple #9
0
 ModelApplicationBase BuildModel(XafApplication application, string configFileName, ApplicationModulesManager applicationModulesManager) {
     var modelsManager = new ApplicationModelsManager(applicationModulesManager.Modules, applicationModulesManager.ControllersManager, applicationModulesManager.DomainComponents, application.ResourcesExportedToModel, GetAspects(configFileName));
     var assemblyFile = application.GetType().GetMethod("GetModelAssemblyFilePath", BindingFlags.NonPublic | BindingFlags.Instance).Invoke(application, null) as string;
     modelsManager.GetType().GetProperty("ModelAssemblyFile", BindingFlags.NonPublic | BindingFlags.Instance).SetValue(modelsManager, assemblyFile, null);
     var modelApplication = (ModelApplicationBase)modelsManager.CreateModel(modelsManager.CreateApplicationCreator(), null, false);
     var modelApplicationBase = modelApplication.CreatorInstance.CreateModelApplication();
     modelApplicationBase.Id = "After Setup";
     modelApplication.AddLayer(modelApplicationBase);
     return modelApplication;
 }
Exemple #10
0
 ModelApplicationBase BuildModel(XafApplication application, string configFileName, ApplicationModulesManager applicationModulesManager) {
     InterfaceBuilder.LoadFromCurrentDomain = true;
     var ruleBaseDescantans = RemoveRuntimeTypeFromIModelRuleBaseDescantans();
     var modelAssemblyFile = ((IXafApplication)application).ModelAssemblyFilePath;
     ModelApplicationBase modelApplication = ModelApplicationHelper.CreateModel(XpandModuleBase.TypesInfo, applicationModulesManager.DomainComponents, applicationModulesManager.Modules,
                                                                                applicationModulesManager.ControllersManager, application.ResourcesExportedToModel, GetAspects(configFileName), modelAssemblyFile, null);
     var modelApplicationBase = modelApplication.CreatorInstance.CreateModelApplication();
     modelApplicationBase.Id = "After Setup";
     ModelApplicationHelper.AddLayer(modelApplication, modelApplicationBase);
     AddRuntimeTypesToIModelRuleBaseDescenants(ruleBaseDescantans);
     InterfaceBuilder.LoadFromCurrentDomain = false;
     return modelApplication;
 }