本文整理汇总了C#中Castle.MicroKernel.Context.CreationContext.GetContextualProperty方法的典型用法代码示例。如果您正苦于以下问题:C# CreationContext.GetContextualProperty方法的具体用法?C# CreationContext.GetContextualProperty怎么用?C# CreationContext.GetContextualProperty使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类Castle.MicroKernel.Context.CreationContext
的用法示例。
在下文中一共展示了CreationContext.GetContextualProperty方法的5个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。
示例1: Resolve
public override object Resolve(CreationContext context, Burden burden, IReleasePolicy releasePolicy)
{
if (cachedBurden != null)
{
return cachedBurden.Instance;
}
var instanceFromContext = context.GetContextualProperty(ComponentActivator);
if (instanceFromContext != null)
{
//we've been called recursively, by some dependency from base.Resolve call
return instanceFromContext;
}
object instance;
lock (ComponentActivator)
{
if (cachedBurden != null)
{
return cachedBurden.Instance;
}
instance = base.CreateInstance(context, burden);
cachedBurden = burden;
}
Track(burden, releasePolicy);
return instance;
}
示例2: Resolve
public override object Resolve(CreationContext context, IReleasePolicy releasePolicy)
{
// 1. read from cache
if (cachedBurden != null)
{
return cachedBurden.Instance;
}
var instanceFromContext = context.GetContextualProperty(ComponentActivator);
if (instanceFromContext != null)
{
//we've been called recursively, by some dependency from base.Resolve call
return instanceFromContext;
}
var initializing = false;
try
{
initializing = init.ExecuteThreadSafeOnce();
if (cachedBurden != null)
{
return cachedBurden.Instance;
}
var burden = CreateInstance(context, true);
cachedBurden = burden;
Track(burden, releasePolicy);
return burden.Instance;
}
finally
{
if (initializing)
{
init.EndThreadSafeOnceSection();
}
}
}
示例3: Resolve
public override object Resolve(CreationContext context)
{
if (instance == null)
{
var instanceFromContext = context.GetContextualProperty(ComponentActivator);
if (instanceFromContext != null)
{
//we've been called recursively, by some dependency from base.Resolve call
return instanceFromContext;
}
lock (ComponentActivator)
{
if (instance == null)
{
instance = base.Resolve(context);
}
}
}
return instance;
}
示例4: Resolve
public override object Resolve(CreationContext context, IReleasePolicy releasePolicy)
{
// 1. read from cache
if (cachedBurden != null)
{
return cachedBurden.Instance;
}
var instanceFromContext = context.GetContextualProperty(ComponentActivator);
if (instanceFromContext != null)
{
//we've been called recursively, by some dependency from base.Resolve call
return instanceFromContext;
}
lock (ComponentActivator)
{
if (cachedBurden != null)
{
return cachedBurden.Instance;
}
return GetNewInstance(context, releasePolicy);
}
}
示例5: GetContextInstance
public object GetContextInstance(CreationContext context)
{
return context.GetContextualProperty(ComponentActivator);
}