本文整理汇总了C#中Castle类的典型用法代码示例。如果您正苦于以下问题:C# Castle类的具体用法?C# Castle怎么用?C# Castle使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。
Castle类属于命名空间,在下文中一共展示了Castle类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。
示例1: Install
public void Install(Castle.Windsor.IWindsorContainer container, Castle.MicroKernel.SubSystems.Configuration.IConfigurationStore store)
{
container.Register
(
new NhibernateAssemblySourceForRegistration(typeof(User).Assembly)
);
}
示例2: Kernel_ComponentRegistered
private static void Kernel_ComponentRegistered(string key, Castle.MicroKernel.IHandler handler)
{
if (typeof(IApplicationService).IsAssignableFrom(handler.ComponentModel.Implementation))
{
handler.ComponentModel.Interceptors.Add(new InterceptorReference(typeof(ValidationInterceptor)));
}
}
示例3: Kernel_ComponentModelCreated
static void Kernel_ComponentModelCreated(Castle.Core.ComponentModel model)
{
if (model.Services.First().IsGenericType && model.Services.First().GetGenericTypeDefinition().Equals(typeof(IHandleCommand<>)))
{
model.CustomComponentActivator = typeof(CommandHandlerComponentActivator);
}
}
示例4: Install
public void Install(Castle.Windsor.IWindsorContainer container, Castle.MicroKernel.SubSystems.Configuration.IConfigurationStore store)
{
container.Register(Component.For<LastTasksByUserPresenter>()
.Named("InnerLastTasksByUserPresenter")
.LifeStyle.Transient);
container.Register(Component.For<ILastTasksByUserPresenter>()
.ImplementedBy<LastTasksByUserPresenterWithScope>()
.ServiceOverrides(ServiceOverride.ForKey<ILastTasksByUserPresenter>().Eq("InnerLastTasksByUserPresenter"))
.LifeStyle.Transient);
container.Register(AllTypes.FromThisAssembly()
.Where(Component.IsInSameNamespaceAs<IBlogsFromDatabasePresenter>())
.WithService.DefaultInterface()
.Configure(c => c.LifeStyle.Transient));
//container.Register(AllTypes.FromThisAssembly()
// .Where(Component.IsInSameNamespaceAs<ILastTasksByUserPresenter>())
// .WithService.DefaultInterface()
// .Configure(c => c.LifeStyle.Transient));
container.Register(AllTypes.FromThisAssembly()
.Where(Component.IsInSameNamespaceAs<ILastTasksByUserQuery>())
.WithService.DefaultInterface()
.Configure(c => c.LifeStyle.Transient));
container.Register(AllTypes.FromThisAssembly()
.Where(Component.IsInSameNamespaceAs<IAddPostCommand>())
.WithService.DefaultInterface()
.Configure(c => c.LifeStyle.Transient));
}
示例5: Install
public void Install(Castle.Windsor.IWindsorContainer container, Castle.MicroKernel.SubSystems.Configuration.IConfigurationStore store)
{
xrc.XrcWindsor.InstallExtension(container, System.Reflection.Assembly.Load("xrc.MVC4"));
xrc.XrcWindsor.InstallExtension(container, System.Reflection.Assembly.Load("xrc.FileSystemPages"));
xrc.XrcWindsor.InstallExtension(container, System.Reflection.Assembly.Load("xrc.Markdown"));
xrc.XrcWindsor.InstallExtension(container, System.Reflection.Assembly.Load("DemoWebSite.Lib"));
}
示例6: Install
public void Install(IWindsorContainer container, Castle.MicroKernel.SubSystems.Configuration.IConfigurationStore store)
{
container.Register(Component.For<Shell>());
container.Register(Component.For<MainModule>());
container.Register(Component.For<TeacherModule>());
container.Register(Component.For<StackPanelRegionAdapter>());
}
示例7: Instantiate
protected override object Instantiate(Castle.MicroKernel.CreationContext context)
{
Type systemType = (Type)
Model.ExtendedProperties[PrevalenceFacility.SystemTypePropertyKey];
String dir = Path.Combine(AppDomain.CurrentDomain.BaseDirectory, (String)
Model.ExtendedProperties[PrevalenceFacility.StorageDirPropertyKey]);
bool autoVersionMigration = (bool)
Model.ExtendedProperties[PrevalenceFacility.AutoMigrationPropertyKey];
bool resetStorage = (bool)
Model.ExtendedProperties[PrevalenceFacility.ResetStoragePropertyKey];
float snapshotPeriod = (float)Model.ExtendedProperties[PrevalenceFacility.SnapshotPeriodPropertyKey];
if (resetStorage)
{
DeleteStorageDir(dir);
}
PrevalenceEngine engine = PrevalenceActivator.CreateEngine(
systemType,
dir,
autoVersionMigration );
if (snapshotPeriod > 0)
{
CreateSnapshotTaker(engine, snapshotPeriod);
}
return engine;
}
示例8: Resolve
protected override void Resolve(Castle.Windsor.IWindsorContainer windsor)
{
//提前注册桩
windsor.RegisterComponent(typeof(ProcessServiceMock));
windsor.RegisterComponent(typeof(SchedulerServiceMock));
base.Resolve(windsor);
}
示例9: Install
public void Install(Castle.Windsor.IWindsorContainer container, Castle.MicroKernel.SubSystems.Configuration.IConfigurationStore store)
{
container.Register(
Component.For<CommandExecutor>(),
Component.For<AppCommands>(),
Component.For<TextChangedTrigger>(),
Component.For<TasksModule>(),
Component.For<ProgramService>(),
Component.For<AppValueProvider>(),
Component.For<VariablesStorage>(),
Component.For<Context>(),
Component.For<XmlDataSource<ItemsDb>>(),
Component.For<DataStorage<ItemsDb>>(),
Component.For<ProgramCommand>(),
Component.For<StartProcessCommand>(),
Component.For<TasksCommand>(),
Component.For<MainViewModel>());
}
示例10: Install
public void Install(Castle.Windsor.IWindsorContainer container,
Castle.MicroKernel.SubSystems.Configuration.IConfigurationStore store)
{
container.Register(Classes.FromThisAssembly()
.BasedOn<ApiController>()
.LifestylePerWebRequest());
}
示例11: Install
public void Install(IWindsorContainer container, Castle.MicroKernel.SubSystems.Configuration.IConfigurationStore store)
{
// use installer.
// container.Install(new PersonInstaller());
container.Register(Component.For<IPerson>().ImplementedBy<Person>());
}
示例12: Start
// Use this for initialization
void Start()
{
direction = Random.Range(0,2);
droppedBomb = true;
enemy = this.GetComponent<Rigidbody2D>();
enemyPosition = enemy.transform.position;
animations = this.GetComponent<Animator>();
healthdecrease = GameObject.FindGameObjectWithTag("Castle").GetComponent<Castle>();
rightToLeft = new Vector3(1,1,1);
leftToRight = new Vector3(-1,1,1);
doNotMove = false;
this.GetComponent<AudioSource>().clip = myclip;
if (direction == 0)
{
tempVar = new Vector3 (9f, 0f, 0f);
enemy.transform.position = tempVar;
}
else
{
tempVar = new Vector3 (9f, 0f, 0f);
enemy.transform.position = -tempVar;
}
}
示例13: Install
public void Install(Castle.Windsor.IWindsorContainer container, Castle.MicroKernel.SubSystems.Configuration.IConfigurationStore store)
{
container.Register(
Classes.FromThisAssembly()
.BasedOn(typeof(System.Web.Mvc.ControllerBase))
.LifestyleTransient());
}
示例14: Install
public void Install(IWindsorContainer container, Castle.MicroKernel.IConfigurationStore store)
{
container
.Register(Component.For<IPostService>()
.ImplementedBy<PostService>())
.Register(Component.For<IMailService>()
.ImplementedBy<MailService>())
.Register(Component.For<IFriendlyUrlGenerator>()
.ImplementedBy<FriendlyUrlGenerator>())
.Register(AllTypes.Of(typeof (IValidatorBase<>))
.FromAssemblyNamed("BlogSharp.Model")
.WithService.FromInterface(typeof (IValidatorBase<>))
.Configure(x => x.LifeStyle.Transient))
.AddFacility<ControllerRegisterFacility>()
.Register(AllTypes.Of<IController>()
.FromAssemblyNamed("BlogSharp.Web").Configure(x => x.LifeStyle.Transient))
.Register(Component.For<IExtendedControllerFactory>()
.ImplementedBy<WindsorControllerFactory>())
.Register(AllTypes.Of<IStartupInstaller>()
.FromAssemblyNamed("BlogSharp.Core.Impl")
.WithService.FirstInterface())
.Register(AllTypes.Of<IHttpModule>()
.FromAssemblyNamed("BlogSharp.Core.Impl"))
.Register(Component.For<BlogContextProvider>()
.ImplementedBy<WebBlogContextProvider>());
}
示例15: Init
public void Init(IKernel kernel, Castle.Core.Configuration.IConfiguration facilityConfig)
{
InterceptorFactory.Create = new InterceptorFactory.CreateInterceptor(delegate()
{
return new AuditInterceptor(kernel);
});
}