public void RemoveApiTest_PropertyNameRegex() { var options = new RemoveOptions { FileInfo = TestFiles.Docx.ToFileInfo(), SearchCriteria = new SearchCriteria { NameOptions = new NameOptions { Value = "^[N]ame[A-Z].*", MatchOptions = new MatchOptions { IsRegex = true } } } }; var request = new RemoveRequest(options); var result = MetadataApi.Remove(request); Assert.IsNotNull(result); Assert.IsNotEmpty(result.Path); Assert.IsNotEmpty(result.Url); Assert.Greater(result.RemovedCount, 0); }
public void RemoveApiTest_PropertyNameExactPhrase() { var options = new RemoveOptions { FileInfo = TestFiles.Docx.ToFileInfo(), SearchCriteria = new SearchCriteria { NameOptions = new NameOptions { Value = "NameOfApplication", MatchOptions = new MatchOptions { ExactPhrase = true } } } }; var request = new RemoveRequest(options); var result = MetadataApi.Remove(request); Assert.IsNotNull(result); Assert.IsNotEmpty(result.Path); Assert.IsNotEmpty(result.Url); Assert.Greater(result.RemovedCount, 0); }
public static void Run() { var apiInstance = new AnnotateApi(Constants.GetConfig()); try { var fileInfo = new FileInfo { FilePath = "one-page.docx" }; var options = new RemoveOptions(); options.FileInfo = fileInfo; options.AnnotationIds = new List <int?> { 1, 2, 3 }; options.OutputPath = "Output/output.docx"; var request = new RemoveAnnotationsRequest(options); var link = apiInstance.RemoveAnnotations(request); Console.WriteLine("DeleteAnnotations: Annotations deleted: " + link.Title); } catch (Exception e) { Console.WriteLine("Exception while calling AnnotateApi: " + e.Message); } }
public void RemoveApiTest_Tag() { var options = new RemoveOptions { FileInfo = TestFiles.Docx.ToFileInfo(), SearchCriteria = new SearchCriteria { TagOptions = new TagOptions { ExactTag = new Tag { Name = "Created", Category = "Time" } } } }; var request = new RemoveRequest(options); var result = MetadataApi.Remove(request); Assert.IsNotNull(result); Assert.IsNotEmpty(result.Path); Assert.IsNotEmpty(result.Url); Assert.Greater(result.RemovedCount, 0); }
public static void Run() { var configuration = new Configuration(Common.MyAppSid, Common.MyAppKey); var apiInstance = new MetadataApi(configuration); try { var fileInfo = new FileInfo { FilePath = "documents/input.doc", StorageName = Common.MyStorage }; var options = new RemoveOptions { FileInfo = fileInfo, SearchCriteria = new SearchCriteria { NameOptions = new NameOptions { Value = "Application" } } }; var request = new RemoveRequest(options); var response = apiInstance.Remove(request); Console.WriteLine("Resultant file path: " + response.Path); } catch (Exception e) { Console.WriteLine("Exception while calling MetadataApi: " + e.Message); } }
public void It_should_run_and_remove_a_FeatureBit() { // Arrange var sb = new StringBuilder(); SystemContext.ConsoleWriteLine = s => sb.Append(s); var opts = new RemoveOptions { Name = "foo" }; var repo = Substitute.For <IFeatureBitsRepo>(); repo.GetByNameAsync("foo").Returns(Task.FromResult((IFeatureBitDefinition) new CommandFeatureBitDefintion { Name = "foo", Id = 5 })); repo.RemoveAsync(Arg.Any <IFeatureBitDefinition>()); var it = new RemoveCommand(opts, repo); // Act var result = it.RunAsync().Result; // Assert result.Should().Be(0); repo.Received().GetByNameAsync("foo"); repo.Received().RemoveAsync(Arg.Any <IFeatureBitDefinition>()); sb.ToString().Should().Be("Feature bit removed."); }
public static void Run() { var configuration = new Configuration(Common.MyAppSid, Common.MyAppKey); var apiInstance = new PagesApi(configuration); try { var fileInfo = new FileInfo { FilePath = "WordProcessing/four-pages.docx" }; var options = new RemoveOptions { FileInfo = fileInfo, OutputPath = "Output/remove-pages.docx", Pages = new List <int?> { 2, 4 } }; var request = new RemoveRequest(options); var response = apiInstance.Remove(request); Console.WriteLine("Output file path: " + response.Path); } catch (Exception e) { Console.WriteLine("Exception while calling api: " + e.Message); } }
private List <BaseEntity> FindObjects(Vector3 startPos, string entity, RemoveOptions options) { var entities = new List <BaseEntity>(); if (options.Radius > 0) { var entitiesList = new List <BaseEntity>(); Vis.Entities(startPos, options.Radius, entitiesList); var entitiesCount = entitiesList.Count; for (var i = entitiesCount - 1; i >= 0; i--) { var ent = entitiesList[i]; if (IsNeededObject(ent, entity, options)) { entities.Add(ent); } } } else { var ents = UnityEngine.Object.FindObjectsOfType <BaseEntity>(); var entsCount = ents.Length; for (var i = 0; i < entsCount; i++) { var ent = ents[i]; if (IsNeededObject(ent, entity, options)) { entities.Add(ent); } } } return(entities); }
/// <summary> /// Remove all docker images /// </summary> /// <param name="options"></param> /// <returns></returns> private static int RunRemove(RemoveOptions options) { int code = 0; try { List <DockerImageInfo> dockerImageInfos = GetCurrentDockerImageInfos(RunCmd("docker images")); Console.WriteLine("Check docker images list on your computer"); foreach (var info in dockerImageInfos) { Console.WriteLine(info.Name); } if (options.All) { Console.WriteLine("Are you accept remove all images [y/n]"); ConsoleKeyInfo userInput = Console.ReadKey(); if (userInput.KeyChar.ToString().ToLower() == "y") { Console.WriteLine(); RunRemoveAllDockerImages(dockerImageInfos); } } } catch (Exception ex) { Console.WriteLine(ex.StackTrace); } return(code); }
public void Remove_Watermark_Incorrect_Password() { var testFile = TestFiles.PasswordProtected; var options = new RemoveOptions { FileInfo = new FileInfo { FilePath = testFile.FullName, Password = "******" }, ImageSearchCriteria = new ImageSearchCriteria { ImageFileInfo = TestFiles.SampleWatermarkTransparent.ToFileInfo() }, TextSearchCriteria = new TextSearchCriteria { SearchText = "Watermark text" }, OutputFolder = "removed_watermarks" }; var request = new RemoveRequest(options); var ex = Assert.Throws <ApiException>(() => { WatermarkApi.Remove(request); }); Assert.AreEqual($"Password provided for file '{testFile.FullName}' is incorrect.", ex.Message); }
public void RemoveApiTest() { var testFile = TestFiles.Docx; var options = new RemoveOptions { FileInfo = testFile.ToFileInfo(), SearchCriteria = new SearchCriteria { TagOptions = new TagOptions { ExactTag = new Tag { Name = "Title", Category = "Content" } } } }; var request = new RemoveRequest(options); var result = MetadataApi.Remove(request); Assert.IsNotNull(result); Assert.Greater(result.RemovedCount, 0); }
private bool IsNeededObject(BaseEntity entity, string shortname, RemoveOptions options) { var isAll = shortname.Equals("all"); return((isAll || entity.ShortPrefabName.IndexOf(shortname, StringComparison.CurrentCultureIgnoreCase) != -1) && (options.InsideCupboard && entity.GetBuildingPrivilege() != null || options.OutsideCupboard && entity.GetBuildingPrivilege() == null)); }
private static async Task <int> RunRemoveAndReturnExitCode(RemoveOptions opts) { var repo = GetCorrectRepository(opts); var cmd = new RemoveCommand(opts, repo); int result = await cmd.RunAsync(); return(result); }
public void It_throws_if_the_repo_is_null() { var opts = new RemoveOptions(); // ReSharper disable once ObjectCreationAsStatement Action act = () => { new RemoveCommand(opts, null); }; act.Should().Throw <ArgumentNullException>(); }
public void It_can_be_created() { var opts = new RemoveOptions(); var repo = Substitute.For <IFeatureBitsRepo>(); var it = new RemoveCommand(opts, repo); it.Should().NotBeNull(); }
public static RemoveOptions Timeout(this RemoveOptions opts, TimeSpan?timeout) { if (timeout.HasValue) { return(opts.Timeout(timeout.Value)); } return(opts); }
private static async Task <bool> RunRemoveAndReturnExitCode(RemoveOptions opts) { if (!configurationHelper.ReadConfig()) { return(false); } return(await iotDeviceHelper.RemoveDevice(opts.DevEui, configurationHelper)); }
private static object RunRemoveAndReturnExitCode(RemoveOptions opts) { if (!configurationHelper.ReadConfig()) { return(false); } return(iotDeviceHelper.RemoveDevice(opts.DevEui, configurationHelper).Result); }
private static int RunWith(RemoveOptions opts) { var storage = new ProfileStorage(); foreach (var profile in storage.GetProfiles(opts)) { storage.Remove(profile.Name); Console.WriteLine($"profile {profile.Name} ({profile.UserName}) removed."); } return(0); }
public void Remove_Watermark_No_Search_Criteria() { var testFile = TestFiles.Xlsx; var options = new RemoveOptions { FileInfo = testFile.ToFileInfo(), OutputFolder = "removed_watermarks" }; var request = new RemoveRequest(options); var ex = Assert.Throws <ApiException>(() => { WatermarkApi.Remove(request); }); Assert.AreEqual("Request parameters missing or have incorrect format", ex.Message); }
public static RemoveOptions Defaults(this RemoveOptions opts, DurabilityLevel?durability, TimeSpan?timeout) { opts = new RemoveOptions().RetryStrategy(RetryStrategy); if (durability.HasValue) { opts = opts.Durability(durability.Value); } if (timeout.HasValue) { opts = opts.Timeout(timeout.Value); } return(opts); }
public static void Run() { string filePath = Constants.SAMPLE_VSDX; string filePathOut = Path.Combine(Constants.GetOutputDirectoryPath(), Constants.SAMPLE_NAME + Path.GetExtension(filePath)); RemoveOptions removeOptions = new RemoveOptions(new int[] { 3, 5 }); using (Merger merger = new Merger(filePath)) { merger.RemovePages(removeOptions); merger.Save(filePathOut); } Console.WriteLine("Source document pages was removed successfully."); Console.WriteLine($"Check output {filePathOut}."); }
private void CommandObject(IPlayer player, string command, string[] args) { var prefix = player.IsServer ? string.Empty : _config.Prefix; if (!player.HasPermission(_config.PermissionObject)) { player.Reply(prefix + GetMsg("No Rights", player.Id)); return; } if (args.Length < 1) { player.Reply(prefix + GetMsg("Help", player.Id)); return; } var options = new RemoveOptions(); options.Parse(args); if (player.IsServer) { options.Radius = 0f; } var entity = args[0]; var position = (player.Object as BasePlayer)?.transform.position ?? Vector3.zero; var before = Time.realtimeSinceStartup; var objects = FindObjects(position, entity, options); var count = objects.Count; if (!options.Count) { for (var i = 0; i < count; i++) { var ent = objects[i]; if (ent == null || ent.IsDestroyed) { continue; } ent.Kill(); } } player.Reply(prefix + GetMsg(options.Count ? "Count" : "Removed", player.Id) .Replace("{count}", count.ToString()).Replace("{time}", (Time.realtimeSinceStartup - before).ToString("0.###"))); }
private static void SaveOptionToConfig(RemoveOptions options) { var config = Configuration.Load(); int count = config.Subtrees.RemoveAll(t => t.Alias == options.Alias); config.Save(); if (count > 0) { Console.WriteLine($"{options.Alias} was removed."); } else { Console.WriteLine($"{options.Alias} not found."); } }
public void TestRemoveAnnotations(string filePath) { var options = new RemoveOptions { FileInfo = new Model.FileInfo { FilePath = filePath }, AnnotationIds = new List <int?> { 1, 2, 3 }, OutputPath = $"{DefaultOutputPath}/{Path.GetFileName(filePath)}" }; var result = AnnotateApi.RemoveAnnotations(new RemoveAnnotationsRequest(options)); Assert.NotNull(result); Assert.IsNotEmpty(result.Href); }
private void DrawRemoveCharacters() { removeOption = (RemoveOptions)EditorGUILayout.EnumPopup("Remove From", removeOption); if (removeOption == RemoveOptions.custom) { startIndex = EditorGUILayout.IntField("Start Index", startIndex); } count = EditorGUILayout.IntField("Count", count); // Prevent input mistakes if (startIndex < 0) { startIndex = 0; } if (count < 0) { count = 0; } }
private void CommandChatObject(BasePlayer player, string command, string[] args) { var id = player.UserIDString; if (!permission.UserHasPermission(id, _config.PermissionUse)) { player.ChatMessage(_config.Prefix + GetMsg("No Rights", id)); return; } if (args.Length < 1) { player.ChatMessage(_config.Prefix + GetMsg("Help", id)); return; } var options = new RemoveOptions(); options.Parse(args); var entity = args[0]; var before = Time.realtimeSinceStartup; var objects = FindObjects(player.transform.position, entity, options); var count = objects.Count; if (options.Count) { player.ChatMessage(_config.Prefix + GetMsg("Count", id).Replace("{count}", count.ToString()).Replace("{time}", (Time.realtimeSinceStartup - before).ToString("0.###"))); } else { for (var i = 0; i < count; i++) { var ent = objects[i]; if (ent == null || ent.IsDestroyed) { continue; } ent.Kill(); } player.ChatMessage(_config.Prefix + GetMsg("Removed").Replace("{count}", count.ToString()).Replace("{time}", (Time.realtimeSinceStartup - before).ToString("0.###"))); } }
public void Remove_FileNotFound() { var testFile = TestFiles.NotExist; var options = new RemoveOptions { FileInfo = testFile.ToFileInfo(), SearchCriteria = new SearchCriteria { TagOptions = new TagOptions { PossibleName = "Empty" } } }; var request = new RemoveRequest(options); var ex = Assert.Throws <ApiException>(() => { MetadataApi.Remove(request); }); Assert.AreEqual($"Can't find file located at '{testFile.FullName}'.", ex.Message); }
public void Remove_Watermark() { var testFile = TestFiles.PdfWithWatermarks; var options = new RemoveOptions { FileInfo = testFile.ToFileInfo(), ImageSearchCriteria = new ImageSearchCriteria { ImageFileInfo = TestFiles.SampleWatermarkTransparent.ToFileInfo() }, TextSearchCriteria = new TextSearchCriteria { SearchText = "Watermark text" }, OutputFolder = "removed_watermarks" }; var request = new RemoveRequest(options); var result = WatermarkApi.Remove(request); CheckIfWatermarkNotExist(result.Path, "Watermark text", TestFiles.SampleWatermarkTransparent.ToFileInfo()); }
public void It_should_run_and_show_an_error_if_it_cannot_be_found_() { // Arrange var sb = new StringBuilder(); SystemContext.ConsoleErrorWriteLine = s => sb.Append(s); var opts = new RemoveOptions { Name = "foo" }; var repo = Substitute.For <IFeatureBitsRepo>(); repo.GetByNameAsync("foo").Returns(Task.FromResult((IFeatureBitDefinition)null)); var it = new RemoveCommand(opts, repo); // Act var result = it.RunAsync().Result; // Assert result.Should().Be(1); repo.Received().GetByNameAsync("foo"); sb.ToString().Should().Be("Feature bit 'foo' could not be found."); }