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


C# DynamicMetaObject.PSGetTypeRestriction方法代码示例

本文整理汇总了C#中System.Dynamic.DynamicMetaObject.PSGetTypeRestriction方法的典型用法代码示例。如果您正苦于以下问题:C# DynamicMetaObject.PSGetTypeRestriction方法的具体用法?C# DynamicMetaObject.PSGetTypeRestriction怎么用?C# DynamicMetaObject.PSGetTypeRestriction使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在System.Dynamic.DynamicMetaObject的用法示例。


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

示例1: CannotIndexTarget

 private DynamicMetaObject CannotIndexTarget(DynamicMetaObject target, DynamicMetaObject[] indexes, DynamicMetaObject value)
 {
     BindingRestrictions bindingRestriction = value.PSGetTypeRestriction();
     bindingRestriction = bindingRestriction.Merge(BinderUtils.GetVersionCheck(this, this._version));
     bindingRestriction = bindingRestriction.Merge(BinderUtils.GetLanguageModeCheckIfHasEverUsedConstrainedLanguage());
     Expression[] expressionArray = new Expression[1];
     expressionArray[0] = Expression.Constant(target.LimitType);
     return target.ThrowRuntimeError(indexes, bindingRestriction, "CannotIndex", ParserStrings.CannotIndex, expressionArray);
 }
开发者ID:nickchal,项目名称:pash,代码行数:9,代码来源:PSSetIndexBinder.cs

示例2: Bind

 public override DynamicMetaObject Bind(DynamicMetaObject target, DynamicMetaObject[] args)
 {
     bool flag;
     if (!target.HasValue)
     {
         return base.Defer(target, new DynamicMetaObject[0]).WriteToDebugLog(this);
     }
     Type resultType = ((target.Value is OrderedDictionary) || (target.Value is Hashtable)) ? typeof(LanguagePrimitives.InternalPSCustomObject) : typeof(PSObject);
     return new DynamicMetaObject(PSConvertBinder.InvokeConverter(LanguagePrimitives.FigureConversion(target.Value, resultType, out flag), target.Expression, resultType, flag, ExpressionCache.InvariantCulture), target.PSGetTypeRestriction()).WriteToDebugLog(this);
 }
开发者ID:nickchal,项目名称:pash,代码行数:10,代码来源:PSCustomObjectConverter.cs

示例3: FallbackConvert

 public override DynamicMetaObject FallbackConvert(DynamicMetaObject target, DynamicMetaObject errorSuggestion)
 {
     bool flag;
     if (!target.HasValue)
     {
         return base.Defer(target, new DynamicMetaObject[0]).WriteToDebugLog(this);
     }
     if (target.Value == AutomationNull.Value)
     {
         return new DynamicMetaObject(Expression.Default(base.Type), target.PSGetTypeRestriction()).WriteToDebugLog(this);
     }
     Type resultType = base.Type;
     LanguagePrimitives.ConversionData conversion = LanguagePrimitives.FigureConversion(target.Value, resultType, out flag);
     if ((errorSuggestion != null) && (target.Value is DynamicObject))
     {
         return errorSuggestion.WriteToDebugLog(this);
     }
     BindingRestrictions restrictions = target.PSGetTypeRestriction().Merge(BinderUtils.GetOptionalVersionAndLanguageCheckForType(this, resultType, this._version));
     return new DynamicMetaObject(InvokeConverter(conversion, target.Expression, resultType, flag, ExpressionCache.InvariantCulture), restrictions).WriteToDebugLog(this);
 }
开发者ID:nickchal,项目名称:pash,代码行数:20,代码来源:PSConvertBinder.cs

示例4: Bind

 public override DynamicMetaObject Bind(DynamicMetaObject target, DynamicMetaObject[] args)
 {
     if (!target.HasValue)
     {
         return base.Defer(target, args);
     }
     if ((target.Value is PSObject) && (PSObject.Base(target.Value) != target.Value))
     {
         return this.DeferForPSObject(new DynamicMetaObject[] { target }).WriteToDebugLog(this);
     }
     DynamicMetaObject obj2 = PSEnumerableBinder.IsEnumerable(target);
     if (obj2 == null)
     {
         return new DynamicMetaObject(Expression.NewArrayInit(typeof(object), new Expression[] { target.Expression.Cast(typeof(object)) }), target.PSGetTypeRestriction()).WriteToDebugLog(this);
     }
     if (PSObject.Base(target.Value) is ArrayList)
     {
         return new DynamicMetaObject(Expression.Call(PSEnumerableBinder.MaybeDebase(this, e => e.Cast(typeof(ArrayList)), target), CachedReflectionInfo.ArrayList_ToArray), PSEnumerableBinder.GetRestrictions(target)).WriteToDebugLog(this);
     }
     return new DynamicMetaObject(Expression.Call(CachedReflectionInfo.EnumerableOps_ToArray, obj2.Expression), target.PSGetTypeRestriction()).WriteToDebugLog(this);
 }
开发者ID:nickchal,项目名称:pash,代码行数:21,代码来源:PSToObjectArrayBinder.cs

示例5: Bind

 public override DynamicMetaObject Bind(DynamicMetaObject target, DynamicMetaObject[] args)
 {
     if (!target.HasValue || !args[0].HasValue)
     {
         return base.Defer(target, args).WriteToDebugLog(this);
     }
     if ((target.Value is PSObject) && (PSObject.Base(target.Value) != target.Value))
     {
         return this.DeferForPSObject(new DynamicMetaObject[] { target, args[0] }).WriteToDebugLog(this);
     }
     BindingRestrictions restrictions = target.PSGetTypeRestriction();
     if (target.LimitType.Equals(typeof(string)))
     {
         return new DynamicMetaObject(target.Expression.Cast(typeof(string)), restrictions).WriteToDebugLog(this);
     }
     return new DynamicMetaObject(InvokeToString(args[0].Expression, target.Expression), restrictions).WriteToDebugLog(this);
 }
开发者ID:nickchal,项目名称:pash,代码行数:17,代码来源:PSToStringBinder.cs

示例6: Bind

 public override DynamicMetaObject Bind(DynamicMetaObject target, DynamicMetaObject[] args)
 {
     if (!target.HasValue)
     {
         return base.Defer(target, args);
     }
     if (target.Value == AutomationNull.Value)
     {
         return new DynamicMetaObject(Expression.Block(typeof(void), new Expression[] { Expression.Call(CachedReflectionInfo.PipelineOps_Nop, new Expression[0]) }), BindingRestrictions.GetInstanceRestriction(target.Expression, AutomationNull.Value)).WriteToDebugLog(this);
     }
     DynamicMetaObject obj2 = PSEnumerableBinder.IsEnumerable(target);
     if (obj2 == null)
     {
         DynamicMetaObject obj3 = PSVariableAssignmentBinder.Get().Bind(target, new DynamicMetaObject[0]);
         BindingRestrictions restrictions = target.LimitType.IsValueType ? obj3.Restrictions : target.PSGetTypeRestriction();
         return new DynamicMetaObject(Expression.Call(args[0].Expression, CachedReflectionInfo.Pipe_Add, new Expression[] { obj3.Expression.Cast(typeof(object)) }), restrictions).WriteToDebugLog(this);
     }
     bool b = !(PSObject.Base(target.Value) is IEnumerator);
     return new DynamicMetaObject(Expression.Call(CachedReflectionInfo.EnumerableOps_WriteEnumerableToPipe, obj2.Expression, args[0].Expression, args[1].Expression, ExpressionCache.Constant(b)), obj2.Restrictions).WriteToDebugLog(this);
 }
开发者ID:nickchal,项目名称:pash,代码行数:20,代码来源:PSPipeWriterBinder.cs

示例7: Bind

 public override DynamicMetaObject Bind(DynamicMetaObject target, DynamicMetaObject[] args)
 {
     string str;
     Expression expression;
     BindingRestrictions restrictions;
     if (!target.HasValue || !args[0].HasValue)
     {
         return base.Defer(target, new DynamicMetaObject[] { args[0] }).WriteToDebugLog(this);
     }
     DynamicMetaObject obj2 = args[0];
     object obj3 = PSObject.Base(obj2.Value);
     if (obj3 is string)
     {
         str = (string) obj3;
         if (obj2.Value is PSObject)
         {
             expression = Expression.Call(CachedReflectionInfo.PSObject_Base, obj2.Expression).Cast(typeof(string));
         }
         else
         {
             expression = obj2.Expression.Cast(typeof(string));
         }
     }
     else
     {
         if (target.Value is IDictionary)
         {
             restrictions = target.PSGetTypeRestriction().Merge(BindingRestrictions.GetExpressionRestriction(Expression.Not(Expression.TypeIs(args[0].Expression, typeof(string)))));
             return new DynamicMetaObject(Expression.Call(CachedReflectionInfo.PSGetDynamicMemberBinder_GetIDictionaryMember, target.Expression.Cast(typeof(IDictionary)), args[0].Expression.Cast(typeof(object))), restrictions).WriteToDebugLog(this);
         }
         str = PSObject.ToStringParser(null, obj3);
         expression = PSToStringBinder.InvokeToString(ExpressionCache.NullConstant, obj2.Expression);
     }
     DynamicMetaObject obj4 = PSGetMemberBinder.Get(str, this._static).FallbackGetMember(target);
     restrictions = obj4.Restrictions.Merge(args[0].PSGetTypeRestriction()).Merge(BindingRestrictions.GetExpressionRestriction(Expression.Call(CachedReflectionInfo.String_Equals, Expression.Constant(str), expression, ExpressionCache.Ordinal)));
     return new DynamicMetaObject(obj4.Expression, restrictions).WriteToDebugLog(this);
 }
开发者ID:nickchal,项目名称:pash,代码行数:37,代码来源:PSGetDynamicMemberBinder.cs

示例8: BinarySubDivOrRem

 private DynamicMetaObject BinarySubDivOrRem(DynamicMetaObject target, DynamicMetaObject arg, DynamicMetaObject errorSuggestion, string numericOpMethodName, string implicitOpMethodName, string errorOperatorText)
 {
     if (target.Value == null)
     {
         target = new DynamicMetaObject(ExpressionCache.Constant(0), target.PSGetTypeRestriction(), (object)0);
     }
     if (target.LimitType.IsNumericOrPrimitive())
     {
         DynamicMetaObject argAsNumericOrPrimitive = PSBinaryOperationBinder.GetArgAsNumericOrPrimitive(arg, target.LimitType);
         if (argAsNumericOrPrimitive == null)
         {
             if (arg.LimitType.Equals(typeof(string)))
             {
                 return this.BinaryNumericStringOp(target, arg);
             }
         }
         else
         {
             return this.BinaryNumericOp(numericOpMethodName, target, argAsNumericOrPrimitive);
         }
     }
     if (!target.LimitType.Equals(typeof(string)))
     {
         return PSBinaryOperationBinder.CallImplicitOp(implicitOpMethodName, target, arg, errorOperatorText, errorSuggestion);
     }
     else
     {
         return this.BinaryNumericStringOp(target, arg);
     }
 }
开发者ID:nickchal,项目名称:pash,代码行数:30,代码来源:PSBinaryOperationBinder.cs

示例9: BinaryMultiply

 private DynamicMetaObject BinaryMultiply(DynamicMetaObject target, DynamicMetaObject arg, DynamicMetaObject errorSuggestion)
 {
     Expression expression;
     Expression expression1;
     if (target.Value != null)
     {
         if (target.LimitType.IsNumeric())
         {
             DynamicMetaObject argAsNumericOrPrimitive = PSBinaryOperationBinder.GetArgAsNumericOrPrimitive(arg, target.LimitType);
             if (argAsNumericOrPrimitive == null)
             {
                 if (arg.LimitType.Equals(typeof(string)))
                 {
                     return this.BinaryNumericStringOp(target, arg);
                 }
             }
             else
             {
                 return this.BinaryNumericOp("Multiply", target, argAsNumericOrPrimitive);
             }
         }
         if (!target.LimitType.Equals(typeof(string)))
         {
             DynamicMetaObject dynamicMetaObject = PSEnumerableBinder.IsEnumerable(target);
             if (dynamicMetaObject == null)
             {
                 return PSBinaryOperationBinder.CallImplicitOp("op_Multiply", target, arg, "*", errorSuggestion);
             }
             else
             {
                 if (arg.LimitType.Equals(typeof(string)))
                 {
                     expression = PSBinaryOperationBinder.ConvertStringToNumber(arg.Expression, typeof(int)).Convert(typeof(int));
                 }
                 else
                 {
                     expression = arg.CastOrConvert(typeof(int));
                 }
                 Expression expression2 = expression;
                 if (!target.LimitType.IsArray)
                 {
                     DynamicMetaObject[] dynamicMetaObjectArray = new DynamicMetaObject[1];
                     dynamicMetaObjectArray[0] = arg;
                     return new DynamicMetaObject(Expression.Call(CachedReflectionInfo.EnumerableOps_Multiply, dynamicMetaObject.Expression, expression2), target.CombineRestrictions(dynamicMetaObjectArray));
                 }
                 else
                 {
                     Type elementType = target.LimitType.GetElementType();
                     Type[] typeArray = new Type[1];
                     typeArray[0] = elementType;
                     DynamicMetaObject[] dynamicMetaObjectArray1 = new DynamicMetaObject[1];
                     dynamicMetaObjectArray1[0] = arg;
                     return new DynamicMetaObject(Expression.Call(CachedReflectionInfo.ArrayOps_Multiply.MakeGenericMethod(typeArray), target.Expression.Cast(elementType.MakeArrayType()), expression2), target.CombineRestrictions(dynamicMetaObjectArray1));
                 }
             }
         }
         else
         {
             if (arg.LimitType.Equals(typeof(string)))
             {
                 expression1 = PSBinaryOperationBinder.ConvertStringToNumber(arg.Expression, typeof(int)).Convert(typeof(int));
             }
             else
             {
                 expression1 = arg.CastOrConvert(typeof(int));
             }
             Expression expression3 = expression1;
             DynamicMetaObject[] dynamicMetaObjectArray2 = new DynamicMetaObject[1];
             dynamicMetaObjectArray2[0] = arg;
             return new DynamicMetaObject(Expression.Call(CachedReflectionInfo.StringOps_Multiply, target.Expression.Cast(typeof(string)), expression3), target.CombineRestrictions(dynamicMetaObjectArray2));
         }
     }
     else
     {
         return new DynamicMetaObject(ExpressionCache.NullConstant, target.PSGetTypeRestriction());
     }
 }
开发者ID:nickchal,项目名称:pash,代码行数:77,代码来源:PSBinaryOperationBinder.cs

示例10: BinaryEqualityComparison

 private DynamicMetaObject BinaryEqualityComparison(DynamicMetaObject target, DynamicMetaObject arg)
 {
     bool flag = false;
     Func<Expression, Expression> func;
     MethodInfo charOpsCompareIeq;
     Expression expression;
     if (base.Operation == ExpressionType.NotEqual)
     {
         func = new Func<Expression, Expression>(Expression.Not);
     }
     else
     {
         func = (Expression e) => e;
     }
     Func<Expression, Expression> func1 = func;
     if (!target.LimitType.Equals(typeof(string)))
     {
         if (target.LimitType.Equals(typeof(char)) && this._ignoreCase)
         {
             Expression expression1 = null;
             BindingRestrictions bindingRestriction = null;
             if (!arg.LimitType.Equals(typeof(char)))
             {
                 string value = arg.Value as string;
                 if (value != null && value.Length == 1)
                 {
                     Expression[] expressionArray = new Expression[1];
                     expressionArray[0] = ExpressionCache.Constant(0);
                     expression1 = Expression.Call(arg.Expression.Cast(typeof(string)), CachedReflectionInfo.String_get_Chars, expressionArray);
                     bindingRestriction = arg.PSGetTypeRestriction().Merge(BindingRestrictions.GetExpressionRestriction(Expression.Equal(Expression.Property(arg.Expression.Cast(typeof(string)), CachedReflectionInfo.String_Length), ExpressionCache.Constant(1))));
                 }
             }
             else
             {
                 expression1 = arg.Expression;
                 bindingRestriction = arg.PSGetTypeRestriction();
             }
             if (expression1 != null)
             {
                 if (base.Operation == ExpressionType.Equal)
                 {
                     charOpsCompareIeq = CachedReflectionInfo.CharOps_CompareIeq;
                 }
                 else
                 {
                     charOpsCompareIeq = CachedReflectionInfo.CharOps_CompareIne;
                 }
                 return new DynamicMetaObject(Expression.Call(charOpsCompareIeq, target.Expression.Cast(typeof(char)), expression1.Cast(typeof(char))), target.PSGetTypeRestriction().Merge(bindingRestriction));
             }
         }
         Expression[] expressionArray1 = new Expression[1];
         expressionArray1[0] = arg.Expression.Cast(typeof(object));
         Expression expression2 = Expression.Call(target.Expression.Cast(typeof(object)), CachedReflectionInfo.Object_Equals, expressionArray1);
         Type limitType = target.LimitType;
         LanguagePrimitives.ConversionData conversionDatum = LanguagePrimitives.FigureConversion(arg.Value, limitType, out flag);
         if (conversionDatum.Rank != ConversionRank.Identity)
         {
             DynamicMetaObject[] dynamicMetaObjectArray = new DynamicMetaObject[1];
             dynamicMetaObjectArray[0] = arg;
             BindingRestrictions bindingRestriction1 = target.CombineRestrictions(dynamicMetaObjectArray);
             bindingRestriction1 = bindingRestriction1.Merge(BinderUtils.GetOptionalVersionAndLanguageCheckForType(this, limitType, this._version));
             ParameterExpression parameterExpression = Expression.Parameter(typeof(bool));
             Expression[] expressionArray2 = new Expression[1];
             expressionArray2[0] = PSConvertBinder.InvokeConverter(conversionDatum, arg.Expression, limitType, flag, ExpressionCache.InvariantCulture).Cast(typeof(object));
             Expression expression3 = Expression.Call(target.Expression.Cast(typeof(object)), CachedReflectionInfo.Object_Equals, expressionArray2);
             ParameterExpression[] parameterExpressionArray = new ParameterExpression[1];
             parameterExpressionArray[0] = parameterExpression;
             Expression[] expressionArray3 = new Expression[3];
             expressionArray3[0] = Expression.Assign(parameterExpression, expression2);
             CatchBlock[] catchBlockArray = new CatchBlock[1];
             catchBlockArray[0] = Expression.Catch(typeof(InvalidCastException), Expression.Assign(parameterExpression, ExpressionCache.Constant(false)));
             expressionArray3[1] = Expression.IfThen(Expression.Not(parameterExpression), Expression.TryCatch(Expression.Assign(parameterExpression, expression3), catchBlockArray));
             expressionArray3[2] = func1(parameterExpression);
             BlockExpression blockExpression = Expression.Block(parameterExpressionArray, expressionArray3);
             return new DynamicMetaObject(blockExpression.Cast(typeof(object)), bindingRestriction1);
         }
         else
         {
             DynamicMetaObject[] dynamicMetaObjectArray1 = new DynamicMetaObject[1];
             dynamicMetaObjectArray1[0] = arg;
             return new DynamicMetaObject(func1(expression2).Cast(typeof(object)), target.CombineRestrictions(dynamicMetaObjectArray1));
         }
     }
     else
     {
         Expression expression4 = target.Expression.Cast(typeof(string));
         if (!arg.LimitType.Equals(typeof(string)))
         {
             expression = Expression.Dynamic(PSToStringBinder.Get(), typeof(string), arg.Expression, ExpressionCache.GetExecutionContextFromTLS);
         }
         else
         {
             expression = arg.Expression.Cast(typeof(string));
         }
         Expression expression5 = expression;
         DynamicMetaObject[] dynamicMetaObjectArray2 = new DynamicMetaObject[1];
         dynamicMetaObjectArray2[0] = arg;
         return new DynamicMetaObject(func1(Compiler.CallStringEquals(expression4, expression5, this._ignoreCase)).Cast(typeof(object)), target.CombineRestrictions(dynamicMetaObjectArray2));
     }
 }
开发者ID:nickchal,项目名称:pash,代码行数:100,代码来源:PSBinaryOperationBinder.cs

示例11: BinaryComparisonCommon

 private DynamicMetaObject BinaryComparisonCommon(DynamicMetaObject targetAsEnumerator, DynamicMetaObject target, DynamicMetaObject arg)
 {
     if (targetAsEnumerator == null || this._scalarCompare)
     {
         if (target.LimitType.IsNumeric())
         {
             DynamicMetaObject argAsNumericOrPrimitive = PSBinaryOperationBinder.GetArgAsNumericOrPrimitive(arg, target.LimitType);
             if (argAsNumericOrPrimitive == null)
             {
                 if (arg.LimitType.Equals(typeof(string)))
                 {
                     return this.BinaryNumericStringOp(target, arg);
                 }
             }
             else
             {
                 string str = null;
                 ExpressionType operation = base.Operation;
                 switch (operation)
                 {
                     case ExpressionType.Equal:
                         {
                             str = "CompareEq";
                             return this.BinaryNumericOp(str, target, argAsNumericOrPrimitive);
                         }
                     case ExpressionType.ExclusiveOr:
                     case ExpressionType.Invoke:
                     case ExpressionType.Lambda:
                     case ExpressionType.LeftShift:
                         {
                             return this.BinaryNumericOp(str, target, argAsNumericOrPrimitive);
                         }
                     case ExpressionType.GreaterThan:
                         {
                             str = "CompareGt";
                             return this.BinaryNumericOp(str, target, argAsNumericOrPrimitive);
                         }
                     case ExpressionType.GreaterThanOrEqual:
                         {
                             str = "CompareGe";
                             return this.BinaryNumericOp(str, target, argAsNumericOrPrimitive);
                         }
                     case ExpressionType.LessThan:
                         {
                             str = "CompareLt";
                             return this.BinaryNumericOp(str, target, argAsNumericOrPrimitive);
                         }
                     case ExpressionType.LessThanOrEqual:
                         {
                             str = "CompareLe";
                             return this.BinaryNumericOp(str, target, argAsNumericOrPrimitive);
                         }
                     default:
                         {
                             if (operation == ExpressionType.NotEqual)
                             {
                                 str = "CompareNe";
                                 return this.BinaryNumericOp(str, target, argAsNumericOrPrimitive);
                             }
                             else
                             {
                                 return this.BinaryNumericOp(str, target, argAsNumericOrPrimitive);
                             }
                         }
                 }
             }
         }
         return null;
     }
     else
     {
         return new DynamicMetaObject(Expression.Call(CachedReflectionInfo.EnumerableOps_Compare, targetAsEnumerator.Expression, arg.Expression.Cast(typeof(object)), Expression.Constant(this.GetScalarCompareDelegate())), targetAsEnumerator.Restrictions.Merge(arg.PSGetTypeRestriction()));
     }
 }
开发者ID:nickchal,项目名称:pash,代码行数:74,代码来源:PSBinaryOperationBinder.cs

示例12: Shift

 private DynamicMetaObject Shift(DynamicMetaObject target, DynamicMetaObject arg, DynamicMetaObject errorSuggestion, string userOp, Func<Expression, Expression, Expression> exprGenerator)
 {
     bool flag = false;
     Type type;
     Type type1;
     byte num;
     if (target.Value != null)
     {
         if (target.LimitType.Equals(typeof(string)) || arg.LimitType.Equals(typeof(string)))
         {
             return this.BinaryNumericStringOp(target, arg);
         }
         else
         {
             TypeCode typeCode = LanguagePrimitives.GetTypeCode(target.LimitType);
             if (target.LimitType.IsNumeric())
             {
                 Type type2 = typeof(int);
                 LanguagePrimitives.ConversionData conversionDatum = LanguagePrimitives.FigureConversion(arg.Value, type2, out flag);
                 if (conversionDatum.Rank != ConversionRank.None)
                 {
                     Expression expression = PSConvertBinder.InvokeConverter(conversionDatum, arg.Expression, type2, flag, ExpressionCache.InvariantCulture);
                     if (typeCode == TypeCode.Decimal || typeCode == TypeCode.Double || typeCode == TypeCode.Single)
                     {
                         if (typeCode == TypeCode.Decimal)
                         {
                             type = typeof(DecimalOps);
                         }
                         else
                         {
                             type = typeof(DoubleOps);
                         }
                         Type type3 = type;
                         if (typeCode == TypeCode.Decimal)
                         {
                             type1 = typeof(decimal);
                         }
                         else
                         {
                             type1 = typeof(double);
                         }
                         Type type4 = type1;
                         string str = userOp.Substring(3);
                         DynamicMetaObject[] dynamicMetaObjectArray = new DynamicMetaObject[1];
                         dynamicMetaObjectArray[0] = arg;
                         return new DynamicMetaObject(Expression.Call(type3.GetMethod(str, BindingFlags.Static | BindingFlags.NonPublic), target.Expression.Cast(type4), expression), target.CombineRestrictions(dynamicMetaObjectArray));
                     }
                     else
                     {
                         Expression expression1 = target.Expression.Cast(target.LimitType);
                         Expression expression2 = expression;
                         if (typeCode < TypeCode.Int64)
                         {
                             num = 31;
                         }
                         else
                         {
                             num = 63;
                         }
                         expression = Expression.And(expression2, Expression.Constant(num, typeof(int)));
                         DynamicMetaObject[] dynamicMetaObjectArray1 = new DynamicMetaObject[1];
                         dynamicMetaObjectArray1[0] = arg;
                         return new DynamicMetaObject(exprGenerator(expression1, expression).Cast(typeof(object)), target.CombineRestrictions(dynamicMetaObjectArray1));
                     }
                 }
                 else
                 {
                     return PSConvertBinder.ThrowNoConversion(arg, typeof(int), this, this._version, new DynamicMetaObject[0]);
                 }
             }
             else
             {
                 return PSBinaryOperationBinder.CallImplicitOp(userOp, target, arg, this.GetOperatorText(), errorSuggestion);
             }
         }
     }
     else
     {
         return new DynamicMetaObject(ExpressionCache.Constant(0).Convert(typeof(object)), target.PSGetTypeRestriction());
     }
 }
开发者ID:nickchal,项目名称:pash,代码行数:81,代码来源:PSBinaryOperationBinder.cs

示例13: GetIndexArray

 private DynamicMetaObject GetIndexArray(DynamicMetaObject target, DynamicMetaObject[] indexes, DynamicMetaObject errorSuggestion)
 {
     Array array = (Array) target.Value;
     if (array.Rank > 1)
     {
         return this.GetIndexMultiDimensionArray(target, indexes, errorSuggestion);
     }
     if (indexes.Length > 1)
     {
         if (!this._allowSlicing && (errorSuggestion == null))
         {
             return this.CannotIndexTarget(target, indexes);
         }
         return this.InvokeSlicingIndexer(target, indexes);
     }
     DynamicMetaObject obj2 = this.CheckForSlicing(target, indexes);
     if (obj2 != null)
     {
         return obj2;
     }
     Expression expression = ConvertIndex(indexes[0], typeof(int));
     if (expression == null)
     {
         return (errorSuggestion ?? PSConvertBinder.ThrowNoConversion(target, typeof(int), this, this._version, indexes));
     }
     return this.IndexWithNegativeChecks(new DynamicMetaObject(target.Expression.Cast(target.LimitType), target.PSGetTypeRestriction()), new DynamicMetaObject(expression, indexes[0].PSGetTypeRestriction()), target.LimitType.GetProperty("Length"), (t, i) => Expression.ArrayIndex(t, i).Cast(typeof(object)));
 }
开发者ID:nickchal,项目名称:pash,代码行数:27,代码来源:PSGetIndexBinder.cs

示例14: GetRestrictions

 internal static BindingRestrictions GetRestrictions(DynamicMetaObject target)
 {
     if (target.Value is PSObject)
     {
         return BindingRestrictions.GetTypeRestriction(target.Expression, typeof(PSObject));
     }
     return target.PSGetTypeRestriction();
 }
开发者ID:nickchal,项目名称:pash,代码行数:8,代码来源:PSEnumerableBinder.cs

示例15: UnaryPlus

 private DynamicMetaObject UnaryPlus(DynamicMetaObject target, DynamicMetaObject errorSuggestion)
 {
     if (!target.HasValue)
     {
         return base.Defer(target, new DynamicMetaObject[0]);
     }
     if ((target.Value is PSObject) && (PSObject.Base(target.Value) != target.Value))
     {
         return this.DeferForPSObject(new DynamicMetaObject[] { target });
     }
     if (!target.LimitType.IsNumeric())
     {
         return new DynamicMetaObject(Expression.Dynamic(PSBinaryOperationBinder.Get(ExpressionType.Add, true, false), typeof(object), ExpressionCache.Constant(0), target.Expression), target.PSGetTypeRestriction());
     }
     Expression expr = target.Expression.Cast(target.LimitType);
     if (target.LimitType.Equals(typeof(byte)) || target.LimitType.Equals(typeof(sbyte)))
     {
         expr = expr.Cast(typeof(int));
     }
     return new DynamicMetaObject(Expression.UnaryPlus(expr).Cast(typeof(object)), target.PSGetTypeRestriction());
 }
开发者ID:nickchal,项目名称:pash,代码行数:21,代码来源:PSUnaryOperationBinder.cs


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