TypesInfo GetTypesInfo() {
     var typesInfo = new TypesInfo();
     typesInfo.AddEntityStore(new NonPersistentEntityStore(typesInfo));
     var xpoSource = new XpoTypeInfoSource(typesInfo);
     typesInfo.AddEntityStore(xpoSource);
     XpandModuleBase.Dictiorary = xpoSource.XPDictionary;
     return typesInfo;
 }
Beispiel #2
0
 TypesInfo GetTypesInfo() {
     var typesInfo = new TypesInfo();
     typesInfo.AddEntityStore(new NonPersistentEntityStore(typesInfo));
     var xpoSource = new XpoTypeInfoSource(typesInfo);
     typesInfo.Source = xpoSource;
     typesInfo.AddEntityStore(xpoSource);
     return typesInfo;
 }
Beispiel #3
0
 public Type LoadFromBaseImpl(string typeName)
 {
     if (BaseImplAssembly != null)
     {
         var typeInfo = TypesInfo.FindTypeInfo(typeName);
         return(typeInfo != null ? typeInfo.Type : null);
     }
     return(null);
 }
 TypesInfo GetTypesInfo() {
     var typesInfo = new TypesInfo();
     typesInfo.AddSource(new ReflectionTypeInfoSource());
     var xpoSource = new XpoTypeInfoSource(typesInfo);
     typesInfo.Source = xpoSource;
     typesInfo.AddSource(xpoSource);
     typesInfo.AddSource(new DynamicTypeInfoSource());
     typesInfo.SetRedirectStrategy((@from, info) => xpoSource.GetFirstRegisteredTypeForEntity(from) ?? from);
     return typesInfo;
 }
 ApplicationModulesManager GetModulesManager(TypesInfo typesInfo, XafApplication application) {
     var modulesManager = CreateApplicationModulesManager(application, string.Empty,
                                                          AppDomain.CurrentDomain.SetupInformation.ApplicationBase, typesInfo);
     try {
         XpandModuleBase.Dictiorary = typesInfo.Source.XPDictionary;
         XpandModuleBase.TypesInfo = typesInfo;
         modulesManager.Load(typesInfo);
     } finally {
         XpandModuleBase.Dictiorary = XafTypesInfo.XpoTypeInfoSource.XPDictionary;
         XpandModuleBase.TypesInfo = XafTypesInfo.Instance;
     }
     return modulesManager;
 }
Beispiel #6
0
        public static IEnumerable <Type> CollectExportedTypesFromAssembly(Assembly assembly)
        {
            var typesList = new ExportedTypeCollection();

            try {
                TypesInfo.LoadTypes(assembly);
                if (assembly == typeof(XPObject).Assembly)
                {
                    typesList.AddRange(XpoTypeInfoSource.XpoBaseClasses);
                }
                else
                {
                    typesList.AddRange(assembly.GetTypes());
                }
            } catch (Exception e) {
                throw new InvalidOperationException(
                          String.Format("Exception occurs while ensure classes from assembly {0}\r\n{1}", assembly.FullName, e.Message), e);
            }
            return(typesList);
        }
 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);
     }
 }
Beispiel #8
0
 bool ValidateBOModel(IPersistentAssemblyInfo persistentAssemblyInfo, Type compileCore) {
     if (persistentAssemblyInfo.ValidateModelOnCompile) {
         try {
             var typesInfo = new TypesInfo();
             typesInfo.AddEntityStore(new NonPersistentEntityStore(typesInfo));
             typesInfo.AddEntityStore(new XpoTypeInfoSource(typesInfo));
             typesInfo.LoadTypes(compileCore.Assembly);
             var applicationModulesManager = new ApplicationModulesManager();
             applicationModulesManager.AddModule(compileCore);
             applicationModulesManager.Load(typesInfo, true);
         } catch (Exception exception) {
             persistentAssemblyInfo.CompileErrors = exception.ToString();
             return false;
         }
     }
     return true;
 }
 public XpandXpoTypeInfoSource(TypesInfo typesInfo)
     : base(typesInfo) {
 }
Beispiel #10
0
 public static void CreateCustomProvider(this XafApplication application, string connectionString, TypesInfo typesInfo, List<IObjectSpaceProvider> objectSpaceProviders, Action createBaseCustomObjectSpaceProvider) {
     var objectSpaceProviderCf = new EFObjectSpaceProviderCF(typeof(EFDemoDbContext), typesInfo, null, connectionString);
     objectSpaceProviderCf.UpdateSchema();
     createBaseCustomObjectSpaceProvider.Invoke();
     objectSpaceProviders.Add(objectSpaceProviderCf);
 }
Beispiel #11
0
        public bool Run(RuntimeSetupInfo setupInfo) {
            var typesInfo = new TypesInfo();
            typesInfo.AddEntityStore(new NonPersistentEntityStore(typesInfo));
            var reflectionDictionary = new ReflectionDictionary();reflectionDictionary.CollectClassInfos(typeof(ModuleArtifact).Assembly);
            var xpoTypeInfoSource = new XpoTypeInfoSource(typesInfo,reflectionDictionary);
            typesInfo.AddEntityStore(xpoTypeInfoSource);
            typesInfo.LoadTypes(typeof(ModuleArtifact).Assembly);
            var exportedTypesFromAssembly = ModuleHelper.CollectExportedTypesFromAssembly(typeof(ModuleArtifact).Assembly,ExportedTypeHelpers.IsExportedType);
            foreach (var type in exportedTypesFromAssembly){
                xpoTypeInfoSource.RegisterEntity(type);
            }

            var objectSpace = new XPObjectSpace(typesInfo, xpoTypeInfoSource, () => new UnitOfWork(reflectionDictionary){ ConnectionString = setupInfo.ConnectionString });
            if (!objectSpace.Contains<ModuleChild>()){
                var moduleTypes = GetModuleTypes(setupInfo);
                var childModules = objectSpace.GetModuleChilds(moduleTypes);
                foreach (var childModule in childModules){
                    childModule.Value.CreateArtifacts(childModule.Key);
                    childModule.Value.CreateExtenderInterfaces(childModule.Key);
                }
                UpdateMapViewModule(childModules, objectSpace);
            }
            CreateObjects(objectSpace, setupInfo);
            objectSpace.CommitChanges();
            return true;
        }