Example #1
0
        public ModelApplicationBase Build(bool rebuild)
        {
            string config = GetConfigPath();

            if (!rebuild)
            {
                _modulesManager = CreateModulesManager(_application, config, _assembliesPath, _typesInfo);
            }
            return(BuildModel(_application, config, _modulesManager));
        }
Example #2
0
        ModelApplicationBase BuildModel(XafApplication application, string configFileName, XpandApplicationModulesManager applicationModulesManager) {
            XpandModuleBase.CallMonitor.Clear();
            var modelAssemblyFile = typeof(XafApplication).Invoke(application, "GetModelAssemblyFilePath") as string;
            applicationModulesManager.TypesInfo.AssignAsInstance();
            var modelApplication = ModelApplicationHelper.CreateModel(applicationModulesManager.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);
            return modelApplication;
        }
Example #3
0
        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);
            }
        }
Example #4
0
        ModelApplicationBase BuildModel(XafApplication application, string configFileName, XpandApplicationModulesManager applicationModulesManager)
        {
            XpandModuleBase.CallMonitor.Clear();
//            var ruleBaseDescantans = RemoveRuntimeTypeFromIModelRuleBaseDescantans();
            var modelAssemblyFile = typeof(XafApplication).Invoke(application, "GetModelAssemblyFilePath") as string;

            applicationModulesManager.TypesInfo.AssignAsInstance();
            var modelApplication = ModelApplicationHelper.CreateModel(applicationModulesManager.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);
            return(modelApplication);
        }
Example #5
0
        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;
                }
                if (!string.IsNullOrEmpty(configFileName)) {
                    applicationModulesManager.AddModuleFromAssemblies(GetModulesFromConfig(application));
                }
                var loadTypesInfo = typesInfo != XafTypesInfo.Instance;
                synchronizeTypesInfo = XafTypesInfo.Instance;
                typesInfo.AssignAsInstance();
                applicationModulesManager.TypesInfo = typesInfo;
                applicationModulesManager.Load(typesInfo, loadTypesInfo);
                return applicationModulesManager;
            } finally {
                synchronizeTypesInfo.AssignAsInstance();
                ReflectionHelper.RemoveResolvePath(assembliesPath);
            }

        }
Example #6
0
 public ModelApplicationBase Build(bool rebuild) {
     string config = GetConfigPath();
     if (!rebuild)
         _modulesManager = CreateModulesManager(_application, config, _assembliesPath, _typesInfo);
     return BuildModel(_application, config, _modulesManager);
 }
Example #7
0
        ModelApplicationBase BuildModel(XafApplication application, string configFileName, XpandApplicationModulesManager applicationModulesManager)
        {
            XpandModuleBase.CallMonitor.Clear();
            var modelAssemblyFile = typeof(XafApplication).Invoke(application, "GetModelAssemblyFilePath") as string;

            if (!File.Exists(modelAssemblyFile))
            {
                throw new FileNotFoundException(
                          $"The ModelEditor requires a valid ModelAssembly. Reference the Xpand.ExpressApp.ModelDifference assembly in your front end project, override the {application.GetType().FullName} GetModelAssemblyFilePath to provide a valid filename using the call this.GetModelFilePath()");
            }

            applicationModulesManager.TypesInfo.AssignAsInstance();
            var modelApplication = ModelApplicationHelper.CreateModel(applicationModulesManager.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);
            return(modelApplication);
        }
Example #8
0
        ModelApplicationBase BuildModel(XafApplication application, string configFileName, XpandApplicationModulesManager applicationModulesManager)
        {
            XpandModuleBase.CallMonitor.Clear();
            var modelAssemblyFile = typeof(XafApplication).Invoke(application, "GetModelAssemblyFilePath") as string;

            if (!File.Exists(modelAssemblyFile))
            {
                string example = @"
//Win
Path.Combine(Path.GetTempPath(),$""{GetType().Name}{ModelAssemblyFileName}"")

//Web
GetType().GetField(""sharedModelManager"", BindingFlags.NonPublic|BindingFlags.FlattenHierarchy|BindingFlags.Static)?.GetValue(this) == null
                ? Path.Combine(Path.GetTempPath(), $""{GetType().Name}{ModelAssemblyFileName}"") : null                    
";
                throw new FileNotFoundException(
                          $"The ModelEditor requires a valid ModelAssembly. Override the {application.GetType().FullName} GetModelAssemblyFilePath to provide a valid filename e.g.{example}");
            }

            applicationModulesManager.TypesInfo.AssignAsInstance();
            typeof(ModelApplicationCreator).SetFieldValue("fileModelAssembly", null);
            var modelApplication = ModelApplicationHelper.CreateModel(applicationModulesManager.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);
            return(modelApplication);
        }