Exemplo n.º 1
0
        public static byte[] CompressStringBuffers(StringDictionaryByName apStrings, Encoding aEncoding)
        {
            int num = 0;

            Compression.CNameBufferValue[] cNameBufferValueArray = new Compression.CNameBufferValue[apStrings.Count];
            foreach (string key in apStrings.Keys)
            {
                Compression.CNameBufferValue cNameBufferValue = new Compression.CNameBufferValue(key, aEncoding.GetBytes(apStrings[key]));
                cNameBufferValueArray[num] = cNameBufferValue;
                num++;
            }
            return(Compression.CompressBinaryBuffers(cNameBufferValueArray));
        }
Exemplo n.º 2
0
        public static void SaveZipFile(string sFileName, StringDictionaryByName apStrings, Encoding aEncoding)
        {
            int num = 0;

            Compression.CNameBufferValue[] cNameBufferValueArray = new Compression.CNameBufferValue[apStrings.Count];
            foreach (string key in apStrings.Keys)
            {
                Compression.CNameBufferValue cNameBufferValue = new Compression.CNameBufferValue(key, aEncoding.GetBytes(apStrings[key]));
                cNameBufferValueArray[num] = cNameBufferValue;
                num++;
            }
            Compression.SaveZipFileFromBuffer(sFileName, cNameBufferValueArray);
        }
Exemplo n.º 3
0
        public static StringDictionaryByName ReadZipFileToStringDict(string sFileName, Encoding aEncoding)
        {
            Compression.CNameBufferValue[] buffer = Compression.ReadZipStreamToBuffer(File.OpenRead(sFileName));
            StringDictionaryByName         stringDictionaryByName = new StringDictionaryByName();

            Compression.CNameBufferValue[] cNameBufferValueArray = buffer;
            for (int i = 0; i < (int)cNameBufferValueArray.Length; i++)
            {
                Compression.CNameBufferValue cNameBufferValue = cNameBufferValueArray[i];
                stringDictionaryByName.Add(cNameBufferValue.Name, aEncoding.GetString(cNameBufferValue.BufferValue));
            }
            return(stringDictionaryByName);
        }
Exemplo n.º 4
0
        public static StringDictionaryByName ReadZipBufferToStringDict(byte[] aoBuffer, Encoding aEncoding)
        {
            Compression.CNameBufferValue[] cNameBufferValueArray  = Compression.DecompressBinaryBuffers(aoBuffer);
            StringDictionaryByName         stringDictionaryByName = new StringDictionaryByName();

            Compression.CNameBufferValue[] cNameBufferValueArray1 = cNameBufferValueArray;
            for (int i = 0; i < (int)cNameBufferValueArray1.Length; i++)
            {
                Compression.CNameBufferValue cNameBufferValue = cNameBufferValueArray1[i];
                stringDictionaryByName.Add(cNameBufferValue.Name, aEncoding.GetString(cNameBufferValue.BufferValue));
            }
            return(stringDictionaryByName);
        }
        public static StringDictionaryByName ComposeStringDict(string[] asDictsPrefix, StringDictionaryByName[] aoDicts)
        {
            StringDictionaryByName stringDictionaryByName = new StringDictionaryByName();
            int num    = 0;
            int length = (int)aoDicts.Length;

            while (num < length)
            {
                string str = asDictsPrefix[num];
                StringDictionaryByName stringDictionaryByName1 = aoDicts[num];
                foreach (string key in stringDictionaryByName1.Keys)
                {
                    stringDictionaryByName.Add(string.Format("{0}__{1}", str, key), stringDictionaryByName1[key]);
                }
                num++;
            }
            return(stringDictionaryByName);
        }
        public static Dictionary <string, StringDictionaryByName> DeComposeStringDict(string[] asDictsPrefix, StringDictionaryByName oDict)
        {
            Dictionary <string, StringDictionaryByName> strs = new Dictionary <string, StringDictionaryByName>((int)asDictsPrefix.Length);

            for (int i = 0; i < (int)asDictsPrefix.Length; i++)
            {
                strs[asDictsPrefix[i]] = new StringDictionaryByName();
            }
            string str = "__";

            foreach (string key in oDict.Keys)
            {
                int num = key.IndexOf(str);
                Trace.Assert(num > 0, string.Format("Cannot Read composed String Dictionary, Key '{0}' is invalid.", key));
                string str1 = key.Substring(0, num);
                string str2 = key.Substring(num + 2);
                strs[str1].Add(str2, oDict[key]);
            }
            return(strs);
        }