我正在关注一个示例,并且在为 MVC 项目创建自定义包时无法使“NoTransform”工作。这是我的代码,由于“NoTransform”产生错误,因此无法编译:“错误 1 找不到类型或命名空间名称 'NoTransform'(您是否缺少 using 指令或程序集引用?)” . 有什么想法吗?
using System;
using System.Collections.Generic;
using System.Configuration;
using System.Data.Entity;
using System.Data.Entity.Infrastructure;
using System.Linq;
using System.Web;
using System.Web.Http;
using System.Web.WebPages;
using System.Web.Mvc;
using System.Web.Optimization;
using System.Web.Routing;
namespace CoyleAzure
{
public class MvcApplication : System.Web.HttpApplication
{
protected void Application_Start()
{
AreaRegistration.RegisterAllAreas();
FilterConfig.RegisterGlobalFilters(GlobalFilters.Filters);
RouteConfig.RegisterRoutes(RouteTable.Routes);
// Added to Add DisplayModes
DisplayModeProvider.Instance.Modes.Insert(0, new DefaultDisplayMode("Phone")
{
ContextCondition = (context => (
(context.GetOverriddenUserAgent() != null) &&
(
(context.GetOverriddenUserAgent().IndexOf("iPhone", StringComparison.OrdinalIgnoreCase) >= 0) ||
(context.GetOverriddenUserAgent().IndexOf("iPod", StringComparison.OrdinalIgnoreCase) >= 0) ||
(context.GetOverriddenUserAgent().IndexOf("Droid", StringComparison.OrdinalIgnoreCase) >= 0) ||
(context.GetOverriddenUserAgent().IndexOf("Blackberry", StringComparison.OrdinalIgnoreCase) >= 0) ||
(context.GetOverriddenUserAgent().StartsWith("Blackberry", StringComparison.OrdinalIgnoreCase))
)
))
});
DisplayModeProvider.Instance.Modes.Insert(0, new DefaultDisplayMode("Tablet")
{
ContextCondition = (context => (
(context.GetOverriddenUserAgent() != null) &&
(
(context.GetOverriddenUserAgent().IndexOf("iPad", StringComparison.OrdinalIgnoreCase) >= 0) ||
(context.GetOverriddenUserAgent().IndexOf("Playbook", StringComparison.OrdinalIgnoreCase) >= 0) ||
(context.GetOverriddenUserAgent().IndexOf("Transformer", StringComparison.OrdinalIgnoreCase) >= 0) ||
(context.GetOverriddenUserAgent().IndexOf("Xoom", StringComparison.OrdinalIgnoreCase) >= 0)
)
))
});
IBundleTransform jsTransformer;
IBundleTransform cssTransformer;
#if DEBUG
jsTransformer = new NoTransform("text/javascript");
cssTransformer = new NoTransform("text/css");
#else
jsTransformer = new JsMinify();
cssTransformer = new CssMinify();
#endif
var
DesktopJSBundle = new Bundle("~/Scripts/DesktopJS", jsTransformer);
DesktopJSBundle.Include("~/Scripts/jquery-1.6.4. js");
DesktopJSBundle.Include("~/Scripts/jquery-ui-1.8.11. js");
DesktopJSBundle.Include("~/Scripts/jquery.unobtrusive-ajax.js");
DesktopJSBundle.Include("~/Scripts/jquery.validate.js");
DesktopJSBundle.Include("~/Scripts/jquery.validate.unobtrusive.js");
BundleTable.Bundles.Add(DesktopJSBundle);
var DesktopCSSBundle = new Bundle("~/Content/DesktopCSS", cssTransformer);
DesktopCSSBundle.Include("~/Content/Site.css");
BundleTable.Bundles.Add(DesktopCSSBundle);
var MobileJSBundle = new Bundle("~/Scripts/MobileJS", jsTransformer);
MobileJSBundle.Include("~/Scripts/jquery-1.6.4.js");
MobileJSBundle.Include("~/Scripts/jquery.mobile-1.1.0.js");
BundleTable.Bundles.Add(MobileJSBundle);
var MobileCSSBundle = new Bundle("~/Content/MobileCSS", cssTransformer);
MobileCSSBundle.Include("~/Content/jquery.mobile-1.1.0.css");
MobileCSSBundle.Include("~/Content/jquery.mobile.structure-1.1.0.css");
BundleTable.Bundles.Add(MobileCSSBundle);
//BundleTable.Bundles.RegisterTemplateBundles();
BundleTable.Bundles.EnableDefaultBundles();
}
//BundleConfig.RegisterBundles(BundleTable.Bundles);
}
}