public void Reset() { _symbols = new List <ISymbol>(); EditHandler = SpanEditHandler.CreateDefault(s => Enumerable.Empty <ISymbol>()); ChunkGenerator = SpanChunkGenerator.Null; Start = SourceLocation.Zero; }
public void Reset() { _symbols = new List<ISymbol>(); EditHandler = SpanEditHandler.CreateDefault(s => Enumerable.Empty<ISymbol>()); ChunkGenerator = SpanChunkGenerator.Null; Start = SourceLocation.Zero; }
public void Reset() { // Need to potentially allocate a new list because Span.ReplaceWith takes ownership // of the original list. _symbols = null; EditHandler = SpanEditHandler.CreateDefault(s => Enumerable.Empty <ISymbol>()); ChunkGenerator = SpanChunkGenerator.Null; Start = SourceLocation.Zero; }
public SpanConstructor With(ISpanChunkGenerator generator) { Builder.ChunkGenerator = generator; return(this); }
private static Block RebuildChunkGenerators(Block block, bool isBound) { var builder = new BlockBuilder(block); // Don't want to rebuild unbound dynamic attributes. They need to run through the conditional attribute // removal system at runtime. A conditional attribute at the parse tree rewriting level is defined by // having at least 1 child with a DynamicAttributeBlockChunkGenerator. if (!isBound && block.Children.Any( child => child.IsBlock && ((Block)child).ChunkGenerator is DynamicAttributeBlockChunkGenerator)) { // The parent chunk generator must be removed because it's normally responsible for conditionally // generating the attribute prefix (class=") and suffix ("). The prefix and suffix concepts aren't // applicable for the TagHelper use case since the attributes are put into a dictionary like object as // name value pairs. builder.ChunkGenerator = ParentChunkGenerator.Null; return(builder.Build()); } var isDynamic = builder.ChunkGenerator is DynamicAttributeBlockChunkGenerator; // We don't want any attribute specific logic here, null out the block chunk generator. if (isDynamic || builder.ChunkGenerator is AttributeBlockChunkGenerator) { builder.ChunkGenerator = ParentChunkGenerator.Null; } for (var i = 0; i < builder.Children.Count; i++) { var child = builder.Children[i]; if (child.IsBlock) { // The child is a block, recurse down into the block to rebuild its children builder.Children[i] = RebuildChunkGenerators((Block)child, isBound); } else { var childSpan = (Span)child; ISpanChunkGenerator newChunkGenerator = null; var literalGenerator = childSpan.ChunkGenerator as LiteralAttributeChunkGenerator; if (literalGenerator != null) { if (literalGenerator.ValueGenerator == null || literalGenerator.ValueGenerator.Value == null) { newChunkGenerator = new MarkupChunkGenerator(); } else { newChunkGenerator = literalGenerator.ValueGenerator.Value; } } else if (isDynamic && childSpan.ChunkGenerator == SpanChunkGenerator.Null) { // Usually the dynamic chunk generator handles creating the null chunk generators underneath // it. This doesn't make sense in terms of tag helpers though, we need to change null code // generators to markup chunk generators. newChunkGenerator = new MarkupChunkGenerator(); } // If we have a new chunk generator we'll need to re-build the child if (newChunkGenerator != null) { var childSpanBuilder = new SpanBuilder(childSpan) { ChunkGenerator = newChunkGenerator }; builder.Children[i] = childSpanBuilder.Build(); } } } return(builder.Build()); }
public SpanConstructor As(ISpanChunkGenerator codeGenerator) { return(_self.With(codeGenerator)); }
public SpanConstructor With(ISpanChunkGenerator generator) { Builder.ChunkGenerator = generator; return this; }
public SpanContext(ISpanChunkGenerator chunkGenerator, SpanEditHandler editHandler) { ChunkGenerator = chunkGenerator; EditHandler = editHandler; }
public SpanConstructor As(ISpanChunkGenerator codeGenerator) { return _self.With(codeGenerator); }
private static Block RebuildChunkGenerators(Block block) { var builder = new BlockBuilder(block); var isDynamic = builder.ChunkGenerator is DynamicAttributeBlockChunkGenerator; // We don't want any attribute specific logic here, null out the block chunk generator. if (isDynamic || builder.ChunkGenerator is AttributeBlockChunkGenerator) { builder.ChunkGenerator = ParentChunkGenerator.Null; } for (var i = 0; i < builder.Children.Count; i++) { var child = builder.Children[i]; if (child.IsBlock) { // The child is a block, recurse down into the block to rebuild its children builder.Children[i] = RebuildChunkGenerators((Block)child); } else { var childSpan = (Span)child; ISpanChunkGenerator newChunkGenerator = null; var literalGenerator = childSpan.ChunkGenerator as LiteralAttributeChunkGenerator; if (literalGenerator != null) { if (literalGenerator.ValueGenerator == null || literalGenerator.ValueGenerator.Value == null) { newChunkGenerator = new MarkupChunkGenerator(); } else { newChunkGenerator = literalGenerator.ValueGenerator.Value; } } else if (isDynamic && childSpan.ChunkGenerator == SpanChunkGenerator.Null) { // Usually the dynamic chunk generator handles creating the null chunk generators underneath // it. This doesn't make sense in terms of tag helpers though, we need to change null code // generators to markup chunk generators. newChunkGenerator = new MarkupChunkGenerator(); } // If we have a new chunk generator we'll need to re-build the child if (newChunkGenerator != null) { var childSpanBuilder = new SpanBuilder(childSpan) { ChunkGenerator = newChunkGenerator }; builder.Children[i] = childSpanBuilder.Build(); } } } return(builder.Build()); }