本文整理汇总了C#中IObjectContainer.AddTransientComponent方法的典型用法代码示例。如果您正苦于以下问题:C# IObjectContainer.AddTransientComponent方法的具体用法?C# IObjectContainer.AddTransientComponent怎么用?C# IObjectContainer.AddTransientComponent使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类IObjectContainer
的用法示例。
在下文中一共展示了IObjectContainer.AddTransientComponent方法的1个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。
示例1: XypericoDependencyResolver
public XypericoDependencyResolver(IObjectContainer container)
{
Container = container;
//
// Register all controller types so the container will be able to resolve them
//
Logger.Debug("Dependency resolver scanning for controllers");
//foreach (Assembly a in AppDomain.CurrentDomain.GetAssemblies())
foreach (Assembly a in BuildManager.GetReferencedAssemblies())
{
try
{
Logger.DebugFormat("Scanning assembly {0}", a.FullName);
foreach (Type controllerType in (from t in a.GetTypes() where typeof(IController).IsAssignableFrom(t) select t))
{
Logger.DebugFormat("Adding {0} as a controller", controllerType);
Container.AddTransientComponent(controllerType, controllerType);
// OLD: AddComponentLifeStyle(controllerType.ToString(), controllerType, Castle.Core.LifestyleType.Transient);
}
}
catch (ReflectionTypeLoadException ex)
{
Logger.Warn(string.Format("Could not load assembly {0}.", a.FullName), ex);
foreach (Exception ex2 in ex.LoaderExceptions)
Logger.Warn("Loader exception", ex2);
}
catch (Exception ex)
{
Logger.Warn(string.Format("Could not load assembly {0}.", a.FullName), ex);
}
}
}