public RestoredFile(Restore restore, RestorePlanFile file, Models.BackupedFile backupedFile) : this() { _Restore = restore; _File = file; _BackupedFile = backupedFile; }
public virtual bool Equals(RestorePlanFile other) { // If parameter is null, return false. if (other == null) { return(false); } bool otherIsTransient = !other.Id.HasValue; bool thisIsTransient = !Id.HasValue; if (otherIsTransient && thisIsTransient) { return(ReferenceEquals(other, this)); } return(other.Id.Equals(Id)); }
// // Loads or creates `RestorePlanFile`s for each file in `files`. // Returns the complete list of `RestorePlanFile`s that are related to `files`. // NOTE: Does not save to the database because this method is run by a secondary thread. // private LinkedList <Models.RestorePlanFile> DoLoadOrCreateRestorePlanFiles(Models.RestorePlan plan, LinkedList <CustomVersionedFile> files) { Assert.IsNotNull(plan); Assert.IsNotNull(files); Assert.IsNotNull(AllFilesFromPlan); LinkedList <Models.RestorePlanFile> result = new LinkedList <Models.RestorePlanFile>(); BackupPlanPathNodeRepository daoPathNode = new BackupPlanPathNodeRepository(); // Check all files. foreach (CustomVersionedFile file in files) { // Throw if the operation was canceled. CancellationToken.ThrowIfCancellationRequested(); // // Create or update `RestorePlanFile`. // Models.RestorePlanFile restorePlanFile = null; bool backupPlanFileAlreadyExists = AllFilesFromPlan.TryGetValue(file.Path, out restorePlanFile); if (!backupPlanFileAlreadyExists) { restorePlanFile = new Models.RestorePlanFile(plan, file.Path); restorePlanFile.CreatedAt = DateTime.UtcNow; } Models.BackupPlanPathNode pathNode = daoPathNode.GetByStorageAccountAndTypeAndPath(plan.StorageAccount, Models.EntryType.FILE, file.Path); Assert.IsNotNull(pathNode, string.Format("{0} has no corresponding {1}", file.Path, typeof(Models.BackupPlanPathNode).Name)); restorePlanFile.PathNode = pathNode; restorePlanFile.VersionedFile = file; result.AddLast(restorePlanFile); } return(result); }
// // REFERENCE: http://nhibernate.info/doc/patternsandpractices/identity-field-equality-and-hash-code.html // public override bool Equals(object obj) { RestorePlanFile other = obj as RestorePlanFile; return(this.Equals(other)); }