Exemplo n.º 1
0
        public T AsObject <T>()
            where T : class, IVariantObject, new()
        {
            CheckType(EnumType.Object, "AsObject()");

            IVariantObject o = ((VariantObjectData)Value).Value;

            T result = o as T;

            if (result == null)
            {
                result = new T();

                if (o.Class != result.Class)
                {
                    throw new VariantException(string.Format("Attempt to coerce object of type {0} into {1}", o.Class, result.Class));
                }

                Variant param = o.Deflate();
                result.Inflate(param, o.Version);

                if (o is VariantObjectProxy)
                {
                    Value = new VariantObjectData(result);
                }
            }

            return(result);
        }
Exemplo n.º 2
0
 public Variant(IVariantObject arg)
 {
     Value = new VariantObjectData(arg);
 }