示例#1
0
        private bool IsValuePrimitive()
        {
            if (m_fIsBoxed || m_fIsEnum)
            {
                if (m_valuePrimitive == null)
                {
                    if (m_rtv.IsBoxed)
                    {
                        var getField = m_rtv.GetFieldAsync(1, 0);
                        getField.Wait();

                        RuntimeValue rtv = getField.Result;

                        Debug.Assert(rtv.IsPrimitive);

                        //Assert that m_class really points to a primitive
                        m_valuePrimitive = (CorDebugValuePrimitive)CreateValue(rtv);
                    }
                    else
                    {
                        Debug.Assert(m_fIsEnum);
                        m_valuePrimitive = new CorDebugValuePrimitive(m_rtv, m_appDomain);
                        Debug.Assert(m_rtv.IsPrimitive);
                    }
                }
            }

            return(m_valuePrimitive != null);
        }
示例#2
0
        public static CorDebugValue CreateValue(RuntimeValue rtv, CorDebugAppDomain appDomain)
        {
            CorDebugValue val = null;
            bool          fIsReference;

            if (rtv.IsBoxed)
            {
                val          = new CorDebugValueBoxedObject(rtv, appDomain);
                fIsReference = true;
            }
            else if (rtv.IsPrimitive)
            {
                CorDebugClass c = ClassFromRuntimeValue(rtv, appDomain);

                if (c.IsEnum)
                {
                    val          = new CorDebugValueObject(rtv, appDomain);
                    fIsReference = false;
                }
                else
                {
                    val          = new CorDebugValuePrimitive(rtv, appDomain);
                    fIsReference = false;
                }
            }
            else if (rtv.IsArray)
            {
                val          = new CorDebugValueArray(rtv, appDomain);
                fIsReference = true;
            }
            else if (rtv.CorElementType == CorElementType.ELEMENT_TYPE_STRING)
            {
                val          = new CorDebugValueString(rtv, appDomain);
                fIsReference = true;
            }
            else
            {
                val          = new CorDebugValueObject(rtv, appDomain);
                fIsReference = !rtv.IsValueType;
            }

            if (fIsReference)
            {
                val = new CorDebugValueReference(val, val.m_rtv, val.m_appDomain);
            }

            if (rtv.IsReference)    //CorElementType.ELEMENT_TYPE_BYREF
            {
                val = new CorDebugValueReferenceByRef(val, val.m_rtv, val.m_appDomain);
            }

            return(val);
        }