本文整理汇总了C#中System.Reflection.Binder.ConstructorAction方法的典型用法代码示例。如果您正苦于以下问题:C# Binder.ConstructorAction方法的具体用法?C# Binder.ConstructorAction怎么用?C# Binder.ConstructorAction使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类System.Reflection.Binder
的用法示例。
在下文中一共展示了Binder.ConstructorAction方法的2个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。
示例1: CreateInstance
private object CreateInstance(TypeIndex tIndex, Binder.BaseTypeConfig cTarget)
{
// try to resolve the type from the custom resolvers
object resolvedObject = m_binder.ResolveType(tIndex.Type);
if (resolvedObject != null)
{
CheckConfigForObject(cTarget, resolvedObject);
return resolvedObject;
}
if (cTarget == null)
{
// for not binded types, find the most suitable constructor
if (!m_notBindedConstructorList.ContainsKey(tIndex.Type))
{
ConstructorInfo constructor = FindConstructor(tIndex.Type);
if (constructor == null)
{
throw new Exceptions.UnboundTypeException();
}
else
{
var expr = CreateExpressionConstructor(constructor,
ci => ci.GetParameters().Select(p => CreateParameterExpression(p)).ToArray());
m_notBindedConstructorList.Add(tIndex.Type, Expression.Lambda<Func<object>>(expr).Compile());
}
}
return m_notBindedConstructorList[tIndex.Type]();
}
else
{
// create the object from the binded configuration
if (cTarget.Constructor == null)
{
CreateConstructor(cTarget);
}
var obj = cTarget.Constructor();
if (cTarget.ConstructorType == Binder.BaseTypeConfig.ConstructorTypeConfig.Action)
{
cTarget.ConstructorAction(obj);
}
return obj;
}
}
开发者ID:sandrapatfer,项目名称:PROMPT11-02-AdvancedProgramming.sandrapatfer,代码行数:45,代码来源:InstanceManager.cs
示例2: CheckConfigForObject
private void CheckConfigForObject(Binder.BaseTypeConfig tConfig, object resolvedObject)
{
if (tConfig == null)
return;
if (tConfig.ConstructorType == Binder.BaseTypeConfig.ConstructorTypeConfig.Action)
{
tConfig.ConstructorAction(resolvedObject);
}
}