ОписаниеТипов (TypeDescription)
Inheritance: BaseSessionObject, IV8XmlSerializable, ICacheLoadable
        internal protected object ConvertV8Value(object obj, TypeDescription typeDescription)
        {
            if (!IsInternalV8Object(obj))
            {
                return obj;
            }


            if (typeDescription != null)
            {
                var types = typeDescription.Types;

                if (types.Length == 1)
                {
                    var typeInfo = types[0];

                    switch (typeInfo.Type)
                    {
                        case TypeEnum.DocumentRef:
                            return new DocumentRef(this.Session, typeInfo.ReferenceTypeName, obj);
                        case TypeEnum.CatalogRef:
                            return new CatalogRef(this.Session, typeInfo.ReferenceTypeName, obj);
                        case TypeEnum.EnumRef:
                            return new EnumRef(this.Session, typeInfo.ReferenceTypeName, obj);
                    }
                }
            }
            
            object ptrMeta;
            try
            {
                ptrMeta = InvokeV8Method(obj, RussianConsts.Metadata, new object[0]);
            }
            catch
            {
                ptrMeta = null;
            }

            if (ptrMeta == null)
            {
                return null;
            }


            MetadataObject metadata = MetadataObject.Create(this.Session, ptrMeta);

            switch (metadata.MetadataType)
            {
                case MetadataType.Catalog:
                    return new CatalogRef(this.Session, metadata.Name, obj);

                case MetadataType.Document:
                    return new DocumentRef(this.Session, metadata.Name, obj);
            }

            //not implemented

            return null;
        }
        internal protected object ConvertV8Value(object obj, TypeDescription typeDescription)
        {
            if (!IsInternalV8Object(obj))
            {
                return(obj);
            }


            if (typeDescription != null)
            {
                var types = typeDescription.Types;

                if (types.Length == 1)
                {
                    var typeInfo = types[0];

                    switch (typeInfo.Type)
                    {
                    case TypeEnum.DocumentRef:
                        return(new DocumentRef(this.Session, typeInfo.ReferenceTypeName, obj));

                    case TypeEnum.CatalogRef:
                        return(new CatalogRef(this.Session, typeInfo.ReferenceTypeName, obj));

                    case TypeEnum.EnumRef:
                        return(new EnumRef(this.Session, typeInfo.ReferenceTypeName, obj));
                    }
                }
            }

            object ptrMeta;

            try
            {
                ptrMeta = InvokeV8Method(obj, RussianConsts.Metadata, new object[0]);
            }
            catch
            {
                ptrMeta = null;
            }

            if (ptrMeta == null)
            {
                return(null);
            }


            MetadataObject metadata = MetadataObject.Create(this.Session, ptrMeta);

            switch (metadata.MetadataType)
            {
            case MetadataType.Catalog:
                return(new CatalogRef(this.Session, metadata.Name, obj));

            case MetadataType.Document:
                return(new DocumentRef(this.Session, metadata.Name, obj));
            }

            //not implemented

            return(null);
        }