/// <summary> /// Initializes a new instance of the WebRequest class /// </summary> /// <param name="url"></param> /// <param name="callback"></param> /// <param name="owner"></param> public WebRequest(string url, Action<int, string> callback, Plugin owner) { URL = url; Callback = callback; Owner = owner; if (Owner != null) Owner.OnRemovedFromManager += owner_OnRemovedFromManager; }
public void EnqueuePost(string url, string postdata, string callback, Plugin owner, Dictionary<string, string> headers = null) { Interface.Oxide.GetLibrary<WebRequests>("WebRequests").EnqueuePost(url, postdata, (a, b) => { owner.CallHook(callback, a, b); }, owner, headers); }
/// <summary> /// Requests the bootstrap file. /// </summary> /// <param name="projectService">The project service.</param> /// <param name="plugin">The plugin.</param> internal void RequestBootstrapFile( IProjectService projectService, Plugin plugin) { TraceService.WriteLine("PluginService::RequestBootstrapFile plugin=" + plugin.FriendlyName); string bootstrapFileName = plugin.FriendlyName + "PluginBootstrap.cs"; //// check if the file already exists IProjectItemService projectItemService = projectService.GetProjectItem(bootstrapFileName); if (projectItemService == null) { //// get the currently requested plugins. string currentPlugins = this.settingsService.PluginsToAdd; string newPlugins = currentPlugins + "+" + bootstrapFileName; //// and now save the new requested plugins. this.settingsService.PluginsToAdd = newPlugins; TraceService.WriteLine("***plugins for" + projectService.Name + " " + newPlugins); } }
public HandleForm(Plugin plugin) { this.m_plugin = plugin; InitializeComponent(); this.m_styleManager = new FixedStyleManager(this); this.clrStyle.SelectedValueChanged += clrStyle_SelectedValueChanged; this.clrTheme.SelectedValueChanged += clrTheme_SelectedValueChanged; this.clrStyle.Items.AddRange(Enum.GetNames(typeof(MetroColorStyle))); this.clrTheme.Items.AddRange(Enum.GetNames(typeof(MetroThemeStyle))); this.widthLabel.Text = String.Format(this.widthLabel.Text, (this.m_plugin.Map != null ? this.m_plugin.Map.Width.ToString() : "Not in world")); this.heightLabel.Text = String.Format(this.heightLabel.Text, (this.m_plugin.Map != null ? this.m_plugin.Map.Height.ToString() : "Not in world")); this.metroTile1.Text = (this.m_plugin.Map != null ? this.m_plugin.Map.Name.ToString() : "Not in world"); this.clrTheme.SelectedItem = this.clrStyle.SelectedItem = "Default"; if (this.m_plugin.Map != null) { this.m_plugin.Map.TilesAdded += Map_TilesAdded; //this.metroProgressBar1.Maximum = this.m_plugin.Map.Tiles[0].Length * this.m_plugin.Map.Tiles[1].Length; } }
public void AddChatCommand(string name, Plugin plugin, string callback_name) { var command_name = name.ToLowerInvariant(); ChatCommand cmd; if (chatCommands.TryGetValue(command_name, out cmd)) { var previous_plugin_name = cmd.Plugin?.Name ?? "an unknown plugin"; var new_plugin_name = plugin?.Name ?? "An unknown plugin"; var msg = $"{new_plugin_name} has replaced the '{command_name}' chat command previously registered by {previous_plugin_name}"; Interface.Oxide.LogWarning(msg); } cmd = new ChatCommand(command_name, plugin, callback_name); // Add the new command to collections chatCommands[command_name] = cmd; var commandAttribute = new CommandAttribute("/" + command_name, string.Empty); var action = (Action<CommandInfo>)Delegate.CreateDelegate(typeof(Action<CommandInfo>), this, GetType().GetMethod("HandleCommand", BindingFlags.NonPublic | BindingFlags.Instance)); commandAttribute.Method = action; if (CommandManager.RegisteredCommands.ContainsKey(command_name)) { var new_plugin_name = plugin?.Name ?? "An unknown plugin"; var msg = $"{new_plugin_name} has replaced the '{command_name}' chat command"; Interface.Oxide.LogWarning(msg); } CommandManager.RegisteredCommands[command_name] = commandAttribute; // Hook the unload event if (plugin) plugin.OnRemovedFromManager += plugin_OnRemovedFromManager; }
/// <summary> /// Implements the OnConnection method of the IDTExtensibility2 interface. /// Receives notification that the Add-in is being loaded. /// </summary> /// <param name="application">The application.</param> /// <param name="connectMode">The connect mode.</param> /// <param name="addInInst">The add in inst.</param> /// <param name="custom">The custom.</param> /// <seealso class="IDTExtensibility2"/> public void OnConnection(object application, ext_ConnectMode connectMode, object addInInst, ref Array custom) { if (_gitPlugin == null) { var cultureInfo = new CultureInfo("en-US"); Thread.CurrentThread.CurrentCulture = cultureInfo; _gitPlugin = new Plugin((DTE2)application, (AddIn)addInInst, "GitExtensions", "GitPlugin.Connect"); } switch (connectMode) { case ext_ConnectMode.ext_cm_UISetup: // Install CommandBar permanently (only runs once per AddIn) GitPluginUISetup(); break; case ext_ConnectMode.ext_cm_Startup: // The add-in was marked to load on startup // Do nothing at this point because the IDE may not be fully initialized // Visual Studio will call OnStartupComplete when fully initialized GitPluginUIUpdate(); break; case ext_ConnectMode.ext_cm_AfterStartup: // The add-in was loaded by hand after startup using the Add-In Manager // Initialize it in the same way that when is loaded on startup GitPluginInit(); break; } }
public static string JavaScript(this UrlHelper helper, Plugin type, string fileName) { var path = string.Empty; switch (type) { case Plugin.Multiselect: path = string.Format("~/Scripts/Plugins/Multiselect/{0}", fileName); break; case Plugin.DataPicker: path = string.Format("~/Scripts/Plugins/DatePicker/{0}", fileName); break; case Plugin.FlexGrid: path = string.Format("~/Scripts/Plugins/Flexigrid/js/{0}", fileName); break; case Plugin.Visualize: path = string.Format("~/Content/js/{0}", fileName); break; case Plugin.AnimatedDIV: path = string.Format("~/Scripts/Plugins/AnimatedDIV/{0}", fileName); break; case Plugin.TimePicker: path = string.Format("~/Scripts/Plugins/TimePicker/{0}", fileName); break; default: path = string.Format("~/Scripts/Plugins/jCombo/{0}", fileName); break; } return helper.Content(path); }
void CrossConnectivity_Current_ConnectivityChanged (object sender, Plugin.Connectivity.Abstractions.ConnectivityChangedEventArgs e) { InvokeOnMainThread(() => { new UIAlertView("status", "Connected: " + e.IsConnected + " Connected: " + CrossConnectivity.Current.IsConnected, null, "OK").Show(); }); }
public PluginViewModel(Plugin plugin) { this.Plugin = plugin; var notifiers = plugin.OfType<INotifier>().ToArray(); if (notifiers.Length >= 1) this.notifier = new AggregateNotifier(notifiers); }
static PluginCache() { _setterRules = new List<Predicate<PropertyInfo>>(); _plugins = new Cache<Type, Plugin>(t => { var plugin = new Plugin(t); foreach (var rule in _setterRules) { plugin.UseSetterRule(rule); } return plugin; }); _builders = new Cache<Type, IInstanceBuilder>(t => { try { Plugin plugin = _plugins[t]; return BuilderCompiler.CreateBuilder(plugin); } catch (Exception e) { throw new StructureMapException(245, e, t.AssemblyQualifiedName); } }); }
public static bool Run(Plugin plugin, ICore core) { var gcList = from Geocache gc in core.Geocaches where gc.FoundDate!=null && ((DateTime)gc.FoundDate).Month == gc.PublishedTime.Month && ((DateTime)gc.FoundDate).Day == gc.PublishedTime.Day select gc; //mass update, so within begin and end core.Geocaches.BeginUpdate(); //reset current selection foreach (Geocache gc in core.Geocaches) { gc.Selected = false; } //set the intended selection foreach (Geocache gc in gcList) { gc.Selected = true; } core.Geocaches.EndUpdate(); return true; }
public static void Register(Player.OnPlayerChat method, Priority priority, Plugin plugin) { if (Find(plugin) != null) throw new Exception("The user tried to register 2 of the same event!"); events.Add(new OnPlayerChatEvent(method, priority, plugin)); Organize(); }
/// <summary> /// Initializes a new instance of the WebRequest class /// </summary> /// <param name="url"></param> /// <param name="callback"></param> /// <param name="owner"></param> public WebRequest(string url, Action<int, string> callback, Plugin owner) { URL = url; Callback = callback; Owner = owner; removedFromManager = Owner?.OnRemovedFromManager.Add(owner_OnRemovedFromManager); }
public static bool Run(Plugin plugin, ICore core) { DateTime dt = DateTime.Now.AddDays(-7); var gcList = from Geocache gc in core.Geocaches where gc.DataFromDate < dt select gc; //mass update, so within begin and end core.Geocaches.BeginUpdate(); //reset current selection foreach (Geocache gc in core.Geocaches) { gc.Selected = false; } //set the intended selection foreach (Geocache gc in gcList) { gc.Selected = true; } if (MessageBox.Show(LanguageSupport.Instance.GetTranslation("Automatically archive selected geocaches?"),LanguageSupport.Instance.GetTranslation("Archive"), MessageBoxButtons.YesNo, MessageBoxIcon.Question, MessageBoxDefaultButton.Button2)== DialogResult.Yes) { foreach (Geocache gc in gcList) { gc.Archived = true; gc.Available = false; } } core.Geocaches.EndUpdate(); return true; }
public GameServer(ref Config uc, ref GameData gd, ref Plugin[] plugs, ref ExtensionHandler ext) { UserConfig = uc; gameData = gd; Plugins = plugs; extensions = ext; }
public void AddConsoleCommand(string name, Plugin plugin, string callback_name) { // Hook the unload event if (plugin) plugin.OnRemovedFromManager += plugin_OnRemovedFromManager; var full_name = name.Trim(); ConsoleCommand cmd; if (consoleCommands.TryGetValue(full_name, out cmd)) { // This is a custom command which was already registered by another plugin var previous_plugin_name = cmd.PluginCallbacks[0].Plugin?.Name ?? "An unknown plugin"; var new_plugin_name = plugin?.Name ?? "An unknown plugin"; var msg = $"{new_plugin_name} has replaced the {name} console command which was previously registered by {previous_plugin_name}"; Interface.Oxide.LogWarning(msg); consoleCommands.Remove(full_name); } // The command either does not already exist or is replacing a previously registered command cmd = new ConsoleCommand(full_name); cmd.AddCallback(plugin, callback_name); // Add the new command to collections consoleCommands[full_name] = cmd; }
/// <summary> /// Initializes a new instance of the RegisteredCommand class /// </summary> /// <param name="source"></param> /// <param name="command"></param> /// <param name="callback"></param> public RegisteredCommand(Plugin source, string command, string callback) { // Store fields Source = source; Command = command; Callback = callback; }
private void loadXML() { XmlDocument store = new XmlDocument(); try { store.Load("store.xml"); } catch(Exception e) { MessageBox.Show("Impossible d'ouvrir le fichier : store.xml\nVeuillez mettre à jour votre liste de plugins."); return; } XmlNode plugins = store.DocumentElement.SelectSingleNode("/plugins"); foreach(XmlNode node in plugins.ChildNodes) { Plugin p = new Plugin(); p.Creator = node.SelectSingleNode("creator").InnerText; p.Description = node.SelectSingleNode("description").InnerText; p.Name = node.SelectSingleNode("name").InnerText; p.Url = node.SelectSingleNode("url").InnerText; p.Version = node.SelectSingleNode("version").InnerText; p.Download = node.SelectSingleNode("download").InnerText; this.plugins.Add(p); listBox1.Items.Add(p.Name); } }
// --- functions --- /// <summary>Loads all non-runtime plugins.</summary> internal static void LoadPlugins() { UnloadPlugins(); string folder = Program.FileSystem.GetDataFolder("Plugins"); string[] files = Directory.GetFiles(folder); List<Plugin> list = new List<Plugin>(); foreach (string file in files) { if (file.EndsWith(".dll", StringComparison.OrdinalIgnoreCase)) { try { Plugin plugin = new Plugin(file); Assembly assembly = Assembly.LoadFile(file); Type[] types = assembly.GetTypes(); foreach (Type type in types) { if (type.IsSubclassOf(typeof(OpenBveApi.Textures.TextureInterface))) { plugin.Texture = (OpenBveApi.Textures.TextureInterface)assembly.CreateInstance(type.FullName); } if (type.IsSubclassOf(typeof(OpenBveApi.Sounds.SoundInterface))) { plugin.Sound = (OpenBveApi.Sounds.SoundInterface)assembly.CreateInstance(type.FullName); } if (type.IsSubclassOf(typeof(OpenBveApi.Objects.ObjectInterface))) { plugin.Object = (OpenBveApi.Objects.ObjectInterface)assembly.CreateInstance(type.FullName); } } if (plugin.Texture != null | plugin.Sound != null | plugin.Object != null) { plugin.Load(); list.Add(plugin); } } catch { // TODO // } } } LoadedPlugins = list.ToArray(); }
public static void UnRegister(Plugin plugin) { if (Find(plugin) == null) throw new Exception("This plugin doesnt have this event registered!"); else events.Remove(Find(plugin)); }
public void Configure(Plugin plugin) { foreach (var rule in _setterRules) { plugin.UseSetterRule(rule); } }
/// <summary> /// Loads a given plugin /// </summary> /// <param name="plugin"></param> /// <param name="waitingForAccess"></param> protected void LoadPlugin(Plugin plugin, bool waitingForAccess = false) { if (!File.Exists(plugin.Filename)) { LoadingPlugins.Remove(plugin.Name); Interface.Oxide.LogWarning("Script no longer exists: {0}", plugin.Name); return; } try { plugin.Load(); Interface.Oxide.UnloadPlugin(plugin.Name); LoadingPlugins.Remove(plugin.Name); Interface.Oxide.PluginLoaded(plugin); } catch (IOException) { if (!waitingForAccess) Interface.Oxide.LogWarning("Waiting for another application to stop using script: {0}", plugin.Name); Interface.Oxide.GetLibrary<Timer>().Once(.5f, () => LoadPlugin(plugin, true)); } catch (Exception ex) { LoadingPlugins.Remove(plugin.Name); Interface.Oxide.LogException($"Failed to load plugin {plugin.Name}", ex); } }
void ConnecitvityChanged (object sender, Plugin.Connectivity.Abstractions.ConnectivityChangedEventArgs e) { Device.BeginInvokeOnMainThread(() => { OfflineStack.IsVisible = !e.IsConnected; }); }
public bool registerPlugin(Plugin plug) { //MenuItem it = (MenuItem)pluginsToolStripMenuItem; ToolStripMenuItem item = new ToolStripMenuItem(plug.Name); item.Click += new EventHandler(pluginClicked); pluginsToolStripMenuItem.DropDownItems.Add(item); return true; }
/// <summary> /// Adds a plugin to this manager /// </summary> /// <param name="plugin"></param> public bool AddPlugin(Plugin plugin) { if (loadedplugins.ContainsKey(plugin.Name)) return false; loadedplugins.Add(plugin.Name, plugin); plugin.HandleAddedToManager(this); if (OnPluginAdded != null) OnPluginAdded(plugin); return true; }
public void got_the_right_number_of_mandatory_and_optional_properties() { var plugin = new Plugin(typeof (SetterTarget)); plugin.Setters.IsMandatory("Name1").ShouldBeFalse(); plugin.Setters.IsMandatory("Name2").ShouldBeTrue(); plugin.Setters.IsMandatory("Name3").ShouldBeFalse(); plugin.Setters.IsMandatory("Name4").ShouldBeTrue(); }
internal Handlers(Plugin Owner) { this.fOwner = Owner; this.fHandlers = new Dictionary<uint, PacketHandler>(); this.fPacketLogs = new StringBuilder(); CoreManager.GetCore().GetConnectionManager().OnConnectionOpen += new ConnectionEventHandler(RegisterHandlersToNew); }
public PluginLoadEvent(Plugin plugin) { if (plugin == null) { throw new ArgumentNullException("plugin"); } Plugin = plugin; }
internal void LoadPlugin(string s) { Plugin p = new Plugin(s, false); TreeNode tn = new TreeNode(p.Name); CreatePluginTree(p, tn); PluginTree.Nodes.Add(tn); UpdateStringEditor(); }
public void set_should_add_plugin() { var args = new ServiceArguments(); var plugin = new Plugin(); args.Has(typeof(Plugin)).ShouldBeFalse(); args.Set(typeof(Plugin), plugin); args.Has(typeof(Plugin)).ShouldBeTrue(); }
private static bool Minimap_UpdateProfilePins(Minimap __instance, ref Minimap.PinData ___m_deathPin) { PlayerProfile prof = Game.instance.GetPlayerProfile(); if (prof.HaveDeathPoint() && ___m_deathPin == null) { var text = string.Empty; if (Settings.MoreDetailsOnDeathMarkers.Value) { text = prof.GetName() + "\n" + DateTime.Now.ToString("hh:mm"); } var newpin = __instance.AddPin(prof.GetDeathPoint(), Minimap.PinType.Death, text, true, false); ___m_deathPin = newpin; if (Settings.ShareDeathMarkers.Value) { Plugin.SendPin(newpin, text); } } bool done = false; if (Settings.ShowCarts.Value) { if (cartZDOs == null) { cartZDOs = new List <ZDO>(); } var cartIndex = index; while (!done && cartIndex - index < sectorsPerFrame) { done = done || ZDOMan.instance.GetAllZDOsWithPrefabIterative(CartPrefab, cartZDOs, ref cartIndex); } cartZDOs = cartZDOs .Distinct() .Where(x => x.GetPosition().y > ZoneSystem.instance.m_waterLevel - 40f) .ToList(); if (cartPins == null) { cartPins = new List <Minimap.PinData>(); } if (cartPins.Count != cartZDOs.Count) { foreach (var pin in cartPins) { Minimap.instance.RemovePin(pin); } cartPins.Clear(); for (int i = 0; i < cartZDOs.Count; i++) { var pos = cartZDOs[i].GetPosition(); var newPin = Minimap.instance.AddPin(pos, Minimap.PinType.Icon1, string.Empty, false, false); newPin.m_icon = Assets.cartSprite; cartPins.Add(newPin); } } for (int i = 0; i < cartZDOs.Count; i++) { cartPins[i].m_pos = cartZDOs[i].GetPosition(); } } if (Settings.ShowBoats.Value) { if (raftZDOs == null) { raftZDOs = new List <ZDO>(); } if (karveZDOs == null) { karveZDOs = new List <ZDO>(); } if (longboatZDOs == null) { longboatZDOs = new List <ZDO>(); } raftZDOs.RemoveAll(x => x == null || !x.IsValid()); karveZDOs.RemoveAll(x => x == null || !x.IsValid()); longboatZDOs.RemoveAll(x => x == null || !x.IsValid()); var raftIndex = index; var karveIndex = index; var longIndex = index; while (!done && raftIndex - index < sectorsPerFrame) { done = done || ZDOMan.instance.GetAllZDOsWithPrefabIterative(RaftPrefabName, raftZDOs, ref raftIndex); ZDOMan.instance.GetAllZDOsWithPrefabIterative(KarvePrefabName, karveZDOs, ref karveIndex); ZDOMan.instance.GetAllZDOsWithPrefabIterative(LongboatPrefabName, longboatZDOs, ref longIndex); } raftZDOs = raftZDOs.Distinct().ToList(); karveZDOs = karveZDOs.Distinct().ToList(); longboatZDOs = longboatZDOs.Distinct().ToList(); var boatZDOs = raftZDOs.Select(x => new Tuple <ZDO, string>(x, Localization.instance.Localize("$ship_raft"))) .Concat(karveZDOs.Select(x => new Tuple <ZDO, string>(x, Localization.instance.Localize("$ship_karve")))) .Concat(longboatZDOs.Select(x => new Tuple <ZDO, string>(x, Localization.instance.Localize("$ship_longship")))) .Where(x => x.Item1.GetPosition().y > ZoneSystem.instance.m_waterLevel - 40f) // Attempt to remove/hide items below the map .ToList() ; if (boatPins == null) { boatPins = new List <Minimap.PinData>(); } if (boatPins.Count != boatZDOs.Count) { foreach (var pin in boatPins) { Minimap.instance.RemovePin(pin); } boatPins.Clear(); for (int i = 0; i < boatZDOs.Count; i++) { var pos = boatZDOs[i].Item1.GetPosition(); var newPin = Minimap.instance.AddPin(pos, Minimap.PinType.Icon1, boatZDOs[i].Item2, false, false); newPin.m_icon = Assets.boatSprite; boatPins.Add(newPin); } } for (int i = 0; i < boatZDOs.Count; i++) { boatPins[i].m_pos = boatZDOs[i].Item1.GetPosition(); boatPins[i].m_name = boatZDOs[i].Item2; } } if (done) { index = 0; } else { index += sectorsPerFrame; } return(true); }
protected override bool OnCommand(string[] args) { if (Plugin.SendMessage(args)) { return(true); } switch (args[0].ToLower()) { case "broadcast": return(OnBroadcastCommand(args)); case "relay": return(OnRelayCommand(args)); case "sign": return(OnSignCommand(args)); case "change": return(OnChangeCommand(args)); case "create": return(OnCreateCommand(args)); case "export": return(OnExportCommand(args)); case "help": return(OnHelpCommand(args)); case "plugins": return(OnPluginsCommand(args)); case "import": return(OnImportCommand(args)); case "list": return(OnListCommand(args)); case "claim": return(OnClaimCommand(args)); case "open": return(OnOpenCommand(args)); case "rebuild": return(OnRebuildCommand(args)); case "send": return(OnSendCommand(args)); case "show": return(OnShowCommand(args)); case "start": return(OnStartCommand(args)); case "upgrade": return(OnUpgradeCommand(args)); default: return(base.OnCommand(args)); } }
/// <summary> /// Unregisters the specified command /// </summary> /// <param name="command"></param> public void UnregisterCommand(string command, Plugin plugin) => registeredCommands.Remove(command);
public DiscordBridgeAPI(Plugin plugin) { this.plugin = plugin; this.initialized = true; }