public void CanReadListMember() { using (var stream = new MemoryStream()) { WithStruct value1 = new WithStruct(161, 321, 641); WithStruct value2 = new WithStruct(162, 322, 642); WithStruct value3 = new WithStruct(163, 323, 643); WithList <WithStruct> expected = new WithList <WithStruct>() { Values = new List <WithStruct>() { value1, value2, value3 } }; using (var bw = new BinaryWriter(stream, Encoding.Default, true)) { expected.WriteTo(bw); } stream.Position = 0; var formatBuilder = Bin.Format() .Includes <WithList <WithStruct> >(cfg => cfg.Read(t => t.Values, lcfg => lcfg.LastElementWhen(c => c.Index > 2))) .Includes <WithStruct>(); var format = formatBuilder.Build <WithList <WithStruct> >(); var actual = format.Read(stream); Assert.AreEqual(expected, actual); } }
public override void WriteToStream(IndentStream stream) { stream.Write("DBCC UPDATEUSAGE("); ObjectIdList.WriteToStreamWithComma(stream); stream.Write(")"); if (WithList != null && WithList.Count > 0) { stream.Write(" WITH("); WithList.WriteToStreamWithComma(stream); stream.Write(")"); } }
public override void WriteToStream(IndentStream stream) { stream.Write($"DBCC {Name}"); stream.Write("("); ParametersList.WriteToStreamWithComma(stream); stream.Write(")"); if (WithList != null && WithList.Count > 0) { stream.Write(" WITH "); WithList.WriteToStream(stream); } }
/// <summary> /// Initializes a new instance of the <see cref="CSharpInspectInstruction"/> class. /// </summary> /// <param name="context">The creation context.</param> /// <param name="parentFeature">The parent feature.</param> /// <param name="source">The Easly instruction from which the C# instruction is created.</param> protected CSharpInspectInstruction(ICSharpContext context, ICSharpFeature parentFeature, IInspectInstruction source) : base(context, parentFeature, source) { SourceExpression = CSharpExpression.Create(context, (IExpression)source.Source); foreach (IWith With in source.WithList) { ICSharpWith NewWith = CSharpWith.Create(context, parentFeature, With); WithList.Add(NewWith); } if (source.ElseInstructions.IsAssigned) { ElseInstructions = CSharpScope.Create(context, parentFeature, (IScope)source.ElseInstructions.Item); } }
/// \param @struct a struct 1 instance /// \param n a number /// \param structList a list a struct 1 /// \param triangle a triangle /// \param structChars a struct of chars /// \param bigListStruct the big list struct static void Structs(Struct1 @struct, int n, Struct1[] structList, Point[] triangle, Chars structChars, WithList bigListStruct) { /* TODO Look at them structs. */ }