/// <summary> /// Checks if the category contains an information type /// </summary> /// <param name="name">name of the information type</param> /// <returns>Return true if the information type is part of this category</returns> public bool ContainsInformationType(string name) { for (int i = 0; i < _infoTypes.Count; i++) { InformationType curType = _infoTypes[i]; if (curType.Name == name) { return(true); } } return(false); }
/// <summary> /// Gets the information type specified by its name /// </summary> /// <param name="name">name of the information type to receive</param> /// <returns>Returns the Instance for the name or null if not found</returns> public InformationType GetInformationType(string name) { if (HasInformationTypes) { for (int i = 0; i < _informationTypes.Count; i++) { InformationType iT = _informationTypes[i]; if (iT.Name == name) { return(iT); } } } return(null); }
/// <summary> /// Merges the lineked information types from cat into this instance /// </summary> /// <param name="cat">category instance</param> internal void MergeInfoTypes(Category cat) { if (cat != null) { if (cat.InformationTypes.Count > 0) { for (int i = 0; i < cat.InformationTypes.Count; i++) { InformationType curType = cat.InformationTypes[i]; if (!ContainsInformationType(curType.Name)) { curType.SetCategoryFlag(true); _infoTypes.Add(curType); } } } } }
/// <summary> /// Reads the object data from a dump store /// </summary> /// <param name="reader">reader to read the data</param> /// <param name="chmFile">current CHMFile instance which reads from dump</param> internal void ReadDump(ref BinaryReader reader, CHMFile chmFile) { _name = reader.ReadString(); _description = reader.ReadString(); int nCnt = reader.ReadInt32(); for (int i = 0; i < nCnt; i++) { string sITName = reader.ReadString(); InformationType linkedType = chmFile.GetInformationType(sITName); if (linkedType != null) { linkedType.SetCategoryFlag(true); _infoTypes.Add(linkedType); } } }
/// <summary> /// Removes the information types and categories read by the CHMFile instance /// </summary> /// <param name="chmFile">file instance</param> private void RemoveFileInfoTypesCategories(CHMFile chmFile) { if (chmFile.HasInformationTypes) { for (int i = 0; i < chmFile.InformationTypes.Count; i++) { InformationType curType = chmFile.InformationTypes[i]; InformationType sysType = GetInformationType(curType.Name); if (sysType != null) { sysType.ReferenceCount--; if (sysType.ReferenceCount <= 0) { _informationTypes.Remove(sysType); } } } } if (chmFile.HasCategories) { for (int i = 0; i < chmFile.Categories.Count; i++) { Category curCat = chmFile.Categories[i]; Category sysCat = GetCategory(curCat.Name); if (sysCat != null) { sysCat.ReferenceCount--; if (sysCat.ReferenceCount <= 0) { _categories.Remove(sysCat); } } } } }
/// <summary> /// Merges the information types and categories read by the CHMFile instance /// into the system instance /// </summary> /// <param name="chmFile">file instance</param> private void MergeFileInfoTypesCategories(CHMFile chmFile) { if (chmFile.HasInformationTypes) { for (int i = 0; i < chmFile.InformationTypes.Count; i++) { InformationType curType = chmFile.InformationTypes[i]; InformationType sysType = GetInformationType(curType.Name); if (sysType == null) { _informationTypes.Add(curType); } else { curType.ReferenceCount++; } } } if (chmFile.HasCategories) { for (int i = 0; i < chmFile.Categories.Count; i++) { Category curCat = chmFile.Categories[i]; Category sysCat = GetCategory(curCat.Name); if (sysCat == null) { _categories.Add(curCat); } else { curCat.ReferenceCount++; } } } }
/// <summary> /// Checks if the category contains an information type /// </summary> /// <param name="type">information type instance to check</param> /// <returns>Return true if the information type is part of this category</returns> public bool ContainsInformationType(InformationType type) { return(_infoTypes.Contains(type)); }
/// <summary> /// Removes an information type from the category /// </summary> /// <param name="type"></param> public void RemoveInformationType(InformationType type) { _infoTypes.Remove(type); }
/// <summary> /// Adds a new information type to the category /// </summary> /// <param name="type"></param> public void AddInformationType(InformationType type) { _infoTypes.Add(type); }