コード例 #1
0
        private string GetDecompressedText(string compressedFilePath, string compressedFileKeysPath)
        {
            var reader           = new TxtReader();
            var compressor       = new HuffmanCompressor();
            var byteReader       = new ByteReader();
            var byteContent      = byteReader.ReadFile(compressedFilePath);
            var bytes            = ByteExtractor.GetBytes(byteContent);
            var codesString      = reader.ReadFile(compressedFileKeysPath, Encoding.UTF8);
            var codesToDecoding  = DictionaryConverter.ConvertFromString(codesString);
            var decompressedText = compressor.Decompress(bytes, codesToDecoding);

            return(decompressedText);
        }
コード例 #2
0
ファイル: Extractors.cs プロジェクト: Neo4Net/Neo4Net
        /// <summary>
        /// Why do we have a public constructor here and why isn't this class an enum?
        /// It's because the array extractors can be configured with an array delimiter,
        /// something that would be impossible otherwise. There's an equivalent <seealso cref="valueOf(string)"/>
        /// method to keep the feel of an enum.
        /// </summary>
        public Extractors(char arrayDelimiter, bool emptyStringsAsNull, bool trimStrings, System.Func <ZoneId> defaultTimeZone)
        {
            try
            {
                foreach (System.Reflection.FieldInfo field in this.GetType().GetFields(BindingFlags.DeclaredOnly | BindingFlags.Public | BindingFlags.NonPublic | BindingFlags.Static | BindingFlags.Instance))
                {
                    if (isStatic(field.Modifiers))
                    {
                        object value = field.get(null);
                        if (value is Extractor)
                        {
//JAVA TO C# CONVERTER WARNING: Java wildcard generics have no direct equivalent in .NET:
//ORIGINAL LINE: instances.put(field.getName(), (Extractor<?>) value);
                            _instances[field.Name] = (Extractor <object>)value;
                        }
                    }
                }

                Add(@string        = new StringExtractor(emptyStringsAsNull));
                Add(_long_         = new LongExtractor());
                Add(_int_          = new IntExtractor());
                Add(_char_         = new CharExtractor());
                Add(_short_        = new ShortExtractor());
                Add(_byte_         = new ByteExtractor());
                Add(_boolean_      = new BooleanExtractor());
                Add(_float_        = new FloatExtractor());
                Add(_double_       = new DoubleExtractor());
                Add(_stringArray   = new StringArrayExtractor(arrayDelimiter, trimStrings));
                Add(_booleanArray  = new BooleanArrayExtractor(arrayDelimiter));
                Add(_byteArray     = new ByteArrayExtractor(arrayDelimiter));
                Add(_shortArray    = new ShortArrayExtractor(arrayDelimiter));
                Add(_intArray      = new IntArrayExtractor(arrayDelimiter));
                Add(_longArray     = new LongArrayExtractor(arrayDelimiter));
                Add(_floatArray    = new FloatArrayExtractor(arrayDelimiter));
                Add(_doubleArray   = new DoubleArrayExtractor(arrayDelimiter));
                Add(_point         = new PointExtractor());
                Add(_date          = new DateExtractor());
                Add(_time          = new TimeExtractor(defaultTimeZone));
                Add(_dateTime      = new DateTimeExtractor(defaultTimeZone));
                Add(_localTime     = new LocalTimeExtractor());
                Add(_localDateTime = new LocalDateTimeExtractor());
                Add(_duration      = new DurationExtractor());
            }
            catch (IllegalAccessException)
            {
                throw new Exception("Bug in reflection code gathering all extractors");
            }
        }