public override void LoadProperty(object obj, string propertyName) { if (this.url.Length < 1) throw new NPersistException("You must specify an url to your NPersist Web Service in your WebServiceRemotingEngine!"); RemotingService rs = new RemotingService(this.Context, url); IMarshalingTransformer transformer = new MarshalingTransformer(Context); IObjectManager om = Context.ObjectManager ; IClassMap classMap = Context.DomainMap.MustGetClassMap(obj.GetType()); IPropertyMap propertyMap = classMap.MustGetPropertyMap(propertyName); MarshalReference mr = transformer.FromObjectAsReference(obj); string xmlObject = (string) Formatter.Serialize(mr); if (useCompression && this.compressor != null) xmlObject = this.compressor.Compress(xmlObject); bool doUseCompression = this.useCompression ; if (this.compressor == null) doUseCompression = false; string result = rs.LoadProperty(xmlObject, propertyName, this.domainKey, doUseCompression); if (useCompression && this.compressor != null) result = this.compressor.Decompress(result); if (propertyMap.IsCollection) { if (propertyMap.ReferenceType == ReferenceType.None) { } else { //Refresh issues!!! (the objects in the list being deserialized may exist in the cache!!) MarshalObjectList mol = (MarshalObjectList) Formatter.Deserialize(result, typeof(MarshalObjectList)); IList freshList = transformer.ToObjectList(mol, RefreshBehaviorType.DefaultBehavior, new ArrayList()); //Context.IdentityMap.RegisterLoadedObject(obj); IList orgList = (IList) om.GetPropertyValue(obj, propertyName); LoadReferenceList(freshList, orgList, om, obj, propertyMap); this.Context.InverseManager.NotifyPropertyLoad(obj, propertyMap, orgList); } } else { if (propertyMap.ReferenceType == ReferenceType.None) { MarshalProperty mp = (MarshalProperty) Formatter.Deserialize(result, typeof(MarshalProperty)); transformer.ToProperty(obj, mp, propertyMap, RefreshBehaviorType.DefaultBehavior ); } else { if (result.Length > 0) { MarshalObject mo = (MarshalObject) Formatter.Deserialize(result, typeof(MarshalObject)); string identity = transformer.GetIdentity(mo); IClassMap refClassMap = Context.DomainMap.MustGetClassMap(mo.Type); Type refType = Context.AssemblyManager.MustGetTypeFromClassMap(refClassMap); object refObject = Context.GetObjectById(identity, refType, true); if (om.GetObjectStatus(refObject) == ObjectStatus.NotLoaded) { transformer.ToObject(mo, ref refObject); } // object refObject = Context.TryGetObjectById(identity, refType, true); // if (refObject == null) // { // refObject = Context.GetObjectById(identity, refType, true); // transformer.ToObject(mo, ref refObject); // } om.SetPropertyValue(obj, propertyName, refObject); om.SetOriginalPropertyValue(obj, propertyName, refObject); om.SetNullValueStatus(obj, propertyName, false); this.Context.InverseManager.NotifyPropertyLoad(obj, propertyMap, refObject); } else { om.SetPropertyValue(obj, propertyName, null); om.SetOriginalPropertyValue(obj, propertyName, null); om.SetNullValueStatus(obj, propertyName, true); } } } }
//Refresh issues!! public override IList LoadObjects(IQuery query, IList listToFill) { if (this.url.Length < 1) throw new NPersistException("You must specify an url to your NPersist Web Service in your WebServiceRemotingEngine!"); RemotingService rs = new RemotingService(this.Context, url); IMarshalingTransformer transformer = new MarshalingTransformer(Context); MarshalQuery mq = transformer.FromQuery(query); string xmlQuery = (string) Formatter.Serialize(mq); if (useCompression && this.compressor != null) xmlQuery = this.compressor.Compress(xmlQuery); bool doUseCompression = this.useCompression ; if (this.compressor == null) doUseCompression = false; string result = rs.LoadObjects(xmlQuery, this.domainKey, doUseCompression); if (useCompression && this.compressor != null) result = this.compressor.Decompress(result); MarshalObjectList mol = (MarshalObjectList) Formatter.Deserialize(result, typeof(MarshalObjectList)); transformer.ToObjectList(mol, query.RefreshBehavior, listToFill); return listToFill; }
public IDomainMap GetMap() { if (this.url.Length < 1) throw new NPersistException("You must specify an url to your NPersist Web Service in your WebServiceRemotingEngine!"); RemotingService rs = new RemotingService(this.Context, url); bool doUseCompression = this.useCompression ; if (this.compressor == null) doUseCompression = false; string result = rs.GetMap(this.domainKey, doUseCompression); if (useCompression && this.compressor != null) result = this.compressor.Decompress(result); return DomainMap.LoadFromXml(result, new DefaultMapSerializer()); }
//Should have no refresh issues public override void LoadObject(ref object obj) { if (this.url.Length < 1) throw new NPersistException("You must specify an url to your NPersist Web Service in your WebServiceRemotingEngine!"); RemotingService rs = new RemotingService(this.Context, url); IClassMap classMap = Context.DomainMap.MustGetClassMap(obj.GetType()); string id = Context.ObjectManager.GetObjectIdentity(obj); bool doUseCompression = this.useCompression ; if (this.compressor == null) doUseCompression = false; string result = rs.LoadObject(classMap.GetName(), id, this.domainKey, doUseCompression); if (useCompression && this.compressor != null) result = this.compressor.Decompress(result); MarshalObject mo = (MarshalObject) Formatter.Deserialize(result, typeof(MarshalObject)); IMarshalingTransformer transformer = new MarshalingTransformer(Context); Context.IdentityMap.RegisterLoadedObject(obj); transformer.ToObject(mo, ref obj); }
public override void Commit(bool recursive) { if (this.url.Length < 1) throw new NPersistException("You must specify an url to your NPersist Web Service in your WebServiceRemotingEngine!"); MarshalUnitOfWork muow = GetUnitOfWork(); RemotingService rs = new RemotingService(this.Context, url); string xmlUoW = (string) Formatter.Serialize(muow); if (useCompression && this.compressor != null) xmlUoW = this.compressor.Compress(xmlUoW); bool doUseCompression = this.useCompression ; if (this.compressor == null) doUseCompression = false; string result = rs.CommitUnitOfWork(xmlUoW, this.domainKey, doUseCompression); if (useCompression && this.compressor != null) result = this.compressor.Decompress(result); MarshalObjectList mol = (MarshalObjectList) Formatter.Deserialize(result, typeof(MarshalObjectList)); UpdateSourceAssigned(mol); ClearUnitOfWork(); }