Aurora.Addon.HyperGrid.ExternalRepresentationUtils.RewriteSOP C# (CSharp) Method

RewriteSOP() public static method

Takes a XML representation of a SceneObjectPart and returns another XML representation with creator data added to it.
public static RewriteSOP ( string xml, string profileURL, IUserAccountService userService, UUID scopeID ) : string
xml string The SceneObjectPart represented in XML2
profileURL string The URL of the profile service for the creator
userService IUserAccountService The service for retrieving user account information
scopeID UUID The scope of the user account information (Grid ID)
return string
        public static string RewriteSOP(string xml, string profileURL, IUserAccountService userService, UUID scopeID)
        {
            if (xml == string.Empty || profileURL == string.Empty || userService == null)
                return xml;

            XmlDocument doc = new XmlDocument ();
            doc.LoadXml (xml);
            XmlNodeList sops = doc.GetElementsByTagName ("SceneObjectPart");

            foreach (XmlNode sop in sops)
            {
                UserAccount creator = null;
                bool hasCreatorData = false;
                XmlNodeList nodes = sop.ChildNodes;
                foreach (XmlNode node in nodes)
                {
                    if (node.Name == "CreatorID")
                    {
                        UUID uuid = UUID.Zero;
                        UUID.TryParse (node.InnerText, out uuid);
                        creator = userService.GetUserAccount (null, uuid);
                    }
                    if (node.Name == "CreatorData" && node.InnerText != null && node.InnerText != string.Empty)
                        hasCreatorData = true;

                    //if (node.Name == "OwnerID")
                    //{
                    //    UserAccount owner = GetUser(node.InnerText);
                    //    if (owner != null)
                    //        node.InnerText = profileServiceURL + "/" + node.InnerText + "/" + owner.FirstName + " " + owner.LastName;
                    //}
                }
                if (!hasCreatorData && creator != null)
                {
                    XmlElement creatorData = doc.CreateElement ("CreatorData");
                    creatorData.InnerText = profileURL + "/" + creator.PrincipalID + ";" + creator.FirstName + " " + creator.LastName;
                    sop.AppendChild (creatorData);
                }
            }

            using (StringWriter wr = new StringWriter ())
            {
                doc.Save (wr);
                return wr.ToString ();
            }
        }

Usage Example

Beispiel #1
0
        protected byte[] AdjustIdentifiers(byte[] data)
        {
            string xml = Utils.BytesToString(data);

            return(Utils.StringToBytes(ExternalRepresentationUtils.RewriteSOP(xml, m_ProfileServiceURL, m_UserAccountService, UUID.Zero)));
        }
ExternalRepresentationUtils