/// <summary> /// Initiates the editing process. The resource to be edited is copied to the session repository and /// a deserialized version is returned from this copy. Subsequent calls will return the same reference /// to this resource object. /// </summary> /// <returns> /// A deserialized version of a session-copy of the resource to be edited /// </returns> public IResource GetEditedResource() { if (_causeForInvalidation != null) { return(null); } if (_editCopy == null) { try { string copy = _conn.GenerateSessionResourceId(ResourceIdentifier.GetResourceTypeAsString(this.ResourceID)); _conn.ResourceService.CopyResource(this.ResourceID, copy, true); _editCopy = _conn.ResourceService.GetResource(copy); _editCopy.PropertyChanged += WeakEventHandler.Wrap <PropertyChangedEventHandler>(OnResourcePropertyChanged, (eh) => _editCopy.PropertyChanged -= eh); } catch (Exception ex) { _causeForInvalidation = ex; } } return(_editCopy); }
/// <summary> /// Initiates the editing process. The resource to be edited is copied to the session repository and /// a deserialized version is returned from this copy. Subsequent calls will return the same reference /// to this resource object. /// </summary> /// <returns> /// A deserialized version of a session-copy of the resource to be edited /// </returns> public IResource GetEditedResource() { if (_editCopy == null) { string copy = _conn.GenerateSessionResourceId(ResourceIdentifier.GetResourceTypeAsString(this.ResourceID)); _conn.ResourceService.CopyResource(this.ResourceID, copy, true); _editCopy = _conn.ResourceService.GetResource(copy); _editCopy.PropertyChanged += WeakEventHandler.Wrap <PropertyChangedEventHandler>(OnResourcePropertyChanged, (eh) => _editCopy.PropertyChanged -= eh); } return(_editCopy); }
/// <summary> /// Generates the session resource id. /// </summary> /// <param name="conn">The conn.</param> /// <param name="resType">Type of the res.</param> /// <returns></returns> public static string GenerateSessionResourceId(this IServerConnection conn, string resType) { Guid id = Guid.NewGuid(); return(conn.GenerateSessionResourceId(id.ToString(), resType)); }