BitMiracle.LibTiff.Classic.FieldValue.ToUIntArray C# (CSharp) Method

ToUIntArray() private method

private ToUIntArray ( ) : uint[]
return uint[]
        public uint[] ToUIntArray()
        {
            if (m_value == null)
                return null;

            Type t = m_value.GetType();
            if (t.IsArray)
            {
                if (m_value is uint[])
                    return m_value as uint[];
                else if (m_value is byte[])
                {
                    byte[] temp = m_value as byte[];
                    if (temp.Length % sizeof(uint) != 0)
                        return null;

                    int totalUInts = temp.Length / sizeof(uint);
                    uint[] result = new uint[totalUInts];

                    int byteOffset = 0;
                    for (int i = 0; i < totalUInts; i++)
                    {
                        uint s = BitConverter.ToUInt32(temp, byteOffset);
                        result[i] = s;
                        byteOffset += sizeof(uint);
                    }

                    return result;
                }
                else if (m_value is short[])
                {
                    short[] temp = m_value as short[];
                    uint[] result = new uint[temp.Length];
                    for (int i = 0; i < temp.Length; i++)
                        result[i] = (uint)temp[i];

                    return result;
                }
                else if (m_value is ushort[])
                {
                    ushort[] temp = m_value as ushort[];
                    uint[] result = new uint[temp.Length];
                    for (int i = 0; i < temp.Length; i++)
                        result[i] = (uint)temp[i];

                    return result;
                }
                else if (m_value is int[])
                {
                    int[] temp = m_value as int[];
                    uint[] result = new uint[temp.Length];
                    for (int i = 0; i < temp.Length; i++)
                        result[i] = (uint)temp[i];

                    return result;
                }
            }

            return null;
        }