public short GetLatest(ModelVersionBreadCrumb.VersionType versionType) { SortedSet <short> versionSet = this.GetVersionSet(versionType); if (versionSet.Count == 0) { throw new InvalidOperationException("Bread crumb doesn't have any versions of the specified type"); } return(versionSet.First <short>()); }
public bool Add(short modelVersion, ModelVersionBreadCrumb.VersionType versionType) { if (this.TotalCrumbCount + 1 > ModelVersionBreadCrumb.MaxCapacity) { throw new InvalidOperationException("Cannot add anymore crumbs. Model Bread Crumb reached max capacity"); } if (modelVersion < 0) { throw new ArgumentException("Only non-negative versions can be added to the crumb"); } SortedSet <short> versionSet = this.GetVersionSet(versionType); return(versionSet.Add(modelVersion)); }
private SortedSet <short> GetVersionSet(ModelVersionBreadCrumb.VersionType versionType) { switch (versionType) { case ModelVersionBreadCrumb.VersionType.Ready: return(this.versionsReady); case ModelVersionBreadCrumb.VersionType.NotReady: return(this.versionsNotReady); default: throw new ArgumentException("Invalid version type"); } }
public IList <short> Prune(int maxNumber, short versionToKeep, ModelVersionBreadCrumb.VersionType versionType) { if (!this.Contains(versionToKeep, versionType)) { throw new InvalidOperationException("The given input version is not contained in the crumb"); } IList <short> list = new List <short>(); SortedSet <short> versionSet = this.GetVersionSet(versionType); if (versionSet.Count > maxNumber) { int num = 0; bool flag = false; foreach (short num2 in versionSet) { num++; bool flag2 = false; if (num > maxNumber) { flag2 = true; } else if (num == maxNumber && !flag) { flag2 = true; } else { flag = (flag ? flag : (num2 == versionToKeep)); } if (flag2 && num2 != versionToKeep) { list.Add(num2); } } } foreach (short item in list) { versionSet.Remove(item); } return(list); }
public bool Remove(short modelVersion, ModelVersionBreadCrumb.VersionType versionType) { SortedSet <short> versionSet = this.GetVersionSet(versionType); return(versionSet.Remove(modelVersion)); }
public bool Contains(short modelVersion, ModelVersionBreadCrumb.VersionType versionType) { SortedSet <short> versionSet = this.GetVersionSet(versionType); return(versionSet.Contains(modelVersion)); }
public byte GetCrumbCount(ModelVersionBreadCrumb.VersionType versionType) { SortedSet <short> versionSet = this.GetVersionSet(versionType); return((byte)versionSet.Count); }
public IEnumerable <short> GetVersions(ModelVersionBreadCrumb.VersionType versionType) { return(this.GetVersionSet(versionType).AsEnumerable <short>()); }