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


C# DynamicMetaObject.Prepend方法代码示例

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


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

示例1: FallbackGetIndex

 public override DynamicMetaObject FallbackGetIndex(DynamicMetaObject target, DynamicMetaObject[] indexes, DynamicMetaObject errorSuggestion)
 {
     if (target.HasValue && !(from mo in indexes
         where !mo.HasValue
         select mo).Any<DynamicMetaObject>())
     {
         if ((!(target.Value is PSObject) || (PSObject.Base(target.Value) == target.Value)) && !(from mo in indexes
             where (mo.Value is PSObject) && (PSObject.Base(mo.Value) != mo.Value)
             select mo).Any<DynamicMetaObject>())
         {
             if (target.Value == null)
             {
                 return (errorSuggestion ?? target.ThrowRuntimeError(indexes, BindingRestrictions.Empty, "NullArray", ParserStrings.NullArray, new Expression[0])).WriteToDebugLog(this);
             }
             if (((indexes.Length == 1) && (indexes[0].Value == null)) && this._allowSlicing)
             {
                 return (errorSuggestion ?? target.ThrowRuntimeError(indexes, BindingRestrictions.Empty, "NullArrayIndex", ParserStrings.NullArrayIndex, new Expression[0])).WriteToDebugLog(this);
             }
             if (target.LimitType.IsArray)
             {
                 return this.GetIndexArray(target, indexes, errorSuggestion).WriteToDebugLog(this);
             }
             foreach (Type type in target.LimitType.GetInterfaces())
             {
                 if (type.IsGenericType && (type.GetGenericTypeDefinition() == typeof(IDictionary<,>)))
                 {
                     DynamicMetaObject obj2 = this.GetIndexDictionary(target, indexes, type);
                     if (obj2 != null)
                     {
                         return obj2.WriteToDebugLog(this);
                     }
                 }
             }
             DefaultMemberAttribute attribute = target.LimitType.GetCustomAttributes<DefaultMemberAttribute>(true).FirstOrDefault<DefaultMemberAttribute>();
             if (attribute != null)
             {
                 return this.InvokeIndexer(target, indexes, errorSuggestion, attribute.MemberName).WriteToDebugLog(this);
             }
             return (errorSuggestion ?? this.CannotIndexTarget(target, indexes).WriteToDebugLog(this));
         }
         return this.DeferForPSObject(indexes.Prepend<DynamicMetaObject>(target).ToArray<DynamicMetaObject>()).WriteToDebugLog(this);
     }
     return base.Defer(indexes.Prepend<DynamicMetaObject>(target).ToArray<DynamicMetaObject>()).WriteToDebugLog(this);
 }
开发者ID:nickchal,项目名称:pash,代码行数:44,代码来源:PSGetIndexBinder.cs

示例2: SetIndexMultiDimensionArray

 private DynamicMetaObject SetIndexMultiDimensionArray(DynamicMetaObject target, DynamicMetaObject[] indexes, DynamicMetaObject value, DynamicMetaObject errorSuggestion)
 {
     Type elementType = target.LimitType.GetElementType();
     Expression expression = PSGetIndexBinder.ConvertIndex(value, elementType);
     if (expression != null)
     {
         if ((int)indexes.Length != 1)
         {
             Array arrays = (Array)target.Value;
             if ((int)indexes.Length == arrays.Rank)
             {
                 Expression[] expressionArray = new Expression[(int)indexes.Length];
                 int num = 0;
                 while (num < (int)indexes.Length)
                 {
                     expressionArray[num] = PSGetIndexBinder.ConvertIndex(indexes[num], typeof(int));
                     if (expressionArray[num] != null)
                     {
                         num++;
                     }
                     else
                     {
                         DynamicMetaObject[] dynamicMetaObjectArray = new DynamicMetaObject[1];
                         dynamicMetaObjectArray[0] = indexes[num];
                         return PSConvertBinder.ThrowNoConversion(indexes[num], typeof(int), this, this._version, indexes.Except<DynamicMetaObject>(dynamicMetaObjectArray).Append<DynamicMetaObject>(target).Append<DynamicMetaObject>(value).ToArray<DynamicMetaObject>());
                     }
                 }
                 return new DynamicMetaObject(Expression.Call(CachedReflectionInfo.ArrayOps_SetMDArrayValue, target.Expression.Cast(typeof(Array)), Expression.NewArrayInit(typeof(int), expressionArray), expression.Cast(typeof(object))), target.CombineRestrictions(indexes).Merge(value.PSGetTypeRestriction()));
             }
             else
             {
                 DynamicMetaObject dynamicMetaObject = errorSuggestion;
                 DynamicMetaObject dynamicMetaObject1 = dynamicMetaObject;
                 if (dynamicMetaObject == null)
                 {
                     DynamicMetaObject dynamicMetaObject2 = target;
                     DynamicMetaObject[] dynamicMetaObjectArray1 = indexes;
                     BindingRestrictions bindingRestriction = value.PSGetTypeRestriction();
                     string str = "NeedMultidimensionalIndex";
                     string needMultidimensionalIndex = ParserStrings.NeedMultidimensionalIndex;
                     Expression[] expressionArray1 = new Expression[2];
                     expressionArray1[0] = ExpressionCache.Constant(arrays.Rank);
                     Expression[] expressionArray2 = expressionArray1;
                     int num1 = 1;
                     MethodInfo arrayOpsIndexStringMessage = CachedReflectionInfo.ArrayOps_IndexStringMessage;
                     Type type = typeof(object);
                     DynamicMetaObject[] dynamicMetaObjectArray2 = indexes;
                     expressionArray2[num1] = Expression.Call(arrayOpsIndexStringMessage, Expression.NewArrayInit(type, dynamicMetaObjectArray2.Select<DynamicMetaObject, Expression>((DynamicMetaObject i) => i.Expression.Cast(typeof(object)))));
                     dynamicMetaObject1 = dynamicMetaObject2.ThrowRuntimeError(dynamicMetaObjectArray1, bindingRestriction, str, needMultidimensionalIndex, expressionArray1);
                 }
                 return dynamicMetaObject1;
             }
         }
         else
         {
             Expression expression1 = PSGetIndexBinder.ConvertIndex(indexes[0], typeof(int[]));
             if (expression1 != null)
             {
                 return new DynamicMetaObject(Expression.Call(CachedReflectionInfo.ArrayOps_SetMDArrayValue, target.Expression.Cast(typeof(Array)), expression1, expression.Cast(typeof(object))), target.CombineRestrictions(indexes).Merge(value.PSGetTypeRestriction()));
             }
             else
             {
                 DynamicMetaObject dynamicMetaObject3 = errorSuggestion;
                 DynamicMetaObject dynamicMetaObject4 = dynamicMetaObject3;
                 if (dynamicMetaObject3 == null)
                 {
                     DynamicMetaObject[] dynamicMetaObjectArray3 = new DynamicMetaObject[2];
                     dynamicMetaObjectArray3[0] = target;
                     dynamicMetaObjectArray3[1] = value;
                     dynamicMetaObject4 = PSConvertBinder.ThrowNoConversion(indexes[0], typeof(int[]), this, this._version, dynamicMetaObjectArray3);
                 }
                 return dynamicMetaObject4;
             }
         }
     }
     else
     {
         DynamicMetaObject dynamicMetaObject5 = errorSuggestion;
         DynamicMetaObject dynamicMetaObject6 = dynamicMetaObject5;
         if (dynamicMetaObject5 == null)
         {
             dynamicMetaObject6 = PSConvertBinder.ThrowNoConversion(value, elementType, this, this._version, indexes.Prepend<DynamicMetaObject>(target).ToArray<DynamicMetaObject>());
         }
         return dynamicMetaObject6;
     }
 }
开发者ID:nickchal,项目名称:pash,代码行数:86,代码来源:PSSetIndexBinder.cs

示例3: FallbackSetIndex

 public override DynamicMetaObject FallbackSetIndex(DynamicMetaObject target, DynamicMetaObject[] indexes, DynamicMetaObject value, DynamicMetaObject errorSuggestion)
 {
     if (target.HasValue)
     {
         DynamicMetaObject[] dynamicMetaObjectArray = indexes;
         if (!dynamicMetaObjectArray.Where<DynamicMetaObject>((DynamicMetaObject mo) => !mo.HasValue).Any<DynamicMetaObject>() && value.HasValue)
         {
             if (target.Value as PSObject == null || PSObject.Base(target.Value) == target.Value)
             {
                 DynamicMetaObject[] dynamicMetaObjectArray1 = indexes;
                 if (!dynamicMetaObjectArray1.Where<DynamicMetaObject>((DynamicMetaObject mo) =>
                 {
                     if ((mo.Value as PSObject == null))
                     {
                         return false;
                     }
                     else
                     {
                         return (PSObject.Base(mo.Value) != mo.Value);
                     }
                 }
                 ).Any<DynamicMetaObject>())
                 {
                     if (target.Value != null)
                     {
                         if ((int)indexes.Length != 1 || indexes[0].Value != null)
                         {
                             if (!target.LimitType.IsArray)
                             {
                                 DefaultMemberAttribute defaultMemberAttribute = target.LimitType.GetCustomAttributes<DefaultMemberAttribute>(true).FirstOrDefault<DefaultMemberAttribute>();
                                 if (defaultMemberAttribute == null)
                                 {
                                     DynamicMetaObject dynamicMetaObject = errorSuggestion;
                                     DynamicMetaObject debugLog = dynamicMetaObject;
                                     if (dynamicMetaObject == null)
                                     {
                                         debugLog = this.CannotIndexTarget(target, indexes, value).WriteToDebugLog(this);
                                     }
                                     return debugLog;
                                 }
                                 else
                                 {
                                     return this.InvokeIndexer(target, indexes, value, errorSuggestion, defaultMemberAttribute.MemberName).WriteToDebugLog(this);
                                 }
                             }
                             else
                             {
                                 return this.SetIndexArray(target, indexes, value, errorSuggestion).WriteToDebugLog(this);
                             }
                         }
                         else
                         {
                             DynamicMetaObject dynamicMetaObject1 = errorSuggestion;
                             DynamicMetaObject debugLog1 = dynamicMetaObject1;
                             if (dynamicMetaObject1 == null)
                             {
                                 debugLog1 = target.ThrowRuntimeError(indexes, BindingRestrictions.Empty, "NullArrayIndex", ParserStrings.NullArrayIndex, new Expression[0]).WriteToDebugLog(this);
                             }
                             return debugLog1;
                         }
                     }
                     else
                     {
                         DynamicMetaObject dynamicMetaObject2 = errorSuggestion;
                         DynamicMetaObject dynamicMetaObject3 = dynamicMetaObject2;
                         if (dynamicMetaObject2 == null)
                         {
                             dynamicMetaObject3 = target.ThrowRuntimeError(indexes, BindingRestrictions.Empty, "NullArray", ParserStrings.NullArray, new Expression[0]);
                         }
                         return dynamicMetaObject3.WriteToDebugLog(this);
                     }
                 }
             }
             return this.DeferForPSObject(indexes.Prepend<DynamicMetaObject>(target).Append<DynamicMetaObject>(value).ToArray<DynamicMetaObject>()).WriteToDebugLog(this);
         }
     }
     return base.Defer(indexes.Prepend<DynamicMetaObject>(target).Append<DynamicMetaObject>(value).ToArray<DynamicMetaObject>()).WriteToDebugLog(this);
 }
开发者ID:nickchal,项目名称:pash,代码行数:78,代码来源:PSSetIndexBinder.cs

示例4: SetIndexArray

 private DynamicMetaObject SetIndexArray(DynamicMetaObject target, DynamicMetaObject[] indexes, DynamicMetaObject value, DynamicMetaObject errorSuggestion)
 {
     Array arrays = (Array)target.Value;
     if (arrays.Rank <= 1)
     {
         if ((int)indexes.Length <= 1)
         {
             Expression expression = PSGetIndexBinder.ConvertIndex(indexes[0], typeof(int));
             if (expression != null)
             {
                 Type elementType = target.LimitType.GetElementType();
                 Expression expression1 = PSGetIndexBinder.ConvertIndex(value, elementType);
                 if (expression1 != null)
                 {
                     PSSetIndexBinder pSSetIndexBinder = this;
                     DynamicMetaObject dynamicMetaObject = new DynamicMetaObject(target.Expression.Cast(target.LimitType), target.PSGetTypeRestriction());
                     DynamicMetaObject dynamicMetaObject1 = new DynamicMetaObject(expression, indexes[0].PSGetTypeRestriction());
                     DynamicMetaObject dynamicMetaObject2 = new DynamicMetaObject(expression1, value.PSGetTypeRestriction());
                     PropertyInfo property = target.LimitType.GetProperty("Length");
                     return pSSetIndexBinder.IndexWithNegativeChecks(dynamicMetaObject, dynamicMetaObject1, dynamicMetaObject2, property, (Expression t, Expression i, Expression v) =>
                     {
                         Expression[] expressionArray = new Expression[1];
                         expressionArray[0] = i;
                         return Expression.Assign(Expression.ArrayAccess(t, expressionArray), v);
                     }
                     );
                 }
                 else
                 {
                     DynamicMetaObject dynamicMetaObject3 = errorSuggestion;
                     DynamicMetaObject dynamicMetaObject4 = dynamicMetaObject3;
                     if (dynamicMetaObject3 == null)
                     {
                         dynamicMetaObject4 = PSConvertBinder.ThrowNoConversion(value, elementType, this, this._version, indexes.Prepend<DynamicMetaObject>(target).OfType<DynamicMetaObject>().ToArray<DynamicMetaObject>());
                     }
                     return dynamicMetaObject4;
                 }
             }
             else
             {
                 DynamicMetaObject dynamicMetaObject5 = errorSuggestion;
                 DynamicMetaObject dynamicMetaObject6 = dynamicMetaObject5;
                 if (dynamicMetaObject5 == null)
                 {
                     DynamicMetaObject[] dynamicMetaObjectArray = new DynamicMetaObject[2];
                     dynamicMetaObjectArray[0] = target;
                     dynamicMetaObjectArray[1] = value;
                     dynamicMetaObject6 = PSConvertBinder.ThrowNoConversion(indexes[0], typeof(int), this, this._version, dynamicMetaObjectArray);
                 }
                 return dynamicMetaObject6;
             }
         }
         else
         {
             DynamicMetaObject dynamicMetaObject7 = errorSuggestion;
             DynamicMetaObject dynamicMetaObject8 = dynamicMetaObject7;
             if (dynamicMetaObject7 == null)
             {
                 DynamicMetaObject dynamicMetaObject9 = target;
                 DynamicMetaObject[] dynamicMetaObjectArray1 = indexes;
                 BindingRestrictions bindingRestriction = value.PSGetTypeRestriction();
                 string str = "ArraySliceAssignmentFailed";
                 string arraySliceAssignmentFailed = ParserStrings.ArraySliceAssignmentFailed;
                 Expression[] expressionArray1 = new Expression[1];
                 Expression[] expressionArray2 = expressionArray1;
                 int num = 0;
                 MethodInfo arrayOpsIndexStringMessage = CachedReflectionInfo.ArrayOps_IndexStringMessage;
                 Type type = typeof(object);
                 DynamicMetaObject[] dynamicMetaObjectArray2 = indexes;
                 expressionArray2[num] = Expression.Call(arrayOpsIndexStringMessage, Expression.NewArrayInit(type, dynamicMetaObjectArray2.Select<DynamicMetaObject, Expression>((DynamicMetaObject i) => i.Expression.Cast(typeof(object)))));
                 dynamicMetaObject8 = dynamicMetaObject9.ThrowRuntimeError(dynamicMetaObjectArray1, bindingRestriction, str, arraySliceAssignmentFailed, expressionArray1);
             }
             return dynamicMetaObject8;
         }
     }
     else
     {
         return this.SetIndexMultiDimensionArray(target, indexes, value, errorSuggestion);
     }
 }
开发者ID:nickchal,项目名称:pash,代码行数:80,代码来源:PSSetIndexBinder.cs


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