/// <summary> /// Indicates whether contains IDSET. /// </summary> /// <param name="idset">A REPLGUID_IDSET.</param> /// <returns>If contains IDSET, return true, else false.</returns> public override bool Contains(IDSET idset) { REPLGUID_IDSET ridset = idset as REPLGUID_IDSET; if (this.idsetList == null || this.idsetList.Count == 0) { if (ridset != null) { return(false); } return(true); } if (ridset != null) { foreach (REPLGUID_IDSETElement ele1 in ridset.idsetList) { foreach (REPLGUID_IDSETElement ele2 in this.idsetList) { foreach (GLOBCNTRange rng1 in ele1.GLOBSET.GLOBCNTRangeList) { bool hasRange = false; foreach (GLOBCNTRange rng2 in ele2.GLOBSET.GLOBCNTRangeList) { if (rng2.Contains(rng1)) { hasRange = true; break; } } if (!hasRange) { return(false); } } } } } return(true); }
/// <summary> /// Gets the REPLGUID_IDSET. /// </summary> /// <param name="id">The id to be calculated.</param> /// <param name="type">The type to be calculated.</param> /// <returns>A REPLGUID_IDSET.</returns> public REPLGUID_IDSET GetIdset(ushort id, ushort type) { if (this.PropList != null) { byte[] buffer = this.PropList.GetPropValue(id, type) as byte[]; if (buffer != null && buffer.Length > 0) { using (MemoryStream ms = new MemoryStream(buffer, false)) { REPLGUID_IDSET idset = null; idset = new REPLGUID_IDSET(); idset.Deserialize(ms, -1); return(idset); } } } return(null); }
/// <summary> /// Gets the REPLGUID_IDSET. /// </summary> /// <param name="id">The id to be calculated.</param> /// <param name="type">The type to be calculated.</param> /// <returns>A REPLGUID_IDSET.</returns> public REPLGUID_IDSET GetIdset(ushort id, ushort type) { if (this.PropList != null) { byte[] buffer = this.PropList.GetPropValue(id, type) as byte[]; if (buffer != null && buffer.Length > 0) { using (MemoryStream ms = new MemoryStream(buffer, false)) { REPLGUID_IDSET idset = null; idset = new REPLGUID_IDSET(); idset.Deserialize(ms, -1); return idset; } } } return null; }
/// <summary> /// Indicate If IDSET is in dictionary. /// </summary> /// <param name="idset">IDSET value.</param> /// <param name="dict">IDSET dictionary.</param> /// <returns>IF id set is in it will return true.</returns> private bool HasSameCnset(REPLGUID_IDSET idset, Dictionary<int, REPLGUID_IDSET> dict) { if (!this.IsInDict(idset, dict)) { return false; } else { foreach (REPLGUID_IDSET ids in dict.Values) { if (ids.Contains(idset) && idset.Contains(ids)) { return true; } } } return false; }
/// <summary> /// Indicate If IDSET is in dictionary. /// </summary> /// <param name="idset">IDSET value.</param> /// <param name="dict">IDSET dictionary.</param> /// <returns>IF id set is in it will return true.</returns> private bool IsInDict(REPLGUID_IDSET idset, Dictionary<int, REPLGUID_IDSET> dict) { AdapterHelper.Site.Assert.IsNotNull(idset, "The value of idset should not be null."); // If the dictionary does not contains anything, // the IDSET is not in the dictionary. if (dict.Values.Count <= 0) { return false; } else { // If any IDSET in the dictionary contains the IDSET // (the IDSET is a subset of any IDSET in the dictionary) foreach (REPLGUID_IDSET ids in dict.Values) { if (ids.Contains(idset)) { return true; } } return false; } }