public void TagRemovalTest() { (var tags1, var entry1) = (new string[] { "cheese", "apple", "ice cream" }, new BlogEntry { Url = Path.Combine(RoutePathInfo.ContentPath, "uno").Replace('\\', '/') }); (var tags2, var entry2) = (new string[] { "orange", "juice", "apple", "cheese", "milk" }, new BlogEntry { Url = Path.Combine(RoutePathInfo.ContentPath, "dos").Replace('\\', '/') }); (var tags3, var entry3) = (new string[] { "apple", "juice", "milk", "cheese" }, new BlogEntry { Url = Path.Combine(RoutePathInfo.ContentPath, "tres").Replace('\\', '/') }); var fileSystem = new MockFileSystem(new Dictionary <string, MockFileData>() { { AppPathInfo.BlogTagPath + "milk.json", new MockFileData("{\"milk\":[]}") } }); var tagManager = new TagManager(fileSystem); tagManager.AddTag(tags1, entry1); tagManager.AddTag(tags2, entry2); tagManager.AddTag(tags3, entry3); IEnumerable <string> removedTarget = new string[] { "dos.md", "tres.md" }; tagManager.Clean(removedTarget); var resultDictionary = GetTagMap(tagManager); resultDictionary.Should().NotContainKey("milk"); resultDictionary["cheese"].Should().ContainKey(Path.Combine(RoutePathInfo.ContentPath, "uno").Replace('\\', '/')) .And.NotContainKey(Path.Combine(RoutePathInfo.ContentPath, "dos").Replace('\\', '/')); tagManager.GetRemovedTags().Should().Contain("milk"); }
public async System.Threading.Tasks.Task MetaCountTest() { var fileSystem = new MockFileSystem( new Dictionary <string, MockFileData>() { { AppPathInfo.BlogTagPath, new MockDirectoryData() } } ); var tagManager = new TagManager(fileSystem); tagManager.AddTag(new string[] { "csharp", "fsharp", "qsharp" }, new BlogEntry { Url = "a" }); tagManager.AddTag(new string[] { "csharp", "fsharp", "jsharp" }, new BlogEntry { Url = "b" }); tagManager.AddTag(new string[] { "csharp", "cplusplus", "cminusminus" }, new BlogEntry { Url = "c" }); await tagManager.Serialize().ConfigureAwait(false); using var stream = fileSystem.File.Open(AppPathInfo.BlogTagPath + "meta.tags.json", System.IO.FileMode.Open); var result = await JsonSerializer.DeserializeAsync <Dictionary <string, TagMeta> >(stream).ConfigureAwait(false); Assert.Equal(1, result["qsharp"].Count); Assert.Equal(2, result["fsharp"].Count); Assert.Equal(3, result["csharp"].Count); }
public async Task AddFolderTag(string id, string tagId) { var tag = await _tagManager.GetById(tagId); var folder = await _folderManager.GetFolderAsync(id); await _tagManager.AddTag(folder, tag); await _tagManager.AddFolderTag(await _folderManager.GetFolderAsync(id), tagId); }
static EditorVR() { VRView.onEnable += OnEVREnabled; VRView.onDisable += OnEVRDisabled; if (!PlayerSettings.virtualRealitySupported) { Debug.Log("<color=orange>EditorVR requires VR support. Please check Virtual Reality Supported in Edit->Project Settings->Player->Other Settings</color>"); } #if !ENABLE_OVR_INPUT && !ENABLE_STEAMVR_INPUT && !ENABLE_SIXENSE_INPUT Debug.Log("<color=orange>EditorVR requires at least one partner (e.g. Oculus, Vive) SDK to be installed for input. You can download these from the Asset Store or from the partner's website</color>"); #endif // Add EVR tags and layers if they don't exist var tags = TagManager.GetRequiredTags(); var layers = TagManager.GetRequiredLayers(); foreach (var tag in tags) { TagManager.AddTag(tag); } foreach (var layer in layers) { TagManager.AddLayer(layer); } }
// Code from the previous static constructor moved here to allow for testability static void HandleInitialization() { if (!s_IsInitialized) { s_IsInitialized = true; #if UNITY_EDITOR if (!PlayerSettings.virtualRealitySupported) { Debug.Log("<color=orange>EditorXR requires VR support. Please check Virtual Reality Supported in Edit->Project Settings->Player->XR Settings</color>"); } #endif #if !ENABLE_OVR_INPUT && !ENABLE_STEAMVR_INPUT && !ENABLE_SIXENSE_INPUT Debug.Log("<color=orange>EditorVR requires at least one partner (e.g. Oculus, Vive) SDK to be installed for input. You can download these from the Asset Store or from the partner's website</color>"); #endif } // Add EVR tags and layers if they don't exist #if UNITY_EDITOR var tags = TagManager.GetRequiredTags(); var layers = TagManager.GetRequiredLayers(); foreach (var tag in tags) { TagManager.AddTag(tag); } foreach (var layer in layers) { TagManager.AddLayer(layer); } #endif }
// Code from the previous static constructor moved here to allow for testability static void HandleInitialization() { if (!s_IsInitialized) { s_IsInitialized = true; #if UNITY_EDITOR if (!PlayerSettings.virtualRealitySupported) { Debug.Log("<color=orange>EditorXR requires VR support. Please check Virtual Reality Supported in Edit->Project Settings->Player->XR Settings</color>"); } #endif } // Add EVR tags and layers if they don't exist #if UNITY_EDITOR var tags = TagManager.GetRequiredTags(); var layers = TagManager.GetRequiredLayers(); foreach (var tag in tags) { TagManager.AddTag(tag); } foreach (var layer in layers) { TagManager.AddLayer(layer); } #endif }
public static async Task AddFolderTag(this TagManager manager, IFolder folder, string tagId) { Ensure.Argument.NotNull(manager, nameof(manager)); Ensure.Argument.NotNull(folder, nameof(folder)); Ensure.Argument.NotNullOrEmpty(tagId.ToString(), nameof(tagId)); var tag = await manager.GetById(tagId); await manager.AddTag(folder, tag); }
public void TagAddingTest() { (var tags1, var entry1) = (new string[] { "cheese", "apple", "ice cream" }, new BlogEntry { Url = "this-is-one" }); (var tags2, var entry2) = (new string[] { "orange", "juice", "apple", "cheese" }, new BlogEntry { Url = "this-is-two" }); var tagManager = new TagManager(new MockFileSystem()); tagManager.AddTag(tags1, entry1); tagManager.AddTag(tags2, entry2); var resultDictionary = GetTagMap(tagManager); resultDictionary.Keys.OrderBy(str => str).Should().Equal(new string[] { "apple", "cheese", "ice cream", "juice", "orange" }); resultDictionary["cheese"].Keys.Should().Contain(entry1.Url) .And.Contain(entry2.Url); resultDictionary["orange"].Keys.Should().NotContain(entry1.Url) .And.Contain(entry2.Url); }
public async Task <IActionResult> CreateAnnouncementWidgetTag([DataSourceRequest] DataSourceRequest request, Tag model, string widgetId, string userId) { if (model != null && ModelState.IsValid && string.IsNullOrEmpty(model.Id)) { var newTag = new Tag(); newTag.UserId = userId; newTag.TagName = model.TagName; model.Id = newTag.Id; await _tagManager.AddTag(newTag); _announcementWidgetService.AddWidgetTag(widgetId, newTag.Id); return(Ok(model)); } else if (model != null && ModelState.IsValid && !string.IsNullOrEmpty(model.Id)) { return(Ok(model)); } return(BadRequest(ModelState)); }
internal override async System.Threading.Tasks.Task SaveAsync(IFileInfo targetFileInfo, Stream sourceStream) { modified = true; sourceStream.Position = 0; using StreamReader reader = new(sourceStream); BlogEntry entry = await _formatter.GetBlogHeadAsync(targetFileInfo, reader).ConfigureAwait(false); BlogItem item = new() { Title = entry.Title, Content = await ReadContent(reader).ConfigureAwait(false), CreationDate = entry.Date, ModificationDate = GetModificationDate(targetFileInfo, entry.Date), Tags = entry.Tags }; entry.Summary = _formatter.GetSummary(item.Content); using MemoryStream resultStream = new(); await JsonSerializer.SerializeAsync(resultStream, item).ConfigureAwait(false); resultStream.Position = 0; await base.SaveAsync(targetFileInfo, resultStream).ConfigureAwait(false); //generate categories _tagManager.AddTag(entry.Tags, entry); }
//[Authorize(Roles = "Marketing")] public ActionResult EditSubmission(SubmissionVM model) { if (ModelState.IsValid) { var postMgr = new PostManager(); var catMgr = new CategoryManager(); var tagMgr = new TagManager(); var editTarget = postMgr.GetById(int.Parse(model.SubmissionId)); //sub.Id = int.Parse(model.SubmissionId); editTarget.Payload.PostTitle = model.SubmissionTitle; editTarget.Payload.PostBody = model.SubmissionBody; editTarget.Payload.PostImageFileName = model.SubmissionImageFileName; var catResponse = catMgr.GetCategoryById(int.Parse(model.SubmissionCategoryId)); if (catResponse.Success) { editTarget.Payload.PostCategory = catResponse.Payload; } else { throw new Exception(catResponse.Message); } var tagResponse = tagMgr.ConvertTagStringToList(model.SubmissionTags); if (tagResponse.Success) { var tagList = new List <Tag>(); foreach (var t in tagResponse.Payload) { t.Posts.Add(editTarget.Payload); tagMgr.AddTag(t); tagList.Add(t); } editTarget.Payload.PostTags = tagList; } else { throw new Exception(); } editTarget.Payload.PostState = PostState.Pending; editTarget.Payload.Username = User.Identity.Name; var subResponse = postMgr.EditPost(editTarget.Payload); if (subResponse.Success) { return(RedirectToAction("ViewSubmissions")); } else { throw new Exception(subResponse.Message); } } else { return(View(model)); } }
public async Task <Models.Tag> AddTag(string tagName) { return(await _tags.AddTag(User.GetUserId(), tagName)); }
public static void ShowMissingTagsAndLayersDialog(string[] tags, string[] layers) { List <string> missingTags = CheckMissingTags(tags); List <string> missingLayers = CheckMissingLayers(layers); // No missing tags and layers, nothing to do if (missingTags.Count == 0 && missingLayers.Count == 0) { return; } StringBuilder sb = new StringBuilder(); string title; // Constructing the dialog message sb.Append("In order to use Dynamic Water System, you have to add following "); if (missingTags.Count != 0 && missingLayers.Count == 0) { sb.Append("tags"); title = "Missing tags"; } else if (missingTags.Count == 0 && missingLayers.Count != 0) { sb.Append("layers"); title = "Missing layers"; } else { sb.Append("tags and layers"); title = "Missing tags and layers"; } sb.Append(":\n\n"); if (missingTags.Count != 0) { sb.Append("Tags:\n"); foreach (string missingTag in missingTags) { sb.AppendFormat("- {0}\n", missingTag); } sb.Append("\n"); } if (missingLayers.Count != 0) { sb.Append("Layers:\n"); foreach (string missingLayer in missingLayers) { sb.AppendFormat("- {0}\n", missingLayer); } sb.Append("\n"); } string consoleMessage = sb.ToString(); sb.Append("Do you want to add them automatically?"); if (EditorUtility.DisplayDialog(title, sb.ToString(), "Add", "Cancel")) { foreach (string missingTag in missingTags) { TagManager.AddTag(missingTag); } foreach (string missingLayer in missingLayers) { TagManager.AddLayer(missingLayer); } } else { Debug.LogWarning(consoleMessage); } }