Esempio n. 1
0
        public static void DisposeService(CoreServiceInfo csi)
        {
            if (csi == null)
            {
                return;
            }

            csi.ToConsole("Disposing...");

            if (!csi.Disposed)
            {
                if (csi.DisposeSupported)
                {
                    TryCatch(csi.GetDisposeHandler(), csi.ToConsole);
                }

                TryCatch(csi.OnDisposed, csi.ToConsole);

                if (OnServiceDisposed != null)
                {
                    TryCatch(() => OnServiceDisposed(csi), csi.ToConsole);
                }

                csi.ToConsole("Done.");
            }
            else
            {
                csi.ToConsole("Already disposed, no action taken.");
            }
        }
Esempio n. 2
0
        public static void SaveService(CoreServiceInfo csi)
        {
            if (csi == null)
            {
                return;
            }

            csi.ToConsole("Saving...");

            TryCatch(csi.SaveOptions, csi.ToConsole);

            if (csi.SaveSupported)
            {
                TryCatch(csi.GetSaveHandler(), csi.ToConsole);
            }

            TryCatch(csi.OnSaved, csi.ToConsole);

            if (OnServiceSaved != null)
            {
                TryCatch(() => OnServiceSaved(csi), csi.ToConsole);
            }

            csi.ToConsole("Done.");
        }
Esempio n. 3
0
        public static void LoadService(CoreServiceInfo csi)
        {
            if (csi == null)
            {
                return;
            }

            csi.ToConsole("Loading...");

            TryCatch(csi.LoadOptions, csi.ToConsole);

            if (csi.LoadSupported)
            {
                TryCatch(csi.GetLoadHandler(), csi.ToConsole);
            }

            TryCatch(csi.OnLoaded, csi.ToConsole);

            if (OnServiceLoaded != null)
            {
                TryCatch(() => OnServiceLoaded(csi), csi.ToConsole);
            }

            csi.ToConsole("Done.");
        }
Esempio n. 4
0
        public static void ConfigureService(CoreServiceInfo csi)
        {
            if (csi == null)
            {
                return;
            }

            csi.ToConsole("Configuring...");

            if (!csi.Configured)
            {
                if (csi.ConfigSupported)
                {
                    TryCatch(csi.GetConfigHandler(), csi.ToConsole);
                }

                TryCatch(csi.OnConfigured, csi.ToConsole);

                if (OnServiceConfigured != null)
                {
                    TryCatch(() => OnServiceConfigured(csi), csi.ToConsole);
                }

                csi.ToConsole("Done.");
            }
            else
            {
                csi.ToConsole("Already configured, no action taken.");
            }
        }
Esempio n. 5
0
        public static void InvokeService(CoreServiceInfo csi)
        {
            if (csi == null)
            {
                return;
            }

            csi.ToConsole("Invoking...");

            if (!csi.Invoked)
            {
                if (csi.InvokeSupported)
                {
                    TryCatch(csi.GetInvokeHandler(), csi.ToConsole);
                }

                TryCatch(csi.OnInvoked, csi.ToConsole);

                if (OnServiceInvoked != null)
                {
                    TryCatch(() => OnServiceInvoked(csi), csi.ToConsole);
                }

                csi.ToConsole("Done.");
            }
            else
            {
                csi.ToConsole("Already invoked, no action taken.");
            }
        }
Esempio n. 6
0
        private void CompileService(int x, int y, int w, int h, CoreServiceInfo cs)
        {
            CompileBufferEntry(x, y, w, h, 0, cs);

            y += 75;
            h -= 75;

            cs.CompileControlPanel(this, x, y, w, h);
        }
Esempio n. 7
0
        public static void DisplayTo(Mobile user, CoreServiceInfo cs)
        {
            var node = "Plugins|Services";

            if (cs != null)
            {
                node += "|" + cs.FullName;
            }

            DisplayTo(user, false, node);
        }
Esempio n. 8
0
        private static void OnCoreCommand(CommandEventArgs e)
        {
            if (e == null || e.Mobile == null || e.Mobile.Deleted)
            {
                return;
            }

            if (e.Arguments == null || e.Arguments.Length == 0)
            {
                new MenuGump(
                    e.Mobile as PlayerMobile,
                    null,
                    new MenuGumpOptions(
                        new[]
                {
                    new ListGumpEntry("Help", () => OnCoreCommand(new CommandEventArgs(e.Mobile, e.Command, "?", new[] { "?" }))),
                    new ListGumpEntry("Services", () => new CoreServiceListGump(e.Mobile as PlayerMobile).Send()),
                    new ListGumpEntry("Modules", () => new CoreModuleListGump(e.Mobile as PlayerMobile).Send())
                })).Send();
                return;
            }

            switch (e.Arguments[0].ToLower())
            {
            case "?":
            case "help":
            {
                e.Mobile.SendMessage(0x55, "Usage: {0}{1} <srv | mod | ? | help>", CommandSystem.Prefix, e.Command);
                e.Mobile.SendMessage(0x55, "Usage: srv <name> <ver | save>");
                e.Mobile.SendMessage(0x55, "Usage: mod <name> <ver | save | enable | disable>");
            }
            break;

            case "srv":
            {
                if (e.Arguments.Length < 2)
                {
                    new CoreServiceListGump(e.Mobile as PlayerMobile).Send();
                    return;
                }

                string          search = e.Arguments[1];
                CoreServiceInfo info   = _CoreServices.FirstOrDefault(csi => Insensitive.Contains(csi.Name, search));

                if (info == null)
                {
                    new CoreServiceListGump(e.Mobile as PlayerMobile).Send();
                    return;
                }

                if (e.Arguments.Length < 3)
                {
                    e.Mobile.SendGump(new PropertiesGump(e.Mobile, info));
                    return;
                }

                switch (e.Arguments[2].ToLower())
                {
                case "ver":
                case "version":
                    e.Mobile.SendMessage(0x55, "{0} version: {1}", info.Name, info.Version);
                    break;

                case "save":
                {
                    Action sh = info.GetSaveHandler();

                    if (sh == null)
                    {
                        e.Mobile.SendMessage(0x22, "{0} does not implement the CSSave feature.", info.Name);
                        return;
                    }

                    TryCatch(sh, ex => e.Mobile.SendMessage(0x22, "An error occured, check the logs for more information."));
                }
                break;
                }
            }
            break;

            case "mod":
            {
                if (e.Arguments.Length < 2)
                {
                    new CoreModuleListGump(e.Mobile as PlayerMobile).Send();
                    return;
                }

                string         search = e.Arguments[1];
                CoreModuleInfo info   = _CoreModules.FirstOrDefault(cmi => Insensitive.Contains(cmi.Name, search));

                if (info == null)
                {
                    new CoreModuleListGump(e.Mobile as PlayerMobile).Send();
                    return;
                }

                if (e.Arguments.Length < 3)
                {
                    e.Mobile.SendGump(new PropertiesGump(e.Mobile, info));
                    return;
                }

                switch (e.Arguments[2].ToLower())
                {
                case "ver":
                case "version":
                    e.Mobile.SendMessage(0x55, "{0} version: {1}", info.Name, info.Version);
                    break;

                case "enable":
                {
                    if (info.Enabled)
                    {
                        e.Mobile.SendMessage(0x22, "{0} is already enabled.", info.Name);
                    }
                    else
                    {
                        info.Enabled = true;
                        e.Mobile.SendMessage(0x55, "{0} has been enabled.", info.Name);
                    }
                }
                break;

                case "disable":
                {
                    if (!info.Enabled)
                    {
                        e.Mobile.SendMessage(0x22, "{0} is already disabled.", info.Name);
                    }
                    else
                    {
                        info.Enabled = false;
                        e.Mobile.SendMessage(0x55, "{0} has been disabled.", info.Name);
                    }
                }
                break;

                case "save":
                {
                    Action sh = info.GetSaveHandler();

                    if (sh == null)
                    {
                        e.Mobile.SendMessage(0x22, "{0} does not implement the CMSave feature.", info.Name);
                    }
                    else
                    {
                        TryCatch(
                            sh,
                            ex =>
                                {
                                    e.Mobile.SendMessage(0x22, "An error occured, check the logs for more information.");
                                    ToConsole(ex);
                                });
                    }
                }
                break;
                }
            }
            break;
            }
        }
Esempio n. 9
0
		public static void DisposeService(CoreServiceInfo csi)
		{
			if (csi == null)
			{
				return;
			}

			csi.ToConsole("Disposing...");

			if (!csi.Disposed)
			{
				if (csi.DisposeSupported)
				{
					TryCatch(csi.GetDisposeHandler(), csi.ToConsole);
				}

				TryCatch(csi.OnDisposed, csi.ToConsole);

				if (OnServiceDisposed != null)
				{
					TryCatch(() => OnServiceDisposed(csi), csi.ToConsole);
				}

				csi.ToConsole("Done.");
			}
			else
			{
				csi.ToConsole("Already disposed, no action taken.");
			}
		}
Esempio n. 10
0
		public static void LoadService(CoreServiceInfo csi)
		{
			if (csi == null)
			{
				return;
			}

			csi.ToConsole("Loading...");

			TryCatch(csi.LoadOptions, csi.ToConsole);

			if (csi.LoadSupported)
			{
				TryCatch(csi.GetLoadHandler(), csi.ToConsole);
			}

			TryCatch(csi.OnLoaded, csi.ToConsole);

			if (OnServiceLoaded != null)
			{
				TryCatch(() => OnServiceLoaded(csi), csi.ToConsole);
			}

			csi.ToConsole("Done.");
		}
Esempio n. 11
0
		public static void SaveService(CoreServiceInfo csi)
		{
			if (csi == null)
			{
				return;
			}

			csi.ToConsole("Saving...");

			TryCatch(csi.SaveOptions, csi.ToConsole);

			if (csi.SaveSupported)
			{
				TryCatch(csi.GetSaveHandler(), csi.ToConsole);
			}

			TryCatch(csi.OnSaved, csi.ToConsole);

			if (OnServiceSaved != null)
			{
				TryCatch(() => OnServiceSaved(csi), csi.ToConsole);
			}

			csi.ToConsole("Done.");
		}
Esempio n. 12
0
		public static void InvokeService(CoreServiceInfo csi)
		{
			if (csi == null)
			{
				return;
			}

			csi.ToConsole("Invoking...");

			if (!csi.Invoked)
			{
				if (csi.InvokeSupported)
				{
					TryCatch(csi.GetInvokeHandler(), csi.ToConsole);
				}

				TryCatch(csi.OnInvoked, csi.ToConsole);

				if (OnServiceInvoked != null)
				{
					TryCatch(() => OnServiceInvoked(csi), csi.ToConsole);
				}

				csi.ToConsole("Done.");
			}
			else
			{
				csi.ToConsole("Already invoked, no action taken.");
			}
		}
Esempio n. 13
0
		public static void ConfigureService(CoreServiceInfo csi)
		{
			if (csi == null)
			{
				return;
			}

			csi.ToConsole("Configuring...");

			if (!csi.Configured)
			{
				if (csi.ConfigSupported)
				{
					TryCatch(csi.GetConfigHandler(), csi.ToConsole);
				}

				TryCatch(csi.OnConfigured, csi.ToConsole);

				if (OnServiceConfigured != null)
				{
					TryCatch(() => OnServiceConfigured(csi), csi.ToConsole);
				}

				csi.ToConsole("Done.");
			}
			else
			{
				csi.ToConsole("Already configured, no action taken.");
			}
		}