コード例 #1
0
		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 ElementAttachingProviderResult GetAlternateElementList(
           EntityToken parentEntityToken,
           Dictionary<string, string> piggybag)
        {
            if (!(parentEntityToken is PackageElementProviderRootEntityToken))
                return null;

            
            ElementAttachingProviderResult result = new ElementAttachingProviderResult()
            {
                Elements = GetRootElements(piggybag),
                Position = ElementAttachingProviderPosition.Top,
                PositionPriority = 0
            };


            return result;
        }
コード例 #3
0
        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;
                }
            }           
        }