Beispiel #1
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);
        }