예제 #1
0
        public object Resolve(object source, Dictionary <string, IResolver> resolvers = null, bool recursive = false)
        {
            var result = new List <Model.NavigationNode>();

            var nodes = source.GetPublicInstancePropertyValue("NavigationNode");

            if (null == nodes)
            {
                nodes = source.GetPublicInstancePropertyValue("NavigationNode1");
            }

            resolvers = new Dictionary <string, IResolver>();
            resolvers.Add($"{typeof(Model.NavigationNode).FullName}.NavigationNodes", new NavigationNodeFromSchemaToModelTypeResolver());

            if (null != nodes)
            {
                foreach (var f in ((IEnumerable)nodes))
                {
                    var targetItem = new Model.NavigationNode();
                    PnPObjectsMapper.MapProperties(f, targetItem, resolvers, recursive);
                    result.Add(targetItem);
                }
            }

            return(result);
        }
예제 #2
0
        internal static Model.NavigationNode ToDomainModelNavigationNode(this Microsoft.SharePoint.Client.NavigationNode node, Web web)
        {
            var result = new Model.NavigationNode
            {
                Title      = node.Title,
                IsExternal = node.IsExternal,
                Url        = node.Url.Replace(web.ServerRelativeUrl, "{site}"),
            };

            node.Context.Load(node.Children);
            node.Context.ExecuteQueryRetry();

            result.NavigationNodes.AddRange(from n in node.Children.AsEnumerable()
                                            select n.ToDomainModelNavigationNode(web));

            return(result);
        }
예제 #3
0
        internal static Model.NavigationNode ToDomainModelNavigationNode(this Microsoft.SharePoint.Client.NavigationNode node, Web web)
        {
            var result = new Model.NavigationNode
            {
                Title = node.Title,
                IsExternal = node.IsExternal,
                Url = node.Url.Replace(web.ServerRelativeUrl, "{site}"),
            };

            node.Context.Load(node.Children);
            node.Context.ExecuteQueryRetry();

            result.NavigationNodes.AddRange(from n in node.Children.AsEnumerable()
                                            select n.ToDomainModelNavigationNode(web));

            return (result);
        }
예제 #4
0
        internal static Model.NavigationNode ToDomainModelNavigationNode(this Microsoft.SharePoint.Client.NavigationNode node, Web web, bool PersistLanguage, CultureInfo currentCulture, int ParentNodeId = 0)
        {
            string nodeTitle = node.Title;

#if !SP2013
            if (PersistLanguage && !string.IsNullOrWhiteSpace(nodeTitle))
            {
                if (UserResourceExtensions.PersistResourceValue($"NavigationNode_{ParentNodeId}_{node.Id}_Title", currentCulture.LCID, nodeTitle))
                {
                    nodeTitle = $"{{res:NavigationNode_{ParentNodeId}_{node.Id}_Title}}";
                }
            }
#endif
            var result = new Model.NavigationNode
            {
                Title      = nodeTitle,
                IsExternal = node.IsExternal,
                Url        = web.ServerRelativeUrl != "/" ? node.Url.Replace(web.ServerRelativeUrl, "{site}") : $"{{site}}{node.Url}"
            };

            node.Context.Load(node.Children);
#if !SP2013
            var acceptLanguage = node.Context.PendingRequest.RequestExecutor.WebRequest.Headers["Accept-Language"];
            if (PersistLanguage)
            {
                node.Context.PendingRequest.RequestExecutor.WebRequest.Headers["Accept-Language"] = currentCulture.Name;
            }
#endif
            node.Context.ExecuteQueryRetry();

            result.NavigationNodes.AddRange(from n in node.Children.AsEnumerable()
                                            select n.ToDomainModelNavigationNode(web, PersistLanguage, currentCulture, node.Id));

#if !SP2013
            if (PersistLanguage)
            {
                node.Context.PendingRequest.RequestExecutor.WebRequest.Headers["Accept-Language"] = acceptLanguage;
            }
#endif
            return(result);
        }
        public static Model.NavigationNode FromSchemaNavigationNodeToModelNavigationNodeV201612(
            this V201612.NavigationNode node)
        {
            var result = new Model.NavigationNode
            {
                IsExternal = node.IsExternal,
                Title = node.Title,
                Url = node.Url,
            };

            if (node.NavigationNode1 != null && node.NavigationNode1.Length > 0)
            {
                result.NavigationNodes.AddRange(
                    (from n in node.NavigationNode1
                     select n.FromSchemaNavigationNodeToModelNavigationNodeV201612()));
            }

            return (result);
        }