当前位置: 首页>>代码示例>>C#>>正文


C# Web.SiteMapProvider类代码示例

本文整理汇总了C#中System.Web.SiteMapProvider的典型用法代码示例。如果您正苦于以下问题:C# SiteMapProvider类的具体用法?C# SiteMapProvider怎么用?C# SiteMapProvider使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。


SiteMapProvider类属于System.Web命名空间,在下文中一共展示了SiteMapProvider类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。

示例1: SiteMapNode

        public SiteMapNode(SiteMapProvider provider, string key, string url, string title, string description,
            IList roles, NameValueCollection attributes, NameValueCollection explicitResourceKeys, string implicitResourceKey) {

            _provider = provider;
            _title = title;
            _description = description;
            _roles = roles;
            _attributes = attributes;
            _key = key;
            _resourceKeys = explicitResourceKeys;
            _resourceKey = implicitResourceKey;

            if (url != null) {
                _url = url.Trim();
            }

            _virtualPath = CreateVirtualPathFromUrl(_url);

            if (_key == null) {
                throw new ArgumentNullException("key");
            }

            if (_provider == null) {
                throw new ArgumentNullException("provider");
            }
        }
开发者ID:iskiselev,项目名称:JSIL.NetFramework,代码行数:26,代码来源:SiteMapNode.cs

示例2: Initialize

 private static void Initialize()
 {
     if (_providers == null)
     {
         HttpRuntime.CheckAspNetHostingPermission(AspNetHostingPermissionLevel.Low, "Feature_not_supported_at_this_level");
         lock (_lockObject)
         {
             if (_providers == null)
             {
                 SiteMapSection siteMap = RuntimeConfig.GetAppConfig().SiteMap;
                 if (siteMap == null)
                 {
                     _providers = new SiteMapProviderCollection();
                 }
                 else
                 {
                     if (!siteMap.Enabled)
                     {
                         throw new InvalidOperationException(System.Web.SR.GetString("SiteMap_feature_disabled", new object[] { "system.web/siteMap" }));
                     }
                     siteMap.ValidateDefaultProvider();
                     _providers = siteMap.ProvidersInternal;
                     _provider = _providers[siteMap.DefaultProvider];
                     _providers.SetReadOnly();
                 }
             }
         }
     }
 }
开发者ID:pritesh-mandowara-sp,项目名称:DecompliedDotNetLibraries,代码行数:29,代码来源:SiteMap.cs

示例3: GetCurrentNode

        public static SiteMapNode GetCurrentNode(SiteMapProvider selectedSiteMapProvider)
        {
            // get the node matching the current URL location
            var currentNode = selectedSiteMapProvider.CurrentNode;

            // if there is no node matching the current URL path,
            // remove parts until we get a hit
            if (currentNode == null)
            {
                var url = HttpContext.Current.Request.Url.LocalPath;

                while (url.Length > 0)
                {
                    // see if we can find a matching node
                    currentNode = selectedSiteMapProvider.FindSiteMapNode(url);

                    // if we get a hit, stop
                    if (currentNode != null) break;

                    // if not, remove the last path item
                    var lastSlashlocation = url.LastIndexOf("/");
                    if (lastSlashlocation < 0) break; // protects us from malformed URLs
                    url = url.Remove(lastSlashlocation);
                }
            }

            return currentNode;
        }
开发者ID:blerimj,项目名称:ScaffR-Generated,代码行数:28,代码来源:PillsExtensions.cs

示例4: IsAccessibleToUser

        /// <summary>
        /// Determines whether node is accessible to user.
        /// </summary>
        /// <param name="controllerTypeResolver">The controller type resolver.</param>
        /// <param name="provider">The provider.</param>
        /// <param name="context">The context.</param>
        /// <param name="node">The node.</param>
        /// <returns>
        /// 	<c>true</c> if accessible to user; otherwise, <c>false</c>.
        /// </returns>
        public virtual bool IsAccessibleToUser(IControllerTypeResolver controllerTypeResolver, SiteMapProvider provider, HttpContext context, SiteMapNode node)
        {
            // Is security trimming enabled?
            if (!provider.SecurityTrimmingEnabled)
            {
                return true;
            }

            // Use child modules
            bool result = true;
            foreach (var module in ChildModules)
            {
                try
                {
                    result &= module.IsAccessibleToUser(controllerTypeResolver, provider, context, node);
                }
                catch (AclModuleNotSupportedException)
                {
                    result &= true; // Convention throughout the provider: if the IAclModule can not authenticate a user, true is returned.
                }
                if (result == false)
                {
                    return false;
                }
            }

            // Return
            return result;
        }
开发者ID:philzhang,项目名称:MvcSiteMapProvider,代码行数:39,代码来源:DefaultAclModule.cs

示例5: FileSiteMapNode

 public FileSiteMapNode(SiteMapProvider provider, string url) 
     : base(provider, url)
 {
     Url = url;
     Title = VirtualPathUtility.GetFileName(url);
     FileExtension = VirtualPathUtility.GetExtension(url).TrimStart('.');
 }
开发者ID:EzyWebwerkstaden,项目名称:n2cms,代码行数:7,代码来源:FileSiteMapNode.cs

示例6: TridionSiteMapNode

 public TridionSiteMapNode(SiteMapProvider provider, string key, string uri, string url, string title, string description, IList roles, NameValueCollection attributes, NameValueCollection explicitResourceKeys, string implicitResourceKey) : base(provider, key, url, title, description, roles, attributes, explicitResourceKeys, implicitResourceKey)
 {
     if (url.StartsWith("tcm:"))
     {
         this.Url = this.MakeDummyUrl(url);
     }
     this.Uri = uri;
 }
开发者ID:pjbeemster,项目名称:scratchpad,代码行数:8,代码来源:TridionSiteMapNode.cs

示例7: Add

 public void Add(SiteMapProvider provider)
 {
     if (provider == null)
     {
         throw new ArgumentNullException("provider");
     }
     base.Add(provider);
 }
开发者ID:pritesh-mandowara-sp,项目名称:DecompliedDotNetLibraries,代码行数:8,代码来源:SiteMapProviderCollection.cs

示例8: base

        /*public MvcSiteMapNode(SiteMapProvider provider, string key, ISiteMapUrlResolver urlResolver)
            : base(provider, key)
        {
            this.urlResolver = urlResolver;
        }*/

        public MvcSiteMapNode(SiteMapProvider provider, string key, string url, string title, string description,
            IList roles, NameValueCollection attributes, NameValueCollection explicitResourceKeys,
            string implicitResourceKey, ISiteMapUrlResolver urlResolver, string controllerName, string actionName)
            : base(provider, key, url, title, description, roles, attributes, explicitResourceKeys, implicitResourceKey)
        {
            this.urlResolver = urlResolver;
            Controller = controllerName;
            Action = actionName;
        }
开发者ID:VlaTo,项目名称:EmpRe.NET,代码行数:15,代码来源:MvcSiteMapNode.cs

示例9: GetVirtualNodes

        public IEnumerable<SiteMapNode> GetVirtualNodes(SiteMapProvider provider)
        {
            List<SiteMapNode> list = new List<SiteMapNode>();

            var siteMapNode = new SiteMapNode(
                provider, Guid.NewGuid().ToString(), string.Empty, DummySiteMapNodeTitle, "description");
            list.Add(siteMapNode);

            return list;
        }
开发者ID:rhullah,项目名称:feather-widgets,代码行数:10,代码来源:DummyBreadcrumbExtender.cs

示例10: IsDeniedURLWithProvider

        public static bool IsDeniedURLWithProvider(string url, string app, SiteMapProvider smProvider)
        {
            if (url.ToLower().EndsWith("accessdeny.aspx") || url.ToLower().EndsWith("changepassword.aspx") || url.ToLower().EndsWith("default.aspx") || url.ToLower().EndsWith("profile.aspx")) return false;
            //if (UserHelper.Username == "admin" || UserHelper.IsAdmin) return false;
            if (UserHelper.IsSysAdmin) return false;
            if ((smProvider != null) && (smProvider.CurrentNode == null)) return true;

            //foreach (string role in RoleDAO.GetRolesForUser(app, UserHelper.Username))
            //    if (IsDeniedURL(url, app, role)) return true;
            return !PermissionDAO.IsAnyRoleInPath(app, RoleDAO.GetRolesForUser(app, UserHelper.Username), url);
        }
开发者ID:thaond,项目名称:vdms-sym-project,代码行数:11,代码来源:Security.cs

示例11: Initialize

        ///<summary>
        ///Initializes the provider.
        ///</summary>
        ///
        ///<param name="config">A collection of the name/value pairs representing the provider-specific 
        /// attributes specified in the configuration for this provider.
        /// The <c>providerId</c> attribute may be used to override the name being used for looking up an object definition.
        /// </param>
        ///<param name="name">The friendly name of the provider.</param>
        ///<exception cref="T:System.ArgumentNullException">The <paramref name="name"/> or <paramref name="config"/> is null.</exception>
        ///<exception cref="T:System.InvalidOperationException">An attempt is made to call <see cref="M:System.Configuration.Provider.ProviderBase.Initialize(System.String,System.Collections.Specialized.NameValueCollection)"></see> on a provider after the provider has already been initialized.</exception>
        ///<exception cref="T:System.ArgumentException">The <paramref name="name"/> has a length of zero or providerId attribute is not set.</exception>
        public override void Initialize(string name, NameValueCollection config)
        {
            if (config == null) throw new ArgumentNullException("config");                        
            
            string providerId = config["providerId"];            
            if (String.IsNullOrEmpty(providerId)) 
                providerId = name;
            config.Remove("providerId");

            this.wrappedProvider = (System.Web.SiteMapProvider)WebApplicationContext.GetRootContext().GetObject(providerId);
            this.wrappedProvider.Initialize(name,config);
        }
开发者ID:fgq841103,项目名称:spring-net,代码行数:24,代码来源:SiteMapProviderAdapter.cs

示例12: GetCurrentSiteMapNodeForChildAction

 /// <summary>
 /// Gets the current site map node for child action.
 /// </summary>
 /// <param name="controller">The controller.</param>
 /// <param name="provider">The provider.</param>
 /// <returns></returns>
 public static SiteMapNode GetCurrentSiteMapNodeForChildAction(this ControllerBase controller, SiteMapProvider provider)
 {
     // Is DefaultSiteMapProvider in use?
     DefaultSiteMapProvider mvcProvider = provider as DefaultSiteMapProvider;
     if (mvcProvider != null && controller.ControllerContext.IsChildAction)
     {
         return mvcProvider.FindSiteMapNode(controller.ControllerContext);
     }
     else
     {
         return provider.CurrentNode;
     }
 }
开发者ID:tshwangq,项目名称:MvcSiteMapProvider,代码行数:19,代码来源:ControllerExtensions.cs

示例13: AddArray

 public void AddArray(SiteMapProvider[] providerArray)
 {
     if (providerArray == null)
     {
         throw new ArgumentNullException("providerArray");
     }
     foreach (SiteMapProvider provider in providerArray)
     {
         if (this[provider.Name] != null)
         {
             throw new ArgumentException(System.Web.SR.GetString("SiteMapProvider_Multiple_Providers_With_Identical_Name", new object[] { provider.Name }));
         }
         this.Add(provider);
     }
 }
开发者ID:pritesh-mandowara-sp,项目名称:DecompliedDotNetLibraries,代码行数:15,代码来源:SiteMapProviderCollection.cs

示例14: SiteMapNode

		public SiteMapNode (SiteMapProvider provider, string key, string url, string title, string description, IList roles, NameValueCollection attributes, NameValueCollection explicitResourceKeys, string implicitResourceKey)
		{
			if (provider == null)
				throw new ArgumentNullException ("provider");
			if (key == null)
				throw new ArgumentNullException ("key");
			
			this.provider = provider;
			this.key = key;
			this.url = url;
			this.title = title;
			this.description = description;
			this.roles = roles;
			this.attributes = attributes;
			this.resourceKeys = explicitResourceKeys;
			this.implicitResourceKey = implicitResourceKey;
		}
开发者ID:jjenki11,项目名称:blaze-chem-rendering,代码行数:17,代码来源:SiteMapNode.cs

示例15: IsAccessibleToUser

        /// <summary>
        /// Determines whether node is accessible to user.
        /// </summary>
        /// <param name="controllerTypeResolver">The controller type resolver.</param>
        /// <param name="provider">The provider.</param>
        /// <param name="context">The context.</param>
        /// <param name="node">The node.</param>
        /// <returns>
        /// 	<c>true</c> if accessible to user; otherwise, <c>false</c>.
        /// </returns>
        public bool IsAccessibleToUser(IControllerTypeResolver controllerTypeResolver, SiteMapProvider provider, HttpContext context, SiteMapNode node)
        {
            // Is security trimming enabled?
            if (!provider.SecurityTrimmingEnabled)
            {
                return true;
            }

            // Is it a regular node?
            var mvcNode = node as MvcSiteMapNode;
            if (mvcNode == null)
            {
                if (provider.ParentProvider != null)
                {
                    return provider.ParentProvider.IsAccessibleToUser(context, node);
                }
            }

            // If we have roles assigned, check them against the roles defined in the sitemap
            if (node.Roles != null && node.Roles.Count > 0)
            {
                    // if there is an authenticated user and the role allows anyone authenticated ("*"), show it
                if ((context.User.Identity.IsAuthenticated) && node.Roles.Contains("*"))
                {
                    return true;
                }

                    // if there is no user, but the role allows unauthenticated users ("?"), show it
                if ((!context.User.Identity.IsAuthenticated) && node.Roles.Contains("?"))
                    {
                        return true;
                    }

                    // if the user is in one of the listed roles, show it
                if (node.Roles.OfType<string>().Any(role => context.User.IsInRole(role)))
                    {
                        return true;
                    }

                    // if we got this far, deny showing
                    return false;
            }

            // Everything seems OK...
            return true;
        }
开发者ID:philzhang,项目名称:MvcSiteMapProvider,代码行数:56,代码来源:XmlRolesAclModule.cs


注:本文中的System.Web.SiteMapProvider类示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。