Exemple #1
0
        public void load_object_with_byte_array_with_TypeNameHandling_All()
        {
            using (var store = GetDocumentStore(new Options
            {
                ModifyDocumentStore = s => s.Conventions.CustomizeJsonSerializer = serializer =>
                {
                    serializer.TypeNameHandling = TypeNameHandling.All;
                }
            }))
            {
                var json           = GetResourceText("DocumentWithBytes.txt");
                var jsonSerializer = new DocumentConventions().CreateSerializer();
                var item           = jsonSerializer.Deserialize <DesignResources>(new JsonTextReader(new StringReader(json)));

                using (var session = store.OpenSession())
                {
                    item.Id       = "resources/123";
                    item.DesignId = "designs/123";
                    session.Store(item);
                    session.SaveChanges();
                }

                using (var session = store.OpenSession())
                    session.Load <DesignResources>("resources/123");
            }
        }
Exemple #2
0
        public void query_for_object_with_byte_array_with_default_TypeNameHandling()
        {
            using (var store = GetDocumentStore())
            {
                var json           = GetResourceText("DocumentWithBytes.txt");
                var jsonSerializer = new DocumentConventions().CreateSerializer();
                var item           = jsonSerializer.Deserialize <DesignResources>(new JsonTextReader(new StringReader(json)));

                using (var session = store.OpenSession())
                {
                    item.Id       = "resources/123";
                    item.DesignId = "designs/123";
                    session.Store(item);
                    session.SaveChanges();
                }

                using (var session = store.OpenSession())
                {
                    session
                    .Query <DesignResources>()
                    .Customize(x => x.WaitForNonStaleResults())
                    .Where(x => x.DesignId == "designs/123")
                    .ToList();
                }
            }
        }
Exemple #3
0
        public void Can_read_date_time_offset_from_lucene_query()
        {
            var jsonSerializer = new DocumentConventions().CreateSerializer();

            using (var reader = new JsonTextReader(new StringReader(@"{""Item"": ""20090402193554412""}")))
            {
                var deserialize = jsonSerializer.Deserialize <Test>(reader);
                Assert.Equal(2009, deserialize.Item.Year);
            }
        }
Exemple #4
0
        public void CanBeDeSerializedProperly()
        {
            var jsonSerializer = new DocumentConventions().CreateSerializer();

            using (var stringWriter = new StringWriter())
            {
                var item = new WithDic
                {
                    Items = new Dictionary <DateTime, int>
                    {
                        { new DateTime(2011, 11, 24), 1 }
                    }
                };

                jsonSerializer.Serialize(stringWriter, item);

                var s       = stringWriter.GetStringBuilder().ToString();
                var withDic = jsonSerializer.Deserialize <WithDic>(new JsonTextReader(new StringReader(s)));

                Assert.Equal(1, withDic.Items[new DateTime(2011, 11, 24)]);
            }
        }
Exemple #5
0
 public void FromText()
 {
     var json           = GetResourceText("DocumentWithBytes.txt");
     var jsonSerializer = new DocumentConventions().CreateSerializer();
     var item           = jsonSerializer.Deserialize <DesignResources>(new JsonTextReader(new StringReader(json)));
 }