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


C# this.Content方法代码示例

本文整理汇总了C#中this.Content方法的典型用法代码示例。如果您正苦于以下问题:C# this.Content方法的具体用法?C# this.Content怎么用?C# this.Content使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在this的用法示例。


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

示例1: TranslateSystemUrl

        public static string TranslateSystemUrl(this UrlHelper urlHelper, string url, string defaultBaseUrl = null)
        {
            if (String.IsNullOrWhiteSpace(url))
                return null;

            url = url.Trim();

            if (url.Contains("://"))
            {
                return url;
            }
            else if (url.StartsWith("//"))
            {
                return String.Format("{0}:{1}", urlHelper.RequestContext.HttpContext.Request.Url.Scheme, url);
            }
            else if (!url.StartsWith("~") && !url.StartsWith("/") && !String.IsNullOrWhiteSpace(defaultBaseUrl))
            {
                defaultBaseUrl = defaultBaseUrl.TrimEnd('/');
                if (defaultBaseUrl.Contains("://"))
                {
                    return defaultBaseUrl + "/" + url;
                }
                else if (defaultBaseUrl.StartsWith("//"))
                {
                    return String.Format("{0}:{1}/{2}", urlHelper.RequestContext.HttpContext.Request.Url.Scheme, defaultBaseUrl, url);
                }

                return urlHelper.Content(defaultBaseUrl + "/" + url);
            }

            return urlHelper.Content(url);
        }
开发者ID:vihongphuc,项目名称:NLogging_Rollbar,代码行数:32,代码来源:UrlHelpers.cs

示例2: LessCss

        public static HtmlString LessCss(this UrlHelper helper, string lessJsPath, params string[] cssFiles)
        {
            var html = new StringBuilder();

            var useClientside = false;
            var lessLinkTagFormat = @"<link rel=""stylesheet/less"" type=""text/css"" href=""{0}"">";
            var cssLinkTagFormat = @"<link rel=""stylesheet"" type=""text/css"" href=""{0}"">";
            #if DEBUG
            useClientside = true;
            #endif

            foreach (var css in cssFiles)
            {
                if (!css.EndsWith(".less"))
                    html.AppendFormat(cssLinkTagFormat, helper.Content(css));
                else if( useClientside )
                    html.AppendFormat(lessLinkTagFormat, helper.Content(css));
                else
                    html.AppendFormat(cssLinkTagFormat, helper.Content(TranslateToCss(css)));
            }

            if (useClientside)
                html.AppendFormat(@"<script src=""{0}"" type=""text/javascript""></script>", helper.Content(lessJsPath));

            return new HtmlString(html.ToString());
        }
开发者ID:joyoon,项目名称:mb,代码行数:26,代码来源:LessUrlHelper.cs

示例3: AvatarUrl

        public static string AvatarUrl(this UrlHelper urlHelper, string avatarIdentifier)
        {
            if (string.IsNullOrEmpty(avatarIdentifier))
                return urlHelper.Content("~/content/img/avatar.jpg");

            return urlHelper.Content("~/avatar/" + avatarIdentifier);
        }
开发者ID:richardrcruzc,项目名称:skimur,代码行数:7,代码来源:Urls.cs

示例4: Css

        /// <summary>
        /// Retrieves a CSS link based on a themes path
        /// </summary>
        /// <param name="urlHelper"></param>
        /// <param name="cssFile"></param>
        /// <param name="theme"></param>
        /// <returns></returns>
        public static string Css(this UrlHelper urlHelper, string cssFile, string theme = null)
        {                        
            object oTheme = urlHelper.RequestContext.HttpContext.Session["Theme"];
            if (oTheme != null)
                theme = oTheme as string;
            
            string url = null;

            if (string.IsNullOrEmpty(theme))
                url = urlHelper.Content("~/css/" + cssFile);
            else
            {
                string lowerCssFile = cssFile.ToLower();
                theme=theme.ToLower();
                string key = theme + "|" + cssFile;


                if (CssFileCache.ContainsKey(key))
                    return CssFileCache[key];

                foreach (string path in CssPaths)
                {
                    string webPath = string.Format(path, cssFile, theme);
                    if (File.Exists(urlHelper.RequestContext.HttpContext.Server.MapPath(webPath)))
                    {
                        url = urlHelper.Content(webPath);
                        CssFileCache.Add(key, url);
                        break;
                    }
                }
            }

            return url;
        }
开发者ID:CocoaLab,项目名称:WestwindToolkit,代码行数:41,代码来源:UrlHelperExtensions.cs

示例5: ImageProduct

 public static string ImageProduct(this UrlHelper urlHelper, string imageName)
 {
     if (string.IsNullOrEmpty(imageName))
     {
         return urlHelper.Content("~/Contents/Images/image.jpg");
     }
     return urlHelper.Content("~/Contents/Images/Product/" + imageName);
 }
开发者ID:Musasthl,项目名称:d-shopping-core,代码行数:8,代码来源:UrlHelperMethod.cs

示例6: GetPhotoUrl

 public static string GetPhotoUrl(this UrlHelper helper, string imageId, string size, string defaultUrl = null)
 {
     var photo = PhotoManager.Provider.GetPhotoResize(imageId, size);
     if (photo != null)
     {
         return helper.Content(photo.Url);
     }
     return defaultUrl != null ? helper.Content(defaultUrl) : "";
 }
开发者ID:nathanbedford,项目名称:ScaffR-Generated,代码行数:9,代码来源:UrlExtensions.Photos.cs

示例7: Content

        public static string Content(this System.Web.Mvc.UrlHelper Url, string Path, bool addTimeStamp)
        {
            if (!addTimeStamp)
                return Url.Content(Path);

            string serverPath = HttpContext.Current.Server.MapPath(Path);
            DateTime lastWrite = File.GetLastWriteTimeUtc(serverPath);
            string result = lastWrite.Ticks.ToString();
            return Url.Content(Path) + "?t=" + result;
        }
开发者ID:cbsistem,项目名称:JRIAppTS,代码行数:10,代码来源:UrlHelperEx.cs

示例8: Content

 public static string Content(this UrlHelper url, string contentPath, bool absolute)
 {
     Uri requestUrl = url.RequestContext.HttpContext.Request.Url;
     if (absolute)
     {
         string absoluteAction = "{0}://{1}{2}".FormatWith(requestUrl.Scheme, requestUrl.Authority, url.Content(contentPath));
         return absoluteAction;
     }
     return url.Content(contentPath);
 }
开发者ID:gowhy,项目名称:LoveBank,代码行数:10,代码来源:UrlExtenstions.cs

示例9: BootstrapJS

        /// <summary>
        /// Provides a Javascript script tag for the Bootstrap framework.
        /// </summary>
        public static MvcHtmlString BootstrapJS(this UrlHelper helper)
        {
            string bootStrapPath = helper.Content("~/Assets/bootstrap/js/bootstrap.min.js");
            string respondPath = helper.Content("~/Assets/bootstrap/js/respond.min.js");

            string html = string.Format("<script type=\"text/javascript\" language=\"javascript\" src=\"{0}?version={1}\"></script>", bootStrapPath, ApplicationSettings.ProductVersion);
            html += string.Format("\n<script type=\"text/javascript\" language=\"javascript\" src=\"{0}?version={1}\"></script>", respondPath, ApplicationSettings.ProductVersion);

            return MvcHtmlString.Create(html);
        }
开发者ID:NaseUkolyCZ,项目名称:roadkill,代码行数:13,代码来源:UrlHelperExtensions.cs

示例10: Script

 public static string Script(this UrlHelper helper, string file)
 {
     if (Config.ActiveConfiguration.MinifyFiles)
     {
         return helper.Content(String.Format("~/Content/{0}/{1}.min.js", ContentDirectory.script.ToString(), file));
     }
     else
     {
         return helper.Content(String.Format("~/Content/{0}/{1}.js", ContentDirectory.script.ToString(), file));
     }
 }
开发者ID:webitpro,项目名称:WolfWeb,代码行数:11,代码来源:UrlHelperExtensions.cs

示例11: Image

 public static string Image(this UrlHelper urlHelper, string imageName)
 {
     if (imageName == "Banner")
     {
         return urlHelper.Content("~/Contents/Images/Banner.JPG");
     }
     else if(string.IsNullOrEmpty(imageName))
     {
         return urlHelper.Content("~/Contents/Images/image.jpg");
     }
     return urlHelper.Content("~/Contents/Images/" + imageName);
 }
开发者ID:Musasthl,项目名称:d-shopping-core,代码行数:12,代码来源:UrlHelperMethod.cs

示例12: Image

        public static string Image(this UrlHelper url, string imageName)
        {
            string path = ConfigurationManager.AppSettings["ImagePath"];

            if (string.IsNullOrWhiteSpace(path))
                path = "~/Content/Images";

            if (string.IsNullOrWhiteSpace(imageName))
                return url.Content(path);

            return url.Content(String.Format("{0}/{1}", path, imageName));
        }
开发者ID:netthanhhung,项目名称:MimosaWeb,代码行数:12,代码来源:UrlHelperExtension.cs

示例13: CssLink

        /// <summary>
        /// Provides a CSS link tag for the CSS file provided. If the relative path does not begin with ~ then
        /// the Assets/Css folder is assumed.
        /// </summary>
        public static MvcHtmlString CssLink(this UrlHelper helper, string relativePath)
        {
            if (!relativePath.StartsWith("~"))
                relativePath = "~/Assets/CSS/" + relativePath;

            return MvcHtmlString.Create("<link href=\"" + helper.Content(relativePath) + "\" rel=\"stylesheet\" type=\"text/css\" />");
        }
开发者ID:Yodadude,项目名称:Roadkill,代码行数:11,代码来源:HtmlLinkExtensions.cs

示例14: Script

        public static string Script(this UrlHelper urlHelper, string fileName)
        {
            if (!fileName.EndsWith(".js"))
                fileName += ".js";

            return urlHelper.Content(string.Format("~/Content/{0}/{1}?version={2}", ScriptDir, fileName, RevisionNumber));
        }
开发者ID:jasonhyland,项目名称:RaccoonBlog,代码行数:7,代码来源:StaticFileUrlHelperExtensions.cs

示例15: ContentVersioned

        public static string ContentVersioned(this UrlHelper urlHelper, string contentPath)
        {
            string url = urlHelper.Content(contentPath);
            int revisionNumber = GetRevisionNumber();

            return String.Format("{0}?v={1}", url, revisionNumber);
        }
开发者ID:aseemshrestha,项目名称:SkillsBook,代码行数:7,代码来源:UrlHelperExtensions.cs


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