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


C# DynamicMetaObject.Append方法代码示例

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


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

示例1: InvokeIndexer

 private DynamicMetaObject InvokeIndexer(DynamicMetaObject target, DynamicMetaObject[] indexes, DynamicMetaObject value, DynamicMetaObject errorSuggestion, string methodName)
 {
     DynamicMetaObject dynamicMetaObject;
     Func<Expression, Expression, Expression, Expression> func = null;
     MethodInfo methodInfo = PSInvokeMemberBinder.FindBestMethod(target, indexes.Append<DynamicMetaObject>(value), string.Concat("set_", methodName), false, this._constraints);
     if (methodInfo != null)
     {
         ParameterInfo[] parameters = methodInfo.GetParameters();
         if ((int)parameters.Length == (int)indexes.Length + 1)
         {
             Expression[] expressionArray = new Expression[(int)parameters.Length];
             int num = 0;
             while (num < (int)parameters.Length)
             {
                 Type parameterType = parameters[num].ParameterType;
                 Expression[] expressionArray1 = expressionArray;
                 int num1 = num;
                 if (num == (int)parameters.Length - 1)
                 {
                     dynamicMetaObject = value;
                 }
                 else
                 {
                     dynamicMetaObject = indexes[num];
                 }
                 expressionArray1[num1] = PSGetIndexBinder.ConvertIndex(dynamicMetaObject, parameterType);
                 if (expressionArray[num] != null)
                 {
                     num++;
                 }
                 else
                 {
                     DynamicMetaObject dynamicMetaObject1 = errorSuggestion;
                     DynamicMetaObject dynamicMetaObject2 = dynamicMetaObject1;
                     if (dynamicMetaObject1 == null)
                     {
                         dynamicMetaObject2 = PSConvertBinder.ThrowNoConversion(target, parameterType, this, this._version, indexes.Append<DynamicMetaObject>(value).ToArray<DynamicMetaObject>());
                     }
                     return dynamicMetaObject2;
                 }
             }
             if ((int)parameters.Length == 2 && parameters[0].ParameterType.Equals(typeof(int)) && target.Value as IDictionary == null)
             {
                 PropertyInfo property = target.LimitType.GetProperty("Length");
                 PropertyInfo propertyInfo = property;
                 if (property == null)
                 {
                     propertyInfo = target.LimitType.GetProperty("Count");
                 }
                 PropertyInfo propertyInfo1 = propertyInfo;
                 if (propertyInfo1 != null)
                 {
                     PSSetIndexBinder pSSetIndexBinder = this;
                     DynamicMetaObject dynamicMetaObject3 = new DynamicMetaObject(target.Expression.Cast(target.LimitType), target.PSGetTypeRestriction());
                     DynamicMetaObject dynamicMetaObject4 = new DynamicMetaObject(expressionArray[0], indexes[0].PSGetTypeRestriction());
                     DynamicMetaObject dynamicMetaObject5 = new DynamicMetaObject(expressionArray[1], value.PSGetTypeRestriction());
                     PropertyInfo propertyInfo2 = propertyInfo1;
                     if (func == null)
                     {
                         func = (Expression t, Expression i, Expression v) => Expression.Call(t, methodInfo, i, v);
                     }
                     return pSSetIndexBinder.IndexWithNegativeChecks(dynamicMetaObject3, dynamicMetaObject4, dynamicMetaObject5, propertyInfo2, func);
                 }
             }
             BindingRestrictions bindingRestriction = target.CombineRestrictions(indexes).Merge(value.PSGetTypeRestriction());
             bindingRestriction = bindingRestriction.Merge(BinderUtils.GetVersionCheck(this, this._version));
             bindingRestriction = bindingRestriction.Merge(BinderUtils.GetLanguageModeCheckIfHasEverUsedConstrainedLanguage());
             Expression expression = expressionArray[(int)expressionArray.Length - 1];
             ParameterExpression parameterExpression = Expression.Parameter(expression.Type, "value");
             expressionArray[(int)expressionArray.Length - 1] = parameterExpression;
             ParameterExpression[] parameterExpressionArray = new ParameterExpression[1];
             parameterExpressionArray[0] = parameterExpression;
             Expression[] expressionArray2 = new Expression[3];
             expressionArray2[0] = Expression.Assign(parameterExpression, expression);
             expressionArray2[1] = Expression.Call(target.Expression.Cast(target.LimitType), methodInfo, expressionArray);
             expressionArray2[2] = parameterExpression.Cast(typeof(object));
             return new DynamicMetaObject(Expression.Block(parameterExpressionArray, expressionArray2), bindingRestriction);
         }
         else
         {
             DynamicMetaObject dynamicMetaObject6 = errorSuggestion;
             DynamicMetaObject dynamicMetaObject7 = dynamicMetaObject6;
             if (dynamicMetaObject6 == null)
             {
                 dynamicMetaObject7 = this.CannotIndexTarget(target, indexes, value);
             }
             return dynamicMetaObject7;
         }
     }
     else
     {
         DynamicMetaObject dynamicMetaObject8 = errorSuggestion;
         DynamicMetaObject dynamicMetaObject9 = dynamicMetaObject8;
         if (dynamicMetaObject8 == null)
         {
             dynamicMetaObject9 = this.CannotIndexTarget(target, indexes, value);
         }
         return dynamicMetaObject9;
     }
 }
开发者ID:nickchal,项目名称:pash,代码行数:100,代码来源:PSSetIndexBinder.cs


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