ISemantic E(NewExpression nex) { // http://www.d-programming-language.org/expression.html#NewExpression ISemantic[] possibleTypes = null; if (nex.Type is IdentifierDeclaration) possibleTypes = TypeDeclarationResolver.Resolve((IdentifierDeclaration)nex.Type, ctxt, filterForTemplateArgs: false); else possibleTypes = TypeDeclarationResolver.Resolve(nex.Type, ctxt); var ctors = new Dictionary<DMethod, TemplateIntermediateType>(); if (possibleTypes == null) return null; foreach (var t in possibleTypes) { var ct = DResolver.StripAliasSymbol(t as AbstractType) as TemplateIntermediateType; if (ct!=null && !ct.Definition.ContainsAttribute(DTokens.Abstract)) foreach (var ctor in GetConstructors(ct)) ctors.Add(ctor, ct); } MemberSymbol finalCtor = null; var kvArray = ctors.ToArray(); /* * TODO: Determine argument types and filter out ctor overloads. */ if (kvArray.Length != 0) finalCtor = new MemberSymbol(kvArray[0].Key, kvArray[0].Value, nex); else if (possibleTypes.Length != 0) return AbstractType.Get(possibleTypes[0]); return finalCtor; }
///<summary>Creates a <see cref="T:System.Linq.Expressions.MemberInitExpression" />.</summary> ///<returns>A <see cref="T:System.Linq.Expressions.MemberInitExpression" /> that has the <see cref="P:System.Linq.Expressions.Expression.NodeType" /> property equal to <see cref="F:System.Linq.Expressions.ExpressionType.MemberInit" /> and the <see cref="P:System.Linq.Expressions.MemberInitExpression.NewExpression" /> and <see cref="P:System.Linq.Expressions.MemberInitExpression.Bindings" /> properties set to the specified values.</returns> ///<param name="newExpression">A <see cref="T:System.Linq.Expressions.NewExpression" /> to set the <see cref="P:System.Linq.Expressions.MemberInitExpression.NewExpression" /> property equal to.</param> ///<param name="bindings">An array of <see cref="T:System.Linq.Expressions.MemberBinding" /> objects to use to populate the <see cref="P:System.Linq.Expressions.MemberInitExpression.Bindings" /> collection.</param> ///<exception cref="T:System.ArgumentNullException"> ///<paramref name="newExpression" /> or <paramref name="bindings" /> is null.</exception> ///<exception cref="T:System.ArgumentException">The <see cref="P:System.Linq.Expressions.MemberBinding.Member" /> property of an element of <paramref name="bindings" /> does not represent a member of the type that <paramref name="newExpression" />.Type represents.</exception> public static MemberInitExpression MemberInit(NewExpression newExpression, params MemberBinding[] bindings) { return MemberInit(newExpression, (IEnumerable<MemberBinding>)bindings); }
protected internal virtual void PostWalk(NewExpression node) { }
public override void PostWalk(NewExpression node) { }
static void CalculateCurrentArgument(NewExpression nex, ArgumentsResolutionResult res, CodeLocation caretLocation, ResolutionContext ctxt, IEnumerable<AbstractType> resultBases=null) { if (nex.Arguments != null) res.CurrentlyTypedArgumentIndex = nex.Arguments.Length; /*{ int i = 0; foreach (var arg in nex.Arguments) { if (caretLocation >= arg.Location && caretLocation <= arg.EndLocation) { res.CurrentlyTypedArgumentIndex = i; break; } i++; } }*/ }
/// <summary> /// Creates a <see cref="ListInitExpression"/> that uses a specified method to add elements to a collection. /// </summary> /// <param name="newExpression">A <see cref="NewExpression"/> to set the <see cref="P:ListInitExpression.NewExpression"/> property equal to.</param> /// <param name="addMethod">A <see cref="MethodInfo"/> that represents an instance method named "Add" (case insensitive), that adds an element to a collection. </param> /// <param name="initializers">An <see cref="IEnumerable{T}"/> that contains <see cref="Expression"/> objects to use to populate the Initializers collection.</param> /// <returns>A <see cref="ListInitExpression"/> that has the <see cref="P:ListInitExpression.NodeType"/> property equal to ListInit and the <see cref="P:ListInitExpression.NewExpression"/> property set to the specified value.</returns> public static ListInitExpression ListInit(NewExpression newExpression, MethodInfo addMethod, IEnumerable<Expression> initializers) { if (addMethod == null) { return ListInit(newExpression, initializers); } ContractUtils.RequiresNotNull(newExpression, "newExpression"); ContractUtils.RequiresNotNull(initializers, "initializers"); var initializerlist = initializers.ToReadOnly(); if (initializerlist.Count == 0) { throw Error.ListInitializerWithZeroMembers(); } ElementInit[] initList = new ElementInit[initializerlist.Count]; for (int i = 0; i < initializerlist.Count; i++) { initList[i] = ElementInit(addMethod, initializerlist[i]); } return ListInit(newExpression, new TrueReadOnlyCollection<ElementInit>(initList)); }
protected override object VisitNew(NewExpression exp) { object[] arguments = exp.Arguments.Select(a => this.Visit(a)).ToArray(); return(exp.Constructor.Invoke(arguments)); }
/// <summary> /// Creates a new expression that is like this one, but using the /// supplied children. If all of the children are the same, it will /// return this expression. /// </summary> /// <param name="newExpression">The <see cref="NewExpression" /> property of the result.</param> /// <param name="initializers">The <see cref="Initializers" /> property of the result.</param> /// <returns>This expression if no children changed, or an expression with the updated children.</returns> public ListInitExpression Update(NewExpression newExpression, IEnumerable<ElementInit> initializers) { if (newExpression == NewExpression && initializers == Initializers) { return this; } return Expression.ListInit(newExpression, initializers); }
protected override NewExpression VisitNew(NewExpression nex) { if (nex.Constructor.DeclaringType == typeof(DateTime)) { if (nex.Arguments[0].NodeType == ExpressionType.Conditional) { if (nex.Arguments.Count == 3) { this.Write("toDateTime(concat(toString("); this.Visit(nex.Arguments[0]); this.Write("), '-', toString("); this.Write(nex.Arguments[1]); this.Write("), '-', toString("); this.Write(nex.Arguments[2]); this.Write(") ))"); return nex; } else if (nex.Arguments.Count == 6) { this.Write("parseDateTimeBestEffort(concat(toString("); this.Visit(nex.Arguments[0]); this.Write("), '-', toString("); this.Write(nex.Arguments[1]); this.Write("), '-', toString("); this.Write(nex.Arguments[2]); this.Write("), ' ', toString("); this.Write(nex.Arguments[3]); this.Write("), ':', toString("); this.Write(nex.Arguments[4]); this.Write("), ':', toString("); this.Write(nex.Arguments[5]); this.Write(") ))"); return nex; } } } /* * select Max(toDate(concat(toString(if((t0."CustomerID" = 'ALFKI'), 1977, 1977)),'-0', toString(7), '-0', toString(6) ) )) * FROM "Customers" AS t0 * WHERE (t0."CustomerID" = 'ALFKI') * */ else { this.Write("("); this.Visit(nex.Arguments[0]); this.Write(" || '-' || (caseWithoutExpression("); this.Visit(nex.Arguments[1]); this.Write(" < 10, '0' || "); this.Visit(nex.Arguments[1]); this.Write(" ELSE "); this.Visit(nex.Arguments[1]); this.Write(" END)"); this.Write(" || '-' || (caseWithoutExpression( "); this.Visit(nex.Arguments[2]); this.Write(" < 10, '0' || "); this.Visit(nex.Arguments[2]); this.Write(" , "); this.Visit(nex.Arguments[2]); this.Write(")"); this.Write(")"); return nex; } return base.VisitNew(nex); }
public Expression ProcessNew(NewExpression expression, out IValue result, IGeneratedQueryCode gc, System.ComponentModel.Composition.Hosting.CompositionContainer container) { throw new NotImplementedException(); }
protected override Expression VisitNew(NewExpression node) { return(null); }
private static Expression SelectStructuralProperties(Expression source, OeSelectItem root) { if (!root.HasNavigationItems) { return(source); } ParameterExpression parameter = Expression.Parameter(OeExpressionHelper.GetCollectionItemType(source.Type)); IReadOnlyList <MemberExpression> joins = OeExpressionHelper.GetPropertyExpressions(parameter); var newJoins = new Expression[joins.Count]; List <OeSelectItem> navigationItems = FlattenNavigationItems(root, true); for (int i = 0; i < navigationItems.Count; i++) { newJoins[i] = joins[i]; if (navigationItems[i].SelectItems.Count > 0) { var properties = new Expression[navigationItems[i].SelectItems.Count]; for (int j = 0; j < navigationItems[i].SelectItems.Count; j++) { if (navigationItems[i].SelectItems[j].EdmProperty is ComputeProperty computeProperty) { properties[j] = new ReplaceParameterVisitor(joins[i]).Visit(computeProperty.Expression); } else { PropertyInfo property = joins[i].Type.GetPropertyIgnoreCase(navigationItems[i].SelectItems[j].EdmProperty); properties[j] = Expression.Property(joins[i], property); } } Expression newTupleExpression = OeExpressionHelper.CreateTupleExpression(properties); if (i > 0 && navigationItems[i].EdmProperty.Type.IsNullable) { UnaryExpression nullConstant = Expression.Convert(OeConstantToVariableVisitor.NullConstantExpression, newTupleExpression.Type); newTupleExpression = Expression.Condition(Expression.Equal(joins[i], OeConstantToVariableVisitor.NullConstantExpression), nullConstant, newTupleExpression); } newJoins[i] = newTupleExpression; } } NewExpression newSelectorBody = OeExpressionHelper.CreateTupleExpression(newJoins); MethodInfo selectMethodInfo = OeMethodInfoHelper.GetSelectMethodInfo(parameter.Type, newSelectorBody.Type); LambdaExpression newSelector = Expression.Lambda(newSelectorBody, parameter); //Quirk EF Core 2.1.1 bug Take/Skip must be last in expression tree var skipTakeExpressions = new List <MethodCallExpression>(); while (source is MethodCallExpression callExpression && (callExpression.Method.Name == nameof(Enumerable.Skip) || callExpression.Method.Name == nameof(Enumerable.Take))) { skipTakeExpressions.Add(callExpression); source = callExpression.Arguments[0]; } source = Expression.Call(selectMethodInfo, source, newSelector); for (int i = skipTakeExpressions.Count - 1; i >= 0; i--) { MethodInfo skipTakeMethodInfo = skipTakeExpressions[i].Method.GetGenericMethodDefinition().MakeGenericMethod(newSelector.ReturnType); source = Expression.Call(skipTakeMethodInfo, source, skipTakeExpressions[i].Arguments[1]); } return(source); }
protected override Expression VisitNew(NewExpression node) { NewExpression = node; return(base.VisitNew(node)); }
internal MemberInitExpression(NewExpression newExpression, ReadOnlyCollection<MemberBinding> bindings) { _newExpression = newExpression; _bindings = bindings; }
private static string VisitNew(NewExpression node) { throw new NotImplementedException(); }
private static void HandleNewExpression_Ctor(NewExpression nex, IBlockNode curBlock, List<AbstractType> _ctors, AbstractType t) { var udt = t as TemplateIntermediateType; if (udt is ClassType || udt is StructType) { bool explicitCtorFound; if (!CtorScan.ScanForConstructors(nex, curBlock, udt, _ctors, out explicitCtorFound)) { if (explicitCtorFound) { // TODO: Somehow inform the user that the current class can't be instantiated } else { // Introduce default constructor _ctors.Add(new MemberSymbol(new DMethod(DMethod.MethodType.Constructor) { Description = "Default constructor for " + udt.Name, Parent = udt.Definition }, udt)); } } } }
/// <summary> /// Visits the new expression. /// </summary> protected virtual Expression VisitNew(NewExpression expression) { var arguments = expression.Arguments.Select(Visit); return(Expression.New(expression.Constructor, arguments, expression.Members)); }
/// <summary> /// Creates a <see cref="ListInitExpression"/> that uses a method named "Add" to add elements to a collection. /// </summary> /// <param name="newExpression">A <see cref="NewExpression"/> to set the <see cref="P:ListInitExpression.NewExpression"/> property equal to.</param> /// <param name="initializers">An <see cref="IEnumerable{T}"/> that contains <see cref="M:ElementInit"/> objects to use to populate the <see cref="ListInitExpression.Initializers"/> collection.</param> /// <returns>A <see cref="ListInitExpression"/> that has the <see cref="P:ListInitExpression.NodeType"/> property equal to ListInit and the <see cref="P:ListInitExpression.NewExpression"/> property set to the specified value.</returns> public static ListInitExpression ListInit(NewExpression newExpression, IEnumerable<Expression> initializers) { ContractUtils.RequiresNotNull(newExpression, "newExpression"); ContractUtils.RequiresNotNull(initializers, "initializers"); var initializerlist = initializers.ToReadOnly(); if (initializerlist.Count == 0) { throw Error.ListInitializerWithZeroMembers(); } MethodInfo addMethod = FindMethod(newExpression.Type, "Add", null, new Expression[] { initializerlist[0] }, BindingFlags.Instance | BindingFlags.Public | BindingFlags.NonPublic); return ListInit(newExpression, addMethod, initializers); }
protected virtual T VisitNew(NewExpression exp) { throw new NotImplementedException(exp.ToString()); }
/// <summary> /// Creates a <see cref="ListInitExpression"/> that uses specified <see cref="M:ElementInit"/> objects to initialize a collection. /// </summary> /// <param name="newExpression">A <see cref="NewExpression"/> to set the <see cref="P:ListInitExpression.NewExpression"/> property equal to.</param> /// <param name="initializers">An <see cref="IEnumerable{T}"/> that contains <see cref="M:ElementInit"/> objects to use to populate the <see cref="ListInitExpression.Initializers"/> collection.</param> /// <returns>An <see cref="IEnumerable{T}"/> that contains <see cref="M:ElementInit"/> objects to use to populate the <see cref="ListInitExpression.Initializers"/> collection.</returns> /// <remarks> /// The <see cref="P:Expressions.Type"/> property of <paramref name="newExpression"/> must represent a type that implements <see cref="System.Collections.IEnumerable"/>. /// The <see cref="P:Expressions.Type"/> property of the resulting <see cref="ListInitExpression"/> is equal to newExpression.Type. /// </remarks> public static ListInitExpression ListInit(NewExpression newExpression, IEnumerable<ElementInit> initializers) { ContractUtils.RequiresNotNull(newExpression, "newExpression"); ContractUtils.RequiresNotNull(initializers, "initializers"); var initializerlist = initializers.ToReadOnly(); if (initializerlist.Count == 0) { throw Error.ListInitializerWithZeroMembers(); } ValidateListInitArgs(newExpression.Type, initializerlist); return new ListInitExpression(newExpression, initializerlist); }
protected override Expression VisitNew(NewExpression node) { return(GiveUp(node)); }
static void HandleNewExpression(NewExpression nex, ArgumentsResolutionResult res, IEditorData Editor, ResolverContextStack ctxt, IBlockNode curBlock) { res.MethodIdentifier = nex; CalculateCurrentArgument(nex, res, Editor.CaretLocation, ctxt); var type = TypeDeclarationResolver.ResolveSingle(nex.Type, ctxt) as ClassType; //TODO: Inform the user that only classes can be instantiated if (type != null) { var constructors = new List<DMethod>(); bool explicitCtorFound = false; foreach (var member in type.Definition) { var dm = member as DMethod; if (dm != null && dm.SpecialType == DMethod.MethodType.Constructor) { explicitCtorFound = true; if (!dm.IsPublic) { var curNode = curBlock; bool pass = false; do { if (curNode == type.Definition) { pass = true; break; } } while ((curNode = curNode.Parent as IBlockNode) != curNode); if (!pass) continue; } constructors.Add(dm); } } if (constructors.Count == 0) { if (explicitCtorFound) { // TODO: Somehow inform the user that the current class can't be instantiated } else { // Introduce default constructor constructors.Add(new DMethod(DMethod.MethodType.Constructor) { Description = "Default constructor for " + type.Name, Parent = type.Definition }); } } // Wrapp all ctor members in MemberSymbols var _ctors = new List<AbstractType>(); foreach (var ctor in constructors) _ctors.Add(new MemberSymbol(ctor, type, nex.Type)); res.ResolvedTypesOrMethods = _ctors.ToArray(); //TODO: Probably pre-select the current ctor by handling previously typed arguments etc. } }
protected override NewExpression VisitNew(NewExpression nex) { return(nex); }
private static void HandleNewExpression_Ctor(NewExpression nex, IBlockNode curBlock, List<AbstractType> _ctors, AbstractType t) { var udt = t as TemplateIntermediateType; if (udt is ClassType || udt is StructType) { bool explicitCtorFound = false; var constructors = new List<DMethod>(); //TODO: Mixed-in ctors? --> Convert to AbstractVisitor/use NameScan foreach (var member in udt.Definition) { var dm = member as DMethod; if (dm != null && dm.SpecialType == DMethod.MethodType.Constructor) { explicitCtorFound = true; if (!dm.IsPublic) { var curNode = curBlock; bool pass = false; do { if (curNode == udt.Definition) { pass = true; break; } } while ((curNode = curNode.Parent as IBlockNode) != curNode); if (!pass) continue; } constructors.Add(dm); } } if (constructors.Count == 0) { if (explicitCtorFound) { // TODO: Somehow inform the user that the current class can't be instantiated } else { // Introduce default constructor constructors.Add(new DMethod(DMethod.MethodType.Constructor) { Description = "Default constructor for " + udt.Name, Parent = udt.Definition }); } } // Wrapp all ctor members in MemberSymbols foreach (var ctor in constructors) _ctors.Add(new MemberSymbol(ctor, t, nex.Type)); } }
protected virtual Expression VisitNew(NewExpression node, Type expectedType) => VisitBase(node, base.VisitNew);
public virtual void PostWalk(NewExpression node) { }
protected sealed override Expression VisitNew(NewExpression node) => VisitNew(node, CurrentExpectedType);
/// <summary> /// NewExpression visit method /// </summary> /// <param name="nex">The NewExpression to visit</param> /// <returns>The visited NewExpression</returns> internal override NewExpression VisitNew(NewExpression nex) { throw new NotSupportedException(Strings.ALinq_NewNotSupported); }
protected abstract void WriteNew(NewExpression expr);
///<summary>Creates a <see cref="T:System.Linq.Expressions.MemberInitExpression" />.</summary> ///<returns>A <see cref="T:System.Linq.Expressions.MemberInitExpression" /> that has the <see cref="P:System.Linq.Expressions.Expression.NodeType" /> property equal to <see cref="F:System.Linq.Expressions.ExpressionType.MemberInit" /> and the <see cref="P:System.Linq.Expressions.MemberInitExpression.NewExpression" /> and <see cref="P:System.Linq.Expressions.MemberInitExpression.Bindings" /> properties set to the specified values.</returns> ///<param name="newExpression">A <see cref="T:System.Linq.Expressions.NewExpression" /> to set the <see cref="P:System.Linq.Expressions.MemberInitExpression.NewExpression" /> property equal to.</param> ///<param name="bindings">An <see cref="T:System.Collections.Generic.IEnumerable`1" /> that contains <see cref="T:System.Linq.Expressions.MemberBinding" /> objects to use to populate the <see cref="P:System.Linq.Expressions.MemberInitExpression.Bindings" /> collection.</param> ///<exception cref="T:System.ArgumentNullException"> ///<paramref name="newExpression" /> or <paramref name="bindings" /> is null.</exception> ///<exception cref="T:System.ArgumentException">The <see cref="P:System.Linq.Expressions.MemberBinding.Member" /> property of an element of <paramref name="bindings" /> does not represent a member of the type that <paramref name="newExpression" />.Type represents.</exception> public static MemberInitExpression MemberInit(NewExpression newExpression, IEnumerable<MemberBinding> bindings) { ContractUtils.RequiresNotNull(newExpression, "newExpression"); ContractUtils.RequiresNotNull(bindings, "bindings"); var roBindings = bindings.ToReadOnly(); ValidateMemberInitArgs(newExpression.Type, roBindings); return new MemberInitExpression(newExpression, roBindings); }
internal static ListInitExpression Update(this ListInitExpression listInitExp, NewExpression newExp, IEnumerable <ElementInit> initializers) { if (newExp != listInitExp.NewExpression || initializers != listInitExp.Initializers) { return(Expression.ListInit(newExp, initializers)); } return(listInitExp); }
public static bool ScanForConstructors(NewExpression sr, IBlockNode scope, UserDefinedType udt, List<AbstractType> _ctors, out bool explicitCtorFound) { explicitCtorFound = false; var ct = new CtorScan(sr, new ResolutionContext(new Misc.LegacyParseCacheView(new RootPackage[] {}), null, scope)); ct.DeepScanClass(udt, new ItemCheckParameters(MemberFilter.Methods), false); _ctors.AddRange(ct.matches_types); var rawList = (udt.Definition as DClassLike)[DMethod.ConstructorIdentifierHash]; if(rawList != null) { foreach(var n in rawList) { var dm = n as DMethod; if(dm == null || dm.IsStatic || dm.SpecialType != DMethod.MethodType.Constructor) continue; explicitCtorFound = true; break; } } return ct.matches_types.Count != 0; }
internal static MemberInitExpression Update(this MemberInitExpression memberInitExp, NewExpression newExp, IEnumerable <MemberBinding> bindings) { if (newExp != memberInitExp.NewExpression || bindings != memberInitExp.Bindings) { return(Expression.MemberInit(newExp, bindings)); } return(memberInitExp); }
public void Visit(NewExpression nex) { res.MethodIdentifier = nex; CalculateCurrentArgument(nex, res, Editor.CaretLocation, ctxt); var type = TypeDeclarationResolver.ResolveSingle(nex.Type, ctxt); var _ctors = new List<AbstractType>(); if (type is AmbiguousType) foreach (var t in (type as AmbiguousType).Overloads) HandleNewExpression_Ctor(nex, curScope, _ctors, t); else HandleNewExpression_Ctor(nex, curScope, _ctors, type); res.ResolvedTypesOrMethods = _ctors.ToArray(); }
/// <summary> /// 处理构造函数调用表达式 /// </summary> /// <param name="expression">表达式</param> /// <returns>表达式</returns> protected virtual Expression VisitNew(NewExpression expression) { return(expression); }
/// <summary> /// Creates a <see cref="ListInitExpression"/> that uses a method named "Add" to add elements to a collection. /// </summary> /// <param name="newExpression">A <see cref="NewExpression"/> to set the <see cref="P:ListInitExpression.NewExpression"/> property equal to.</param> /// <param name="initializers">An array of <see cref="Expression"/> objects to use to populate the <see cref="ListInitExpression.Initializers"/> collection.</param> /// <returns>A <see cref="ListInitExpression"/> that has the <see cref="P:ListInitExpression.NodeType"/> property equal to ListInit and the <see cref="P:ListInitExpression.NewExpression"/> property set to the specified value.</returns> public static ListInitExpression ListInit(NewExpression newExpression, params Expression[] initializers) { ContractUtils.RequiresNotNull(newExpression, "newExpression"); ContractUtils.RequiresNotNull(initializers, "initializers"); return ListInit(newExpression, initializers as IEnumerable<Expression>); }
private bool CompareNew(NewExpression a, NewExpression b) => Equals(a.Constructor, b.Constructor) && CompareExpressionList(a.Arguments, b.Arguments) && CompareMemberList(a.Members, b.Members);
/// <summary> /// Creates a <see cref="ListInitExpression"/> that uses a specified method to add elements to a collection. /// </summary> /// <param name="newExpression">A <see cref="NewExpression"/> to set the <see cref="P:ListInitExpression.NewExpression"/> property equal to.</param> /// <param name="addMethod">A <see cref="MethodInfo"/> that represents an instance method named "Add" (case insensitive), that adds an element to a collection. </param> /// <param name="initializers">An array of <see cref="Expression"/> objects to use to populate the <see cref="ListInitExpression.Initializers"/> collection.</param> /// <returns>A <see cref="ListInitExpression"/> that has the <see cref="P:ListInitExpression.NodeType"/> property equal to ListInit and the <see cref="P:ListInitExpression.NewExpression"/> property set to the specified value.</returns> public static ListInitExpression ListInit(NewExpression newExpression, MethodInfo addMethod, params Expression[] initializers) { if (addMethod == null) { return ListInit(newExpression, initializers as IEnumerable<Expression>); } ContractUtils.RequiresNotNull(newExpression, "newExpression"); ContractUtils.RequiresNotNull(initializers, "initializers"); return ListInit(newExpression, addMethod, initializers as IEnumerable<Expression>); }
/// <summary> /// Creates a new KeyExpressionTransformer /// </summary> /// <param name="querySourceReference">QuerySourceReferenceExpression that references an IQuerySource returning an IGrouping</param> /// <param name="newExpression">NewExpression which was used to create the multipart key for grouping</param> public MultiKeyExpressionTransfomer(QuerySourceReferenceExpression querySourceReference, NewExpression newExpression) { if (querySourceReference == null) { throw new ArgumentNullException("querySourceReference"); } if (newExpression == null) { throw new ArgumentNullException("newExpression"); } _querySourceReference = querySourceReference; _keyPropertyInfo = querySourceReference.ReferencedQuerySource.ItemType.GetProperty("Key"); _newExpression = newExpression; }
/// <summary> /// Creates a <see cref="ListInitExpression"/> that uses specified <see cref="M:ElementInit"/> objects to initialize a collection. /// </summary> /// <param name="newExpression">A <see cref="NewExpression"/> to set the <see cref="P:ListInitExpression.NewExpression"/> property equal to.</param> /// <param name="initializers">An array that contains <see cref="M:ElementInit"/> objects to use to populate the <see cref="ListInitExpression.Initializers"/> collection.</param> /// <returns> /// A <see cref="ListInitExpression"/> that has the <see cref="P:Expressions.NodeType"/> property equal to ListInit /// and the <see cref="P:ListInitExpression.NewExpression"/> and <see cref="P:ListInitExpression.Initializers"/> properties set to the specified values. /// </returns> /// <remarks> /// The <see cref="P:Expressions.Type"/> property of <paramref name="newExpression"/> must represent a type that implements <see cref="System.Collections.IEnumerable"/>. /// The <see cref="P:Expressions.Type"/> property of the resulting <see cref="ListInitExpression"/> is equal to newExpression.Type. /// </remarks> public static ListInitExpression ListInit(NewExpression newExpression, params ElementInit[] initializers) { return ListInit(newExpression, (IEnumerable<ElementInit>)initializers); }
private IBsonSerializer BuildNew(NewExpression node) { var mapping = ProjectionMapper.Map(node); return(BuildProjectedSerializer(mapping)); }
internal ListInitExpression(NewExpression newExpression, ReadOnlyCollection<ElementInit> initializers) { _newExpression = newExpression; _initializers = initializers; }
protected override Expression VisitNew(NewExpression node) { SetValue(node); return(node); }
public void Visit(NewExpression expression) { outStream.Write("new "); expression.Function.Accept(this); outStream.Write("("); if (expression.Arguments.Count > 0) { expression.Arguments.First().Accept(this); foreach (var a in expression.Arguments.Skip(1)) { outStream.Write(", "); a.Accept(this); } } outStream.Write(")"); }
public static ConstructorDefinition CreateConstructorGenerator(NewExpression newExpr) { return(new ConstructorDefinition( newExpr.Constructor, newExpr.Arguments.Select(ParseGeneratorVariable).ToArray())); }
public NewExpressionProxy(NewExpression node) { _node = node; }
public static BotConfiguration ParseConstructor(NewExpression newExpr) { var constructorGenerator = CreateConstructorGenerator(newExpr); return(new BotConfiguration(newExpr.Type, constructorGenerator)); }
static void HandleNewExpression(NewExpression nex, ArgumentsResolutionResult res, IEditorData Editor, ResolutionContext ctxt, IBlockNode curBlock, IEnumerable<AbstractType> resultBases = null) { res.MethodIdentifier = nex; CalculateCurrentArgument(nex, res, Editor.CaretLocation, ctxt); var type = TypeDeclarationResolver.ResolveSingle(nex.Type, ctxt); var _ctors = new List<AbstractType>(); if (type is AmbiguousType) foreach (var t in (type as AmbiguousType).Overloads) HandleNewExpression_Ctor(nex, curBlock, _ctors, t); else HandleNewExpression_Ctor(nex, curBlock, _ctors, type); res.ResolvedTypesOrMethods = _ctors.ToArray(); }
internal ListInitExpression(NewExpression newExpression, ReadOnlyCollection <ElementInit> initializers) : base(ExpressionType.ListInit, newExpression.Type) { NewExpression = newExpression; Initializers = initializers; }
// NewExpression public virtual bool Walk(NewExpression node) { return true; }
protected override Expression VisitNew(NewExpression expression) { VisitArguments(expression.Arguments); return(expression); }
// NewExpression public override bool Walk(NewExpression node) { return false; }
public void VisitNewExpression(NewExpression newExpression) { VisitExpression(newExpression.Expression); }
// NewExpression protected internal virtual bool Walk(NewExpression node) { return true; }
/// <summary> /// Creates a new expression that is like this one, but using the /// supplied children. If all of the children are the same, it will /// return this expression. /// </summary> /// <param name="newExpression">The <see cref="NewExpression" /> property of the result.</param> /// <param name="bindings">The <see cref="Bindings" /> property of the result.</param> /// <returns>This expression if no children changed, or an expression with the updated children.</returns> public MemberInitExpression Update(NewExpression newExpression, IEnumerable<MemberBinding> bindings) { if (newExpression == NewExpression && bindings == Bindings) { return this; } return Expression.MemberInit(newExpression, bindings); }
public void VisitNewExpression(NewExpression newExpr) { newExpr.CreationExpression.AcceptWalker(this); }
internal ConstructorWalker FromConstrucorNode(NewExpression exp) { return(new ConstructorWalker(exp.Constructor, rootCriteria)); }