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


C# System.TypedReference类代码示例

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


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

示例1: GetNextArg

        public TypedReference GetNextArg(RuntimeTypeHandle rth)
        {
            if (sigPtr != IntPtr.Zero)
            {
                // This is an ordinary ArgIterator capable of determining
                // types from a signature. Just do a regular GetNextArg.
                return GetNextArg();
            }
            else
            {
                // Prevent abuse of this API with a default ArgIterator (it
                // doesn't require permission to create a zero-inited value
                // type). Check that ArgPtr isn't zero or this API will allow a
                // malicious caller to increment the pointer to an arbitrary
                // location in memory and read the contents.
                if (ArgPtr == IntPtr.Zero)
                    throw new ArgumentNullException();

                TypedReference result = new TypedReference ();
                // reference to TypedReference is banned, so have to pass result as pointer
                unsafe
                {
                    InternalGetNextArg(&result, rth.GetRuntimeType());
                }
                return result;
            }
        }
开发者ID:kouvel,项目名称:coreclr,代码行数:27,代码来源:ArgIterator.cs

示例2: SetTypedReference

		public static void SetTypedReference (TypedReference target, object value) 
		{
			if (value == null) {
				throw new ArgumentNullException ("value");
			}
			throw new NotImplementedException ();
		}
开发者ID:calumjiao,项目名称:Mono-Class-Libraries,代码行数:7,代码来源:TypedReference.cs

示例3: GetValueDirect

 public override unsafe object GetValueDirect(TypedReference obj)
 {
     if (obj.IsNull)
     {
         throw new ArgumentException(Environment.GetResourceString("Arg_TypedReference_Null"));
     }
     return RuntimeFieldHandle.GetValueDirect(this, (RuntimeType) this.FieldType, (void*) &obj, (RuntimeType) this.DeclaringType);
 }
开发者ID:pritesh-mandowara-sp,项目名称:DecompliedDotNetLibraries,代码行数:8,代码来源:RtFieldInfo.cs

示例4: buildLCS

 private static String buildLCS( /*int[,,,]*/TypedReference _b,
                         /*char[]*/ TypedReference _X,
                         /*int[]*/ TypedReference _ind)
 {
     int _i = 0;
     for (TypedReference i = __makeref(_i);
         __refvalue(i, int) < RANK; _i++)
         if (__refvalue(_ind, int[])[__refvalue(i, int)] == 0) return "";
开发者ID:l1183479157,项目名称:coreclr,代码行数:8,代码来源:lcs.cs

示例5: TestRef

 private static void TestRef(TypedReference _ref)
 {
     if (__reftype(_ref) == typeof(Array))
     {
         for (int i = 0; i < __refvalue(_ref, Array).Length; i++)
             __refvalue(_ref, Array).SetValue(new Test(), i);
     }
     if (__reftype(_ref) == typeof(long[]))
     {
         for (int i = 0; i < __refvalue(_ref, long[]).Length; i++)
开发者ID:CheneyWu,项目名称:coreclr,代码行数:10,代码来源:array1.cs

示例6: GetNextArg

 public TypedReference GetNextArg()
 {
     TypedReference result = new TypedReference ();
     // reference to TypedReference is banned, so have to pass result as pointer
     unsafe
     {
         FCallGetNextArg (&result);
     }
     return result;
 }
开发者ID:REALTOBIZ,项目名称:mono,代码行数:10,代码来源:argiterator.cs

示例7: PackRef

 public virtual void PackRef(TypedReference _ref, int iterCount)
 {
     if (++iterCount == ITERATIONS)
     {
         UnpackRef(_ref, iterCount);
     }
     else
     {
         ulong N = UnpackRef(_ref, 0);
         PackRef(__makeref(N), iterCount);
     }
 }
开发者ID:l1183479157,项目名称:coreclr,代码行数:12,代码来源:virtcall.cs

示例8: PackRef

 private static void PackRef(TypedReference _ref, int iterCount)
 {
     if (++iterCount == ITERATIONS)
     {
         Console.WriteLine(ITERATIONS.ToString() + " refs packed.");
         UnpackRef(_ref, iterCount);
     }
     else
     {
         ulong N = UnpackRef(_ref, 0);
         PackRef(__makeref(N), iterCount);
     }
 }
开发者ID:CheneyWu,项目名称:coreclr,代码行数:13,代码来源:stress1.cs

示例9: TestRef

 private static void TestRef(TypedReference _ref)
 {
     if (__reftype(_ref) == typeof(ulong[,]))
     {
         for (int i = 0; i < 2; i++)
         {
             for (int j = 0; j < 3; j++)
             {
                 __refvalue(_ref, ulong[,])[i, j]--;
             }
         }
     }
 }
开发者ID:l1183479157,项目名称:coreclr,代码行数:13,代码来源:array2.cs

示例10: GetNextArg

 public unsafe TypedReference GetNextArg(RuntimeTypeHandle rth)
 {
     if (this.sigPtr != IntPtr.Zero)
     {
         return this.GetNextArg();
     }
     if (this.ArgPtr == IntPtr.Zero)
     {
         throw new ArgumentNullException();
     }
     TypedReference reference = new TypedReference();
     this.InternalGetNextArg((void*) &reference, rth);
     return reference;
 }
开发者ID:randomize,项目名称:VimConfig,代码行数:14,代码来源:ArgIterator.cs

示例11: MakeTypedReference

        public static TypedReference MakeTypedReference(Object target, FieldInfo[] flds) {
            if (target == null)
                throw new ArgumentNullException("target");
            if (flds == null)
                throw new ArgumentNullException("flds");
            Contract.EndContractBlock();
            if (flds.Length == 0)
                throw new ArgumentException(Environment.GetResourceString("Arg_ArrayZeroError"));

            IntPtr[] fields = new IntPtr[flds.Length];
            // For proper handling of Nullable<T> don't change GetType() to something like 'IsAssignableFrom'
            // Currently we can't make a TypedReference to fields of Nullable<T>, which is fine.  
            RuntimeType targetType = (RuntimeType)target.GetType();
            for (int i = 0; i < flds.Length; i++)
            {
                RuntimeFieldInfo field = flds[i] as RuntimeFieldInfo;
                if (field == null)
                    throw new ArgumentException(Environment.GetResourceString("Argument_MustBeRuntimeFieldInfo"));

                if (field.IsInitOnly || field.IsStatic)
                    throw new ArgumentException(Environment.GetResourceString("Argument_TypedReferenceInvalidField"));
                
                if (targetType != field.GetDeclaringTypeInternal() && !targetType.IsSubclassOf(field.GetDeclaringTypeInternal()))
                    throw new MissingMemberException(Environment.GetResourceString("MissingMemberTypeRef"));

                RuntimeType fieldType = (RuntimeType)field.FieldType;
                if (fieldType.IsPrimitive)
                    throw new ArgumentException(Environment.GetResourceString("Arg_TypeRefPrimitve"));
                
                if (i < (flds.Length - 1) && !fieldType.IsValueType)
                    throw new MissingMemberException(Environment.GetResourceString("MissingMemberNestErr"));
                
                fields[i] = field.FieldHandle.Value;
                targetType = fieldType;
            }

#if MONO
            return MakeTypedReferenceInternal (target, flds);
#else
            TypedReference result = new TypedReference ();

            // reference to TypedReference is banned, so have to pass result as pointer
            unsafe 
            {
                InternalMakeTypedReference(&result, target, fields, targetType);
            }
            return result;
#endif
        }
开发者ID:ItsVeryWindy,项目名称:mono,代码行数:49,代码来源:typedreference.cs

示例12: UnpackRef

 public virtual ulong UnpackRef(TypedReference _ref, int iterCount)
 {
     if (iterCount++ == ITERATIONS)
     {
         if (__refvalue(_ref, ulong) == MAGIC)
         {
             throw new ArgumentException();  //cleanup in an unusual way
         }
         else
         {
             throw new Exception();
         }
     }
     else
         return __refvalue(_ref, ulong);
 }
开发者ID:l1183479157,项目名称:coreclr,代码行数:16,代码来源:virtcall.cs

示例13: MakeTypedReference

 public static unsafe TypedReference MakeTypedReference(object target, FieldInfo[] flds)
 {
     if (target == null)
     {
         throw new ArgumentNullException("target");
     }
     if (flds == null)
     {
         throw new ArgumentNullException("flds");
     }
     if (flds.Length == 0)
     {
         throw new ArgumentException(Environment.GetResourceString("Arg_ArrayZeroError"));
     }
     RuntimeFieldHandle[] handleArray = new RuntimeFieldHandle[flds.Length];
     System.Type type = target.GetType();
     for (int i = 0; i < flds.Length; i++)
     {
         FieldInfo info = flds[i];
         if (!(info is RuntimeFieldInfo))
         {
             throw new ArgumentException(Environment.GetResourceString("Argument_MustBeRuntimeFieldInfo"));
         }
         if (info.IsInitOnly || info.IsStatic)
         {
             throw new ArgumentException(Environment.GetResourceString("Argument_TypedReferenceInvalidField"));
         }
         if ((type != info.DeclaringType) && !type.IsSubclassOf(info.DeclaringType))
         {
             throw new MissingMemberException(Environment.GetResourceString("MissingMemberTypeRef"));
         }
         System.Type fieldType = info.FieldType;
         if (fieldType.IsPrimitive)
         {
             throw new ArgumentException(Environment.GetResourceString("Arg_TypeRefPrimitve"));
         }
         if ((i < (flds.Length - 1)) && !fieldType.IsValueType)
         {
             throw new MissingMemberException(Environment.GetResourceString("MissingMemberNestErr"));
         }
         handleArray[i] = info.FieldHandle;
         type = fieldType;
     }
     TypedReference reference = new TypedReference();
     InternalMakeTypedReference((void*) &reference, target, handleArray, type.TypeHandle);
     return reference;
 }
开发者ID:randomize,项目名称:VimConfig,代码行数:47,代码来源:TypedReference.cs

示例14: UnpackRef

 private static ulong UnpackRef(TypedReference _ref, int iterCount)
 {
     if (iterCount++ == ITERATIONS)
     {
         Console.WriteLine(ITERATIONS.ToString() + " refs unpacked.");
         if (__refvalue(_ref, ulong) == MAGIC)
         {
             Console.WriteLine("Passed.");
             throw new ArgumentException();  //cleanup in an unusual way
         }
         else
         {
             Console.WriteLine("failed.");
             throw new Exception();
         }
     }
     else
         return __refvalue(_ref, ulong);
 }
开发者ID:CheneyWu,项目名称:coreclr,代码行数:19,代码来源:stress1.cs

示例15: SetValueDirect

 internal extern void SetValueDirect(RuntimeTypeHandle fieldType, TypedReference obj, Object value, RuntimeTypeHandle contextType);
开发者ID:gbarnett,项目名称:shared-source-cli-2.0,代码行数:1,代码来源:runtimehandles.cs


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