public override void Write(NLSMap?value) { if (value.HasValue) { this.Write(true); Write(value.Value); return; } this.Write(false); }
public void _NLSMap() { using (var ms = new MemoryStream()) { var r = SlimFormat.Instance.MakeReadingStreamer(); var w = SlimFormat.Instance.MakeWritingStreamer(); r.BindStream(ms); w.BindStream(ms); NLSMap?map = new NLSMap( @"nls{ eng{n='Cream>Serum>Day' d='Daily Serum Care'} rus{n='Крем>Серум>Дневной' d='Дневной Уход Серум'} deu{n='Ein Drek'} }".AsLaconicConfig(handling: ConvertErrorHandling.Throw)); w.Write(map); ms.Position = 0; var map2 = r.ReadNullableNLSMap(); Aver.IsTrue(map2.HasValue); Aver.AreEqual(3, map2.Value.Count); Aver.AreEqual("Cream>Serum>Day", map2.Value["eng"].Name); Aver.AreEqual("Крем>Серум>Дневной", map2.Value["rus"].Name); Aver.AreEqual("Крем>Серум>Дневной", map2.Value[CoreConsts.ISOA_LANG_RUSSIAN].Name); Aver.AreEqual("Ein Drek", map2.Value["deu"].Name); Aver.AreEqual("Ein Drek", map2.Value[CoreConsts.ISOA_LANG_GERMAN].Name); ms.Position = 0; NLSMap?nullmap = null; w.Write(nullmap); ms.Position = 0; var map3 = r.ReadNullableNLSMap(); Aver.IsFalse(map3.HasValue); } }
public abstract void Write(NLSMap?map);
public AllTypesDoc Populate(bool withDoc = true) { Enum = CustomEnumType.DElement; EnumN = CustomEnumType.C; EnumArray = new CustomEnumType[] { CustomEnumType.A, CustomEnumType.B }; EnumList = new List <CustomEnumType> { CustomEnumType.C, CustomEnumType.DElement }; EnumNArray = new CustomEnumType?[] { null, null, CustomEnumType.B }; EnumNList = new List <CustomEnumType?> { CustomEnumType.C, null, null, CustomEnumType.DElement }; if (withDoc) { Doc = new AllTypesDoc().Populate(false); DocArray = new AllTypesDoc[] { null, null, new AllTypesDoc().Populate(false) }; DocList = new List <AllTypesDoc> { new AllTypesDoc().Populate(false) }; } Gdid = new GDID(12, 23423); GdidN = new GDID(24, 243534); GdidArray = new GDID[] { new GDID(122, 2342543), new GDID(122, 233423), new GDID(12, 232423) }; GdidList = new List <GDID> { new GDID(122, 2342543), new GDID(122, 233423), new GDID(12, 232423) }; GdidNArray = new GDID?[] { new GDID(122, 2342543), null, new GDID(12, 232423) }; GdidNList = new List <GDID?> { null, new GDID(122, 233423), new GDID(12, 232423) }; GdidSymbol = new GDIDSymbol(new GDID(12, 23423), "fsdfsd"); GdidSymbolN = new GDIDSymbol(new GDID(312, 323423), "jezl kulaz"); GdidSymbolArray = new GDIDSymbol[] { new GDIDSymbol(new GDID(1, 53), "fs44dfsd"), new GDIDSymbol(new GDID(2, 923), "liopa") }; GdidSymbolList = new List <GDIDSymbol> { new GDIDSymbol(new GDID(1, 53), "fs44dfsd"), new GDIDSymbol(new GDID(2, 923), "liopa") }; GdidSymbolNArray = new GDIDSymbol?[] { null, new GDIDSymbol(new GDID(2, 923), "liopa") }; GdidSymbolNList = new List <GDIDSymbol?> { new GDIDSymbol(new GDID(1, 53), "fs44dfsd"), null }; Guid = System.Guid.NewGuid(); GuidN = System.Guid.NewGuid(); GuidArray = new Guid[] { System.Guid.NewGuid(), System.Guid.NewGuid() }; GuidList = new List <Guid> { System.Guid.NewGuid(), System.Guid.NewGuid(), System.Guid.NewGuid() }; GuidNArray = new Guid?[] { null, System.Guid.NewGuid() }; GuidNList = new List <Guid?> { System.Guid.NewGuid(), null }; Atom = Atom.Encode("a"); AtomN = Atom.Encode("ae3"); AtomArray = new Atom[] { Atom.Encode("a2e3"), Atom.Encode("a1e3") }; AtomList = new List <Atom> { Atom.Encode("a3"), Atom.Encode("23"), Atom.Encode("r4") }; AtomNArray = new Atom?[] { null, Atom.Encode("a3") }; AtomNList = new List <Atom?> { Atom.Encode("2a3"), null }; Fid = new FID(23); FidN = new FID(323); FidArray = new FID[] { new FID(23), new FID(123) }; FidList = new List <FID> { new FID(233), new FID(23), new FID(23) }; FidNArray = new FID?[] { null, new FID(223) }; FidNList = new List <FID?> { new FID(423), null }; Pileptr = new PilePointer(1, 23); PileptrN = new PilePointer(1, 23); PileptrArray = new PilePointer[] { new PilePointer(1, 243), new PilePointer(1, 223) }; PileptrList = new List <PilePointer> { new PilePointer(21, 23), new PilePointer(1, 23), new PilePointer(1, 263) }; PileptrNArray = new PilePointer?[] { null, new PilePointer(1, 293) }; PileptrNList = new List <PilePointer?> { new PilePointer(1, 223), null }; NLSMap = new NLSMap("{eng: {n: 'Cucumber',d: 'It is green'}, deu: {n: 'Gurke',d: 'Es ist grün'}}"); NLSMapN = new NLSMap("{eng: {n: 'Cur',d: 'Is'}}"); NLSMapArray = new NLSMap[] { new NLSMap("{eng: {n: 'Cewqeur',d: 'Is'}}"), new NLSMap("{eng: {n: 'Cur23',d: 'Isee'}}") }; NLSMapList = new List <NLSMap> { new NLSMap("{eng: {n: 'Cr',d: 'Is'}}"), new NLSMap("{eng: {n: 'Currr',d: 'Iws'}}"), new NLSMap("{eng: {n: 'ertCur',d: 'rtIs'}}") }; NLSMapNArray = new NLSMap?[] { null, new NLSMap("{eng: {n: 'Cweur',d: 'Is'}}") }; NLSMapNList = new List <NLSMap?> { new NLSMap("{eng: {n: 'Cuer',d: 'Is'}}"), null }; Amount = new Amount("usd", 123.11m); AmountN = new Amount("usd", 223.11m); AmountArray = new Amount[] { new Amount("usd", 123.11m), new Amount("usd", 223.11m) }; AmountList = new List <Amount> { new Amount("usd", 123.11m), new Amount("usd", 253.11m), new Amount("usd", 243.11m) }; AmountNArray = new Amount?[] { null, new Amount("usd", 323.11m) }; AmountNList = new List <Amount?> { new Amount("usd", 523.11m), null }; StringMap = new StringMap { { "a", "aaa" }, { "b", "bbb" } }; StringMapArray = new StringMap[] { new StringMap { { "a", "aaa" }, { "b", "bbb" } }, null, new StringMap { { "23a", "23423weaaa" } } }; StringMapList = new List <StringMap> { new StringMap { { "a", "aaa" }, { "b", "bbb" } }, null, new StringMap { { "23a", "23423weaaa" } } }; this.String = "kazapzon"; this.StringArray = new string[] { "mox", null, null, "zaporojets", "kefal" }; this.StringList = new List <string> { "mox", null, null, "zaporojets", "kefal" }; Int = -7; IntN = -789; IntArray = new int[] { 3, 8, 9, -23, 234, 0 }; IntList = new List <int>() { 0, 1, 4, 8 }; IntNArray = new int?[] { 3, null, 9, -23, 234, 0 }; IntNList = new List <int?>() { 0, 1, null, 8 }; UInt = 7; UIntN = 789; UIntArray = new uint[] { 3, 8, 9, 23, 234, 0 }; UIntList = new List <uint>() { 0, 1, 4, 8 }; UIntNArray = new uint?[] { 3, null, 9, 23, 234, 0 }; UIntNList = new List <uint?>() { 0, 1, null, 8 }; //------------------------------------------------------- Long = -74; LongN = -7893; LongArray = new long[] { 43, 8, 59, -243, 234, 0 }; LongList = new List <long>() { 03, 1, 43, 8 }; LongNArray = new long?[] { 3, null, 9, -23, 2344, 0 }; LongNList = new List <long?>() { 0, 1, null, 58 }; ULong = 78; ULongN = 159; ULongArray = new ulong[] { 3, 5, 19, 23, 24, 0 }; ULongList = new List <ulong>() { 0, 1, 7, 9 }; ULongNArray = new ulong?[] { 3, null, 9, 5, 24, 0 }; ULongNList = new List <ulong?>() { 0, 7, null, 8 }; Short = -4; ShortN = -73; ShortArray = new short[] { 16, 8, 59, -23, 34, 0 }; ShortList = new List <short>() { 0, 3, 1, 4, 8 }; ShortNArray = new short?[] { 3, null, 9, -23, 24, 0 }; ShortNList = new List <short?>() { 0, 4, null, 5 }; UShort = 5; UShortN = 59; UShortArray = new ushort[] { 3, 5, 67, 23, 38, 0 }; UShortList = new List <ushort>() { 0, 1, 5, 9 }; UShortNArray = new ushort?[] { 3, null, 9, 0, 4, 0 }; UShortNList = new List <ushort?>() { 0, 7, null, 8, 9 }; //---- Byte = 15; ByteN = 22; ByteArray = new byte[] { 16, 22, 59, 28, 34, 0 }; ByteList = new List <byte>() { 0, 8, 1, 6, 3 }; ByteNArray = new byte?[] { 3, null, 9, 15, 33, 0 }; ByteNList = new List <byte?>() { 0, 4, null, 5 }; Sbyte = 6; SbyteN = 97; SbyteArray = new sbyte[] { 3, 38, 45, 2, 38, 0 }; SbyteList = new List <sbyte>() { 0, 1, 7, 4 }; SbyteNArray = new sbyte?[] { 3, null, 2, 6, 4, 0 }; SbyteNList = new List <sbyte?>() { 0, 7, null, 8, 9 }; Char = 'a'; CharN = 'c'; CharArray = new char[] { 'b', 'c', 'f' }; CharList = new List <char>() { 'a', 'd', 'e', 'h' }; CharNArray = new char?[] { 'v', 'r', 'u', }; CharNList = new List <char?>() { 'w', 'e', 'r', 't' }; Bool = true; BoolN = false; BoolArray = new bool[] { true, false, false, true }; BoolList = new List <bool>() { true, true, false }; BoolNArray = new bool?[] { false, false, true }; BoolNList = new List <bool?>() { true, false, false }; Float = -8; FloatN = -79; FloatArray = new float[] { 3.89f, 8, 9, -2332.5f, 34, 0 }; FloatList = new List <float>() { 0, 1.3f, 4, 8 }; FloatNArray = new float?[] { 3, null, 9, -23, 234, 0 }; FloatNList = new List <float?>() { 0, 1, null, 8 }; this.Double = -7; DoubleN = -89; DoubleArray = new double[] { 3.2, 8, 9, -3.93, 23, 0 }; DoubleList = new List <double>() { 0.1, 1.7, 4, 8 }; DoubleNArray = new double?[] { 3, null, 9, -23, 234, 0 }; DoubleNList = new List <double?>() { 0, 1, null, 8 }; this.Decimal = 2; DecimalN = 89; DecimalArray = new decimal[] { 7, 8, 9, 3, 234, 0 }; DecimalList = new List <decimal>() { 0, 1, 4, 8 }; DecimalNArray = new decimal?[] { 3, null, 9, -23, 234, 0 }; DecimalNList = new List <decimal?>() { 0, 1, null, 8 }; Timespan = TimeSpan.FromHours(2.45); TimespanN = TimeSpan.FromHours(8.19); TimespanArray = new TimeSpan[] { TimeSpan.FromHours(2.001), TimeSpan.FromHours(4.72) }; TimespanList = new List <TimeSpan>() { TimeSpan.FromHours(12.45), TimeSpan.FromHours(11.09) }; TimespanNArray = new TimeSpan?[] { TimeSpan.FromHours(2.435), null, TimeSpan.FromHours(32.45) }; TimespanNList = new List <TimeSpan?>() { TimeSpan.FromHours(2.45), null, TimeSpan.FromHours(7.401) }; Datetime = new DateTime(1980, 2, 3); DatetimeN = new DateTime(1980, 2, 3); DatetimeArray = new DateTime[] { new DateTime(1980, 2, 3), new DateTime(1980, 2, 3) }; DatetimeList = new List <DateTime>() { new DateTime(1980, 2, 3), new DateTime(1980, 2, 3) }; DatetimeNArray = new DateTime?[] { new DateTime(1980, 2, 3), null, new DateTime(1980, 2, 3) }; DatetimeNList = new List <DateTime?>() { new DateTime(1980, 2, 3), null, new DateTime(1980, 2, 3) }; return(this); }