當前位置: 首頁>>代碼示例>>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;未經允許,請勿轉載。