Ejemplo n.º 1
0
 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);
     }
 }
Ejemplo n.º 2
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);
            }

        }