public void AddOtherBucket(Bucket OtherBucket) { if (!OtherBucket.FileType.Equals(this.FileType)) throw new ApplicationException(string.Format("Cannot add bucket for type {0} into one for type {1}", OtherBucket.FileType, this.FileType)); this.FileCount += OtherBucket.FileCount; this.FileSize += OtherBucket.FileSize; }
public object Clone() { Bucket Other = new Bucket(this.FileType); Other.FileCount = this.FileCount; Other.FileSize = this.FileSize; Other.IncludedInTotals = this.IncludedInTotals; return Other; }
public Bucket ComputeTotalsBucket() { Bucket B; Bucket Totals = new Bucket(""); //The type is not used for a totals buket foreach(DictionaryEntry Entry in this._buckets) { B = (Bucket) Entry.Value; if (B.IncludedInTotals) { Totals.FileCount += B.FileCount; Totals.FileSize += B.FileSize; } } return Totals; }
/// <summary> /// Return the bucket for this type. If it is not found, add it. /// </summary> /// <param name="FileType"></param> /// <returns></returns> public Bucket FindOrAddBucket(string FileType) { Bucket b; string NormalizedFileType; b = this.FindBucket(FileType); //Add new bucket for new file type if (b == null) { NormalizedFileType = this.NormalizedFileType(FileType); b = new Bucket(NormalizedFileType); this._buckets.Add(NormalizedFileType, b); } return b; }
/// <summary> /// This method will clear our totals bucket so that it can be recomputed /// (and recreated) on demand the next time. /// </summary> public void ClearTotals() { this._totalsBucket = null; }