private void SerializeValue(IDataAdapter data, object target) { objectsCache.Add(target, maxObjId++); TypeWrapper wrapper = TypeCache.GetWrapper(target.GetType()); if (wrapper.TrySerialize(target, data, this)) { return; } for (int i = 0; i < wrapper.Properties.Count; i++) { PropertyWrapper property = wrapper.Properties[i]; if (property.IsPrivate) { if (!settings.SerializePrivateProperties) { continue; } havePrivateProperties = true; } bool isReadOnly; if (property.ConstructorArg != -1 || // will be used in constructor settings.SerializeReadOnly) { isReadOnly = false; // always serialize } else { isReadOnly = !property.CanWrite; } object value = property.GetValue(target); if (value != null) { SerializeValue(property.MemberType, value, data, new Info(property), isReadOnly); } else if (settings.SerializeNull) { data.AddNullValue(property.Name, property.Location != NanoLocation.SubNode); } } for (int i = 0; i < wrapper.Fields.Count; i++) { FieldWrapper field = wrapper.Fields[i]; if (!settings.IgnoreNotSerialized && field.Info.IsNotSerialized) { continue; } object value = field.GetValue(target); if (value != null) { SerializeValue(field.MemberType, value, data, new Info(field), false); } else if (settings.SerializeNull) { data.AddNullValue(field.Name, field.Location != NanoLocation.SubNode); } } }