Exemplo n.º 1
0
        internal static object CreateObjectFromHandle(ObjectHandle handle)
        {
            if (handle == null)
            {
                throw new ArgumentNullException(nameof(handle));
            }

            using (var type = Surface.Type)
            {
                if (handle.IsCast(type))
                {
                    return(new Surface(handle));
                }
            }

            using (var type = RgbaUintFormat.Type)
            {
                if (handle.IsCast(type))
                {
                    return(new RgbaUintFormat(handle));
                }
            }

            using (var type = Face.Type)
            {
                if (handle.IsCast(type))
                {
                    return(new Face(handle));
                }
            }

            using (var type = Glyph.Type)
            {
                if (handle.IsCast(type))
                {
                    return(new Glyph(handle));
                }
            }

            using (var type = Figure.Type)
            {
                if (handle.IsCast(type))
                {
                    return(new Figure(handle));
                }
            }

            throw new InvalidOperationException();
        }