public void Plugin_registration_helper_should_accept_custom_ILogger_parameter() { var context = new XrmFakedContext(); var orgService = context.GetOrganizationService(); context.Initialize(new List <Entity>() { UpdateSdkMessage, CreateSdkMessage, UpdateContactMessageFilter, UpdateAccountMessageFilter, CreateContactMessageFilter }); var logger = new StubLogger(); var pluginWrapper = new PluginWrapper(); pluginWrapper.RegisterPlugins(SampleFullPluginManifest, orgService, logger); var postRegisteredAssemblies = (from a in context.CreateQuery <PluginAssembly>() where a.Name == "SamplePluginAssembly" select a).ToList(); // Stub logger only stores the last call logger.ResponseMessage.Should().Be("Exiting PluginWrapper.RegisterPlugins"); logger.ResponseLogLevel.Should().Be(LogLevel.Debug); postRegisteredAssemblies.Should().HaveCount(1); }
public void Invalid_Manifest_Returns_Negative_Result_And_List_Of_Errors() { var manifest = new PluginManifest() { CdsConnection = new CdsConnection() { CdsUrl = "https://testurl.crm.dynamics.com", CdsAppId = "ID", CdsAppSecret = "SECRET!" }, PluginAssemblies = new[] { new CdsPluginAssembly() { Name = "Test Assembly", Plugins = new[] { new CdsPlugin() { Name = "Test Plugin" } } } } }; var wrapper = new PluginWrapper(); var result = wrapper.Validate(manifest); result.IsValid.Should().BeFalse("assembly and child plugin have missing mandatory data"); result.Errors.Should().HaveCount(3, "assembly has two errors and child plugin has one"); }
public void Plugin_wrapper_consumes_tracing_configuration_from_manifest() { var context = new XrmFakedContext(); var orgService = context.GetOrganizationService(); context.Initialize(new List <Entity>() { UpdateSdkMessage, CreateSdkMessage, UpdateContactMessageFilter, UpdateAccountMessageFilter, CreateContactMessageFilter }); SampleFullPluginManifest.LoggingConfiguration = new LoggingConfiguration() { LoggerConfigurationType = LoggerConfigurationType.Console, LogLevelToTrace = LogLevel.Debug }; var originalConsole = Console.Out; var testConsole = new StringWriter(); Console.SetOut(testConsole); var pluginWrapper = new PluginWrapper(); pluginWrapper.RegisterPlugins(SampleFullPluginManifest, orgService); Console.SetOut(originalConsole); testConsole.ToString().Should().Contain("Exiting PluginWrapper.RegisterPlugins"); }
public void ServiceEndpointAlreadyExistsWithClobber() { var manifestPath = $"{PluginManifestFolderPath}/plugin-manifest.xml"; var manifest = SerialisationWrapper.DeserialiseFromFile <PluginManifest>(manifestPath); var context = new XrmFakedContext(); var orgService = context.GetOrganizationService(); context.Initialize(new List <Entity>() { ExistingTesterQueueEndpoint, UpdateSdkMessage, UpdateContactMessageFilter, UpdateAccountMessageFilter }); var pluginWrapper = new PluginWrapper(); pluginWrapper.RegisterServiceEndpoints(manifest, orgService); var postRegisteredEndpoints = (from e in context.CreateQuery <ServiceEndpoint>() where e.Name == "TesterQueue" select e).ToList(); Assert.AreEqual(1, postRegisteredEndpoints.Count); }
public void New_Plugin_Assembly_And_Steps_Should_Be_Registered() { var context = new XrmFakedContext(); var orgService = context.GetOrganizationService(); context.Initialize(new List <Entity>() { UpdateSdkMessage, CreateSdkMessage, UpdateContactMessageFilter, UpdateAccountMessageFilter, CreateContactMessageFilter }); var pluginWrapper = new PluginWrapper(); pluginWrapper.RegisterPlugins(SampleFullPluginManifest, orgService); var postRegisteredAssemblies = (from a in context.CreateQuery <PluginAssembly>() where a.Name == "SamplePluginAssembly" select a).ToList(); postRegisteredAssemblies.Should().HaveCount(1); }
/// <summary> /// Load the plugins. /// </summary> /// <history> /// [Curtis_Beard] 07/28/2006 Created /// [Curtis_Beard] 08/07/2007 CHG: remove check against version /// </history> public static void Load() { // for right now, just load the internal plugins Plugins.MicrosoftWord.MicrosoftWordPlugin wordPlugin = new Plugins.MicrosoftWord.MicrosoftWordPlugin(); PluginWrapper wrapper = new PluginWrapper(wordPlugin, string.Empty, wordPlugin.Name, true, true); Add(wrapper); // enable/disable plugins based on saved state (if found) string[] plugins = Common.SplitByString(Core.PluginSettings.Plugins, Constants.PLUGIN_SEPARATOR); foreach (string plugin in plugins) { string[] values = Common.SplitByString(plugin, Constants.PLUGIN_ARGS_SEPARATOR); if (values.Length == 3) { string name = values[0]; string version = values[1]; string enabled = values[2]; for (int i = 0; i < __PluginCollection.Count; i++) { if (__PluginCollection[i].Plugin.Name.Equals(name)) { __PluginCollection[i].Enabled = bool.Parse(enabled); break; } } } } }
/// <summary> /// Add a plugin to the collection. /// </summary> /// <param name="plugin">Plugin to add (IbSearchPlugin)</param> /// <returns>Position of plugin in collection</returns> public static int Add(IbSearchPlugin plugin) { PluginWrapper wrapper = new PluginWrapper(plugin, string.Empty, plugin.Name, true, true, __PluginCollection.Count); __PluginCollection.Add(wrapper); return(__PluginCollection.Count - 1); }
/// <summary> /// Add a plugin to the collection. /// </summary> /// <param name="plugin">Plugin to add (IAstroGrepPlugin)</param> /// <returns>Position of plugin in collection</returns> /// <history> /// [Curtis_Beard] 07/28/2006 Created /// </history> public static int Add(IAstroGrepPlugin plugin) { PluginWrapper wrapper = new PluginWrapper(plugin, string.Empty, plugin.Name, true, true); return(__PluginCollection.Add(wrapper)); }
private void initPlugins() { var pluginSection = (Section)System.Configuration.ConfigurationManager.GetSection("pluginsettings"); var sharedSettings = readSharedSettings(); for (var i = 0; i < pluginSection.Plugins.Count; i++) { var pe = (pluginSection.Plugins[i] as IElement); for (var j = 1; j <= pe.NumberOfInstances; j++) { IPlugin plugin = (IPlugin)Activator.CreateInstance(pe.Assembly, pe.Type).Unwrap(); var mre = new ManualResetEvent(false); var wrapper = new PluginWrapper() { Plugin = plugin, Alias = pe.Alias, InstanceID = j, MRE = mre, Settings = convertToDictionary(pe.Settings, sharedSettings) }; var t = new Task(taskAction, wrapper, cancelationTokenSource.Token); plugins.Add(wrapper); pluginTasks.Add(t); } } }
public void Plugin_registration_should_exit_after_assembly_reg_if_update_only() { var context = new XrmFakedContext(); var orgService = context.GetOrganizationService(); context.Initialize(new List <Entity>() { UpdateSdkMessage, CreateSdkMessage, UpdateContactMessageFilter, UpdateAccountMessageFilter, CreateContactMessageFilter }); SampleFullPluginManifest.UpdateAssemblyOnly = true; var pluginWrapper = new PluginWrapper(); pluginWrapper.RegisterPlugins(SampleFullPluginManifest, orgService); var postRegisteredAssemblies = (from a in context.CreateQuery <PluginAssembly>() where a.Name == "SamplePluginAssembly" select a).ToList(); var postRegistrationPlugins = (from p in context.CreateQuery <PluginType>() select p).ToList(); postRegisteredAssemblies.Should().HaveCount(1, "assembly should always be registered"); postRegistrationPlugins.Should().HaveCount(0, "would be 2 if UpdateAssemblyOnly == false"); }
private List <PluginWrapper> TryLoadPlugin(Assembly assembly, DirectoryInfo directoryInfo) { var pluginWrappers = new List <PluginWrapper>(); try { var dir = assembly.ManifestModule.ScopeName.Replace(".dll", ""); var fullPath = directoryInfo.FullName; var types = assembly.GetTypes(); if (types.Length == 0) { DebugWindow.LogError($"Not found any types in plugin {fullPath}"); return(null); } var classesWithIPlugin = types.WhereF(type => typeof(IPlugin).IsAssignableFrom(type)); var settings = types.FirstOrDefaultF(type => typeof(ISettings).IsAssignableFrom(type)); if (settings == null) { DebugWindow.LogError("Not found setting class"); return(null); } foreach (var type in classesWithIPlugin) { if (type.IsAbstract) { continue; } if (Activator.CreateInstance(type) is IPlugin instance) { instance.DirectoryName = dir; instance.DirectoryFullName = fullPath; var pluginWrapper = new PluginWrapper(instance); pluginWrapper.SetApi(GameController, Graphics, PluginManager); pluginWrapper.LoadSettings(); pluginWrapper.Onload(); var sw = PluginLoadTime[directoryInfo.FullName]; sw.Stop(); var elapsedTotalMilliseconds = sw.Elapsed.TotalMilliseconds; pluginWrapper.LoadedTime = elapsedTotalMilliseconds; DebugWindow.LogDebug($"{pluginWrapper.Name} loaded in {elapsedTotalMilliseconds} ms.", 1); pluginWrappers.Add(pluginWrapper); } } return(pluginWrappers); } catch (Exception e) { DebugWindow.LogError($"Error when load plugin ({assembly.ManifestModule.ScopeName}): {e})"); return(null); } }
public static PluginWrapper GetInstance() { if (_instance == null) { _instance = new GameObject("PluginWrapper").AddComponent <PluginWrapper>(); } return(_instance); }
public void clicked() { print("# Button clicked."); PluginWrapper wrapper = new PluginWrapper(); wrapper.showNativeDialog(); }
public ManifestValidationResult ValidateManifest(ICustomisationManifest manifest) { var pluginManifest = (PluginManifest)manifest; var pluginWrapper = new PluginWrapper(); ValidationResult = pluginWrapper.Validate(pluginManifest); return(ValidationResult); }
private void OnPluginUnloaded(PointBlankPlugin plugin) { PluginWrapper wrapper = PM.Plugins.First(a => a.PluginClass == plugin); foreach (KeyValuePair <DetourAttribute, DetourWrapper> kvp in Detours.Where(a => a.Key.Method.DeclaringType.Assembly == wrapper.PluginAssembly && !a.Value.Local)) { kvp.Value.Revert(); Detours.Remove(kvp.Key); } }
/// <summary> /// Reloads a specific plugin /// </summary> /// <param name="plugin">The plugin to reload</param> public static void Reload(PointBlankPlugin plugin) { PluginWrapper wrapper = PM.Plugins.FirstOrDefault(a => a.PluginClass == plugin); if (wrapper != null) { wrapper.Unload(); wrapper.Load(); } }
/// <summary> /// Constructor /// </summary> /// <param name="controller">Main Controller</param> /// <param name="plugin">Plugin</param> public PluginMenuItem(Controller controller, PluginWrapper plugin) : base(plugin.DisplayName()) { this.controller = controller; this.plugin = plugin; OwnerDraw = true; Click += new EventHandler(MenuOnClick); DrawItem += new DrawItemEventHandler(MenuOnDrawItem); MeasureItem += new MeasureItemEventHandler(MenuOnMeasureItem); }
private void OnPluginUnloaded(PointBlankPlugin plugin) { PluginWrapper wrapper = PluginManager.PluginManager.Plugins.First(a => a.PluginClass == plugin); foreach (CommandWrapper wrap in Commands.Where(a => a.Class.DeclaringType.Assembly == wrapper.PluginAssembly)) { Commands.Remove(wrap); } UniConfig.Save(); }
/// <summary> /// Add a plugin to the collection. /// </summary> /// <param name="path">Full file path to plugin</param> /// <returns>Position of plugin in collection</returns> /// <history> /// [Curtis_Beard] 07/28/2006 Created /// </history> public static int Add(string path) { PluginWrapper plugin = LoadPlugin(path); if (plugin != null) { return(__PluginCollection.Add(plugin)); } return(-1); }
/// <summary> /// Plugin has been enabled. /// </summary> /// <param name="plugin">The plugin.</param> private void PluginEnabled(PluginWrapper plugin) { if (plugin == null) { return; } plugin.Plugin.OnStartup( ); Refresh(plugin); }
public void Invalid_plugin_manifest_should_throw_correct_exception() { var context = new XrmFakedContext(); var orgService = context.GetOrganizationService(); var pluginWrapper = new PluginWrapper(); Action sut = () => pluginWrapper.RegisterPlugins(InvalidPluginManifest, orgService); sut.Should().Throw <InvalidManifestException>() .Where(e => e.Message.Contains("'Name' must not be empty")); }
/// <summary> /// Plugin has been disabled. /// </summary> /// <param name="plugin">The plugin.</param> private void PluginDisabled(PluginWrapper plugin) { if (plugin == null) { return; } plugin.Plugin.OnShutdown( ); Refresh(plugin, true); }
private void OnPluginLoaded(PointBlankPlugin plugin) { PluginWrapper wrapper = PluginManager.PluginManager.Plugins.First(a => a.PluginClass == plugin); foreach (Type tClass in wrapper.PluginAssembly.GetTypes()) { if (tClass.IsClass) { LoadCommand(tClass); } } }
// Start is called before the first frame update void Start() { pw_instance = PluginWrapper.GetInstance(); //pr_instance = PlayerRotation.GetInstance(); //Used for testing GetInstance() x = pw_instance.getAngleX(); y = pw_instance.getAngleY(); z = pw_instance.getAngleZ(); Debug.Log("X coord: " + x + ", Y coord: " + y + ", Z coord: " + z); rb_character = GetComponent <Rigidbody>(); Debug.Log(rb_character); //Debug.Log(rb_character); }
// Use this for initialization void Start() { //rb = (Rigidbody)GameObject.Find("ZombiePlayer_Spawn_Postion/Zombie_Player(Clone)/rig/hips/spine/chest").GetComponent<Rigidbody>(); SetText("START"); //InvokeRepeating("repeatCall", 0.1f, 0.1f); PluginWrapper.GetInstance().CallJavaFunc("javaTestFunc", "UnityJavaJarTest"); PluginWrapper.GetInstance().CallJavaFunc("javaGetCoordFunc", "UnityJavaJarTest"); if (GameObject.Find("Wall_spawner").GetComponentInChildren <CollisionDetection>()) { collisionDetection = (CollisionDetection)GameObject.Find("Wall_spawner").GetComponentInChildren <CollisionDetection>(); } }
/// <summary> /// Add a plugin to the collection. /// </summary> /// <param name="path">Full file path to plugin</param> /// <returns>Position of plugin in collection</returns> /// <history> /// [Curtis_Beard] 07/28/2006 Created /// </history> public static int Add(string path) { PluginWrapper plugin = LoadPlugin(path); if (plugin != null) { plugin.Index = __PluginCollection.Count; __PluginCollection.Add(plugin); return __PluginCollection.Count - 1; } return -1; }
/// <summary> /// Load the plugins. /// </summary> public static void Load() { // load the internal plugins // Mono2.4 doesn't like the internal plugins. if (Type.GetType("System.MonoType") == null) { Plugin.MicrosoftWord.MicrosoftWordPlugin wordPlugin = new Plugin.MicrosoftWord.MicrosoftWordPlugin(); PluginWrapper wrapper = new PluginWrapper(wordPlugin, string.Empty, wordPlugin.Name, true, true, 0); Add(wrapper); Plugin.IFilter.IFilterPlugin iFilterPlugin = new Plugin.IFilter.IFilterPlugin(); PluginWrapper iFilterWrapper = new PluginWrapper(iFilterPlugin, string.Empty, iFilterPlugin.Name, true, false, 1); Add(iFilterWrapper); } // load any external plugins string pluginPath = System.IO.Path.Combine(ApplicationPaths.DataFolder, "Plugins"); if (System.IO.Directory.Exists(pluginPath)) { LoadPluginsFromDirectory(pluginPath); } // enable/disable plugins based on saved state (if found) string[] plugins = Utils.SplitByString(Core.PluginSettings.Plugins, DELIMETER); foreach (string plugin in plugins) { string[] values = Utils.SplitByString(plugin, Constants.PLUGIN_ARGS_SEPARATOR); if (values.Length == 3 || values.Length == 4) { string name = values[0]; string version = values[1]; string enabled = values[2]; for (int i = 0; i < __PluginCollection.Count; i++) { if (__PluginCollection[i].Plugin.Name.Equals(name)) { __PluginCollection[i].Enabled = bool.Parse(enabled); __PluginCollection[i].Index = values.Length == 4 ? int.Parse(values[3]) : i; break; } } } } // adjust order __PluginCollection.Sort(new PluginWrapperComparer()); }
private void OnPluginLoaded(PointBlankPlugin plugin) { PluginWrapper wrapper = PM.Plugins.First(a => a.PluginClass == plugin); foreach (Type tClass in wrapper.PluginAssembly.GetTypes()) { if (tClass.IsClass) { foreach (MethodInfo method in tClass.GetMethods(BindingFlags.Public | BindingFlags.NonPublic | BindingFlags.Static | BindingFlags.Instance)) { LoadDetour(method); } } } }
/// <summary> /// Adds the plugin to the collection. /// </summary> /// <param name="plugin">The plugin.</param> /// <param name="addedSections">The added sections.</param> /// <returns></returns> private Section AddPlugin(PluginWrapper plugin, IEnumerable <Section> addedSections) { Section newSection = null; if (addedSections == null) { throw new ArgumentNullException("addedSections"); } if (!string.IsNullOrEmpty(plugin.Plugin.SectionName)) { Section section = addedSections.FirstOrDefault(s => s.Name == plugin.Plugin.SectionName); if (section == null) { section = new Section(plugin); newSection = section; } Entry entry = section.Entries.FirstOrDefault(e => e.Name == plugin.Plugin.EntryName); if (entry == null) { entry = new Entry(plugin); section.Entries.Add(entry); } } if (plugin.Enabled) { plugin.Plugin.OnStartup( ); RefreshAccordion( ); FrameworkElement toolbarItem = plugin.Plugin.GetToolBar( ); if (toolbarItem != null) { ToolbarItems.Add(toolbarItem); _toolBarMap[plugin.Token.AddInFullName] = toolbarItem; } } return(newSection); }
/// <summary> /// Initialises class. No connections are made at init of class, so call `Initialise()` to begin sending and /// recieiving. /// </summary> public Client(string address, int port) { if (!Directory.Exists(ClientConfiguration.DefaultResourceDirectory)) { Directory.CreateDirectory(ClientConfiguration.DefaultResourceDirectory); } ClientConfiguration.CheckCreateConfig(ClientConfiguration.DefaultFilePath); ClientConfiguration = JsonConvert.DeserializeObject <ClientConfiguration>(File.ReadAllText(ClientConfiguration.DefaultFilePath)); wrapper = new PluginWrapper(); MainDatabase = new Database(ClientConfiguration.DatabaseFilePath); Connection conn = new Connection(address, port); Server = new Server(conn); }
internal PluginSettings(PluginWrapper p) { FileName = p.FileName; Name = p.Name; IsEnabled = p.IsEnabled; }
internal PluginSettings(PluginWrapper p) { FileName = p.RelativeFilePath; Name = p.Name; IsEnabled = p.IsEnabled; }