public void SectionRefWithParameters() { AtParser parser = new AtParser(); parser.Reader = new StringReader( @"class A { @+ Fields(fields) } @section Fields(f: string[]) @code foreach (var field in f) { @text private string @(field); @end_text } @end_code @end_section"); Intruder parserIntruder = new Intruder(parser); parserIntruder.CallMethod <object>("InitParsing"); parserIntruder.CallMethod <object>("BuildAst"); AtTemplateAst ast = parserIntruder.ReadField <AtTemplateAst>("ast"); SectionReference sectionRef = (SectionReference)ast.Body.Directives[1]; Assert.That(sectionRef.Name, Is.EqualTo("Fields")); Assert.That(sectionRef.Rest, Is.EqualTo("(fields)")); }
public async Task <SectionReference> CreateSplitForContract(string company, Section section, bool reduceContractedValue = false) { var queryParameters = new DynamicParameters(); queryParameters.Add("@SectionDetails", ToArrayTVP(section, company)); queryParameters.Add("@SectionTypeId", (int)SectionType.Split); queryParameters.Add("@IsTradeImage", reduceContractedValue); queryParameters.Add(DataVersionIdParameter, null); var sec = await ExecuteQueryAsync <Section>( StoredProcedureNames.CreateSection, queryParameters, true); SectionReference reference = null; if (sec.FirstOrDefault() != null) { reference = new SectionReference { ContractLabel = sec.FirstOrDefault().ContractLabel, SectionId = sec.FirstOrDefault().SectionId, SectionOriginId = sec.FirstOrDefault().SectionOriginId, Quantity = sec.FirstOrDefault().Quantity }; } return(reference); }
private void ProcessSectionSectionRef(SectionReference directive) { GenerateDebugLine(this.builder, directive.Line); if (string.IsNullOrEmpty(directive.Rest)) { this.builder.Append(directive.Name); this.builder.Append("(_spaces_ + \""); this.builder.Append(EscapeToCSharp(directive.Spaces)); this.builder.Append("\", writerKey);"); } else { this.builder.Append(directive.Name); this.builder.Append(directive.Rest); this.builder.Remove(this.builder.Length - 1, 1); if (this.builder[this.builder.Length - 1] != '(') { this.builder.Append(", "); } this.builder.Append("_spaces_ + \""); this.builder.Append(EscapeToCSharp(directive.Spaces)); this.builder.Append("\", writerKey);"); } this.builder.AppendLine(); }
public void SectionRefWithNoParameters() { AtParser parser = new AtParser(); parser.Reader = new StringReader( @"class A { @+ Fields } @section Fields line1 @end_section"); Intruder parserIntruder = new Intruder(parser); parserIntruder.CallMethod <object>("InitParsing"); parserIntruder.CallMethod <object>("BuildAst"); AtTemplateAst ast = parserIntruder.ReadField <AtTemplateAst>("ast"); SectionReference sectionRef = (SectionReference)ast.Body.Directives[1]; Assert.That(sectionRef.Name, Is.EqualTo("Fields")); }
public void WriteSectionReference(SectionReference r) { Writer.Write((UInt32)r.Section); Writer.Write(r.Offset); }
internal void Seek(SectionReference reference) { Debug.Assert(reference.IsValid); Seek(reference.Section, reference.Offset); }
public SectionReference ReadSectionReferenceUnchecked() { var reference = new SectionReference(); reference.Section = InputReader.ReadUInt32(); reference.Offset = InputReader.ReadUInt32(); return reference; }