public virtual void Construct(LocationDataObject location, bool includeDirtyObjectsOnly) { if (location == null) { return; } this.PrimaryKey = location.PrimaryKey; if (location.ObjectsDataSet == null) { var dataset = ApplicationSettings.Container.Resolve <IObjectsDataSet>(); dataset.AddObject(location); } if (location.ObjectsDataSet == null) { _logEngine.LogError("Unable to set a dataset to the Entity Location", "Unable to set a dataset to the entity. Container may not be initialized", "LocationDataObject", null); throw new PulpException("Unexpected Error : Unable to set a dataset to the entity : Location"); } if (location.InternalObjectId == null) { _logEngine.LogError("Unable to construct an object without InternalObjectId in LocationDataObject", "The Object you are trying to construct doesn't have an InternalObjectId", "LocationDataObject", null); throw new PulpException("Unexpected Error : Unable to construct an object without InternalObjectId in LocationDataObject"); } this.InternalObjectId = (int)location.InternalObjectId; this.ObjectsDataSet = includeDirtyObjectsOnly ? location.ObjectsDataSet.CloneDirtyObjects() : location.ObjectsDataSet; }
/// <summary> /// Copy Constructor /// </summary> public LocationDataObject(LocationDataObject template, bool deepCopy) { this.SetAbstractValue(template.Abstract, false, false); this.SetNameValue(template.Name, false, false); this.SetURIValue(template.URI, false, false); this.SetIsNewValue(template.IsNew, false, false); if (deepCopy) { this.ObjectsDataSet = template.ObjectsDataSet.Clone(); // Remove the template object from the dataset this.ObjectsDataSet.RemoveObject(template); // And Replace by the one we're currently constructing this.ObjectsDataSet.AddObject(this); } this.SetIsDirtyValue(template.IsDirty, false, false); this.SetIsMarkedForDeletionValue(template.IsMarkedForDeletion, false, false); }
public virtual void SetLocationValue(LocationDataObject valueToSet, bool notifyChanges, bool dirtyHandlerOn) { LocationDataObject existing_location = null; if (!(this.LocationURI == null || ObjectsDataSet == null)) { var key = this._location_NewObjectId == null ? new LocationDataObject(this.LocationURI) { IsNew = false } : new LocationDataObject() { IsNew = true, InternalObjectId = this._location_NewObjectId }; existing_location = (LocationDataObject)ObjectsDataSet.GetObject(key); } if (ReferenceEquals(existing_location, valueToSet)) { return; } // Give opportunity to change value before set OnBeforeSetRelationField("Location", valueToSet); // Setting the navigator desync the FK. The FK should be resync if (!ReferenceEquals(null, valueToSet)) { if (ObjectsDataSet == null) { _logEngine.LogError("Unable to set Relation Field", "Unable to set Relation Field, your entity doesn't have a DataSet.", "PlaceToLocationDataObject", null); throw new PulpException("Unable to set Relation fields, your entity doesn't have a DataSet"); } ObjectsDataSet.AddObjectIfDoesNotExist(valueToSet); if (valueToSet.IsNew) { if (_location_NewObjectId != valueToSet.InternalObjectId) { _location_NewObjectId = valueToSet.InternalObjectId; _locationURI = valueToSet.URI; OnPropertyChanged("LocationURI", notifyChanges, dirtyHandlerOn); } } else { if (_locationURI != valueToSet.URI) { _location_NewObjectId = null; _locationURI = valueToSet.URI; OnPropertyChanged("LocationURI", notifyChanges, dirtyHandlerOn); } } } else { _locationURI = null; OnPropertyChanged("LocationURI", notifyChanges, dirtyHandlerOn); } if (!ReferenceEquals(existing_location, valueToSet)) { OnPropertyChanged("Location", notifyChanges, dirtyHandlerOn); } }
public virtual void SetLocationValue(LocationDataObject valueToSet) { SetLocationValue(valueToSet, true, true); }
public LocationContainer(LocationDataObject location, bool includeDirtyObjectsOnly) { Construct(location, includeDirtyObjectsOnly); }
public LocationContainer(LocationDataObject location) { Construct(location, false); }
public IEnumerable <PlaceToLocationDataObject> GetPlaceToLocationItemsForLocation(LocationDataObject locationInstance) { if (locationInstance.IsNew) { return(PlaceToLocationObjects.Where(o => o.Value._location_NewObjectId != null && o.Value._location_NewObjectId == locationInstance.InternalObjectId).Select(o => o.Value)); } if (Location_FKIndex.ContainsKey(locationInstance.URI)) { return(Location_FKIndex[locationInstance.URI].Where(e => PlaceToLocationObjects.ContainsKey(e)).Select(e => PlaceToLocationObjects[e])); } return(new DataObjectCollection <PlaceToLocationDataObject>()); }