public MigrationContext( MigrationSettings settings, OrmPackage package, PortalApplication portal, BundleManifest manifest, IVSProject vsProject, CodeDomProvider codeProvider, StrongNameKeyPair keyPair, IExtendedLog log, IOperationStatus status, ICollection<Plugin> plugins) { _settings = settings; _package = package; _portal = portal; _manifest = manifest; _vsProject = vsProject; _codeProvider = codeProvider; _keyPair = keyPair; _log = log; _status = status; _plugins = plugins; _forms = new Dictionary<string, FormInfo>(StringComparer.InvariantCultureIgnoreCase); _mainViews = new Dictionary<string, MainViewInfo>(StringComparer.InvariantCultureIgnoreCase); _navigation = new List<NavigationInfo>(); _scripts = new Dictionary<string, ScriptInfo>(StringComparer.InvariantCultureIgnoreCase); _tables = new Dictionary<string, TableInfo>(StringComparer.InvariantCultureIgnoreCase); _entities = new Dictionary<string, OrmEntity>(StringComparer.InvariantCultureIgnoreCase); _relationships = new Dictionary<DataPathJoin, RelationshipInfo>(); _linkedFiles = new List<LinkedFile>(); _localizedStrings = new Dictionary<string, string>(StringComparer.InvariantCultureIgnoreCase); _references = new Dictionary<string, string>(StringComparer.InvariantCultureIgnoreCase); _smartParts = new List<SmartPartMapping>(); _secondaryJoins = new Dictionary<DataPathJoin, DataPathJoin>(); }
public SilverlightApp(Guid projectGuid, IVSProject silverlightProject, string pathInWeb, bool configurationSpecificFolders) { this.ProjectGuid = projectGuid; this.SilverlightProject = silverlightProject; this.PathInWeb = pathInWeb; this.ConfigurationSpecificFolders = configurationSpecificFolders; }
/// <summary> Creates memory module. </summary> /// /// <remarks> Ken, 10/4/2020. </remarks> /// /// <param name="project"> The project. </param> /// /// <returns> The new memory module. </returns> public ModuleBuilder CreateMemoryModuleBuilder(IVSProject project) { var assemblyName = new AssemblyName(); AppDomain appDomain; AssemblyBuilder assemblyBuilder; ModuleBuilder moduleBuilder; assemblyName.Name = project.Name; appDomain = AppDomain.CurrentDomain; assemblyBuilder = appDomain.DefineDynamicAssembly(assemblyName, AssemblyBuilderAccess.RunAndCollect); moduleBuilder = assemblyBuilder.DefineDynamicModule(assemblyName.Name, Path.GetFileNameWithoutExtension(project.FileName) + ".dll"); return(moduleBuilder); }
/// <summary> Process this. </summary> /// /// <remarks> Ken, 10/3/2020. </remarks> /// /// <param name="domainModel"> The domain model. </param> /// <param name="businessModel"> The business model. </param> /// <param name="appUIHierarchyNodeObject"></param> /// <param name="projectType"> Type of the project. </param> /// <param name="projectFolderRoot"> The project folder root. </param> /// <param name="entitiesProject"> The entities project. </param> /// <param name="generatorConfiguration"> The generator configuration. </param> /// /// <returns> True if it succeeds, false if it fails. </returns> public bool Process(EntityDomainModel domainModel, BusinessModel businessModel, UIHierarchyNodeObject appUIHierarchyNodeObject, Guid projectType, string projectFolderRoot, IVSProject entitiesProject, IGeneratorConfiguration generatorConfiguration) { return(true); }
/// <summary> Process this. </summary> /// /// <remarks> Ken, 10/3/2020. </remarks> /// /// <param name="entityDomainModel"> The entity domain model. </param> /// <param name="businessModel"> The business model. </param> /// <param name="projectType"> Type of the project. </param> /// <param name="projectFolderRoot"> The project folder root. </param> /// <param name="entitiesProject"></param> /// <param name="generatorConfiguration"> The generator configuration. </param> /// <param name="appUIHierarchyNodeObject"></param> /// /// <returns> True if it succeeds, false if it fails. </returns> public bool Process(EntityDomainModel entityDomainModel, BusinessModel businessModel, Guid projectType, string projectFolderRoot, IVSProject entitiesProject, IGeneratorConfiguration generatorConfiguration, out AppUIHierarchyNodeObject appUIHierarchyNodeObject) { var appSystemObject = businessModel.GetDescendants().Single(a => a.IsApp && a.Name == generatorConfiguration.AppName); var topLevelObject = businessModel.TopLevelObject; var topHierarchyNodeObjects = new List <UIHierarchyNodeObject>(); var allHierarchyNodeObjects = new List <UIHierarchyNodeObject>(); var appSettingsObjects = new Dictionary <AppSettingsKind, BusinessModelObject>(); IMemoryModuleBuilder memoryModuleBuilder; ModuleBuilder entititesModuleBuilder; UIHierarchyNodeObject topHierarchyNodeObject = null; string debugUIHierarchy; // create the UI hierarchy appUIHierarchyNodeObject = null; topLevelObject.GetDescendantsAndSelf <BusinessModelObject, UIHierarchyNodeObject>(o => o.Children, (o, n) => { var hierarchyNodeObject = new UIHierarchyNodeObject(o); if (topHierarchyNodeObject == null) { topHierarchyNodeObject = hierarchyNodeObject; } if (n != null) { n.AddChild(hierarchyNodeObject); } return(hierarchyNodeObject); }); // prune the tree topHierarchyNodeObject.GetDescendantsAndSelf(n => n.Children, n => { if (n.Parent != null) { var parent = n.Parent; if (!parent.ShowInUI) { var newParent = parent.Parent; if (newParent == null) { n.Parent = null; if (n.ShowInUI) { topHierarchyNodeObjects.Add(n); } } else { newParent.Children.Remove(parent); newParent.AddChild(n); } } } }); foreach (var hierarchyNodeObject in topHierarchyNodeObjects) { allHierarchyNodeObjects.AddRange(hierarchyNodeObject.GetDescendantsAndSelf()); } // create the app UI Hierarchy appUIHierarchyNodeObject = allHierarchyNodeObjects.Single(n => n.Id == appSystemObject.Id).CreateCopy <AppUIHierarchyNodeObject>(); foreach (var hierarchyNodeObject in topHierarchyNodeObjects) { hierarchyNodeObject.Name = "Home"; appUIHierarchyNodeObject.TopUIHierarchyNodeObjects.Add(hierarchyNodeObject); } // attach entities foreach (var entity in entityDomainModel.Entities) { if (entity.IsInherentDataItem) { appUIHierarchyNodeObject.InherentEntities.Add(entity); } else { var hierarchyNodeObject = allHierarchyNodeObjects.Single(n => n.Id == entity.ParentDataItem); foreach (var shadowHierarchyNodeObject in allHierarchyNodeObjects.Where(n => n.ShadowItem == hierarchyNodeObject.Id)) { shadowHierarchyNodeObject.Entities.Add(entity); } hierarchyNodeObject.Entities.Add(entity); } appUIHierarchyNodeObject.AllEntities.Add(entity); } // create new entities from app settings kind foreach (var appSettingsObject in topLevelObject.GetDescendants().Where(o => o.AppSettingsKind != null)) { var appSettingsKind = EnumUtils.GetValue <AppSettingsKind>(appSettingsObject.AppSettingsKind); appSettingsObjects.Add(appSettingsKind, appSettingsObject); } foreach (var pair in appSettingsObjects) { var appSettingsKind = pair.Key; var handler = generatorConfiguration.GetAppSettingsKindHandler(appSettingsKind); if (handler != null) { handler.Process(entityDomainModel, businessModel, appUIHierarchyNodeObject, appSettingsObjects, projectType, projectFolderRoot, generatorConfiguration); } } // create new entities from many-to-many containers foreach (var entity in appUIHierarchyNodeObject.AllEntities.ToList().Where(e => e.HasRelatedEntityAttributes())) { foreach (var containsManyToManyAttribute in entity.GetRelatedEntityAttributes().Where(a => a.Properties.Single(p => p.PropertyName == "RelatedEntity").ChildProperties.Any(p2 => p2.PropertyName == "RelationshipKind" && p2.PropertyValue == "ContainsManyToMany"))) { var relatedEntityProperty = containsManyToManyAttribute.Properties.Single(p => p.PropertyName == "RelatedEntity"); var containsManyToManyProperty = relatedEntityProperty.ChildProperties.Single(p2 => p2.PropertyName == "RelationshipKind" && p2.PropertyValue == "ContainsManyToMany"); var existingEntityProperty = containsManyToManyProperty.ChildProperties.Single(p3 => p3.PropertyName == "ExistingEntity"); var existingEntityName = existingEntityProperty.PropertyValue; var existingEntity = appUIHierarchyNodeObject.AllEntities.Single(e => e.Name == existingEntityName); var containerNameProperty = containsManyToManyProperty.ChildProperties.Single(p3 => p3.PropertyName == "ContainerName"); var containerName = containerNameProperty.PropertyValue; var associateEntityObject = new EntityObject() { Name = containerName, IsInherentDataItem = true, Attributes = new List <AttributeObject>() { new AttributeObject { Name = entity.Name, AttributeType = "related entity", Properties = new List <EntityPropertyItem>() { new EntityPropertyItem() { PropertyName = "RelatedEntity", PropertyValue = "IsLookupOfManyToOne", ChildProperties = new List <EntityPropertyItem>() { new EntityPropertyItem() { PropertyName = "ExistingEntity", PropertyValue = entity.Name } } } } }, new AttributeObject { Name = existingEntityName, AttributeType = "related entity", Properties = new List <EntityPropertyItem>() { new EntityPropertyItem() { PropertyName = "RelatedEntity", PropertyValue = "IsLookupOfManyToOne", ChildProperties = new List <EntityPropertyItem>() { new EntityPropertyItem() { PropertyName = "ExistingEntity", PropertyValue = existingEntityName } } } } } } }; if (entity.HasIdentityEntityKind(IdentityEntityKind.User) && existingEntity.HasIdentityEntityKind(IdentityEntityKind.Role)) { associateEntityObject.Properties = new List <EntityPropertyItem>() { new EntityPropertyItem() { PropertyName = "IdentityEntity", ChildProperties = new List <EntityPropertyItem>() { new EntityPropertyItem() { PropertyName = "IdentityEntityKind", PropertyValue = IdentityEntityKind.UserToRole.ToString() } } } }; } appUIHierarchyNodeObject.InherentEntities.Add(associateEntityObject); appUIHierarchyNodeObject.AllEntities.Add(associateEntityObject); } } debugUIHierarchy = appUIHierarchyNodeObject.DebugPrintUIHierarchy(); // build types memoryModuleBuilder = generatorConfiguration.GetMemoryModuleBuilder(); entititesModuleBuilder = memoryModuleBuilder.CreateMemoryModuleBuilder(entitiesProject); appUIHierarchyNodeObject.EntitiesModuleBuilder = entititesModuleBuilder; foreach (var entity in appUIHierarchyNodeObject.AllEntities) { generatorConfiguration.CreateTypeForEntity(entititesModuleBuilder, entity, appUIHierarchyNodeObject); } return(true); }