本文整理汇总了C#中ICSharpCode.NRefactory.CSharp.Resolver.CSharpResolver.ResolveObjectCreation方法的典型用法代码示例。如果您正苦于以下问题:C# CSharpResolver.ResolveObjectCreation方法的具体用法?C# CSharpResolver.ResolveObjectCreation怎么用?C# CSharpResolver.ResolveObjectCreation使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类ICSharpCode.NRefactory.CSharp.Resolver.CSharpResolver
的用法示例。
在下文中一共展示了CSharpResolver.ResolveObjectCreation方法的2个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。
示例1: ResolveConstructor
public IMethod ResolveConstructor(ITypeResolveContext context)
{
CSharpResolver r = new CSharpResolver(context);
IType type = attributeType.Resolve(context);
int totalArgumentCount = 0;
if (positionalArguments != null)
totalArgumentCount += positionalArguments.Count;
if (namedCtorArguments != null)
totalArgumentCount += namedCtorArguments.Count;
ResolveResult[] arguments = new ResolveResult[totalArgumentCount];
string[] argumentNames = new string[totalArgumentCount];
int i = 0;
if (positionalArguments != null) {
while (i < positionalArguments.Count) {
IConstantValue cv = positionalArguments[i];
arguments[i] = new ConstantResolveResult(cv.GetValueType(context), cv.GetValue(context));
i++;
}
}
if (namedCtorArguments != null) {
foreach (var pair in namedCtorArguments) {
argumentNames[i] = pair.Key;
arguments[i] = new ConstantResolveResult(pair.Value.GetValueType(context), pair.Value.GetValue(context));
i++;
}
}
MemberResolveResult mrr = r.ResolveObjectCreation(type, arguments, argumentNames) as MemberResolveResult;
return mrr != null ? mrr.Member as IMethod : null;
}
示例2: GetCtorInvocation
InvocationResolveResult GetCtorInvocation()
{
ResolveResult rr = LazyInit.VolatileRead(ref this.ctorInvocation);
if (rr != null) {
return rr as InvocationResolveResult;
} else {
CSharpResolver resolver = new CSharpResolver(context);
int totalArgumentCount = unresolved.positionalArguments.Count + unresolved.namedCtorArguments.Count;
ResolveResult[] arguments = new ResolveResult[totalArgumentCount];
string[] argumentNames = new string[totalArgumentCount];
int i = 0;
while (i < unresolved.positionalArguments.Count) {
IConstantValue cv = unresolved.positionalArguments[i];
arguments[i] = cv.Resolve(context);
i++;
}
foreach (var pair in unresolved.namedCtorArguments) {
argumentNames[i] = pair.Key;
arguments[i] = pair.Value.Resolve(context);
i++;
}
rr = resolver.ResolveObjectCreation(attributeType, arguments, argumentNames);
return LazyInit.GetOrSet(ref this.ctorInvocation, rr) as InvocationResolveResult;
}
}