public void TestSerializationChecks()
 {
     Assert.IsTrue(_target.CanSerialize <int>(), "Failed to recognize integer.");
     Assert.IsTrue(_target.CanSerialize <double>(), "Failed to recognize double.");
     Assert.IsTrue(_target.CanSerialize <string>(), "Failed to recognize string (generic).");
     Assert.IsTrue(_target.CanSerialize(typeof(string)), "Failed to recognize string.");
 }
Exemple #2
0
 public void TestSerializationChecks()
 {
     Assert.True(_target.CanSerialize <decimal>());  //Failed to recognize decimal.");
     Assert.True(_target.CanSerialize <DateTime>()); //Failed to recognize date time.");
     Assert.True(_target.CanSerialize <Uri>());      //Failed to recognize uri.");
     Assert.True(_target.CanSerialize <Guid>());     //Failed to recognize guid.");
     Assert.True(_target.CanSerialize <TimeSpan>()); //Failed to recognize timespan.");
 }
Exemple #3
0
        private void _InnerSave(Type type, string propertyName, object instance, BinaryWriter bw, CycleCache cache)
        {
            if (_database.IsRegistered(type))
            {
                // foreign table - write if it is null or not, and if not null, write the key
                // then serialize it separately
                _SerializeClass(type, propertyName, instance, bw, cache);
                return;
            }

            if (_serializer.CanSerialize(type))
            {
                _SerializeProperty(type, propertyName, instance, bw);
                return;
            }

            if (instance is Array)
            {
                bw.Write(propertyName + PROPERTY_VALUE_SEPARATOR);
                bw.Write(_typeResolver(type.AssemblyQualifiedName));
                _SaveArray(bw, cache, instance as Array);
                return;
            }

            if (typeof(IList).IsAssignableFrom(type))
            {
                bw.Write(propertyName + PROPERTY_VALUE_SEPARATOR);
                bw.Write(_typeResolver(type.AssemblyQualifiedName));
                _SaveList(instance as IList, bw, cache);
                return;
            }

            if (typeof(IDictionary).IsAssignableFrom(type))
            {
                bw.Write(propertyName + PROPERTY_VALUE_SEPARATOR);
                bw.Write(_typeResolver(type.AssemblyQualifiedName));
                _SaveDictionary(instance as IDictionary, bw, cache);
                return;
            }

            bw.Write(propertyName + PROPERTY_VALUE_SEPARATOR);
            bw.Write(_typeResolver(type.AssemblyQualifiedName));
            Save(type, instance, bw, cache, false);
        }
 public void TestSerializationChecks()
 {
     Assert.IsTrue(_target.CanSerialize <int>(), "Failed to recognize integer.");
     Assert.IsTrue(_target.CanSerialize <double>(), "Failed to recognize double.");
     Assert.IsTrue(_target.CanSerialize <string>(), "Failed to recognize string (generic).");
     Assert.IsTrue(_target.CanSerialize(typeof(string)), "Failed to recognize string.");
     Assert.IsTrue(_target.CanSerialize(typeof(TestStruct)), "Failed to recognize test structure.");
     Assert.IsFalse(_target.CanSerialize(_date.GetType()), "Accepted data time.");
 }