private static void LoadAllAttachingProviders()
 {
     foreach (string name in ElementAttachingProviderRegistry.ElementAttachingProviderNames)
     {
         var provider = ElementAttachingProviderPluginFacade.GetElementAttachingProvider(name);
     }
 }
예제 #2
0
        private static IEnumerable <Element> GetChildren(ElementHandle elementHandle, SearchToken searchToken, bool performSecurityCheck, bool useForeign)
        {
            if (elementHandle == null)
            {
                throw new ArgumentNullException("elementHandle");
            }

            IPerformanceCounterToken performanceToken = PerformanceCounterFacade.BeginElementCreation();

            IEnumerable <Element> children;

            if (ElementProviderRegistry.ElementProviderNames.Contains(elementHandle.ProviderName))
            {
                if ((useForeign == false) || (ElementProviderPluginFacade.IsLocaleAwareElementProvider(elementHandle.ProviderName) == false))
                {
                    children = ElementProviderPluginFacade.GetChildren(elementHandle.ProviderName, elementHandle.EntityToken, searchToken).Evaluate();
                }
                else
                {
                    children = ElementProviderPluginFacade.GetForeignChildren(elementHandle.ProviderName, elementHandle.EntityToken, searchToken).Evaluate();
                }
            }
            else if (ElementAttachingProviderRegistry.ElementAttachingProviderNames.Contains(elementHandle.ProviderName))
            {
                children = ElementAttachingProviderPluginFacade.GetChildren(elementHandle.ProviderName, elementHandle.EntityToken, elementHandle.Piggyback).Evaluate();
            }
            else
            {
                throw new InvalidOperationException(string.Format("No element provider named '{0}' found", elementHandle.ProviderName));
            }

            foreach (Element element in children)
            {
                if (element.VisualData.HasChildren == false)
                {
                    element.VisualData.HasChildren = ElementAttachingProviderFacade.HaveCustomChildElements(element.ElementHandle.EntityToken, element.ElementHandle.Piggyback);
                }
            }

            children = ElementAttachingProviderFacade.AttachElements(elementHandle.EntityToken, elementHandle.Piggyback, children).Evaluate();

            int totalElementCount = children.Count();

            ElementActionProviderFacade.AddActions(children, elementHandle.ProviderName);

            if (performSecurityCheck)
            {
                children = children.FilterActions().Evaluate();
            }

            PerformanceCounterFacade.EndElementCreation(performanceToken, children.Count(), totalElementCount);

            return(children);
        }
예제 #3
0
 private static string GetElementAttachingProviderName()
 {
     foreach (string providerName in ElementAttachingProviderRegistry.ElementAttachingProviderNames)
     {
         var provider = ElementAttachingProviderPluginFacade.GetElementAttachingProvider(providerName);
         if (provider is TreeElementAttachingProvider)
         {
             return(providerName);
         }
     }
     return(null);
 }
예제 #4
0
        public static bool HaveCustomChildElements(EntityToken parentEntityToken, Dictionary <string, string> piggybag)
        {
            foreach (string providerName in ElementAttachingProviderRegistry.ElementAttachingProviderNames)
            {
                bool result = ElementAttachingProviderPluginFacade.HaveCustomChildElements(providerName, parentEntityToken, piggybag);
                if (result)
                {
                    return(true);
                }
            }

            return(false);
        }
예제 #5
0
        private static IEnumerable <Element> GetChildrenFromProvider(ElementHandle elementHandle, SearchToken searchToken, bool useForeign)
        {
            if (ElementProviderRegistry.ElementProviderNames.Contains(elementHandle.ProviderName))
            {
                if (!useForeign || !ElementProviderPluginFacade.IsLocaleAwareElementProvider(elementHandle.ProviderName))
                {
                    return(ElementProviderPluginFacade.GetChildren(elementHandle.ProviderName, elementHandle.EntityToken, searchToken));
                }

                return(ElementProviderPluginFacade.GetForeignChildren(elementHandle.ProviderName, elementHandle.EntityToken, searchToken));
            }

            if (ElementAttachingProviderRegistry.ElementAttachingProviderNames.Contains(elementHandle.ProviderName))
            {
                return(ElementAttachingProviderPluginFacade.GetChildren(elementHandle.ProviderName, elementHandle.EntityToken, elementHandle.Piggyback));
            }

            throw new InvalidOperationException($"No element provider named '{elementHandle.ProviderName}' found");
        }
예제 #6
0
        public static void Initialize(string elementAttachingProviderName = null)
        {
            if (_sharedRootFolders != null)
            {
                return;
            }

            lock (_lock)
            {
                if (_sharedRootFolders != null)
                {
                    return;
                }

                if (_elementAttachingProviderName == null)
                {
                    if (elementAttachingProviderName == null)
                    {
                        foreach (string providerName in ElementAttachingProviderRegistry.ElementAttachingProviderNames)
                        {
                            IElementAttachingProvider elementAttachingProvider = ElementAttachingProviderPluginFacade.GetElementAttachingProvider(providerName);
                            if (elementAttachingProvider is TreeElementAttachingProvider)
                            {
                                _elementAttachingProviderName = providerName;
                                break;
                            }
                        }
                    }
                    else
                    {
                        _elementAttachingProviderName = elementAttachingProviderName;
                    }
                }

                DoInitialize(_elementAttachingProviderName);
            }
        }
예제 #7
0
        public static IEnumerable <Element> AttachElements(EntityToken parentEntityToken, Dictionary <string, string> piggybag, IEnumerable <Element> currentElements)
        {
            var topResults    = new List <ElementAttachingProviderResult>();
            var bottomResults = new List <ElementAttachingProviderResult>();

            foreach (string providerName in ElementAttachingProviderRegistry.ElementAttachingProviderNames)
            {
                if (!ElementAttachingProviderPluginFacade.IsMultipleResultElementAttachingProvider(providerName))
                {
                    var result = ElementAttachingProviderPluginFacade.GetAlternateElementList(providerName, parentEntityToken, piggybag);

                    if (result?.Elements == null)
                    {
                        continue;
                    }

                    if (result.Position == ElementAttachingProviderPosition.Top)
                    {
                        topResults.Add(result);
                    }
                    else if (result.Position == ElementAttachingProviderPosition.Bottom)
                    {
                        bottomResults.Add(result);
                    }
                }
                else
                {
                    var results = ElementAttachingProviderPluginFacade.GetAlternateElementLists(providerName, parentEntityToken, piggybag);

                    if (results == null)
                    {
                        continue;
                    }

                    foreach (ElementAttachingProviderResult result in results)
                    {
                        if (result?.Elements == null)
                        {
                            continue;
                        }

                        if (result.Position == ElementAttachingProviderPosition.Top)
                        {
                            topResults.Add(result);
                        }
                        else if (result.Position == ElementAttachingProviderPosition.Bottom)
                        {
                            bottomResults.Add(result);
                        }
                    }
                }
            }

            Comparison <ElementAttachingProviderResult> sortMethod =
                (r1, r2) => r2.PositionPriority - r1.PositionPriority;

            topResults.Sort(sortMethod);
            bottomResults.Sort(sortMethod);


            IEnumerable <Element> topElements = null;

            foreach (var result in topResults)
            {
                topElements = topElements.ConcatOrDefault(result.Elements);
            }


            IEnumerable <Element> bottomElements = null;

            foreach (var result in bottomResults)
            {
                bottomElements = bottomElements.ConcatOrDefault(result.Elements);
            }


            return(topElements
                   .ConcatOrDefault(currentElements)
                   .ConcatOrDefault(bottomElements));
        }
예제 #8
0
        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);
        }