Esempio n. 1
0
        public void Unload()
        {
            try
            {
                if (status == PluginStatus.Active)
                {
                    mainBot.CommandManager.UnregisterPlugin(this);
                }

                if (proxy != null)
                {
                    proxy.Stop();
                }

                if (domain != null)
                {
                    AppDomain.Unload(domain);
                }
            }
            finally
            {
                proxy  = null;
                domain = null;
                status = PluginStatus.Off;
            }
        }
Esempio n. 2
0
        public PluginResponse Prepare()
        {
            try
            {
                if (file.Extension != ".cs" && file.Extension != ".dll" && file.Extension != ".exe")
                {
                    return(PluginResponse.UnsupportedFile);
                }

                //todo test shadowcopying
                domain = AppDomain.CreateDomain(
                    "Plugin_" + file.Name,
                    AppDomain.CurrentDomain.Evidence,
                    new AppDomainSetup
                {
                    ApplicationBase     = ts3File.Directory.FullName,
                    PrivateBinPath      = "Plugin/..;Plugin",
                    PrivateBinPathProbe = ""
                });
                domain.UnhandledException += (s, e) => Unload();
                proxy = (PluginProxy)domain.CreateInstanceAndUnwrap(
                    proxType.Assembly.FullName,
                    proxType.FullName);

                PluginResponse result;
                if (file.Extension == ".cs")
                {
                    result = PrepareSource();
                }
                else if (file.Extension == ".dll" || file.Extension == ".exe")
                {
                    result = proxy.LoadAssembly(domain, file);
                }
                else
                {
                    throw new InvalidProgramException();
                }

                if (result == PluginResponse.Ok)
                {
                    status = PluginStatus.Ready;
                }
                return(result);
            }
            catch (Exception ex)
            {
                Log.Write(Log.Level.Warning, "Possible plugin failed to load: ", ex);
                return(PluginResponse.Crash);
            }
        }
Esempio n. 3
0
		public WrappedCommand(int invNum, PluginProxy wrapParent, CommandBuildInfo data) : base(data)
		{
			proxy = wrapParent;
			mId = invNum;
		}
Esempio n. 4
0
		public void Unload()
		{
			try
			{
				if (status == PluginStatus.Active)
					mainBot.CommandManager.UnregisterPlugin(this);

				if (proxy != null)
					proxy.Stop();

				if (domain != null)
					AppDomain.Unload(domain);
			}
			finally
			{
				proxy = null;
				domain = null;
				status = PluginStatus.Off;
			}
		}
Esempio n. 5
0
		public PluginResponse Prepare()
		{
			try
			{
				if (file.Extension != ".cs" && file.Extension != ".dll" && file.Extension != ".exe")
					return PluginResponse.UnsupportedFile;

				//todo test shadowcopying
				domain = AppDomain.CreateDomain(
					"Plugin_" + file.Name,
					AppDomain.CurrentDomain.Evidence,
					new AppDomainSetup
					{
						ApplicationBase = ts3File.Directory.FullName,
						PrivateBinPath = "Plugin/..;Plugin",
						PrivateBinPathProbe = ""
					});
				domain.UnhandledException += (s, e) => Unload();
				proxy = (PluginProxy)domain.CreateInstanceAndUnwrap(
					proxType.Assembly.FullName,
					proxType.FullName);

				PluginResponse result;
				if (file.Extension == ".cs")
					result = PrepareSource();
				else if (file.Extension == ".dll" || file.Extension == ".exe")
					result = proxy.LoadAssembly(domain, file);
				else throw new InvalidProgramException();

				if (result == PluginResponse.Ok)
					status = PluginStatus.Ready;
				return result;
			}
			catch (Exception ex)
			{
				Log.Write(Log.Level.Warning, "Possible plugin failed to load: ", ex);
				return PluginResponse.Crash;
			}
		}
Esempio n. 6
0
		public WrappedCommand(int invNum, PluginProxy wrapParent, CommandBuildInfo data) : base(data)
		{
			proxy = wrapParent;
			mId = invNum;
		}