/// <summary> /// Standard constructor /// </summary> /// <param name="name">name of the information type</param> /// <param name="description">description</param> /// <param name="mode">mode of the information type</param> public InformationType(string name, string description, InformationTypeMode mode) { _name = name; _description = description; _typeMode = mode; }
/// <summary> /// Reads the object data from a dump store /// </summary> /// <param name="reader">reader to read the data</param> internal void ReadDump(ref BinaryReader reader) { _typeMode = (InformationTypeMode)reader.ReadInt32(); _name = reader.ReadString(); _description = reader.ReadString(); }
/// <summary> /// Parses the very first <OBJECT> tag in the sitemap file and extracts /// information types and categories. /// </summary> /// <param name="sText">text of the object tag</param> /// <param name="chmFile">CHMFile instance</param> private static void ParseGlobalSettings(string sText, CHMFile chmFile) { int innerPTextIdx = ParamRE.GroupNumberFromName("innerText"); // get group-name indexes int nameIndex = AttributesRE.GroupNumberFromName("attributeName"); int valueIndex = AttributesRE.GroupNumberFromName("attributeValue"); int tdIndex = AttributesRE.GroupNumberFromName("attributeTD"); // read parameters int nParamIndex = 0; // 0... unknown // 1... inclusinve info type name // 2... exclusive info type name // 3... hidden info type name // 4... category name // 5... incl infotype name for category // 6... excl infotype name for category // 7... hidden infotype name for category int prevItem = 0; string sName = ""; string sDescription = ""; string curCategory = ""; while (ParamRE.IsMatch(sText, nParamIndex)) { Match mP = ParamRE.Match(sText, nParamIndex); string innerP = mP.Groups[innerPTextIdx].Value; string paramName = ""; string paramValue = ""; int nAttrIdx = 0; while (AttributesRE.IsMatch(innerP, nAttrIdx)) { Match mA = AttributesRE.Match(innerP, nAttrIdx); string attributeName = mA.Groups[nameIndex].Value; string attributeValue = mA.Groups[valueIndex].Value; string attributeTD = mA.Groups[tdIndex].Value; if (attributeTD.Length > 0) { // delete the trailing textqualifier if (attributeValue.Length > 0) { int ltqi = attributeValue.LastIndexOf(attributeTD); if (ltqi >= 0) { attributeValue = attributeValue.Substring(0, ltqi); } } } if (attributeName.ToLower() == "name") { paramName = HttpUtility.HtmlDecode(attributeValue); // for unicode encoded values } if (attributeName.ToLower() == "value") { paramValue = HttpUtility.HtmlDecode(attributeValue); // for unicode encoded values // delete trailing / while ((paramValue.Length > 0) && (paramValue[paramValue.Length - 1] == '/')) { paramValue = paramValue.Substring(0, paramValue.Length - 1); } } nAttrIdx = mA.Index + mA.Length; } switch (paramName.ToLower()) { case "savetype": // inclusive information type name { prevItem = 1; sName = paramValue; }; break; case "savetypedesc": // description of information type { InformationTypeMode mode = InformationTypeMode.Inclusive; sDescription = paramValue; if (prevItem == 1) { mode = InformationTypeMode.Inclusive; } if (prevItem == 2) { mode = InformationTypeMode.Exclusive; } if (prevItem == 3) { mode = InformationTypeMode.Hidden; } if (chmFile.GetInformationType(sName) == null) { // check if the HtmlHelpSystem already holds such an information type if (chmFile.SystemInstance.GetInformationType(sName) == null) { // info type not found yet InformationType newType = new InformationType(sName, sDescription, mode); chmFile.InformationTypes.Add(newType); } else { InformationType sysType = chmFile.SystemInstance.GetInformationType(sName); chmFile.InformationTypes.Add(sysType); } } prevItem = 0; }; break; case "saveexclusive": // exclusive information type name { prevItem = 2; sName = paramValue; }; break; case "savehidden": // hidden information type name { prevItem = 3; sName = paramValue; }; break; case "category": // category name { prevItem = 4; sName = paramValue; curCategory = sName; }; break; case "categorydesc": // category description { sDescription = paramValue; if (chmFile.GetCategory(sName) == null) { // check if the HtmlHelpSystem already holds such a category if (chmFile.SystemInstance.GetCategory(sName) == null) { // add category Category newCat = new Category(sName, sDescription); chmFile.Categories.Add(newCat); } else { Category sysCat = chmFile.SystemInstance.GetCategory(sName); chmFile.Categories.Add(sysCat); } } prevItem = 0; }; break; case "type": // inclusive information type which is member of the previously read category { prevItem = 5; sName = paramValue; }; break; case "typedesc": // description of type for category { sDescription = paramValue; Category cat = chmFile.GetCategory(curCategory); if (cat != null) { // category found InformationType infoType = chmFile.GetInformationType(sName); if (infoType != null) { if (!cat.ContainsInformationType(infoType)) { infoType.SetCategoryFlag(true); cat.AddInformationType(infoType); } } } prevItem = 0; }; break; case "typeexclusive": // exclusive information type which is member of the previously read category { prevItem = 6; sName = paramValue; }; break; case "typehidden": // hidden information type which is member of the previously read category { prevItem = 7; sName = paramValue; }; break; default: { prevItem = 0; sName = ""; sDescription = ""; }; break; } nParamIndex = mP.Index + mP.Length; } }