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