private bool CheckExistence(NpcPresenceInfo pInfo)
        {
            NpcPresenceInfo        result;
            List <NpcPresenceInfo> reslist;

            m_Log.Info("Check that entry exists by npcid 1");
            if (!m_PresenceService.ContainsKey(pInfo.Npc.ID))
            {
                return(false);
            }

            m_Log.Info("Check that entry exists by npcid 2");
            if (!m_PresenceService.TryGetValue(pInfo.Npc.ID, out result))
            {
                return(false);
            }

            m_Log.Info("Verify equality");
            if (!IsEqual(result, pInfo))
            {
                return(false);
            }

            m_Log.Info("Check that entry exists by regionid");
            reslist = m_PresenceService[pInfo.RegionID];
            if (reslist.Count != 1)
            {
                return(false);
            }

            m_Log.Info("Verify equality");
            if (!IsEqual(reslist[0], pInfo))
            {
                return(false);
            }

            m_Log.Info("Check that entry exists by firstname and lastname");
            if (!m_PresenceService.TryGetValue(pInfo.RegionID, pInfo.Npc.FirstName, pInfo.Npc.LastName, out result))
            {
                return(false);
            }

            m_Log.Info("Verify equality");
            if (!IsEqual(result, pInfo))
            {
                return(false);
            }

            m_Log.Info("Check that entry does not exist by firstname and lastname and other regionid");
            if (m_PresenceService.TryGetValue(UUID.RandomFixedFirst(0xFFFFFFFF), pInfo.Npc.FirstName, pInfo.Npc.LastName, out result))
            {
                return(false);
            }

            return(true);
        }
        private void SaveIarCommand(List <string> args, TTY io, UUID limitedToScene)
        {
            if (args[0] == "help")
            {
                string outp = "Available commands:\n";
                outp += "save npc-iar [--noassets] <firstname> <lastname> <inventorypath> <filename>\n";
                io.Write(outp);
                return;
            }

            UUID selectedScene = io.SelectedScene;

            if (limitedToScene != UUID.Zero)
            {
                selectedScene = limitedToScene;
            }

            if (UUID.Zero == selectedScene)
            {
                io.Write("No scene selected");
                return;
            }

            string firstname     = null;
            string lastname      = null;
            string filename      = null;
            string inventorypath = null;
            var    options       = InventoryArchiver.IAR.SaveOptions.None;

            for (int argi = 2; argi < args.Count; ++argi)
            {
                string arg = args[argi];
                if (arg == "--noassets")
                {
                    options |= InventoryArchiver.IAR.SaveOptions.NoAssets;
                }
                else if (firstname == null)
                {
                    firstname = arg;
                }
                else if (lastname == null)
                {
                    lastname = arg;
                }
                else if (inventorypath == null)
                {
                    inventorypath = arg;
                }
                else
                {
                    filename = arg;
                }
            }

            if (string.IsNullOrEmpty(filename))
            {
                io.Write("missing parameters");
                return;
            }

            NpcPresenceInfo presence;

            if (!m_NpcPresenceService.TryGetValue(selectedScene, firstname, lastname, out presence))
            {
                io.Write("Persistent npc not found");
                return;
            }

            try
            {
                using (Stream s = new FileStream(filename, FileMode.Create, FileAccess.Write))
                {
                    InventoryArchiver.IAR.Save(presence.Npc, m_NpcInventoryService, m_NpcAssetService, m_AvatarNameServices, options, filename, inventorypath, io);
                }
                io.Write("IAR saved successfully.");
            }
            catch (Exception e)
            {
                io.WriteFormatted("IAR saving failed: {0}", e.Message);
            }
        }