本文整理汇总了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;
}
}
示例2: SetTypedReference
public static void SetTypedReference (TypedReference target, object value)
{
if (value == null) {
throw new ArgumentNullException ("value");
}
throw new NotImplementedException ();
}
示例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);
}
示例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 "";
示例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++)
示例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;
}
示例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);
}
}
示例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);
}
}
示例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]--;
}
}
}
}
示例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;
}
示例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
}
示例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);
}
示例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;
}
示例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);
}
示例15: SetValueDirect
internal extern void SetValueDirect(RuntimeTypeHandle fieldType, TypedReference obj, Object value, RuntimeTypeHandle contextType);