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


C# AnonymousTypeCreateExpression类代码示例

本文整理汇总了C#中AnonymousTypeCreateExpression的典型用法代码示例。如果您正苦于以下问题:C# AnonymousTypeCreateExpression类的具体用法?C# AnonymousTypeCreateExpression怎么用?C# AnonymousTypeCreateExpression使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。


AnonymousTypeCreateExpression类属于命名空间,在下文中一共展示了AnonymousTypeCreateExpression类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。

示例1: VisitAnonymousTypeCreateExpression

 public virtual void VisitAnonymousTypeCreateExpression(AnonymousTypeCreateExpression anonymousTypeCreateExpression)
 {
     if (this.ThrowException)
     {
         throw (Exception)this.CreateException(anonymousTypeCreateExpression);
     }
 }
开发者ID:fabriciomurta,项目名称:BridgeUnified,代码行数:7,代码来源:Visitor.Exception.cs

示例2: BuildExpression

        public string BuildExpression(Dictionary<string, Expression> selectExpressions)
        {
            var anonymousTypeCreateExpression = new AnonymousTypeCreateExpression();
            var crrv = new ChangeRootReferenceVisitor(FromIdentifier);
            foreach (var curExpr in selectExpressions.OrderBy(x => x.Key))
            {
                curExpr.Value.AcceptVisitor(crrv);
                anonymousTypeCreateExpression.Initializers.Add(
                    new AssignmentExpression(new IdentifierExpression(curExpr.Key), curExpr.Value.Clone()));
            }
            if (FromExpression == null)
                FromExpression = new IdentifierExpression();

            var queryExpr = new QueryExpression
            {
                Clauses =
                {
                    new QueryFromClause
                    {
                        Identifier = "doc",
                        Expression = FromExpression.Clone()
                    },
                    new QuerySelectClause
                    {
                        Expression = anonymousTypeCreateExpression.Clone()
                    }
                }
            };
            FromIdentifier = "doc";

            var printer = new StringWriter();
            var printerVisitor = new CSharpOutputVisitor(printer, FormattingOptionsFactory.CreateSharpDevelop());
            queryExpr.AcceptVisitor(printerVisitor);
            return printer.GetStringBuilder().ToString();
        }
开发者ID:ReginaBricker,项目名称:ravendb,代码行数:35,代码来源:IndexData.cs

示例3: VisitAnonymousTypeCreateExpression

		public void VisitAnonymousTypeCreateExpression(AnonymousTypeCreateExpression anonymousTypeCreateExpression)
		{
			StartNode(anonymousTypeCreateExpression);
			WriteKeyword(AnonymousTypeCreateExpression.NewKeywordRole);
			PrintInitializerElements(anonymousTypeCreateExpression.Initializers);
			EndNode(anonymousTypeCreateExpression);
		}
开发者ID:x-strong,项目名称:ILSpy,代码行数:7,代码来源:CSharpOutputVisitor.cs

示例4: VisitAnonymousTypeCreateExpression

		public virtual void VisitAnonymousTypeCreateExpression(AnonymousTypeCreateExpression anonymousTypeCreateExpression)
		{
			VisitChildren (anonymousTypeCreateExpression);
		}
开发者ID:modulexcite,项目名称:ICSharpCode.Decompiler-retired,代码行数:4,代码来源:DepthFirstAstVisitor.cs

示例5: Visit

			public override object Visit(NewAnonymousType newAnonymousType)
			{
				var result = new AnonymousTypeCreateExpression();
				var location = LocationsBag.GetLocations(newAnonymousType);
				result.AddChild(new CSharpTokenNode(Convert(newAnonymousType.Location), ObjectCreateExpression.NewKeywordRole), ObjectCreateExpression.NewKeywordRole);
				if (location != null)
					result.AddChild(new CSharpTokenNode(Convert(location [0]), Roles.LBrace), Roles.LBrace);
				if (newAnonymousType.Parameters != null) {
					foreach (var par in newAnonymousType.Parameters) {
						if (par == null)
							continue;
						var parLocation = LocationsBag.GetLocations(par);
						
						if (parLocation == null) {
							if (par.Expr != null)
								result.AddChild((Expression)par.Expr.Accept(this), Roles.Expression);
						} else {
							var namedExpression = new NamedExpression();
							namedExpression.AddChild(Identifier.Create(par.Name, Convert(par.Location)), Roles.Identifier);
							namedExpression.AddChild(new CSharpTokenNode(Convert(parLocation [0]), Roles.Assign), Roles.Assign);
							if (par.Expr != null)
								namedExpression.AddChild((Expression)par.Expr.Accept(this), Roles.Expression);
							result.AddChild(namedExpression, Roles.Expression);
						}
					}
				}
				if (location != null && location.Count > 1)
					result.AddChild(new CSharpTokenNode(Convert(location [1]), Roles.RBrace), Roles.RBrace);
				return result;
			}
开发者ID:0xb1dd1e,项目名称:NRefactory,代码行数:30,代码来源:CSharpParser.cs

示例6: AnonymousTypeCreateBlock

 public AnonymousTypeCreateBlock(IEmitter emitter, AnonymousTypeCreateExpression anonymousTypeCreateExpression)
     : base(emitter, anonymousTypeCreateExpression)
 {
     this.Emitter = emitter;
     this.AnonymousTypeCreateExpression = anonymousTypeCreateExpression;
 }
开发者ID:txdv,项目名称:Builder,代码行数:6,代码来源:AnonymousTypeCreateBlock.cs

示例7: ConvertNewObject

        Expression ConvertNewObject(InvocationExpression invocation)
        {
            if (invocation.Arguments.Count < 1 || invocation.Arguments.Count > 3)
                return NotSupported(invocation);

            Match m = newObjectCtorPattern.Match(invocation.Arguments.First());
            if (!m.Success)
                return NotSupported(invocation);

            MethodReference ctor = m.Get<AstNode>("ctor").Single().Annotation<MethodReference>();
            if (ctor == null)
                return null;

            AstType declaringTypeNode;
            TypeReference declaringType;
            if (m.Has("declaringType")) {
                declaringTypeNode = m.Get<AstType>("declaringType").Single().Clone();
                declaringType = declaringTypeNode.Annotation<TypeReference>();
            } else {
                declaringTypeNode = AstBuilder.ConvertType(ctor.DeclaringType);
                declaringType = ctor.DeclaringType;
            }
            if (declaringTypeNode == null)
                return null;

            ObjectCreateExpression oce = new ObjectCreateExpression(declaringTypeNode);
            if (invocation.Arguments.Count >= 2) {
                IList<Expression> arguments = ConvertExpressionsArray(invocation.Arguments.ElementAtOrDefault(1));
                if (arguments == null)
                    return null;
                oce.Arguments.AddRange(arguments);
            }
            if (invocation.Arguments.Count >= 3 && declaringType.IsAnonymousType()) {
                MethodDefinition resolvedCtor = ctor.Resolve();
                if (resolvedCtor == null || resolvedCtor.Parameters.Count != oce.Arguments.Count)
                    return null;
                AnonymousTypeCreateExpression atce = new AnonymousTypeCreateExpression();
                var arguments = oce.Arguments.ToArray();
                if (AstMethodBodyBuilder.CanInferAnonymousTypePropertyNamesFromArguments(arguments, resolvedCtor.Parameters)) {
                    oce.Arguments.MoveTo(atce.Initializers);
                } else {
                    for (int i = 0; i < resolvedCtor.Parameters.Count; i++) {
                        atce.Initializers.Add(
                            new NamedExpression {
                                Name = resolvedCtor.Parameters[i].Name,
                                Expression = arguments[i].Detach()
                            });
                    }
                }
                return atce;
            }

            return oce;
        }
开发者ID:ropean,项目名称:Usable,代码行数:54,代码来源:ExpressionTreeConverter.cs

示例8: Visit

			public override object Visit (NewAnonymousType newAnonymousType)
			{
				var result = new AnonymousTypeCreateExpression ();
				if (newAnonymousType.Parameters == null)
					return result;
				foreach (var par in newAnonymousType.Parameters) {
					var location = LocationsBag.GetLocations (par);

					if (location == null) {
						if (par.Expr != null)
							result.AddChild ((Expression)par.Expr.Accept (this), AnonymousTypeCreateExpression.Roles.Expression);
					} else {
						var namedExpression = new NamedExpression ();
						namedExpression.AddChild (Identifier.Create (par.Name, Convert (par.Location)), AnonymousTypeCreateExpression.Roles.Identifier);
						namedExpression.AddChild (new CSharpTokenNode (Convert (location[0]), 1), AnonymousTypeCreateExpression.Roles.Assign);
						if (par.Expr != null)
							namedExpression.AddChild ((Expression)par.Expr.Accept (this), AnonymousTypeCreateExpression.Roles.Expression);
						result.AddChild (namedExpression, AnonymousTypeCreateExpression.Roles.Expression);
					}
				}
				return result;
			}
开发者ID:N3X15,项目名称:ILSpy,代码行数:22,代码来源:CSharpParser.cs

示例9: TransformByteCode


//.........这里部分代码省略.........
								Arguments = { dir.Expression.Detach() }
							};
						} else {
							return InlineAssembly(byteCode, args);
						}
					}
				case ILCode.Refanytype:
					return new UndocumentedExpression {
						UndocumentedExpressionType = UndocumentedExpressionType.RefType,
						Arguments = { arg1 }
					}.Member("TypeHandle");
				case ILCode.Refanyval:
					return MakeRef(
						new UndocumentedExpression {
							UndocumentedExpressionType = UndocumentedExpressionType.RefValue,
							Arguments = { arg1, new TypeReferenceExpression(operandAsTypeRef) }
						});
					case ILCode.Newobj: {
						Cecil.TypeReference declaringType = ((MethodReference)operand).DeclaringType;
						if (declaringType is ArrayType) {
							ComposedType ct = AstBuilder.ConvertType((ArrayType)declaringType) as ComposedType;
							if (ct != null && ct.ArraySpecifiers.Count >= 1) {
								var ace = new Ast.ArrayCreateExpression();
								ct.ArraySpecifiers.First().Remove();
								ct.ArraySpecifiers.MoveTo(ace.AdditionalArraySpecifiers);
								ace.Type = ct;
								ace.Arguments.AddRange(args);
								return ace;
							}
						}
						if (declaringType.IsAnonymousType()) {
							MethodDefinition ctor = ((MethodReference)operand).Resolve();
							if (methodDef != null) {
								AnonymousTypeCreateExpression atce = new AnonymousTypeCreateExpression();
								if (CanInferAnonymousTypePropertyNamesFromArguments(args, ctor.Parameters)) {
									atce.Initializers.AddRange(args);
								} else {
									for (int i = 0; i < args.Count; i++) {
										atce.Initializers.Add(
											new NamedExpression {
												Name = ctor.Parameters[i].Name,
												Expression = args[i]
											});
									}
								}
								return atce;
							}
						}
						var oce = new Ast.ObjectCreateExpression();
						oce.Type = AstBuilder.ConvertType(declaringType);
						oce.Arguments.AddRange(args);
						return oce.WithAnnotation(operand);
					}
					case ILCode.No: return InlineAssembly(byteCode, args);
					case ILCode.Nop: return null;
					case ILCode.Pop: return arg1;
					case ILCode.Readonly: return InlineAssembly(byteCode, args);
				case ILCode.Ret:
					if (methodDef.ReturnType.FullName != "System.Void") {
						return new Ast.ReturnStatement { Expression = arg1 };
					} else {
						return new Ast.ReturnStatement();
					}
					case ILCode.Rethrow: return new Ast.ThrowStatement();
					case ILCode.Sizeof:  return new Ast.SizeOfExpression { Type = operandAsTypeRef };
					case ILCode.Stloc: {
开发者ID:linquize,项目名称:ILSpy,代码行数:67,代码来源:AstMethodBodyBuilder.cs

示例10: VisitAnonymousTypeCreateExpression

 public StringBuilder VisitAnonymousTypeCreateExpression(AnonymousTypeCreateExpression anonymousTypeCreateExpression, int data)
 {
     throw new SLSharpException("SL# does not understand anonymous types");
 }
开发者ID:hach-que,项目名称:SLSharp,代码行数:4,代码来源:VisitorBase.Illegal.cs

示例11: VisitAnonymousTypeCreateExpression

 public override void VisitAnonymousTypeCreateExpression(AnonymousTypeCreateExpression anonymousTypeCreateExpression)
 {
     new AnonymousTypeCreateBlock(this, anonymousTypeCreateExpression).Emit();
 }
开发者ID:yindongfei,项目名称:bridge.lua,代码行数:4,代码来源:Emitter.Visitor.cs

示例12: VisitAnonymousTypeCreateExpression

		public virtual void VisitAnonymousTypeCreateExpression(AnonymousTypeCreateExpression anonymousTypeCreateExpression)
		{
			DebugExpression(anonymousTypeCreateExpression);
			StartNode(anonymousTypeCreateExpression);
			WriteKeyword(AnonymousTypeCreateExpression.NewKeywordRole);
			PrintInitializerElements(anonymousTypeCreateExpression.Initializers, CodeBracesRangeFlags.OtherBlockBraces);
			EndNode(anonymousTypeCreateExpression);
		}
开发者ID:0xd4d,项目名称:NRefactory,代码行数:8,代码来源:CSharpOutputVisitor.cs

示例13: VisitAnonymousTypeCreateExpression

        public void VisitAnonymousTypeCreateExpression(AnonymousTypeCreateExpression anonymousTypeCreateExpression)
        {
            JsonObject expression = CreateJsonExpression(anonymousTypeCreateExpression);
            AddKeyword(expression, AnonymousTypeCreateExpression.NewKeywordRole);
            expression.AddJsonValue("elements", GetInitializerElements(anonymousTypeCreateExpression.Initializers));
            Push(expression);

        }
开发者ID:CompilerKit,项目名称:CodeWalk,代码行数:8,代码来源:AstCsToJson.cs

示例14: VisitAnonymousTypeCreateExpression

			public override void VisitAnonymousTypeCreateExpression (AnonymousTypeCreateExpression anonymousTypeCreateExpression)
			{
				base.VisitAnonymousTypeCreateExpression (anonymousTypeCreateExpression);

				foreach (var init in anonymousTypeCreateExpression.Initializers.ToList ()) {
					var ident = init as IdentifierExpression;
					if (ident != null) {
						init.ReplaceWith (new NamedExpression (ident.Identifier, ident.Clone ()));
					}
				}
			}
开发者ID:RReverser,项目名称:Netjs,代码行数:11,代码来源:CsToTs.cs

示例15: VisitAnonymousTypeCreateExpression

 public void VisitAnonymousTypeCreateExpression(AnonymousTypeCreateExpression node)
 {
     NotSupported(node);
 }
开发者ID:evanw,项目名称:minisharp,代码行数:4,代码来源:Lower.cs


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