protected override void Visit(LiteralCodeAttributeChunk chunk) { if (chunk.Value == null) { // TODO: This is a hack, this should really be handled at the chunk generation level var dynamicCodeAttributeChunk = new DynamicCodeAttributeChunk { Children = chunk.Children, Association = chunk.Association, Prefix = chunk.Prefix, Start = chunk.Start }; Visit(dynamicCodeAttributeChunk); return; } var attributePiece = new LiteralAttributePiece { DocumentLocation = CreateMappingLocation(chunk.Start, chunk.Association.Length), Prefix = chunk.Prefix, Value = chunk.Value, }; _context.Builder.Add(attributePiece); }
protected override void Visit(LiteralCodeAttributeChunk chunk) { var visitChildren = chunk.Value == null; if (Context.Host.DesignTimeMode) { // Render the attribute without wrapping it in a call to WriteAttribute if (visitChildren) { Accept(chunk.Children); } return; } if (!string.IsNullOrEmpty(Context.TargetWriterName)) { Writer.WriteStartMethodInvocation(Context.Host.GeneratedClassContext.WriteAttributeValueToMethodName) .Write(Context.TargetWriterName) .WriteParameterSeparator(); } else { Writer.WriteStartMethodInvocation(WriteAttributeValueMethodName); } Writer .WriteLocationTaggedString(chunk.Prefix) .WriteParameterSeparator(); if (visitChildren) { var currentRenderingMode = Context.ExpressionRenderingMode; Context.ExpressionRenderingMode = ExpressionRenderingMode.InjectCode; Accept(chunk.Children); Context.ExpressionRenderingMode = currentRenderingMode; Writer .WriteParameterSeparator() .Write(chunk.ValueLocation.AbsoluteIndex.ToString(CultureInfo.InvariantCulture)) .WriteParameterSeparator() .Write(chunk.Association.Length.ToString(CultureInfo.InvariantCulture)) .WriteParameterSeparator() .WriteBooleanLiteral(false) .WriteEndMethodInvocation(); } else { Writer .WriteLocationTaggedString(chunk.Value) .WriteParameterSeparator() .Write(chunk.Association.Length.ToString(CultureInfo.InvariantCulture)) .WriteParameterSeparator() .WriteBooleanLiteral(true) .WriteEndMethodInvocation(); } }
protected override void Visit(LiteralCodeAttributeChunk chunk) { var visitChildren = chunk.Value == null; if (Context.Host.DesignTimeMode) { // Render the attribute without wrapping it in a call to WriteAttribute if (visitChildren) { Accept(chunk.Children); } return; } Writer.WriteParameterSeparator() .WriteStartMethodInvocation("Tuple.Create") .WriteLocationTaggedString(chunk.Prefix) .WriteParameterSeparator(); if (visitChildren) { Writer.WriteStartMethodInvocation("Tuple.Create", new string[] { "System.Object", "System.Int32" }); var currentRenderingMode = Context.ExpressionRenderingMode; Context.ExpressionRenderingMode = ExpressionRenderingMode.InjectCode; Accept(chunk.Children); Context.ExpressionRenderingMode = currentRenderingMode; Writer.WriteParameterSeparator() .Write(chunk.ValueLocation.AbsoluteIndex.ToString(CultureInfo.CurrentCulture)) .WriteEndMethodInvocation(false) .WriteParameterSeparator() .WriteBooleanLiteral(false) .WriteEndMethodInvocation(false); } else { Writer.WriteLocationTaggedString(chunk.Value) .WriteParameterSeparator() .WriteBooleanLiteral(true) .WriteEndMethodInvocation(false); } }
protected override void Visit(LiteralCodeAttributeChunk chunk) { if (Context.Host.DesignTimeMode) { return; // Don't generate anything! } Writer.WriteParameterSeparator() .WriteStartMethodInvocation("Tuple.Create") .WriteLocationTaggedString(chunk.Prefix) .WriteParameterSeparator(); if (chunk.Children.Count > 0 || chunk.Value == null) { Writer.WriteStartMethodInvocation("Tuple.Create", new string[] { "System.Object", "System.Int32" }); ExpressionRenderingMode currentRenderingMode = Context.ExpressionRenderingMode; Context.ExpressionRenderingMode = ExpressionRenderingMode.InjectCode; Accept(chunk.Children); Context.ExpressionRenderingMode = currentRenderingMode; Writer.WriteParameterSeparator() .Write(chunk.ValueLocation.AbsoluteIndex.ToString(CultureInfo.CurrentCulture)) .WriteEndMethodInvocation(false) .WriteParameterSeparator() .WriteBooleanLiteral(false) .WriteEndMethodInvocation(false); } else { Writer.WriteLocationTaggedString(chunk.Value) .WriteParameterSeparator() .WriteBooleanLiteral(true) .WriteEndMethodInvocation(false); } }
protected override void Visit(LiteralCodeAttributeChunk chunk) { }
protected virtual void Visit(LiteralCodeAttributeChunk chunk) { }
protected abstract void Visit(LiteralCodeAttributeChunk chunk);