// This scans over all instance fields in the object and uses a TypeConverter to convert them to string // If any fields cannot be converted an exception is thrown because the entire state was not stored internal override void Store(Element element, object serialized, object source, TypeCache typeCache, Cache cache) { if (source == null || serialized == null) { return; } // Custom store List <SerializedValue> values = (List <SerializedValue>)serialized; ICustomStore custom = source as ICustomStore; if (custom != null && values.Count > 0) { // The custom serialized value is always first custom.Store(element, values[0]); values.RemoveAt(0); } // Store the members foreach (SerializedValue value in values) { value.PersistentMemberAttribute.StoreValue(element, value.Serialized, value.Member, value.MemberTypeCache, cache); } }
internal override object Serialize(object source, TypeCache typeCache, Cache cache) { if (source == null) { return(null); } List <SerializedValue> values = new List <SerializedValue>(); // Do custom serialization ICustomStore custom = source as ICustomStore; if (custom != null) { values.Add(new SerializedValue(null, custom.Serialize(), null, null)); } // Serialize the members foreach (PersistentMemberInfo memberInfo in typeCache.PersistentMemberInfo.Where(m => m.Attribute.Store)) { object member = memberInfo.GetValue(source); TypeCache memberTypeCache = cache.GetTypeCache(memberInfo.Type); object serialized = memberInfo.Attribute.SerializeValue(member, memberTypeCache, cache); values.Add(new SerializedValue(memberInfo.Attribute, serialized, member, memberTypeCache)); } return(values); }
public ApplicationUserManager(ICustomStore <ApplicationUser> store) : base(store) { _store = store; }