本文整理汇总了C#中IBinding.GetType方法的典型用法代码示例。如果您正苦于以下问题:C# IBinding.GetType方法的具体用法?C# IBinding.GetType怎么用?C# IBinding.GetType使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类IBinding
的用法示例。
在下文中一共展示了IBinding.GetType方法的1个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。
示例1: TypeToGetResolved
private Type TypeToGetResolved(Type serviceKey, IBinding binding)
{
if (binding != null)
{
if (binding.Target != BindingTarget.Type && binding.Target != BindingTarget.Self)
{
throw new InvalidOperationException("Cannot use unnamed parameters for getting types that are not bound to self or to another type");
}
try
{
var req = _kernel.CreateRequest(serviceKey, metadata => true, new IParameter[0], true, false);
var cache = _kernel.Components.Get<ICache>();
var planner = _kernel.Components.Get<IPlanner>();
var pipeline = _kernel.Components.Get<IPipeline>();
var provider = binding.GetProvider(new Context(_kernel, req, binding, cache, planner, pipeline));
return provider.Type;
}
catch (Exception)
{
return binding.GetType();
}
}
if (serviceKey.IsClass && !serviceKey.IsAbstract)
{
return serviceKey;
}
return null;
}