/// ------------------------------------------------------------------------------------ /// <summary> /// Output a list of mappings to the blob /// </summary> /// <param name="blob">The settings blob</param> /// <param name="fParatext">true if this is for Paratext</param> /// <param name="mappings">A collection of mappings that belong together in the blob (there /// are three such globs in a well-formed blob)</param> /// ------------------------------------------------------------------------------------ private void OutputMappings(BinarySettings blob, bool fParatext, ArrayList mappings) { if (mappings == null) { blob.AddInt(0); return; } blob.AddInt(mappings.Count); foreach (MappingInfo mapping in mappings) { blob.AddString(mapping.beginMarker); blob.AddString(mapping.endMarker); blob.AddIntShort(mapping.isInline ? 1 : 0); // inline blob.AddString(string.Empty); // marker encoding blob.AddString(mapping.dataEncoding); blob.AddIntShort((int)mapping.domain); blob.AddString(mapping.styleName); blob.AddString(mapping.ws); // writing system blob.AddIntShort(1); // confirmed // Looks like we accidentally got these two parameters in opposite order for // Paratext and ECProject - ugh! if (fParatext) { blob.AddIntShort((int)mapping.mappingTarget); blob.AddIntShort(mapping.isExcluded ? 1 : 0); } else { blob.AddIntShort(mapping.isExcluded ? 1 : 0); blob.AddIntShort((int)mapping.mappingTarget); } } }
/// ------------------------------------------------------------------------------------ /// <summary> /// Return a binary blob representing "ECProject" values /// </summary> /// <returns>a byte array containing the settings</returns> /// ------------------------------------------------------------------------------------ private byte[] GetEcProjectSettingsArray(ArrayList mappingList, ArrayList fileList) { BinarySettings blob = new BinarySettings("ECProject"); // stuff at the start of the file blob.AddString(@"\id"); blob.AddString(string.Empty); // data encoding blob.AddString(string.Empty); // marker encoding blob.AddString(string.Empty); // binary directory blob.AddString(string.Empty); // SSF file name blob.AddString(string.Empty); // STY file name // Marker mappings OutputMappings(blob, false, mappingList); // file list blob.AddInt(fileList.Count); foreach (string fileName in fileList) { blob.AddString(fileName); blob.AddIntShort(1); // file encoding (dummy value) blob.AddIntShort(1); // file encoding source (dummy value) blob.AddIntShort(100); // percent certain } return blob.Finalize(); }