Пример #1
0
        /// <summary>
        /// Takes a XML representation of a SceneObjectPart and returns another XML representation
        /// with creator data added to it.
        /// </summary>
        /// <param name="xml">The SceneObjectPart represented in XML2</param>
        /// <param name="sceneName">An identifier for the component that's calling this function</param>
        /// <param name="homeURL">The URL of the user agents service (home) for the creator</param>
        /// <param name="userService">The service for retrieving user account information</param>
        /// <param name="scopeID">The scope of the user account information (Grid ID)</param>
        /// <returns>The SceneObjectPart represented in XML2</returns>
        public static string RewriteSOP(string xmlData, string sceneName, string homeURL, IUserAccountService userService, UUID scopeID)
        {
            //            Console.WriteLine("Input XML [{0}]", xmlData);
            if (xmlData == string.Empty || homeURL == string.Empty || userService == null)
            {
                return(xmlData);
            }

            // Deal with bug
            xmlData = ExternalRepresentationUtils.SanitizeXml(xmlData);

            using (StringWriter sw = new StringWriter())
                using (XmlTextWriter writer = new XmlTextWriter(sw))
                    using (XmlTextReader wrappedReader = new XmlTextReader(xmlData, XmlNodeType.Element, null))
                        using (XmlReader reader = XmlReader.Create(wrappedReader, new XmlReaderSettings()
                        {
                            IgnoreWhitespace = true, ConformanceLevel = ConformanceLevel.Fragment
                        }))
                        {
                            TransformXml(reader, writer, sceneName, homeURL, userService, scopeID);

                            //                Console.WriteLine("Output: [{0}]", sw.ToString());

                            return(sw.ToString());
                        }
        }
Пример #2
0
        /// <summary>
        /// Reify/deserialize landData
        /// </summary>
        /// <param name="serializedLandData"></param>
        /// <returns></returns>
        /// <exception cref="System.Xml.XmlException"></exception>
        public static LandData Deserialize(string serializedLandData)
        {
            LandData landData = new LandData();

            using (XmlTextReader reader = new XmlTextReader(new StringReader(serializedLandData)))
            {
                reader.ReadStartElement("LandData");

                ExternalRepresentationUtils.ExecuteReadProcessors <LandData>(landData, m_ldProcessors, reader);

                reader.ReadEndElement();
            }

            return(landData);
        }
        /// <summary>
        /// Deserialize settings
        /// </summary>
        /// <param name="serializedSettings"></param>
        /// <returns></returns>
        /// <exception cref="System.Xml.XmlException"></exception>
        public static InventoryItemBase Deserialize(string serialization)
        {
            InventoryItemBase item = new InventoryItemBase();

            using (XmlTextReader reader = new XmlTextReader(new StringReader(serialization)))
            {
                reader.ReadStartElement("InventoryItem");

                ExternalRepresentationUtils.ExecuteReadProcessors <InventoryItemBase>(
                    item, m_InventoryItemXmlProcessors, reader);

                reader.ReadEndElement(); // InventoryItem
            }

            //m_log.DebugFormat("[XXX]: parsed InventoryItemBase {0} - {1}", obj.Name, obj.UUID);
            return(item);
        }
Пример #4
0
        public static void ProcessParcelAccessList(LandData ld, XmlReader xtr)
        {
            if (!xtr.IsEmptyElement)
            {
                while (xtr.Read() && xtr.NodeType != XmlNodeType.EndElement)
                {
                    LandAccessEntry lae = new LandAccessEntry();

                    xtr.ReadStartElement("ParcelAccessEntry");

                    ExternalRepresentationUtils.ExecuteReadProcessors <LandAccessEntry>(lae, m_laeProcessors, xtr);

                    xtr.ReadEndElement();

                    ld.ParcelAccessList.Add(lae);
                }
            }

            xtr.Read();
        }
        public static string Serialize(InventoryItemBase inventoryItem, Dictionary <string, object> options, IUserAccountService userAccountService)
        {
            StringWriter  sw     = new StringWriter();
            XmlTextWriter writer = new XmlTextWriter(sw);

            writer.Formatting = Formatting.Indented;
            writer.WriteStartDocument();

            writer.WriteStartElement("InventoryItem");

            writer.WriteStartElement("Name");
            writer.WriteString(inventoryItem.Name);
            writer.WriteEndElement();
            writer.WriteStartElement("ID");
            writer.WriteString(inventoryItem.ID.ToString());
            writer.WriteEndElement();
            writer.WriteStartElement("InvType");
            writer.WriteString(inventoryItem.InvType.ToString());
            writer.WriteEndElement();
            writer.WriteStartElement("CreatorUUID");
            writer.WriteString(OspResolver.MakeOspa(inventoryItem.CreatorIdAsUuid, userAccountService));
            writer.WriteEndElement();
            writer.WriteStartElement("CreationDate");
            writer.WriteString(inventoryItem.CreationDate.ToString());
            writer.WriteEndElement();
            writer.WriteStartElement("Owner");
            writer.WriteString(inventoryItem.Owner.ToString());
            writer.WriteEndElement();
            writer.WriteStartElement("Description");
            writer.WriteString(inventoryItem.Description);
            writer.WriteEndElement();
            writer.WriteStartElement("AssetType");
            writer.WriteString(inventoryItem.AssetType.ToString());
            writer.WriteEndElement();
            writer.WriteStartElement("AssetID");
            writer.WriteString(inventoryItem.AssetID.ToString());
            writer.WriteEndElement();
            writer.WriteStartElement("SaleType");
            writer.WriteString(inventoryItem.SaleType.ToString());
            writer.WriteEndElement();
            writer.WriteStartElement("SalePrice");
            writer.WriteString(inventoryItem.SalePrice.ToString());
            writer.WriteEndElement();
            writer.WriteStartElement("BasePermissions");
            writer.WriteString(inventoryItem.BasePermissions.ToString());
            writer.WriteEndElement();
            writer.WriteStartElement("CurrentPermissions");
            writer.WriteString(inventoryItem.CurrentPermissions.ToString());
            writer.WriteEndElement();
            writer.WriteStartElement("EveryOnePermissions");
            writer.WriteString(inventoryItem.EveryOnePermissions.ToString());
            writer.WriteEndElement();
            writer.WriteStartElement("NextPermissions");
            writer.WriteString(inventoryItem.NextPermissions.ToString());
            writer.WriteEndElement();
            writer.WriteStartElement("Flags");
            writer.WriteString(inventoryItem.Flags.ToString());
            writer.WriteEndElement();
            writer.WriteStartElement("GroupID");
            writer.WriteString(inventoryItem.GroupID.ToString());
            writer.WriteEndElement();
            writer.WriteStartElement("GroupOwned");
            writer.WriteString(inventoryItem.GroupOwned.ToString());
            writer.WriteEndElement();
            if (options.ContainsKey("creators") && !string.IsNullOrEmpty(inventoryItem.CreatorData))
            {
                writer.WriteElementString("CreatorData", inventoryItem.CreatorData);
            }
            else if (options.ContainsKey("home"))
            {
                if (userAccountService != null)
                {
                    UserAccount account = userAccountService.GetUserAccount(UUID.Zero, inventoryItem.CreatorIdAsUuid);
                    if (account != null)
                    {
                        string creatorData = ExternalRepresentationUtils.CalcCreatorData((string)options["home"], inventoryItem.CreatorIdAsUuid, account.FirstName + " " + account.LastName);
                        writer.WriteElementString("CreatorData", creatorData);
                    }
                    writer.WriteElementString("CreatorID", inventoryItem.CreatorId);
                }
            }

            writer.WriteEndElement();

            writer.Close();
            sw.Close();

            return(sw.ToString());
        }