我正在ASP.NET MVC 4中的一个项目,我做了以下步骤:
从http://blog.getbootstrap.com/2013/12/05/bootstrap-3-0-3-released/下载的twitter bootstrap
将字体文件的构建操作设置为内容(文件位于〜/ Content/font文件夹中)
glyphicons-halflings-regular.eot
glyphicons-halflings-regular.svg
glyphicons-halflings-regular.ttf
glyphicons-halflings-regular.woff
Run Code Online (Sandbox Code Playgroud)添加到RouteConfig.cs
routes.IgnoreRoute("{folder}/{*pathInfo}",new {folder ="Content"});
向Web.config添加了以下元素
<?xml version="1.0" encoding="UTF-8"?>
<system.webServer>
<staticContent>
<remove fileExtension=".eot" />
<remove fileExtension=".ttf" />
<remove fileExtension=".otf"/>
<remove fileExtension=".woff"/>
<mimeMap fileExtension=".eot" mimeType="application/vnd.ms-fontobject" />
<mimeMap fileExtension=".ttf" mimeType="font/ttf" />
<mimeMap fileExtension=".otf" mimeType="font/otf" />
<mimeMap fileExtension=".woff" mimeType="font/x-woff" />
</staticContent>
</system.webServer>
Run Code Online (Sandbox Code Playgroud)包含在BundleConfig.cs中的以下代码
bundles.Add(new StyleBundle("~/bundles/maincss")
.Include("~/Content/bootstrap/bootstrap.css")
.Include("~/Content/bootstrap/bootstrap-theme.css")
.Include("~/Content/hbl-full.css"));
Run Code Online (Sandbox Code Playgroud)
还尝试使用以下代码
IItemTransform cssFixer = new CssRewriteUrlTransform();
bundles.Add(new StyleBundle("~/bundles/maincss")
.Include("~/Content/bootstrap/bootstrap.css", cssFixer)
.Include("~/Content/bootstrap/bootstrap-theme.css", cssFixer)
.Include("~/Content/hbl-full.css", cssFixer));
Run Code Online (Sandbox Code Playgroud)在主Layout.cshtml中调用
@ Styles.Render( "〜/捆绑/ maincss")
仍然在localhost图标正常显示,但当我推送代码发布服务器时,我只能看到方形而不是图标,在Chrome的控制台选项卡中我得到
获取http://domain.apphb.com/fonts/glyphicons-halflings-regular.woff 404(未找到)测试:1 …
我在一个具体的例子中对依赖注入实现感到困惑.
假设我们有一个SomeClass类,它具有IClassX类型的依赖关系.
public class SomeClass
{
public SomeClass(IClassX dependency){...}
}
Run Code Online (Sandbox Code Playgroud)
创建IClassX接口的具体实现取决于运行时参数N.
使用给定的构造函数,我无法配置DI容器(使用Unity),因为我不知道将在运行时使用什么IClassX实现.Mark Seemann在他的着作Dependency Injection In .Net中建议我们应该使用Abstract Factory作为注入参数.
现在我们有SomeAbstractFactory,它基于运行时参数runTimeParam返回IClassX的实现.
public class SomeAbstractFactory
{
public SomeAbstractFactory(){ }
public IClassX GetStrategyFor(int runTimeParam)
{
switch(runTimeParam)
{
case 1: return new ClassX1();
case 2: return new ClassX2();
default : return new ClassDefault();
}
}
}
Run Code Online (Sandbox Code Playgroud)
SomeClass现在接受ISomeAbstractFactory作为注入参数:
public class SomeClass
{
public SomeClass(ISomeAbstractFactory someAbstractfactory){...}
}
Run Code Online (Sandbox Code Playgroud)
那没关系.我们只有一个组合根,我们在其中创建对象图.我们配置Unity容器以将SomeAbstractFactory注入SomeClass.
但是,我们假设类ClassX1和ClassX2有自己的依赖项:
public class ClassX1 : IClassX
{
public ClassX1(IClassA, IClassB) {...}
}
public class ClassX2 : IClassX
{
public ClassX2(IClassA, …Run Code Online (Sandbox Code Playgroud) .net c# dependency-injection service-locator abstract-factory
我试图在我的wamp上安装APC(PHP 5.3.10/Apache2.2.21).我正在使用的操作系统是Windows 7.
我从http://dev.freshsite.pl/php-accelerators/apc.html下载了'APC 3.1.9 for PHP 5.3 vc9(Win7/2008)'dll .
我将php_apc.dll复制到wamp/php/5.3.10/ext,并将extension = php_apc.dll添加到php.ini文件中.
phpinfo()不显示APC配置,APC无法正常工作.phpinfo()值编译器:MSVC9,体系结构:x86,为线程安全启用.
谢谢