Esempio n. 1
0
    public static string AppendToUrlPager2(string Url, string key, string value)
    {
        if (string.IsNullOrEmpty(Url))
        {
            Url = ReadConfiguration.SiteUrl + "default.aspx";
        }
        //Url = Url.ToLower();
        string PageUrl;

        string[] qsKeys;
        if (Url.Contains("?"))
        {
            PageUrl = Url.Substring(0, Url.IndexOf('?') + 1);
            qsKeys  = Url.Substring(Url.IndexOf('?') + 1).Split('&');
            foreach (string sParam in qsKeys)
            {
                if (!string.IsNullOrEmpty(sParam) && !sParam.StartsWith(key + "="))
                {
                    PageUrl += sParam + "&";
                }
            }
        }
        else
        {
            PageUrl = Url + "?";
        }
        if (!string.IsNullOrEmpty(value))
        {
            PageUrl += key + "=" + value;
        }


        if (PageUrl.EndsWith("?"))
        {
            PageUrl = PageUrl.Substring(0, PageUrl.Length - 1);
        }
        if (PageUrl.EndsWith("&"))
        {
            PageUrl = PageUrl.Substring(0, PageUrl.Length - 1);
        }
        return(PageUrl);
    }
Esempio n. 2
0
        /// <summary>
        /// Initializes a new instance of the <see cref="PageInfo" /> class.
        /// </summary>
        /// <param name="action">The action.</param>
        /// <param name="controller">The controller.</param>
        /// <param name="area">The area.</param>
        /// <param name="controllerType">Type of the controller.</param>
        /// <param name="pageInfoAttribute">The page information attribute.</param>
        /// <param name="metaInfoAttribute">The meta information attribute.</param>
        /// <param name="menuInfoAttribute">The menu information attribute.</param>
        /// <param name="routeInfoAttribute">The route information attribute.</param>
        /// <param name="tagInfoAttribute">The tag information attribute.</param>
        /// <param name="visibleInfoAttribute">The visible information attribute.</param>
        /// <param name="relatedInfoAttributes">The related information attributes.</param>
        /// <param name="propertyInfoAttributes">The property information attributes.</param>
        /// <param name="authorizationRoles">The authorization roles.</param>
        // ReSharper disable once FunctionComplexityOverflow
        public PageInfo(
            string action,
            string controller,
            string area,
            Type controllerType,
            PageInfoAttribute pageInfoAttribute,
            MetaInfoAttribute metaInfoAttribute,
            MenuInfoAttribute menuInfoAttribute,
            RouteInfoAttribute routeInfoAttribute,
            TagInfoAttribute tagInfoAttribute,
            VisibleInfoAttribute visibleInfoAttribute,
            IEnumerable <RelatedInfoAttribute> relatedInfoAttributes,
            IEnumerable <CustomPropertyInfoAttribute> propertyInfoAttributes,
            string authorizationRoles)
        {
            Children = new List <PageInfo>();

            Action     = action;
            Controller = controller;
            Area       = area;

            ControllerType = controllerType;

            Title    = pageInfoAttribute != null ? pageInfoAttribute.Title : "";
            SubTitle = pageInfoAttribute != null ? pageInfoAttribute.SubTitle : "";

            AlternatePageUrl = (Action != "Index" ? Action : Controller).ToLowerInvariant().Trim() + "/";
            PageUrl          = routeInfoAttribute != null ? (string.IsNullOrEmpty(routeInfoAttribute.Url) ? AlternatePageUrl : routeInfoAttribute.Url) : AlternatePageUrl;
            if (!string.IsNullOrEmpty(PageUrl) && !PageUrl.EndsWith("/"))
            {
                PageUrl = PageUrl += "/";
            }

            ParentKey    = routeInfoAttribute != null ? routeInfoAttribute.ParentKey : "";
            Key          = routeInfoAttribute != null ? routeInfoAttribute.Key : "";
            RedirectUrls = routeInfoAttribute != null ? (routeInfoAttribute.RedirectUrls ?? new string[0]) : new string[0];
            BlockUrl     = routeInfoAttribute?.BlockUrl ?? false;

            Visible = visibleInfoAttribute == null || visibleInfoAttribute.Visible;

            IsMenuItem = menuInfoAttribute != null;
            MenuOrder  = menuInfoAttribute?.Order ?? 0;

            MenuOnlyVisibleForRoles = menuInfoAttribute?.Roles?.ToList();
            IsHomePageItem          = pageInfoAttribute != null && pageInfoAttribute.IsHomePageItem;

            MetaTitle       = metaInfoAttribute != null ? metaInfoAttribute.Title : "";
            MetaDescription = metaInfoAttribute != null ? metaInfoAttribute.Description : "";
            MetaNoIndex     = metaInfoAttribute != null && metaInfoAttribute.NoIndex;
            MetaNoFollow    = metaInfoAttribute != null && metaInfoAttribute.NoFollow;

            Tags    = tagInfoAttribute != null ? tagInfoAttribute.Tags : "";
            Image   = pageInfoAttribute != null ? pageInfoAttribute.Image : "";
            Summary = pageInfoAttribute != null ? pageInfoAttribute.Summary : "";

            RelatedInfos = new List <RelatedInfo>();
            if (relatedInfoAttributes != null)
            {
                foreach (var relatedInfoAttribute in relatedInfoAttributes)
                {
                    RelatedInfos.Add(new RelatedInfo(relatedInfoAttribute.Title, relatedInfoAttribute.Url));
                }
            }

            PropertyInfos = new Dictionary <string, string>();
            if (propertyInfoAttributes != null)
            {
                PropertyInfos = propertyInfoAttributes.ToDictionary(p => p.Key, p => p.Value);
            }

            AuthorizationRoles = authorizationRoles ?? "";
        }