当前位置: 首页>>代码示例>>C#>>正文


C# CSharpResolver.ResolveObjectCreation方法代码示例

本文整理汇总了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;
		}
开发者ID:yayanyang,项目名称:monodevelop,代码行数:29,代码来源:CSharpAttribute.cs

示例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;
				}
			}
开发者ID:0xb1dd1e,项目名称:NRefactory,代码行数:25,代码来源:CSharpAttribute.cs


注:本文中的ICSharpCode.NRefactory.CSharp.Resolver.CSharpResolver.ResolveObjectCreation方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。