protected virtual object GetObjectCore(IModelDetailView modelView, object objectKey, IObjectSpace objectSpace) { Type type = modelView.ModelClass.TypeInfo.Type; object obj; if (XafTypesInfo.CastTypeToTypeInfo(type).IsPersistent) { if (objectKey != null && !(objectKey is CriteriaOperator)) { obj = objectSpace.GetObjectByKey(type, objectKey); } else { obj = objectSpace.FindObject(type, (CriteriaOperator)objectKey) ?? objectSpace.CreateObject(type); if (!(objectSpace.IsNewObject(obj))) { _application.ViewShown += ApplicationOnViewShown; } } } else { obj = (type.GetConstructor(new[] { typeof(Session) }) != null) ? objectSpace.CreateObject(type) : type.CreateInstance(); } return(obj); }
public void Dispose() { XpoTypesInfoHelper.Reset(); XafTypesInfo.HardReset(); // GC.Collect(); if (TestContext.CurrentContext.Result.Outcome.Status == TestStatus.Failed) { // var settingsPath = $"{AppDomain.CurrentDomain.ApplicationPath()}\\TestRun.Settings"; // while (!File.Exists(settingsPath)){ // var parent = new DirectoryInfo($"{Path.GetDirectoryName(settingsPath)}").Parent; // if (parent == null){ // settingsPath = null; // break; // } // settingsPath = $"{parent.FullName}\\TestRun.Settings"; // } // // if (settingsPath != null){ // var settings=Newtonsoft.Json.JsonConvert.DeserializeObject<dynamic>(settingsPath); // var fileName = $"{settings.TestArtifactsDirectory}\\TestsRun.zip"; // ZipFile.CreateFromDirectory(settings.TestArtifactsDirectory,fileName,CompressionLevel.NoCompression, false); // TestContext.AddTestAttachment(fileName); // } } }
public override void UpdateDatabaseBeforeUpdateSchema() { base.UpdateDatabaseBeforeUpdateSchema(); if (SequenceGenerator.UseGuidKey && XpandModuleBase.SequenceObjectType != null) { var classInfo = XafTypesInfo.CastTypeToTypeInfo(XpandModuleBase.SequenceObjectType).QueryXPClassInfo(); var dbTable = GetDbTable(classInfo.TableName); var typeNamePropertyName = nameof(ISequenceObject.TypeName); if (dbTable != null && dbTable.PrimaryKey.Columns.Contains(typeNamePropertyName)) { if (SequenceGeneratorHelper.IsMySql()) { throw new NotImplementedException("Set SequenceGenerator.UseGuidKey=false or update the set Oid as key property manually"); } var memberInfo = classInfo.Members.FirstOrDefault(info => info.IsCollection && typeof(ISequenceReleasedObject).IsAssignableFrom(info.CollectionElementType.ClassType)); if (memberInfo != null) { var tableName = memberInfo.CollectionElementType.Table.Name; if (GetDbTable(tableName) != null) { ExecuteNonQueryCommand("drop table " + tableName, false); } } ExecuteNonQueryCommand(String.Format( CultureInfo.InvariantCulture, "alter table {0} drop constraint PK_{0}", classInfo.TableName), false); } } }
private static IMemberInfo GetDefaultMember(Type type) { var typeInfo = XafTypesInfo.CastTypeToTypeInfo(type); var defaultMember = typeInfo.GetDefaultMember(); return(defaultMember); }
private T createController <T>(Type objectType, bool activate, XPObjectSpace XPObjectSpace, HandleInfo handleInfo) where T : ViewController { XafTypesInfo.Instance.RegisterEntity(objectType); var source = new CollectionSource(XPObjectSpace, objectType); var listEditor = Isolate.Fake.Instance <ListEditor>(); Isolate.WhenCalled(() => listEditor.RequiredProperties).WillReturn(new string[0]); var listView = new ListView(source, listEditor); Isolate.WhenCalled(() => listView.ObjectTypeInfo).WillReturn(XafTypesInfo.CastTypeToTypeInfo(objectType)); Isolate.WhenCalled(() => listView.ObjectSpace).WillReturn(XPObjectSpace); var controller = Isolate.Fake.Instance <T>(Members.CallOriginal, ConstructorWillBe.Called); Isolate.WhenCalled(() => controller.Application).WillReturn(Isolate.Fake.Instance <XafApplication>()); controller.Active[""] = false; controller.SetView(listView); View view = controller.View; Isolate.WhenCalled(() => view.ObjectSpace).WillReturn(XPObjectSpace); if (activate) { Activate(controller, handleInfo); } return(controller); }
private static IList GetObjects(IObjectSpace objectSpace, Type dashBoardObjectType) { var proxyCollection = new ProxyCollection(objectSpace, XafTypesInfo.CastTypeToTypeInfo(dashBoardObjectType), objectSpace.GetObjects(dashBoardObjectType)); proxyCollection.DisplayableMembers = string.Join(";", proxyCollection.DisplayableMembers.Split(';').Where(s => !s.EndsWith("!"))); return(proxyCollection); }
ApplicationModulesManager GetApplicationModulesManager(PathInfo pathInfo) { string assemblyPath = Path.GetDirectoryName(pathInfo.AssemblyPath); var designerModelFactory = new DesignerModelFactory(); ReflectionHelper.Reset(); XafTypesInfo.HardReset(); XpoTypesInfoHelper.ForceInitialize(); if (pathInfo.IsApplicationModel) { _currentDomainOnAssemblyResolvePathInfo = pathInfo; AppDomain.CurrentDomain.ReflectionOnlyAssemblyResolve += CurrentDomainOnAssemblyResolve; AppDomain.CurrentDomain.AssemblyResolve += CurrentDomainOnAssemblyResolve; var applicationInstance = Activator.CreateInstance(Assembly.Load(pathInfo.AssemblyPath).GetTypes().First(type => typeof(XafApplication).IsAssignableFrom(type))); AppDomain.CurrentDomain.ReflectionOnlyAssemblyResolve -= CurrentDomainOnAssemblyResolve; AppDomain.CurrentDomain.AssemblyResolve -= CurrentDomainOnAssemblyResolve; _currentDomainOnAssemblyResolvePathInfo = null; var configFileName = applicationInstance is WinApplication? pathInfo.AssemblyPath + ".config":Path.Combine(pathInfo.FullPath, "web.config"); return(designerModelFactory.CreateModulesManager((XafApplication)applicationInstance, configFileName, Path.GetDirectoryName(pathInfo.AssemblyPath))); } var moduleFromFile = designerModelFactory.CreateModuleFromFile(pathInfo.AssemblyPath, assemblyPath); return(designerModelFactory.CreateModulesManager(moduleFromFile, pathInfo.AssemblyPath)); }
public void AfterContextCleanup() { Isolate.CleanUp(); ReflectionHelper.Reset(); XafTypesInfo.Reset(); XafTypesInfo.HardReset(); XpoTypesInfoHelper.GetXpoTypeInfoSource().ResetDictionary(); }
public static TypeDecorator GetTypeDecorator(Type decorator, Position position) { IEnumerable <TypeDecorator> typeDecorators = GetTypeDecorators(new List <ITypeInfo> { XafTypesInfo.CastTypeToTypeInfo(decorator) }); return(typeDecorators.Where(PredicatePosition(position)).FirstOrDefault()); }
public void Dispose() { XpoTypesInfoHelper.Reset(); XafTypesInfo.HardReset(); if (TestContext.CurrentContext.Result.Outcome.Status == TestStatus.Failed) { TestContext.AddTestAttachment(ReactiveLoggerService.RXLoggerLogPath); } }
void AddMember(XPMemberInfo memberInfo, List <XPMemberInfo> result) { var memberClassInfo = XafTypesInfo.CastTypeToTypeInfo(memberInfo.MemberType).QueryXPClassInfo(); if (memberClassInfo != null && !memberClassInfo.IsPersistent) { return; } result.Add(memberInfo); }
protected virtual Type[] EditorTypes() { var typeInfo = ReflectionHelper.FindTypeDescendants(XafTypesInfo.CastTypeToTypeInfo(typeof(TreeListEditorVisibilityCalculatorHelper))).SingleOrDefault(); if (typeInfo != null) { var visibilityCalculatorHelper = (TreeListEditorVisibilityCalculatorHelper)typeInfo.Type.CreateInstance(); return(visibilityCalculatorHelper.TreelistEditorType()); } return(Type.EmptyTypes); }
ApplicationModulesManager GetApplicationModulesManager(PathInfo pathInfo) { string assemblyPath = Path.GetDirectoryName(pathInfo.AssemblyPath); var designerModelFactory = new DesignerModelFactory(); var moduleFromFile = designerModelFactory.CreateModuleFromFile(pathInfo.AssemblyPath, assemblyPath); ReflectionHelper.Reset(); XafTypesInfo.HardReset(); XpoTypesInfoHelper.ForceInitialize(); return(designerModelFactory.CreateModulesManager(moduleFromFile, pathInfo.AssemblyPath)); }
static string GetPropertiesCode(AttributeInfoAttribute attributeInfoAttribute) { if (attributeInfoAttribute.Instance == null) { return(null); } var typeInfo = XafTypesInfo.CastTypeToTypeInfo(attributeInfoAttribute.Instance.GetType()); var memberInfos = typeInfo.Members.Where(info => info.FindAttribute <AttributeInfoAttribute>() != null); string Func(string current, IMemberInfo memberInfo) => current + (memberInfo.Name + "=" + GetArgumentCodeCore(memberInfo.GetValue(attributeInfoAttribute.Instance)) + ","); return(memberInfos.Aggregate(null, (Func <string, IMemberInfo, string>)Func)?.TrimEnd(',')); }
private AssociationAttribute assertMemberCreation(object collection, string name, Type type) { Assert.IsNotNull(collection); ITypeInfo typeInfo = XafTypesInfo.CastTypeToTypeInfo(type); IMemberInfo memberInfo = typeInfo.FindMember(name); Assert.IsNotNull(memberInfo); var attribute = memberInfo.FindAttribute <AssociationAttribute>(); Assert.IsNotNull(attribute); Assert.AreEqual("association", attribute.Name); return(attribute); }
static string GetPropertiesCode(AttributeInfoAttribute attributeInfoAttribute) { if (attributeInfoAttribute.Instance == null) { return(null); } var typeInfo = XafTypesInfo.CastTypeToTypeInfo(attributeInfoAttribute.Instance.GetType()); var memberInfos = typeInfo.Members.Where(info => info.FindAttribute <AttributeInfoAttribute>() != null); Func <string, IMemberInfo, string> func = (current, memberInfo) => current + (memberInfo.Name + "=" + GetArgumentCodeCore(memberInfo.MemberType, memberInfo.GetValue(attributeInfoAttribute.Instance)) + ","); string code = memberInfos.Aggregate(null, func).TrimEnd(','); return(string.IsNullOrEmpty(code) ? null : string.Format(",{0}", code)); }
public override void Setup(XafApplication application) { if (RuntimeMode && XafTypesInfo.PersistentEntityStore == null) { XafTypesInfo.SetPersistentEntityStore(new XpandXpoTypeInfoSource((TypesInfo)application.TypesInfo)); } base.Setup(application); if (RuntimeMode) { application.SetupComplete += (sender, args) => RuntimeMemberBuilder.CreateRuntimeMembers(application.Model); application.CustomProcessShortcut += ApplicationOnCustomProcessShortcut; application.ListViewCreating += ApplicationOnListViewCreating; application.DetailViewCreating += ApplicationOnDetailViewCreating; application.CreateCustomCollectionSource += LinqCollectionSourceHelper.CreateCustomCollectionSource; application.LoggedOn += (sender, args) => RuntimeMemberBuilder.CreateRuntimeMembers(application.Model); } }
void CreateRefElelement(IClassInfoGraphNode classInfoGraphNode, Type objectType, XElement root, object theObject, XElement propertyElement, ElementSchema elementSchema) { var serializedObjectRefElement = new XElement(elementSchema.SerializedObjectRef); propertyElement.Add(serializedObjectRefElement); serializedObjectRefElement.Add(new XAttribute(elementSchema.Type, objectType.Name)); serializedObjectRefElement.Add(new XAttribute(elementSchema.Strategy, classInfoGraphNode.SerializationStrategy)); if (theObject != null) { var classInfoGraphNodes = _serializeClassInfoGraphNodesCalculator.GetSerializedClassInfoGraphNodes(theObject, objectType.Name).ToArray(); CreateRefKeyElements(XafTypesInfo.CastTypeToTypeInfo(objectType), classInfoGraphNodes, theObject, serializedObjectRefElement, elementSchema); if (classInfoGraphNode.SerializationStrategy == SerializationStrategy.SerializeAsObject) { ExportCore(theObject, classInfoGraphNodes, root, elementSchema); } } }
ApplicationModulesManager GetApplicationModulesManager(PathInfo pathInfo) { var designerModelFactory = new DesignerModelFactory(); ReflectionHelper.Reset(); XafTypesInfo.HardReset(); XpoTypesInfoHelper.ForceInitialize(); if (pathInfo.IsApplicationModel) { var assembliesPath = Path.GetDirectoryName(pathInfo.AssemblyPath); var application = designerModelFactory.CreateApplicationFromFile(pathInfo.AssemblyPath, assembliesPath); InitializeTypeInfoSources(application.Modules, assembliesPath); var applicationModulesManager = designerModelFactory.CreateModulesManager(application, null, assembliesPath); return(applicationModulesManager); } var moduleFromFile = designerModelFactory.CreateModuleFromFile(pathInfo.AssemblyPath, Path.GetDirectoryName(pathInfo.AssemblyPath)); return(designerModelFactory.CreateModulesManager(moduleFromFile, pathInfo.AssemblyPath)); }
internal static IModelApplication CreateApplication(Type[] boModelTypes, Action <ITypesInfo>?customizeTypesInfo = null) { XafTypesInfo.HardReset(); if (XafTypesInfo.Instance is TypesInfo typesInfo) { var store = typesInfo.FindEntityStore(typeof(NonPersistentTypeInfoSource)); if (store is not null) { foreach (var type in boModelTypes) { store.RegisterEntity(type); } } } var modelManager = new ApplicationModelManager(null, true); var modules = new ModuleBase[] { new DXSystemModele(), new TestModule(boModelTypes, customizeTypesInfo) }; foreach (var module in modules) { module.CustomizeTypesInfo(XafTypesInfo.Instance); } modelManager.Setup( XafTypesInfo.Instance, boModelTypes, modules, Enumerable.Empty <Controller>(), Enumerable.Empty <Type>(), Enumerable.Empty <string>(), null, null ); return((IModelApplication)modelManager.CreateModelApplication(Enumerable.Empty <ModelApplicationBase>())); }
public void Generate(ISerializationConfiguration serializationConfiguration) { var typeToSerialize = serializationConfiguration.TypeToSerialize; var castTypeToTypeInfo = XafTypesInfo.CastTypeToTypeInfo(typeToSerialize); var objectSpace = XPObjectSpace.FindObjectSpaceByObject(serializationConfiguration); _serializationConfigurationGroup = serializationConfiguration.SerializationConfigurationGroup; if (_serializationConfigurationGroup == null) { throw new NullReferenceException("_serializationConfigurationGroup"); } foreach (var descendant in ReflectionHelper.FindTypeDescendants(castTypeToTypeInfo)) { Generate(objectSpace, descendant.Type); } foreach (IClassInfoGraphNode classInfoGraphNode in CreateGraph(objectSpace, castTypeToTypeInfo)) { serializationConfiguration.SerializationGraph.Add(classInfoGraphNode); } }
public virtual void Setup() { DictionaryNode.ReaderWriterLockWrapperCreator = new ReaderWriterLockWrapper(); elDictionary = new Dictionary(new DictionaryXmlReader().ReadFromString(elClassXml), Schema.GetCommonSchema()); DefaultDictionary = new Dictionary(new DictionaryXmlReader().ReadFromString(DefaultClassXml), Schema.GetCommonSchema()); PersistentAppDictionary = new Dictionary(new DictionaryXmlReader().ReadFromString(PersistentAppClassXml), Schema.GetCommonSchema()); DefaultDictionary2 = new Dictionary(new DictionaryXmlReader().ReadFromString(DefaultClassXml2), Schema.GetCommonSchema()); Session.DefaultSession.Disconnect(); // dataSet = new DataSet(); XafTypesInfo.Reset(true); var dataStore = new InMemoryDataStore(AutoCreateOption.DatabaseAndSchema); dataLayer = new SimpleDataLayer(XafTypesInfo.XpoTypeInfoSource.XPDictionary, dataStore); XpoDefault.DataLayer = dataLayer; // Isolate.Fake.ISecurityComplex(); }
public override void Setup(XafApplication application) { lock (XafTypesInfo.Instance) { if (RuntimeMode && XafTypesInfo.PersistentEntityStore == null) { XafTypesInfo.SetPersistentEntityStore(new XpandXpoTypeInfoSource((TypesInfo)application.TypesInfo)); } } base.Setup(application); CheckApplicationTypes(); if (RuntimeMode) { ApplicationHelper.Instance.Initialize(application); var helper = new ConnectionStringHelper(); helper.Attach(this); var generatorHelper = new SequenceGeneratorHelper(); generatorHelper.Attach(this); helper.ConnectionStringUpdated += (sender, args) => generatorHelper.InitializeSequenceGenerator(); } if (Executed("Setup")) { return; } if (ManifestModuleName == null) { ManifestModuleName = application.GetType().Assembly.ManifestModule.Name; } application.CreateCustomUserModelDifferenceStore += OnCreateCustomUserModelDifferenceStore; application.SetupComplete += ApplicationOnSetupComplete; application.SettingUp += ApplicationOnSettingUp; application.CreateCustomCollectionSource += ApplicationOnCreateCustomCollectionSource; if (RuntimeMode) { application.LoggedOn += (sender, args) => RuntimeMemberBuilder.CreateRuntimeMembers(application.Model); } }
public override void UpdateDatabaseAfterUpdateSchema() { base.UpdateDatabaseAfterUpdateSchema(); InitializeSecurity(ObjectSpace); new DummyDataBuilder((XPObjectSpace)ObjectSpace).CreateObjects(); var workflowServiceUser = ObjectSpace.FindObject(SecuritySystem.UserType, new BinaryOperator("UserName", "WorkflowService")); if (workflowServiceUser == null) { CriteriaOperator criteriaOperator = CriteriaOperator.Parse("Name=?", SecurityStrategy.AdministratorRoleName); CreateworkflowServiceUser(ObjectSpace.FindObject <Role>(criteriaOperator)); ObjectSpace.CommitChanges(); var updaters = ReflectionHelper.FindTypeDescendants(XafTypesInfo.CastTypeToTypeInfo(typeof(FCUpdater))); foreach (var findTypeDescendant in updaters) { var updater = (FCUpdater)Activator.CreateInstance(findTypeDescendant.Type, ObjectSpace, CurrentDBVersion); updater.UpdateDatabaseAfterUpdateSchema(); } } }
protected virtual ICollection GetPermissionTypeNames() { var typeDescendants = ReflectionHelper.FindTypeDescendants(XafTypesInfo.CastTypeToTypeInfo(typeof(XpandPermissionData))); return(typeDescendants.Select(info => info.FullName).ToList()); }
protected virtual ITypesInfo CreateTypesInfo() { XafTypesInfo.DebugTest_Recreate(); return(XafTypesInfo.Instance); }
protected virtual void EraseTypesInfo() { XafTypesInfo.DebugTest_Recreate(); }
protected BaseSpecs() { XafTypesInfo.HardReset(); }
public virtual void Dispose() { XpoTypesInfoHelper.Reset(); XafTypesInfo.HardReset(); }
public void Setup() { XafTypesInfo.Reset(); }