Microsoft.CSharp.RuntimeBinder.Semantics.ExprFactory.CreatePropertyInfo C# (CSharp) Method

CreatePropertyInfo() public method

public CreatePropertyInfo ( Microsoft.CSharp.RuntimeBinder.Semantics.PropertySymbol prop, AggregateType propertyType ) : Microsoft.CSharp.RuntimeBinder.Semantics.EXPRPropertyInfo
prop Microsoft.CSharp.RuntimeBinder.Semantics.PropertySymbol
propertyType AggregateType
return Microsoft.CSharp.RuntimeBinder.Semantics.EXPRPropertyInfo
        public EXPRPropertyInfo CreatePropertyInfo(PropertySymbol prop, AggregateType propertyType)
        {
            Debug.Assert(prop != null);
            Debug.Assert(propertyType != null);
            EXPRPropertyInfo propInfo = new EXPRPropertyInfo();

            propInfo.kind = ExpressionKind.EK_PROPERTYINFO;
            propInfo.type = GetTypes().GetOptPredefAgg(PredefinedType.PT_PROPERTYINFO).getThisType();
            propInfo.flags = 0;
            propInfo.Property = new PropWithType(prop, propertyType);

            return propInfo;
        }

Usage Example

示例#1
0
        /////////////////////////////////////////////////////////////////////////////////
        // Statement types.
        protected override Expr VisitASSIGNMENT(ExprAssignment assignment)
        {
            Debug.Assert(assignment != null);

            // For assignments, we either have a member assignment or an indexed assignment.
            //Debug.Assert(assignment.GetLHS().isPROP() || assignment.GetLHS().isFIELD() || assignment.GetLHS().isARRAYINDEX() || assignment.GetLHS().isLOCAL());
            Expr lhs;

            if (assignment.LHS is ExprProperty prop)
            {
                if (prop.OptionalArguments == null)
                {
                    // Regular property.
                    lhs = Visit(prop);
                }
                else
                {
                    // Indexed assignment. Here we need to find the instance of the object, create the
                    // PropInfo for the thing, and get the array of expressions that make up the index arguments.
                    //
                    // The LHS becomes Expression.Property(instance, indexerInfo, arguments).
                    Expr instance  = Visit(prop.MemberGroup.OptionalObject);
                    Expr propInfo  = ExprFactory.CreatePropertyInfo(prop.PropWithTypeSlot.Prop(), prop.PropWithTypeSlot.Ats);
                    Expr arguments = GenerateParamsArray(
                        GenerateArgsList(prop.OptionalArguments),
                        PredefinedType.PT_EXPRESSION);

                    lhs = GenerateCall(PREDEFMETH.PM_EXPRESSION_PROPERTY, instance, propInfo, arguments);
                }
            }
            else
            {
                lhs = Visit(assignment.LHS);
            }

            Expr rhs = Visit(assignment.RHS);

            return(GenerateCall(PREDEFMETH.PM_EXPRESSION_ASSIGN, lhs, rhs));
        }
All Usage Examples Of Microsoft.CSharp.RuntimeBinder.Semantics.ExprFactory::CreatePropertyInfo