public static ElementAttachingProviderResult GetAlternateElementList(string providerName, EntityToken parentEntityToken, Dictionary <string, string> piggybag) { Verify.ArgumentNotNullOrEmpty(providerName, "providerName"); IElementAttachingProvider elementAttachingProvider = GetElementAttachingProvider(providerName); ElementAttachingProviderResult result = elementAttachingProvider.GetAlternateElementList(parentEntityToken, piggybag); return(result); }
public ElementAttachingProviderResult GetAlternateElementList( EntityToken parentEntityToken, Dictionary <string, string> piggybag) { if (ElementAttachingPointFacade.IsAttachingPoint(parentEntityToken, AttachingPoint.ContentPerspective) == false) { return(null); } ElementAttachingProviderResult result = new ElementAttachingProviderResult() { Elements = GetRootElements(piggybag), Position = ElementAttachingProviderPosition.Bottom, PositionPriority = 0 }; return(result); }
public ElementAttachingProviderResult GetAlternateElementList(EntityToken parentEntityToken, Dictionary <string, string> piggybag) { if (parentEntityToken is GeneratedDataTypesElementProviderTypeEntityToken) { var token = parentEntityToken as GeneratedDataTypesElementProviderTypeEntityToken; if (token.SerializedTypeName == TypeManager.SerializeType(typeof(ApiKey))) { var label = IssuuApi.GetDefaultLabel(); if (!string.IsNullOrEmpty(label)) { ElementAttachingProviderResult result = new ElementAttachingProviderResult() { Elements = GetRootElements(label, piggybag), Position = ElementAttachingProviderPosition.Top, PositionPriority = 0 }; return(result); } } } return(null); }
public IEnumerable <ElementAttachingProviderResult> GetAlternateElementLists(EntityToken parentEntityToken, Dictionary <string, string> piggybag) { TreeSharedRootsFacade.Initialize(Context.ProviderName); IEnumerable <Tree> trees = TreeFacade.GetTreesByEntityToken(parentEntityToken); foreach (Tree tree in trees) { foreach (IAttachmentPoint attachmentPoint in tree.GetAttachmentPoints(parentEntityToken)) { TreeNodeDynamicContext dynamicContext = new TreeNodeDynamicContext(TreeNodeDynamicContextDirection.Down) { ElementProviderName = this.Context.ProviderName, Piggybag = piggybag, CurrentEntityToken = parentEntityToken, CurrentTreeNode = tree.RootTreeNode, IsRoot = true }; ElementAttachingProviderResult result = null; try { result = new ElementAttachingProviderResult() { Elements = tree.RootTreeNode.GetElements(parentEntityToken, dynamicContext).Evaluate(), Position = attachmentPoint.Position, PositionPriority = 0 }; } catch (Exception ex) { LoggingService.LogError("TreeFacade", string.Format("Getting elements from the three '{0}' failed", tree.TreeId)); LoggingService.LogError("TreeFacade", ex); Element errorElement = ShowErrorElementHelper.CreateErrorElement( StringResourceSystemFacade.GetString("Composite.C1Console.Trees", "KeyFacade.ErrorTreeNode.Label"), tree.TreeId, ex.Message); result = new ElementAttachingProviderResult() { Elements = new List <Element>() { errorElement }, Position = attachmentPoint.Position, PositionPriority = 0 }; } yield return(result); } } foreach (CustomTreePerspectiveInfo info in TreeSharedRootsFacade.SharedRootFolders.Values) { if (info.AttachmentPoint.IsAttachmentPoint(parentEntityToken)) { Element element = new Element(new ElementHandle(info.Element.ElementHandle.ProviderName, info.Element.ElementHandle.EntityToken)) { VisualData = info.Element.VisualData }; int counter = 0; foreach (Tree tree in info.Trees) { string key = StringConstants.PiggybagSharedTreeId + (counter++); element.ElementHandle.Piggyback[key] = tree.TreeId; } ElementAttachingProviderResult result = new ElementAttachingProviderResult { Elements = new [] { info.Element }, Position = info.AttachmentPoint.Position, PositionPriority = 10000 }; yield return(result); } } }
public static IEnumerable <Element> AttachElements(EntityToken parentEntityToken, Dictionary <string, string> piggybag, IEnumerable <Element> currentElements) { List <ElementAttachingProviderResult> topResults = new List <ElementAttachingProviderResult>(); List <ElementAttachingProviderResult> bottomResults = new List <ElementAttachingProviderResult>(); foreach (string providerName in ElementAttachingProviderRegistry.ElementAttachingProviderNames) { if (ElementAttachingProviderPluginFacade.IsMultibleResultElementAttachingProvider(providerName) == false) { ElementAttachingProviderResult result = ElementAttachingProviderPluginFacade.GetAlternateElementList(providerName, parentEntityToken, piggybag); if ((result == null) || (result.Elements == null)) { continue; } if (result.Position == ElementAttachingProviderPosition.Top) { topResults.Add(result); } else if (result.Position == ElementAttachingProviderPosition.Bottom) { bottomResults.Add(result); } } else { IEnumerable <ElementAttachingProviderResult> results = ElementAttachingProviderPluginFacade.GetAlternateElementLists(providerName, parentEntityToken, piggybag); if (results == null) { continue; } foreach (ElementAttachingProviderResult result in results) { if ((result == null) || (result.Elements == null)) { continue; } if (result.Position == ElementAttachingProviderPosition.Top) { topResults.Add(result); } else if (result.Position == ElementAttachingProviderPosition.Bottom) { bottomResults.Add(result); } } } } Comparison <ElementAttachingProviderResult> sortMethod = delegate(ElementAttachingProviderResult r1, ElementAttachingProviderResult r2) { return(r2.PositionPriority - r1.PositionPriority); }; topResults.Sort(sortMethod); bottomResults.Sort(sortMethod); IEnumerable <Element> topElements = null; foreach (ElementAttachingProviderResult result in topResults) { if (topElements == null) { topElements = result.Elements; } else { topElements = topElements.Concat(result.Elements); } } IEnumerable <Element> bottomElements = null; foreach (ElementAttachingProviderResult result in bottomResults) { if (bottomElements == null) { bottomElements = result.Elements; } else { bottomElements = bottomElements.Concat(result.Elements); } } IEnumerable <Element> resultElements = topElements; if (resultElements == null) { resultElements = currentElements; } else { resultElements = resultElements.Concat(currentElements); } if (bottomElements != null) { resultElements = resultElements.Concat(bottomElements); } return(resultElements); }