62,041
社区成员
发帖
与我相关
我的任务
分享
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using Ninject.Modules;
using System.Web;
namespace Botwave.EasyCollect.Web.Module
{
public class Ninject : NinjectModule
{
public override void Load()
{
Bind<ITestNinject>().To<DoNinject>();
}
}
public interface ITestNinject
{
string Test();
}
public class DoNinject : ITestNinject
{
public string Test()
{
return "Hello Ninject";
}
}
}
namespace AspNETWebFormNinject
{
public class Global : NinjectHttpApplication
{
private static readonly log4net.ILog log = log4net.LogManager.GetLogger("Global.asax");
protected override IKernel CreateKernel()
{
return new StandardKernel(new Botwave.EasyCollect.Web.Module.Ninject());
}
}
}
public partial class test_TestNinject : System.Web.UI.Page
{
[Inject]
public ITestNinject MyNinject { get; set; }
protected void Page_Load(object sender, EventArgs e)
{
Response.Write(MyNinject.Test());
}
}