コード例 #1
0
        /// <summary>
        /// Get the Dna object that represents a list of ItemId's
        /// </summary>
        /// <param name="itemIdsForObject"></param>
        /// <returns></returns>
        public Dna GetDna(IEnumerable <ItemId> itemIdsForObject)
        {
            Dna dna = new Dna();
            Dictionary <ItemId, List <XmlNode> > itemIdsToAssetXmls = GetAssetXmlFromItemList(itemIdsForObject);

            foreach (ItemId itemId in itemIdsToAssetXmls.Keys)
            {
                List <XmlNode> assetXmlList = itemIdsToAssetXmls[itemId];
                foreach (XmlNode assetXml in assetXmlList)
                {
                    ServerAssetInfo assetInfo = new ServerAssetInfo(itemId, assetXml);
                    dna.ApplyInfoToDna(assetInfo);
                }
            }
            return(dna);
        }
コード例 #2
0
        /// <summary>
        /// Get a reference system avatar.  This avatar is used to fill in missing required info when pulling an avatar from the db
        /// </summary>
        private void GetReferenceAvatar(Action <Dna> gotReferenceAvatarFinished)
        {
            Action <XmlDocument> systemAvatarCallback = delegate(XmlDocument xmlResponse)
            {
                // Get the avatars for the friends without Hangout Avatars
                XmlNode       avatarXmlNode = xmlResponse.SelectSingleNode("/Avatars/Avatar[@AvatarId='1']");
                AvatarId      avatarId;
                List <ItemId> itemIds = null;
                if (AvatarXmlUtil.GetAvatarInfoFromAvatarXmlNode(avatarXmlNode, out avatarId, out itemIds))
                {
                    //use the ServerAssetRepo to composite the List<ItemId> into an XmlNode
                    XmlDocument itemsXml = mServerAssetRepository.GetXmlDna(itemIds);

                    // Get a list of AssetInfos from this xml
                    IEnumerable <AssetInfo> assetInfoList = ServerAssetInfo.Parse(itemsXml);

                    // Make dna
                    mReferenceAvatarDna = new Dna();
                    mReferenceAvatarDna.UpdateDna(assetInfoList);
                    gotReferenceAvatarFinished(mReferenceAvatarDna);
                    mLogger.Debug("System avatar xml = " + xmlResponse.OuterXml);
                }
                else
                {
                    StateServerAssert.Assert(new Exception("Didn't get a valid system avatar for reference avatar, using an empty DNA"));
                    mReferenceAvatarDna = new Dna();
                    gotReferenceAvatarFinished(mReferenceAvatarDna);
                }
            };

            if (mReferenceAvatarDna == null)
            {
                AvatarManagerServiceAPI.GetSystemAvatars(systemAvatarCallback);
            }
            else
            {
                gotReferenceAvatarFinished(mReferenceAvatarDna);
            }
        }