NOODB: Serializer

For a while, I’ve been saying that I need to eliminate the custom serializer. That requires some elaboration.

The NOODB serializer converts an object graph to an xml string. The point of that was to allow it to send the string to a Wcf endpoint without the server having to be aware of the types. It eliminates all kinds of TYPE issues. If a property is defined as an interface, it tracks the actual implementation so it knows what to create.

That all works fine. But, later I realized it was unnecessary. Instead of converting it to xml, I can convert it to a graph of objects that are known by the client and the server and can be marshaled. The objects are, essentially, glorified name value pairs.

Because the client and server know these objects, we can pass them to a Wcf endpoint no problem.

But, the new “thing” would convert an object graph to something else for the purposes of persistence. So, it’s still a serializer.

Anyway, I made good progress on projections. But, I got to the point where I had to integrate it with some existing code, which resulted in mingling with some serializer stuff. Since I knew all of the serializer stuff was gong to change, it felt like a waste of time doing the integration work.

So, I’m in the process of eliminating the xml serializer in favor for my simple object graph. So far, it’s working for:

  • Primitives
  • Nullable Primitives
  • Complex Objects
  • Arrays

I still have 3 or 4 other types to do. This new serializer is MUCH cleaner; I’ve learned from the previous attempts. I expect the remaining types to go in pretty easily.

But, there’s more to it than that. Once done, I have to gut part of the server to get it in there.

So, it’s going to be a while. But, it’s an important improvement. I’ll keep you posted.

        public void Primitives()
            Guid guid = Guid.NewGuid();
            Guid guid2 = Guid.NewGuid();
            ObjectConverterTest test = new ObjectConverterTest
                Boolean1 = true,
                Boolean2 = false,
                Guid = guid,
                Integer = 993344,
                IntegerNull1 = null,
                IntegerNull2 = 3333,
                String = "test",
                SomeEnum = SomeEnum.Two,
                BoolNull1 = null,
                BoolNull2 = true,
                IntegerArray = new int[] { 1, 2, 3, 4, 5 },
                Nested = new ObjectConverterTest
                    Boolean1 = false,
                    Boolean2 = true,
                    Guid = guid2,
                    Integer = 2222,
                    String = "nested string",
                    SomeEnum = SomeEnum.One | SomeEnum.Three

            ObjectConverter converter = new ObjectConverter();
            Part serialized = converter.Serialize(test, null);

            ObjectConverterTest deserialized = (ObjectConverterTest)converter.Deserialize(serialized);
            Assert.AreEqual(guid, deserialized.Guid);
            Assert.AreEqual(993344, deserialized.Integer);
            Assert.AreEqual("test", deserialized.String);
            Assert.AreEqual(SomeEnum.Two, deserialized.SomeEnum);
            Assert.AreEqual(3333, deserialized.IntegerNull2);
            Assert.AreEqual(5, deserialized.IntegerArray.Length);
            for (int i = 0; i < 5; i++)
                Assert.AreEqual(i + 1, deserialized.IntegerArray[i]);

            Assert.AreEqual(guid2, deserialized.Nested.Guid);
            Assert.AreEqual(2222, deserialized.Nested.Integer);
            Assert.AreEqual("nested string", deserialized.Nested.String);
            Assert.AreEqual(SomeEnum.One | SomeEnum.Three, deserialized.Nested.SomeEnum);

Leave a Reply

Please log in using one of these methods to post your comment: Logo

You are commenting using your account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s

%d bloggers like this: