Ejemplo n.º 1
0
        public static ATuple <int, object> GetPartialObjectInfo(object o, SqoTypeInfo ti, string fieldName, Cache.MetaCache metaCache)
        {
            int oid = metaCache.GetOIDOfObject(o, ti);

            foreach (FieldSqoInfo attKey in ti.Fields)
            {
                if (attKey.Name != fieldName)
                {
                    continue;
                }
#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;
                }
                return(new ATuple <int, object>(oid, objVal));
            }
            return(null);
        }