Ejemplo n.º 1
0
        private T[] CoerceArrayValue <T>(PropertyType unboxType)
        {
            if (this.Type == unboxType)
            {
                return((T[])this._data);
            }
            Array array = this._data as Array;

            if (array == null)
            {
                throw new InvalidCastException(Environment.GetResourceString("InvalidCast_WinRTIPropertyValueElement", (object)this.Type, (object)typeof(T).MakeArrayType().Name), -2147316576);
            }
            PropertyType type = this.Type - 1024;

            T[] objArray = new T[array.Length];
            for (int index = 0; index < array.Length; ++index)
            {
                try
                {
                    objArray[index] = CLRIPropertyValueImpl.CoerceScalarValue <T>(type, array.GetValue(index));
                }
                catch (InvalidCastException ex)
                {
                    InvalidCastException invalidCastException = new InvalidCastException(Environment.GetResourceString("InvalidCast_WinRTIPropertyValueArrayCoersion", (object)this.Type, (object)typeof(T).MakeArrayType().Name, (object)index, (object)ex.Message), (Exception)ex);
                    int hr = ex._HResult;
                    invalidCastException.SetErrorCode(hr);
                    throw invalidCastException;
                }
            }
            return(objArray);
        }
Ejemplo n.º 2
0
 // Token: 0x0600640E RID: 25614 RVA: 0x00153B48 File Offset: 0x00151D48
 private T CoerceScalarValue <T>(PropertyType unboxType)
 {
     if (this.Type == unboxType)
     {
         return((T)((object)this._data));
     }
     return(CLRIPropertyValueImpl.CoerceScalarValue <T>(this.Type, this._data));
 }
Ejemplo n.º 3
0
        // Token: 0x0600640D RID: 25613 RVA: 0x00153A1C File Offset: 0x00151C1C
        private T[] CoerceArrayValue <T>(PropertyType unboxType)
        {
            if (this.Type == unboxType)
            {
                return((T[])this._data);
            }
            Array array = this._data as Array;

            if (array == null)
            {
                throw new InvalidCastException(Environment.GetResourceString("InvalidCast_WinRTIPropertyValueElement", new object[]
                {
                    this.Type,
                    typeof(T).MakeArrayType().Name
                }), -2147316576);
            }
            PropertyType type = this.Type - 1024;

            T[] array2 = new T[array.Length];
            for (int i = 0; i < array.Length; i++)
            {
                try
                {
                    array2[i] = CLRIPropertyValueImpl.CoerceScalarValue <T>(type, array.GetValue(i));
                }
                catch (InvalidCastException ex)
                {
                    Exception ex2 = new InvalidCastException(Environment.GetResourceString("InvalidCast_WinRTIPropertyValueArrayCoersion", new object[]
                    {
                        this.Type,
                        typeof(T).MakeArrayType().Name,
                        i,
                        ex.Message
                    }), ex);
                    ex2.SetErrorCode(ex._HResult);
                    throw ex2;
                }
            }
            return(array2);
        }