private static object[] GetNameDictionary(TOle2File Ole2File) { byte[] PropCountArray = new byte[4]; Ole2File.Read(PropCountArray, PropCountArray.Length); Int32 PropCount = BitOps.GetInt32(PropCountArray, 0); object[] Properties = new object[PropCount]; for (int i = 0; i < Properties.Length; i++) { TUnconvertedOlePropertyName PropName = new TUnconvertedOlePropertyName(); Ole2File.Read(PropCountArray, PropCountArray.Length); PropName.Id = BitConverter.ToUInt32(PropCountArray, 0); Ole2File.Read(PropCountArray, PropCountArray.Length); int StrLen = BitOps.GetInt32(PropCountArray, 0); if (StrLen <= 1) { PropName.Name = new TUnconvertedString(new byte[0], false); //StrLen includes the trailing #0 } else { byte[] Str = new byte[StrLen - 1]; Ole2File.Read(Str, Str.Length); Ole2File.SeekForward(Ole2File.Position + 1); //go over the 0 byte. This is needed for vectors/arrays. PropName.Name = new TUnconvertedString(Str, false); } Properties[i] = PropName; } return(Properties); }
private object ConvertStrings(object o, Encoding CodePage) { object[] oArr = o as object[]; if (oArr != null) { for (int i = 0; i < oArr.Length; i++) { oArr[i] = ConvertStrings(oArr[i], CodePage); } return(oArr); } TUnconvertedString uc = o as TUnconvertedString; if (uc != null) { return(uc.ConvertToString(CodePage)); } TUnconvertedOlePropertyName pn = o as TUnconvertedOlePropertyName; if (pn != null) { return(pn.ConvertToPropertyName(CodePage)); } return(o); }