예제 #1
0
 public static CollectionsClass Create()
 {
     return(new CollectionsClass
     {
         TypeHash = new HashSet <string> {
             "Goodbye", ",", "world!"
         },
         TypeList =
             new List <string> {
             "It", "was", "a", "pleasure", "to", "be", "here."
         },
         TypeDictionary =
             new Dictionary <string, RecursiveClass>
         {
             { "Hello", RecursiveClass.Create() },
             { "Valhalla", RecursiveClass.Create() }
         }
     });
 }
예제 #2
0
        public void ExpressionEntityTypeRecordizer_RecursiveType_Regression()
        {
            var helper = new SerializationHelper((lf, rf) => new RecordizingBonsaiSerializer(lf, rf));

            var e = Expression.Constant(RecursiveClass.Create());

            using var stream = new MemoryStream();

            helper.Serialize(e, stream);

            stream.Position = 0;

            var json = new StreamReader(stream).ReadToEnd();

            Assert.AreEqual(
                @"{""Context"":{""Types"":[[""::"",""System.String"",0],[""{;}"",[[""contoso://entities/parent/typestring"",0],[""contoso://entities/parent/recursive"",1]]]],""Assemblies"":[""STD""],""Version"":""0.9.0.0""},""Expression"":["":"",{""contoso://entities/parent/typestring"":""Hello"",""contoso://entities/parent/recursive"":{""contoso://entities/parent/typestring"":"","",""contoso://entities/parent/recursive"":{""contoso://entities/parent/typestring"":""World"",""contoso://entities/parent/recursive"":null}}},1]}",
                json
                .Replace("System.Private.CoreLib, Version=4.0.0.0, Culture=neutral, PublicKeyToken=7cec85d7bea7798e", "STD")
                .Replace("System.Private.CoreLib, Version=5.0.0.0, Culture=neutral, PublicKeyToken=7cec85d7bea7798e", "STD")
                .Replace("mscorlib, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089", "STD")
                );
        }