public ObjectInventoryUpdateInfo(ObjectPartInventoryItem item)
 {
     Item   = item;
     PartID = item.ParentFolderID;
     ItemID = item.ID;
 }
Ejemplo n.º 2
0
        private static void FromXmlSavedScriptStateInner(XmlTextReader reader, ObjectGroup group, UUID itemID)
        {
            string tagname        = reader.Name;
            bool   isEmptyElement = reader.IsEmptyElement;
            var    attrs          = new Dictionary <string, string>();

            if (reader.MoveToFirstAttribute())
            {
                do
                {
                    attrs[reader.Name] = reader.Value;
                } while (reader.MoveToNextAttribute());
            }
            ObjectPartInventoryItem item = null;

            if (!attrs.ContainsKey("Asset") || !attrs.ContainsKey("Engine"))
            {
                if (!isEmptyElement)
                {
                    reader.ReadToEndElement(tagname);
                }
                return;
            }

            foreach (ObjectPart part in group.Values)
            {
                if (part.Inventory.ContainsKey(itemID))
                {
                    item = part.Inventory[itemID];
                    UUID assetid;

                    /* validate inventory item */
                    if (!UUID.TryParse(attrs["Asset"], out assetid) ||
                        item.AssetType != SilverSim.Types.Asset.AssetType.LSLText ||
                        item.InventoryType != SilverSim.Types.Inventory.InventoryType.LSL ||
                        assetid != item.AssetID)
                    {
                        item = null;
                    }
                    break;
                }
            }

            if (item == null)
            {
                if (!isEmptyElement)
                {
                    reader.ReadToEndElement(tagname);
                }
            }
            else
            {
                IScriptCompiler compiler;
                string          engineName;
                try
                {
                    engineName = attrs["Engine"];
                    compiler   = CompilerRegistry[engineName];
                }
                catch
                {
                    if (!isEmptyElement)
                    {
                        reader.ReadToEndElement(tagname);
                    }
                    return;
                }

                try
                {
                    item.SetLoadedScriptState(engineName, compiler.StateFromXml(reader, attrs, item));
                }
                catch (ScriptStateLoaderNotImplementedException)
                {
                    if (!isEmptyElement)
                    {
                        reader.ReadToEndElement(tagname);
                    }
                    return;
                }
            }
        }