public override async Task ProcessAsync(TagHelperContext context, TagHelperOutput output)
 {
     var childContent = await context.GetChildContentAsync();
     var modalContext = (ModalContext)context.Items[typeof(ModalTagHelper)];
     modalContext.Body = childContent;
     output.SuppressOutput();
 }
 public override void Process(TagHelperContext context, TagHelperOutput output)
 {
     if (!Condition)
     {
         output.SuppressOutput();
     }
 }
Exemplo n.º 3
0
 public override void Process(TagHelperContext context, TagHelperOutput output)
 {
     if (!AspVisible)
     {
         output.SuppressOutput();
     }
 }
Exemplo n.º 4
0
        //[HtmlAttributeName("DisplaySteps")]
        //public bool DisplaySteps { get; set; }
        public override void Process(TagHelperContext context, TagHelperOutput output)
        {
            // [initial-board] -> [solved-board]
            // seqences of boards

            if(MoveResult == null) {
                output.SuppressOutput();
                return;
            }
            output.TagName = "span";
            AddBoardToOutput(MoveResult.OriginalBoard.Board, output);

            output.Content.AppendEncoded(Environment.NewLine);
            output.Content.AppendEncoded(@" ");

            AddBoardToOutput(MoveResult.CurrentBoard.Board, output);

            //if (DisplaySteps) {
            //    output.Content.AppendEncoded(Environment.NewLine);
            //    output.Content.AppendEncoded(@"<br/>");
            //    output.Content.AppendEncoded(@"<div style=""height: 10px;"">&nbsp;</div>");

            //    foreach (var move in MoveResult.MovesPlayed) {
            //        AddBoardToOutput(move.Board, output);
            //        output.Content.AppendEncoded(@"&nbsp;");
            //        output.Content.AppendEncoded(Environment.NewLine);
            //    }
            //}
        }
Exemplo n.º 5
0
 public async override Task ProcessAsync(TagHelperContext context, TagHelperOutput output)
 {
     if (context.AllAttributes["managed"].Value.ToString() == "true")
     {
         var content = await context.GetChildContentAsync();
         _manager.Scripts.Add(content);
         output.SuppressOutput();
     }
 }
Exemplo n.º 6
0
        public override void Process(TagHelperContext context, TagHelperOutput output)
        {
            if (this.ViewContext == null || this.For == null)
            return;

              output.SuppressOutput();
              output.Content.Clear();
              output.Content.Append(this.GenerateCheckBox(this.ViewContext, this.For));
        }
        public override void Process(TagHelperContext context, TagHelperOutput output)
        {
            if (string.IsNullOrEmpty(this.Identity))
            return;

              output.SuppressOutput();
              output.Content.Clear();
              output.Content.Append(this.GenerateCheckBox());
        }
        public override void Process(TagHelperContext context, TagHelperOutput output)
        {
            if (this.ViewContext == null || this.For == null || this.Options == null)
            return;

              output.SuppressOutput();
              output.Content.Clear();
              output.Content.Append(this.GenerateDropDownList(this.ViewContext, this.For, this.Options));
        }
        public override void Process(TagHelperContext context, TagHelperOutput output)
        {
            if (this.For == null)
            return;

              output.SuppressOutput();
              output.Content.Clear();
              output.Content.Append(this.GenerateField());
        }
 public override async Task ProcessAsync(TagHelperContext context, TagHelperOutput output)
 {
     if (ShowDismiss)
     {
         output.PreContent.AppendFormat(@"<button type='button' class='btn btn-default' data-dismiss='modal'>{0}</button>", DismissText);
     }
     var childContent = await context.GetChildContentAsync();
     var modalContext = (ModalContext)context.Items[typeof(ModalTagHelper)];
     modalContext.Footer = childContent;
     output.SuppressOutput();
 }
 public override async Task ProcessAsync(TagHelperContext context, TagHelperOutput output)
 {
     var result = await AngularRenderer.RenderToString(
         nodeServices: this.nodeServices,
         componentModuleName: this.ModuleName,
         componentExportName: this.ExportName,
         componentTagName: output.TagName,
         requestUrl: UriHelper.GetEncodedUrl(this.contextAccessor.HttpContext.Request)
     );
     output.SuppressOutput();
     output.PostElement.AppendEncoded(result);
 }
Exemplo n.º 12
0
        public void SuppressOutput_Sets_TagName_Content_PreContent_PostContent_ToNull()
        {
            // Arrange
            var tagHelperOutput = new TagHelperOutput("p");
            tagHelperOutput.PreContent.Append("Pre Content");
            tagHelperOutput.Content.Append("Content");
            tagHelperOutput.PostContent.Append("Post Content");

            // Act
            tagHelperOutput.SuppressOutput();

            // Assert
            Assert.Null(tagHelperOutput.TagName);
            Assert.NotNull(tagHelperOutput.PreContent);
            Assert.Empty(tagHelperOutput.PreContent.GetContent());
            Assert.NotNull(tagHelperOutput.Content);
            Assert.Empty(tagHelperOutput.Content.GetContent());
            Assert.NotNull(tagHelperOutput.PostContent);
            Assert.Empty(tagHelperOutput.PostContent.GetContent());
        }
Exemplo n.º 13
0
        /// <inheritdoc />
        public override void Process(TagHelperContext context, TagHelperOutput output)
        {
            // Always strip the outer tag name as we never want <environment> to render
            output.TagName = null;

            if (string.IsNullOrWhiteSpace(Names))
            {
                // No names specified, do nothing
                return;
            }

            var environments = Names.Split(NameSeparator, StringSplitOptions.RemoveEmptyEntries)
                                    .Where(name => !string.IsNullOrWhiteSpace(name));

            if (!environments.Any())
            {
                // Names contains only commas or empty entries, do nothing
                return;
            }

            var currentEnvironmentName = HostingEnvironment.EnvironmentName?.Trim();

            if (string.IsNullOrWhiteSpace(currentEnvironmentName))
            {
                // No current environment name, do nothing
                return;
            }

            if (environments.Any(name =>
                string.Equals(name.Trim(), currentEnvironmentName, StringComparison.OrdinalIgnoreCase)))
            {
                // Matching environment name found, do nothing
                return;
            }
            
            // No matching environment name found, suppress all output
            output.SuppressOutput();
        }
Exemplo n.º 14
0
        public void SuppressOutput_PreventsTagOutput()
        {
            // Arrange
            var tagHelperOutput = new TagHelperOutput("p",
                attributes: new Dictionary<string, object>
                {
                    { "class", "btn" },
                    { "something", "   spaced    " }
                });
            tagHelperOutput.PreContent.Append("Pre Content");
            tagHelperOutput.Content.Append("Content");
            tagHelperOutput.PostContent.Append("Post Content");

            // Act
            tagHelperOutput.SuppressOutput();

            // Assert
            Assert.NotNull(tagHelperOutput.PreContent);
            Assert.Empty(tagHelperOutput.PreContent.GetContent());
            Assert.NotNull(tagHelperOutput.Content);
            Assert.Empty(tagHelperOutput.Content.GetContent());
            Assert.NotNull(tagHelperOutput.PostContent);
            Assert.Empty(tagHelperOutput.PostContent.GetContent());
        }
Exemplo n.º 15
0
        /// <inheritdoc />
        public override async Task ProcessAsync(TagHelperContext context, TagHelperOutput output)
        {
            TagHelperContent result = null;
            if (Enabled)
            {
                var key = GenerateKey(context);
                if (!MemoryCache.TryGetValue(key, out result))
                {
                    // Create an entry link scope and flow it so that any triggers related to the cache entries
                    // created within this scope get copied to this scope.
                    using (var link = MemoryCache.CreateLinkingScope())
                    {
                        result = await context.GetChildContentAsync();

                        MemoryCache.Set(key, result, GetMemoryCacheEntryOptions(link));
                    }
                }
            }

            // Clear the contents of the "cache" element since we don't want to render it.
            output.SuppressOutput();
            if (Enabled)
            {
                output.Content.SetContent(result);
            }
            else
            {
                result = await context.GetChildContentAsync();
                output.Content.SetContent(result);
            }
        }
Exemplo n.º 16
0
        public override void Process(TagHelperContext context, TagHelperOutput output)
        {
          
            if(PagingModel == null) 
            {
                output.SuppressOutput();
                return;
            }
            int totalPages = (int)Math.Ceiling(PagingModel.TotalItems / (double)PagingModel.ItemsPerPage);
            // don't render if only 1 page 
            if (totalPages <= 1) 
            {
                output.SuppressOutput();
                return;
            }
            
            //change the bs-pager element into a ul
            output.TagName = "ul";
            
            string querySeparator;

            //prepare things needed by generatpageeurl function
            TagBuilder linkTemplate = GenerateLinkTemplate();
            baseHref = linkTemplate.Attributes["href"];
            querySeparator = baseHref.Contains("?") ? "&" : "?";
            baseHref = baseHref + querySeparator + PageNumberParam + "=";

            List<PaginationLink> links = linkBuilder.BuildPaginationLinks(
                PagingModel, 
                GeneratePageUrl,
                FirstPageText,
                FirstPageTitle,
                PreviousPageText,
                PreviousPageTitle,
                NextPageText,
                NextPageTitle,
                LastPageText,
                LastPageTitle,
                "...");

            foreach(PaginationLink link in links)
            {
                var li = new TagBuilder("li");

                if (link.IsCurrent)
                {
                    li.AddCssClass(LiCurrentCssClass);
                }

                if (!link.Active)
                {
                    li.AddCssClass(LiNonActiveCssClass);
                }

                var a = new TagBuilder("a");

                if(link.Url.Length > 0)
                {
                    a.MergeAttribute("href", link.Url);
                }
                else
                {
                    a.MergeAttribute("href", "#");
                }
                

                if (link.Text == "«")
                {
                    //a.InnerHtml = "&laquo;";
                    a.InnerHtml.AppendEncoded("&laquo;");
                    
                }
                else if (link.Text == "»")
                {
                    //a.InnerHtml = "&raquo;";
                    a.InnerHtml.AppendEncoded("&raquo;");

                }
                else
                {
                    a.InnerHtml.Append(link.Text);
                }

                if(link.Title.Length > 0)
                {
                    a.MergeAttribute("title", link.Title);
                }
                
                if (AjaxTarget.Length > 0)
                {
                    a.MergeAttribute("data-ajax", "true");
                    a.MergeAttribute("data-ajax-mode", AjaxMode);
                    a.MergeAttribute("data-ajax-update", AjaxTarget);
                }
                
                li.InnerHtml.Append(a);
                
                output.Content.Append(li);
            }

            output.Attributes.Clear();
            output.Attributes.Add("class", UlCssClass);
            
        }
Exemplo n.º 17
0
        public void SuppressOutput_PreventsTagOutput()
        {
            // Arrange
            var tagHelperOutput = new TagHelperOutput("p",
                new TagHelperAttributeList
                {
                    { "class", "btn" },
                    { "something", "   spaced    " }
                });
            tagHelperOutput.PreContent.Append("Pre Content");
            tagHelperOutput.Content.Append("Content");
            tagHelperOutput.PostContent.Append("Post Content");

            // Act
            tagHelperOutput.SuppressOutput();

            // Assert
            Assert.NotNull(tagHelperOutput.PreElement);
            Assert.Empty(tagHelperOutput.PreElement.GetContent(new CommonTestEncoder()));
            Assert.NotNull(tagHelperOutput.PreContent);
            Assert.Empty(tagHelperOutput.PreContent.GetContent(new CommonTestEncoder()));
            Assert.NotNull(tagHelperOutput.Content);
            Assert.Empty(tagHelperOutput.Content.GetContent(new CommonTestEncoder()));
            Assert.NotNull(tagHelperOutput.PostContent);
            Assert.Empty(tagHelperOutput.PostContent.GetContent(new CommonTestEncoder()));
            Assert.NotNull(tagHelperOutput.PostElement);
            Assert.Empty(tagHelperOutput.PostElement.GetContent(new CommonTestEncoder()));
        }
Exemplo n.º 18
0
        public void SuppressOutput_Sets_AllContent_ToNullOrEmpty()
        {
            // Arrange
            var tagHelperOutput = new TagHelperOutput("p");
            tagHelperOutput.PreContent.Append("Pre Content");
            tagHelperOutput.Content.Append("Content");
            tagHelperOutput.PostContent.Append("Post Content");

            // Act
            tagHelperOutput.SuppressOutput();

            // Assert
            Assert.Null(tagHelperOutput.TagName);
            Assert.NotNull(tagHelperOutput.PreElement);
            Assert.Empty(tagHelperOutput.PreElement.GetContent(new CommonTestEncoder()));
            Assert.NotNull(tagHelperOutput.PreContent);
            Assert.Empty(tagHelperOutput.PreContent.GetContent(new CommonTestEncoder()));
            Assert.NotNull(tagHelperOutput.Content);
            Assert.Empty(tagHelperOutput.Content.GetContent(new CommonTestEncoder()));
            Assert.NotNull(tagHelperOutput.PostContent);
            Assert.Empty(tagHelperOutput.PostContent.GetContent(new CommonTestEncoder()));
            Assert.NotNull(tagHelperOutput.PostElement);
            Assert.Empty(tagHelperOutput.PostElement.GetContent(new CommonTestEncoder()));
        }
Exemplo n.º 19
0
        /// <inheritdoc />
        public override async Task ProcessAsync(TagHelperContext context, TagHelperOutput output)
        {
            var key = GenerateKey(context);
            TagHelperContent result;
            if (!MemoryCache.TryGetValue(key, out result))
            {
                // Create an EntryLink and flow it so that it is accessible via the ambient EntryLinkHelpers.ContentLink
                // for user code.
                var entryLink = new EntryLink();
                using (entryLink.FlowContext())
                {
                    result = await context.GetChildContentAsync();
                }

                MemoryCache.Set(key, cacheSetContext =>
                {
                    UpdateCacheContext(cacheSetContext, entryLink);
                    return result;
                });
            }

            // Clear the contents of the "cache" element since we don't want to render it.
            output.SuppressOutput();
            output.Content.SetContent(result);
        }