コード例 #1
0
		public override void Get(FieldDescriptor ds_, IDataReader dr_)
		{
			switch( ds_.Pos )
			{
				case 0: dr_.AsMessage( Vals??(Vals = new OptFields())); break;
				case 1: dr_.AsMessage( Reps??(Reps = new RepFields())); break;
				case 2: { var _f2_= new OptFields(); dr_.AsMessage(_f2_); _lots.Add(_f2_); } break;
				case 3: Tags = dr_.AsString(); break;
			}
		}
コード例 #2
0
 public int RepeatedValuesProtoTests(int seed)
 {
     var opts = CreateRepeated(seed);
     var bto = opts.ToByteArray();
     if (Mode == 0) return bto.Length;
     var optz = new RepFields();
     optz.MergeFrom(bto);
     Assert.That(opts.Equals(optz), "PB multi values encode-decode");
     return bto.Length;
 }
コード例 #3
0
 public int RepeatedValuesJsonTests(int seed)
 {
     var opts = CreateRepeated(seed);
     var sts = opts.ToString();
     if (Mode == 0) return sts.Length;
     var optz = new RepFields();
     optz.MergeFrom(sts);
     Assert.That(opts.Equals(optz), "JSON multi values encode-decode");
     return sts.Length;
 }
コード例 #4
0
 protected RepFields CreateRepeated(int i32)
 {
     var reps = new RepFields();
     for (int i = 0; i < i32; i++)
         reps.AddI32(100 + i);
     reps.AddI32(1); reps.AddI32(-45); reps.AddI32(102); reps.AddI32(-800);
     reps.AddI64(-708); reps.AddI64(456); reps.AddI64(0); reps.AddI64(-77);
     reps.AddBln(true); reps.AddBln(false); reps.AddBln(true);
     reps.AddBts(new byte[2] { 1, 2 }); reps.AddBts(new byte[5] { 11, 22, 33, 44, 55 });
     reps.AddStr("one"); reps.AddStr("two"); reps.AddStr("three");
     reps.AddChr('A'); reps.AddChr('b'); reps.AddChr('C'); reps.AddChr('D'); reps.AddChr('e');
     reps.AddSi32(-11); reps.AddSi32(32); reps.AddSi32(-987654321);
     reps.AddSi64(-223311); reps.AddSi64(42); reps.AddSi64(-9876543210098765);
     reps.AddUi32(11); reps.AddUi32(32); reps.AddUi32(987654321);
     reps.AddUi64(223311); reps.AddUi64(42); reps.AddUi64(9876543210098765);
     reps.AddCur(new Currency(1100.345)); reps.AddCur(new Currency(451100.3451));
     reps.AddDat(new DateTime(2011, 9, 29, 11, 22, 33)); reps.AddDat(new DateTime(2010, 10, 27, 12, 12, 12));
     reps.AddFlt(12345.67F); reps.AddFlt(12345.68F); reps.AddFlt(-12345.67F);
     reps.AddDbl(12345.67D); reps.AddDbl(12345.68D); reps.AddDbl(-12345.67D);
     reps.AddDec(new Decimal(-435.908)); reps.AddDec(new Decimal(123435.90804));
     reps.AddEnu(Colors.Red); reps.AddEnu(Colors.Blue); reps.AddEnu(Colors.Green);
     reps.AddF32(88); reps.AddF32(3790874215); reps.AddF32(1009876535); reps.AddF32(25); reps.AddF32(0);
     reps.AddF64(99223311); reps.AddF64(5848644545353376343); reps.AddF64(987654321009876535);
     return reps;
 }