Ejemplo n.º 1
0
        public static ObjectInfo GetObjectInfo(object o, SqoTypeInfo ti, Sqo.Cache.MetaCache metaCache)
        {
            ObjectInfo oi = new ObjectInfo(ti, o);

            oi.Oid       = metaCache.GetOIDOfObject(o, ti);
            oi.TickCount = MetaHelper.GetTickCountOfObject(o, ti.Type);

            foreach (FieldSqoInfo attKey in ti.Fields)
            {
#if SILVERLIGHT
                object objVal = null;
                try
                {
                    objVal = MetaHelper.CallGetValue(attKey.FInfo, o, ti.Type);
                }
                catch (Exception ex)
                {
                    throw new SiaqodbException("Override GetValue and SetValue methods of SqoDataObject-Silverlight limitation to private fields");
                }
#else
                object objVal = attKey.FInfo.GetValue(o);
#endif
                if (attKey.FInfo.FieldType == typeof(string))
                {
                    if (objVal == null)
                    {
                        objVal = string.Empty;
                    }
                }
                if (attKey.AttributeTypeId == MetaExtractor.documentID && objVal != null)
                {
                    Sqo.MetaObjects.DocumentInfo dinfo = new Sqo.MetaObjects.DocumentInfo();
                    dinfo.OID      = metaCache.GetDocumentInfoOID(ti, o, attKey.Name);
                    dinfo.TypeName = MetaHelper.GetDiscoveringTypeName(attKey.AttributeType);
                    if (SiaqodbConfigurator.DocumentSerializer == null)
                    {
                        throw new SiaqodbException("Document serializer is not set, use SiaqodbConfigurator.SetDocumentSerializer method to set it");
                    }
                    dinfo.Document = SiaqodbConfigurator.DocumentSerializer.Serialize(objVal);
                    objVal         = dinfo;
                }
                oi.AtInfo[attKey] = objVal;
            }
            return(oi);
        }