public virtual int SaveChanges() { //Assembly asm= Assembly.GetExecutingAssembly(); var props = this.GetType().GetProperties();//.All(p => p.MemberType.GetType() == typeof(FileSet<Object>)); foreach (var prop in props) { var propType = prop.PropertyType; if (propType.GenericTypeArguments.Length == 0) { continue; } var attribute = prop.GetCustomAttribute <FileSetUsePrefixPathAttribute>(); var gen_type = propType.GenericTypeArguments[0]; var ret_type = gen_type.GetType(); if (ret_type.IsInstanceOfType(typeof(IFileSet))) { var prefix = attribute == null ? null : this.PrefixPath; string filename = store.GetFileName(gen_type, prefix); if (!string.IsNullOrEmpty(filename)) { object o = prop.GetValue(this); //string contents = XmlHelper.SerializeObject(o, prop.PropertyType); string contents = store.Save(o, prop.PropertyType); TxFileManager fileMgr = new TxFileManager(); using (TransactionScope scope1 = new TransactionScope()) { fileMgr.WriteAllText(filename, contents); scope1.Complete(); } } else if (string.IsNullOrEmpty(filename)) { object o = prop.GetValue(this); store.Save(o, prop.PropertyType); var deletedList = o.GetType().GetProperty("LocalDeleted").GetValue(o); store.ToDelete(deletedList, prop.PropertyType); var updatedList = o.GetType().GetProperty("LocalUpdated").GetValue(o); store.ToUpdate(updatedList, prop.PropertyType); } } } return(0); }
public string ToDelete(object o, Type type) { return(baseStore.ToDelete(o, type)); }