Beispiel #1
0
        private void Unbox(ref CorValue value)
        {
            CorBoxValue boxVal = value.CastToBoxValue();

            if (boxVal != null)
            {
                value = boxVal.GetObject();
            }
        }
Beispiel #2
0
        static CorValue Unbox(EvaluationContext ctx, CorBoxValue boxVal)
        {
            CorObjectValue bval  = boxVal.GetObject();
            Type           ptype = Type.GetType(ctx.Adapter.GetTypeName(ctx, bval.ExactType));

            if (ptype != null && ptype.IsPrimitive)
            {
                ptype = bval.ExactType.GetTypeInfo(((CorEvaluationContext)ctx).Session);
                foreach (FieldInfo field in ptype.GetFields(BindingFlags.Public | BindingFlags.NonPublic | BindingFlags.Instance))
                {
                    if (field.Name == "m_value")
                    {
                        CorValue val = bval.GetFieldValue(bval.ExactType.Class, field.MetadataToken);
                        val = GetRealObject(ctx, val);
                        return(val);
                    }
                }
            }

            return(GetRealObject(ctx, bval));
        }