首页
学习
活动
专区
圈层
工具
发布
社区首页 >问答首页 >为什么ServiceStack MvcHtmlString没有命名空间

为什么ServiceStack MvcHtmlString没有命名空间
EN

Stack Overflow用户
提问于 2014-10-15 21:11:28
回答 1查看 113关注 0票数 0

在我们的项目中,我们在几个地方使用System.Web.Mvc.MvcHtmlString。在添加了对ServiceStack程序集的引用之后,我得到了编译错误:

Cannot convert expression type System.Web.Mvc.MvcHtmlString to return type MvcHtmlString

碰撞是System.Web.Mvc.MvcHtmlStringMvcHtmlString在ServiceStack中的碰撞。在ServiceStack中,这个类没有名称空间,您可以在下面的代码或github上看到

这有什么好的理由吗?这个类不应该在ServiceStack.Html命名空间中吗?命名空间已在最后一次提交中删除。

有很好的解决办法吗?我必须在所有出现的MvcHtmlString前加上名称空间前缀System.Web.Mvc

代码语言:javascript
复制
using System;
using System.Diagnostics.CodeAnalysis;
using System.Web;

public sealed class MvcHtmlString : HtmlString
{
    private readonly string _value;

    public MvcHtmlString(string value)
        : base(value ?? String.Empty)
    {
        _value = value ?? String.Empty;
    }

    [SuppressMessage("Microsoft.Security", "CA2104:DoNotDeclareReadOnlyMutableReferenceTypes", Justification = "MvcHtmlString is immutable")]
    public static readonly MvcHtmlString Empty = Create(String.Empty);

    public static MvcHtmlString Create(string value)
    {
        return new MvcHtmlString(value);
    }

    public static bool IsNullOrEmpty(MvcHtmlString value)
    {
        return (value == null || value._value.Length == 0);
    }
}
EN

回答 1

Stack Overflow用户

回答已采纳

发布于 2014-10-16 00:14:59

该提交似乎被错误地还原到全局命名空间中。它已经被重构到ServiceStack.Html命名空间在这个承诺中中。

此更改可从v4.0.33+ (现在为可在MyGet上获得 )中获得。

票数 0
EN
页面原文内容由Stack Overflow提供。腾讯云小微IT领域专用引擎提供翻译支持
原文链接:

https://stackoverflow.com/questions/26392192

复制
相关文章

相似问题

领券
问题归档专栏文章快讯文章归档关键词归档开发者手册归档开发者手册 Section 归档