private void ConvertTags(IList <Tag> tags, TagMapping mapping, Tag parent) { if (!string.IsNullOrWhiteSpace(mapping.Slug)) { Tag tag = new Tag { Slug = mapping.Slug, Description = mapping.Description, Name = mapping.Name ?? mapping.Slug, Id = Guid.NewGuid().ToString(), ParentId = parent?.Id }; _tagLookup.Add(mapping.Slug, tag.Id); if (mapping.Aliases != null) { foreach (var alias in mapping.Aliases) { _tagLookup.Add(alias, tag.Id); } } tags.Add(tag); if (mapping.ChildTags != null) { foreach (var child in mapping.ChildTags) { ConvertTags(tags, child, tag); } } } }
protected override void OnModelCreating(ModelBuilder modelBuilder) { base.OnModelCreating(modelBuilder); ArticleMapping.Map(modelBuilder.Entity <Article>()); TagMapping.Map(modelBuilder.Entity <Tag>()); ArticleTagMapping.Map(modelBuilder.Entity <ArticleTag>()); }
public TagMappingContract(TagMapping tagMapping, ContentLanguagePreference lang) { ParamIs.NotNull(() => tagMapping); SourceTag = tagMapping.SourceTag; Tag = new TagBaseContract(tagMapping.Tag, lang); }
private void ProcessInsertQuery() { Log.TraceEnterFunction(this); SqlConnection sqlConnection = new SqlConnection(ActiveQuery.DatabasesRow.ConnectionString); SqlCommand sqlCommand = new SqlCommand("", sqlConnection); String InsertQueryStart = "INSERT INTO " + ActiveQuery.QueryText + " ("; String InsertQueryEnd = " VALUES ("; var TagMappings = ActiveModel.QueryTagMappings.Where(p => p.Query == ActiveQuery.PK); foreach (Model.QueryTagMappingsRow TagMapping in TagMappings) { if (TagMapping != null && !TagMapping.IsColumnNameNull() && TagMapping.TagsRow != null && TagMapping.QueriesRow != null) { Log.Debug(this, "Mapping parameter to query: " + TagMapping.TagsRow + " to column " + TagMapping.ColumnName); Model.TagsRow Tag = TagMapping.TagsRow; ControllerBase Controller = Tag.ControllersRow.Controller; InsertQueryStart += TagMapping.ColumnName + ", "; String ValueRead = Controller.Read(TagMapping.TagsRow).ToSqlString() + ", "; InsertQueryEnd += ValueRead; Log.Info(this, "Read input parameter for column '" + TagMapping.ColumnName + " from Tag " + TagMapping.TagsRow + "'. Value Read=" + ValueRead); } } InsertQueryStart = InsertQueryStart.Remove(InsertQueryStart.Length - 2) + ")"; InsertQueryEnd = InsertQueryEnd.Remove(InsertQueryEnd.Length - 2) + ")"; String InsertQuery = InsertQueryStart + InsertQueryEnd; Log.Info(this, "Query string assembled: " + InsertQuery); sqlCommand.CommandText = InsertQuery; sqlConnection.Open(); sqlCommand.ExecuteNonQuery(); sqlConnection.Close(); Log.TraceExitFunction(this); }
public void RemoveGameFileTag(IEnumerable <IGameFile> gameFiles, ITagData tag) { TagMapping tagMapping = new TagMapping(); foreach (IGameFile gameFile in gameFiles) { tagMapping.TagID = tag.TagID; tagMapping.FileID = gameFile.GameFileID.Value; DataSourceAdapter.DeleteTagMapping(tagMapping); } }
/// <summary> /// The decorate with discovered tag mappings. /// </summary> /// <param name="featureFile">The feature File.</param> /// <param name="tagName">The tag Name.</param> /// <param name="method">The method.</param> protected virtual void DecorateWithDiscoveredTagMappings(string featureFile, string tagName, CodeMemberMethod method) { PluginSection pluginSection = this.GetConfiguration(Path.GetDirectoryName(featureFile)); TagMapping tagMapping = null; if (pluginSection != null) { tagMapping = pluginSection.TagMappings.Cast <TagMapping>().SingleOrDefault(t => t.Tag == tagName); } if (tagMapping != null) { CodeAttributeDeclarationCollection attributeDeclarations = GetAttributeDeclarationsFromTagMapping(tagMapping); if (attributeDeclarations != null) { method.CustomAttributes.AddRange(attributeDeclarations); } } }
public void AddGameFileTag(IEnumerable <IGameFile> gameFiles, ITagData tag, out List <IGameFile> alreadyTagged) { alreadyTagged = new List <IGameFile>(); foreach (IGameFile gameFile in gameFiles) { TagMapping tagMapping = new TagMapping { FileID = gameFile.GameFileID.Value, TagID = tag.TagID }; if (!DataSourceAdapter.GetTagMappings(tagMapping.FileID).Contains(tagMapping)) { DataSourceAdapter.InsertTagMapping(tagMapping); } else { alreadyTagged.Add(gameFile); } } }
private IEnumerable <Redirect> GetRedirectForTagMappingRecursive(TagMapping tag) { foreach (string bloggerTag in tag.BloggerTag) { yield return(new Redirect { From = RedirectHelper.NormalizeAndMakeCaseInsensitive("/search/label/" + bloggerTag), To = string.IsNullOrWhiteSpace(tag.Slug) ? "/" : "/tag/" + tag.Slug }); if (tag.ChildTags != null && tag.ChildTags.Any()) { foreach (var childTag in tag.ChildTags) { foreach (var redirect in GetRedirectForTagMappingRecursive(childTag)) { yield return(redirect); } } } } }
public void Two_TagMappings_With_Same_Tag_And_TagReferences_Are_Considered_Equal() { var guid = Guid.NewGuid(); var left = new TagMapping() { Reference = new TagTargetReference() { FullTypeName = "string", Id = guid }, Tag = new Tag("test") }; var right = new TagMapping() { Reference = new TagTargetReference() { FullTypeName = "string", Id = guid }, Tag = new Tag("test") }; Assert.AreEqual(left, right); }
/// <summary> /// Gets attribute declarations from tag mapping. /// </summary> /// <param name="tagMapping">The tag mapping.</param> /// <returns>The <see cref="CodeAttributeDeclaration"/>.</returns> private static CodeAttributeDeclarationCollection GetAttributeDeclarationsFromTagMapping(TagMapping tagMapping) { CodeAttributeDeclarationCollection result = new CodeAttributeDeclarationCollection(); foreach (TagAttribute attribute in tagMapping.Attributes) { result.Add(new CodeAttributeDeclaration(attribute.Type, attribute.Arguments.Cast <TagAttributeArgument>().Select(arg => new CodeAttributeArgument(arg.Name, new CodeSnippetExpression(arg.CodeSnippet))).ToArray())); } return(result); }
public ActionResult SaveEdit(TagMapping model) { return(RedirectToAction("Index")); }