public void ProcessContainer(IEntityContainer container) { var tabs = this.GeneratorConfiguration.HierarchyStack.Count; var tabText = this.CurrentTabText; string identitySet = null; HandlerStackItem handlerStackItem; if (container.Facets.Length > 0) { var facetList = container.Facets.Select(f => string.Format("{0}[{1}]", tabText, f.AttributeCode)).ToMultiLineList(); var uiHierarchyPath = container.Facets.GetUIHierarchyPathList(generatorOptions.PrintMode); this.CurrentUIHierarchyPath = uiHierarchyPath; WriteLine(facetList, PrintMode.PrintFacetsOnly); WriteLine(uiHierarchyPath, PrintMode.PrintUIHierarchyPathOnly); if (container.HasFacetAttribute <IdentityAttribute>()) { var identityAttribute = container.GetFacetAttribute <IdentityAttribute>(); identitySet = identityAttribute.IdentitySet; } if (container.HasFacetAttribute <ResourcesAttribute>()) { var resourcesAttribute = container.GetFacetAttribute <ResourcesAttribute>(); this.GeneratorConfiguration.ResourcesHandler = resourcesAttribute.CreateHandler(); } } if (container.NoUIConfigOrFollow()) { this.GeneratorConfiguration.HandleFacets(container); } else { handlerStackItem = this.GeneratorConfiguration.HandleFacets(container); this.GeneratorConfiguration.Push(handlerStackItem); } WriteLine("{0}{1}", PrintMode.All, tabText, container.Name); using (this.GeneratorConfiguration.PushContainer(container)) { if (identitySet != null) { var membershipSet = container.EntitySets.SingleOrDefault(e => e.Name == identitySet); if (membershipSet != null) { ProcessEntitySet(membershipSet, true); } } foreach (var entitySet in container.EntitySets) { if (entitySet.CanFollowWithout()) { ProcessEntitySet(entitySet); } } } }
public void QueueContainerAction(IEntityContainer container, Action action) { var tabs = this.GeneratorConfiguration.HierarchyStack.Count; var tabText = this.CurrentTabText; var parentModel = container.Parent; if (container.Facets.Length > 0) { if (container.HasFacetAttribute <AppNameAttribute>()) { var appNameAttribute = container.GetFacetAttribute <AppNameAttribute>(); if (this.HasRegisteredAppConfig()) { var config = this.GeneratorConfiguration; if (config.CurrentPass != GeneratorPass.Files) { throw new InvalidOperationException("Cannot have more than one container with app specific attributes"); } } else { KeyValuePair <string, IGeneratorOverrides> appNameOverridePair; string argumentsKind; IGeneratorOverrides appNameOverride; appNameOverridePair = generatorOverridePairs.Where(o => o.Value.OverridesAppName).Last(); argumentsKind = appNameOverridePair.Key; appNameOverride = appNameOverridePair.Value; if (appNameOverride == null) { this.GeneratorConfiguration.AppName = appNameAttribute.Name; } else { this.GeneratorConfiguration.AppName = appNameOverride.GetAppName(this.GeneratorConfiguration, argumentsKind); } this.GeneratorConfiguration.AppDescription = appNameAttribute.Description; this.GeneratorConfiguration.ClientId = appNameAttribute.Name; this.GeneratorConfiguration.ClientSecret = Guid.NewGuid().ToString(); } } baseObjectDictionary.Add(parentModel.ID, parentModel); baseObjectDictionary.Add(container.ID, container); container.EntityDictionary = baseObjectDictionary; foreach (var baseObject in container.GetFollowingDescendants(this.GeneratorConfiguration.PartsAliasResolver)) { baseObjectDictionary.Add(baseObject.ID, baseObject); baseObject.EntityDictionary = baseObjectDictionary; } } else { baseObjectDictionary.Add(container.ID, container); baseObjectDictionary.Add(parentModel.ID, parentModel); container.EntityDictionary = baseObjectDictionary; if (container.CanFollowWithout()) { foreach (var baseObject in container.GetFollowingDescendants(this.GeneratorConfiguration.PartsAliasResolver)) { if (container.PreventRecursion) { if (!baseObjectDictionary.ContainsKey(baseObject.ID)) { baseObjectDictionary.Add(baseObject.ID, baseObject); } } else { baseObjectDictionary.Add(baseObject.ID, baseObject); } baseObject.EntityDictionary = baseObjectDictionary; } } } this.containerActionQueue.Enqueue(new ContainerAction(container, action)); }