public AddCommand(IWordContainer container, ICoder coder, IAppSettings appSettings) { _customName = "add"; _container = container; _coder = coder; _appSettings = appSettings; }
public void HandleMessage(Message readMessage, Context context, ICoder coder) { if (readMessage.Template.HasAttribute(ResetProperty)) { coder.Reset(); } }
public TCP(IServerConfig serverConfig, ICoder coder, bool reconnect = true, int maxReconnectTimes = 3) { this.serverConfig = serverConfig; this.coder = coder; autoReconnect = reconnect; this.maxReconnectTimes = maxReconnectTimes; }
void Listen(string ip, UInt32 port, ISSClientSessionHandler _handler, ICoder _coder, int listen_max_count) { _handler.Init(); handler = _handler; coder = _coder; Net.Instance.Listen(ip, port, this, listen_max_count); }
public GlueVideoAction(ICoder coder, FileWorker fileWorker, String videoName, Statistica stat) { this.coder = coder; this.fileWorker = fileWorker; this.videoName = videoName; this.stat = stat; }
public FastDecoderCommand(IOutput output, ICoder coder) { _customName = "fdec"; _output = output; _coder = coder; }
public GetCommand(IOutput output, IWordContainer container, ICoder coder, IAppSettings appSettings) { _customName = "get"; _output = output; _container = container; _coder = coder; _appSettings = appSettings; }
public static ICoder <T> GenFunction <T, T1>(ICoder <T1> signatureCoder, ICoder <T> bodyCoder, Func <T, T1> selector) where T : class where T1 : class { var body = bodyCoder.WithPrefix("\n").WithPostfix("\n").Brace().WithPostfix("\n"); return(GenCombineReverse(signatureCoder.WithPostfix("\n"), body, selector)); }
public static ICoder <IEnumerable <T> > GenSwitch <T>(ICoder <object> switchCoder, ICoder <T> labelCoder, ICoder <T> statementCoder, ICoder <object> defaultCoder) where T : class { var sing = labelCoder.WithPrefix("\tcase ").WithPostfix(":").Combine(statementCoder, Id).WithPostfix("break;"); var body = sing.Many("\n").WithPostfix("\n\tdefault:").Combine(defaultCoder, m => new object()).Between("\n").Brace(); return(body.CombineReverse(switchCoder.Bracket().WithPrefix("switch").WithPostfix("\n"), m => new object())); }
public SaveCommand(IWordContainer container, ICoder coder, IAppSettings appSettings, IFileAction fileAction) { _customName = "save"; _container = container; _coder = coder; _appSettings = appSettings; _fileAction = fileAction; }
private IUserToken InitUserToken() { IUserToken userToken = (IUserToken)Activator.CreateInstance(_userTokenType); ICoder coder = (ICoder)Activator.CreateInstance(_coderType); userToken.Coder = coder; userToken.Buffer = new byte[_bufferSize]; return(userToken); }
public FileLoaderCommand(IWordContainer container, IFileAction fileAction, ICoder coder, IAppSettings appSettings) { _customName = "load"; _container = container; _fileAction = fileAction; _coder = coder; _appSettings = appSettings; }
public void Encode() { Dictionary <byte, int> symbolQuantityDic = createDictionary(); var builder = new HuffmanCodecBuilder <byte>(); var tree = builder.BuildTree(Comparer <byte> .Default, symbolQuantityDic); ICoder <byte> huffmanCoder = builder.GetCoder(tree); huffmanCoder.Encode(new StandardHuffmanCoderInput(inputReader), new HuffmanCoderOutput(coderOutputWriter)); coderOutputWriter.CreateFileBytes(HuffmanEncodeModel.Standard, false, SymbolQuantityMapConverter.StandardIntToExtConvert(symbolQuantityDic, huffmanCoder.GetEncodingDictionary())); }
public CodingThreadInfo(ICoder coder, Stream inStream, Stream outStream, long inSize, long outSize, ICodingProgress progress = null) { this.Coder = coder; this.InStream = inStream; this.OutStream = outStream; this.Progress = progress; this.InSize = inSize; this.OutSize = outSize; this.FinishedEvent = new ManualResetEventSlim(false); }
private ICoder GetEncryptor(IRepositoryFolder targetFolder) { ICoder retval = null; if (targetFolder.Properties.EnableEncryption.HasValue && targetFolder.Properties.EnableEncryption.Value) { retval = Repository.ObjectFactory.GetEncryptor(targetFolder.Properties.Encryptor); } return(retval); }
public static ICoder <T> GenRegion <T>(ICoder <T> coder, string name) where T : class { var coderBegin = new UnitCoder <T>(string.Format("\n#region {0}", name)); var coderEnd = new UnitCoder <T>("#endregion\n"); return(new SequenceCoder <T>(coderBegin.Code , GenUnit("\n").Code , coder.Code , GenUnit("\n").Code , coderEnd.Code)); }
public static void CodeColFormat(this ICoder coder, ref Col.Format colFormat) { var reading = coder.IsReading; string formatName = reading ? null : colFormat.GetName().ToString(); coder.CodeString(ref formatName); if (reading) { colFormat = Col.FormatOfName(formatName); } }
public static ICoder <T> SkipLine <T>(this ICoder <T> coder, int num = 1) where T : class { var postFix = new char[num]; for (int i = 0; i < num; i++) { postFix[i] = '\n'; } return(coder.WithPostfix(new string(postFix))); }
/// <summary> /// 初始化一个IUserToken /// </summary> /// <returns></returns> private IUserToken InitUserToken() { IUserToken userToken = (IUserToken)Activator.CreateInstance(_userTokenType); ICoder coder = (ICoder)Activator.CreateInstance(_coderType); userToken.Coder = coder; userToken.ReadArgs = _argsPool.Pop(); _bufferManager.SetBuffer(userToken.ReadArgs); userToken.WriteArgs = _argsPool.Pop(); userToken.ReadArgs.UserToken = userToken.WriteArgs.UserToken = userToken; return(userToken); }
public static void CodePixFormat(this ICoder coder, ref PixFormat pixFormat) { var reading = coder.IsReading; Type type = reading ? null : pixFormat.Type; string formatName = reading ? null : pixFormat.Format.GetName().ToString(); coder.CodeType(ref type); coder.CodeString(ref formatName); if (reading) { pixFormat = new PixFormat(type, Col.FormatOfName(formatName)); } }
private Dictionary <DefaultableSymbol <byte>, ICoder <byte> > createCoderDictionary() { Dictionary <DefaultableSymbol <byte>, Dictionary <byte, int> > perSymbolDictionary = createSymbolDictionary(); Dictionary <DefaultableSymbol <byte>, ICoder <byte> > coderDictionary = new Dictionary <DefaultableSymbol <byte>, ICoder <byte> >(); foreach (DefaultableSymbol <byte> key in perSymbolDictionary.Keys) { var builder = new HuffmanCodecBuilder <byte>(); var tree = builder.BuildTree(Comparer <byte> .Default, perSymbolDictionary[key]); ICoder <byte> huffmanCoder = builder.GetCoder(tree); coderDictionary.Add(key, huffmanCoder); } return(coderDictionary); }
public MainPresenter(IMainForm view, IFileManager manager, IMessageService service, ICoder coder) { _view = view; _manager = manager; _messageService = service; _coder = coder; _view.SetSymbolCount(0); _view.ContentChanged += _view_ContentChanged; _view.FileOpenClick += _view_FileOpenClick; _view.FileSaveClick += _view_FileSaveClick; _view.DecipherClick += _view_DecipherClick; _view.EncrypterClick += _view_EncrypterClick; _view.FontChanged += _view_FontChanged; }
public LzmaStream(Stream stream, CompressionMode mode) { modo = mode; this.stream = stream; if (modo == CompressionMode.Decompress) { coder = new SevenZip.Compression.LZMA.Decoder(); } else { coder = new SevenZip.Compression.LZMA.Encoder(); } iniciadoCoder = false; }
public static void Coded(ICoder coder, string inputFileName, string outputFileName, Action <int> progress) { File.Create(outputFileName).Close(); using (var fileWrite = new BinaryWriter(File.Open(outputFileName, FileMode.Open, FileAccess.Write))) using (var fileRead = new BinaryReader(File.Open(inputFileName, FileMode.Open, FileAccess.Read))) { const int readBufer = 3200000; while (fileRead.BaseStream.Position != fileRead.BaseStream.Length) { var temp = fileRead.ReadBytes(readBufer); progress((int)((double)fileRead.BaseStream.Position / fileRead.BaseStream.Length * 100)); coder.Coded(temp); fileWrite.Write(temp); } } }
public static void Coded(ICoder coder, string inputFileName, string outputFileName, Action<int> progress) { File.Create(outputFileName).Close(); using (var fileWrite = new BinaryWriter(File.Open(outputFileName, FileMode.Open, FileAccess.Write))) using (var fileRead = new BinaryReader(File.Open(inputFileName, FileMode.Open, FileAccess.Read))) { const int readBufer = 3200000; while (fileRead.BaseStream.Position != fileRead.BaseStream.Length) { var temp = fileRead.ReadBytes(readBufer); progress((int)((double)fileRead.BaseStream.Position / fileRead.BaseStream.Length * 100)); coder.Coded(temp); fileWrite.Write(temp); } } }
public static byte[] Code(this ICoder coder, byte[] input, int outputStreamLength, int minimumOutputLength = -1) { Contract.Requires(coder != null); Contract.Requires(input != null); Contract.Requires(outputStreamLength >= 0); Contract.Requires(minimumOutputLength >= -1); Contract.Ensures(Contract.Result <byte[]>() != null); using (var inStream = new MemoryStream(input)) { using (var outStream = new MemoryStream(outputStreamLength)) { coder.Code(inStream, outStream, input.Length, minimumOutputLength, null); return(outStream.ToArray()); } } }
internal DirectSingleFolderWriter( IFolder repoFolder , ICoder coder , ICoder encryptor) { this.Coder = coder; this.Encryptor = encryptor; _targetFolder = repoFolder; _dirty = false; _desiredItemsPerFile = repoFolder.Properties.DesiredItemsPerFile; if (0 >= _desiredItemsPerFile) { _desiredItemsPerFile = Constants.DefaultDataItemsPerFile; } _trackUnsavedItems = false; SetUpUnsavedItemsTracking(); _transactionManager = new LongSlaveTransactionManager(_targetFolder.Repository, (ITransactionNotification)this); }
private void process_one_packet(byte[] bytes, int offset, UInt32 body_len) { byte[] package = new byte[body_len]; Array.Copy(bytes, offset, package, 0, body_len); ICoder coder = session.GetCoder(); byte[] zip_bytes = null; if (coder.UnzipBody(package, out zip_bytes) == false) { close(false); return; } byte[] decode_bytes = null; coder.DecodeBody(zip_bytes, out decode_bytes); Event evt = new Event(EventType.ConnRecvMsgType, this, decode_bytes); net.PushEvent(evt); }
public static TsFile[] Convert(IEnumerable <Type> types, IEnumerable <ICoder> coders, ICoder defaultCoder = null, IEnumerable <ICustomTypeConverter> customTypeConverters = null) { if (customTypeConverters != null) { TsType.RegisterCustomTypeConverters(customTypeConverters); } var csDeclarations = CsDeclarationFactory.Create(types).ToArray(); var writtenTsFiles = coders.SelectMany(coder => coder.Rewrite(csDeclarations)) .Where(x => x.Declarations.Any()) .ToArray(); return(FixBuild(writtenTsFiles, defaultCoder ?? new DefaultCoder(), csDeclarations)); }
/// <summary> /// /// </summary> /// <param name="dataFolder"> /// Leaf data folder in which the data files will be accessed. /// </param> /// <param name="repoFile"> /// Target repo file, optional. New instance will be created using object factory if null is supplied. /// </param> /// <param name="coder"> /// Compressor instance /// </param> /// <param name="equalTimestampedItemsComparer"> /// Comparer to use when sorting data items for items with equal timestamps. /// When timestamps are not equal the comparer has no effect. /// </param> internal RepositoryFileAccessor( IDataFolder dataFolder , IRepositoryFileName repoFile , ICoder coder , IComparer <IDataItem> equalTimestampedItemsComparer) { Check.DoRequireArgumentNotNull(dataFolder, "dataFolder"); Check.DoRequireArgumentNotNull(repoFile, "repoFile"); Check.DoRequireArgumentNotNull(coder, "coder"); RepositoryFolder.CheckNotDetached(dataFolder.RepoFolder); _folder = dataFolder.RepoFolder; _repoFile = repoFile; _dataFolder = dataFolder; if (_repoFile == null) { _repoFile = _folder.Repository.ObjectFactory.CreateNewFile(_folder); } this.Coder = coder; if (repoFile.Encrypted) { this.Encryptor = _folder.Repository.ObjectFactory.GetEncryptor(repoFile.EncryptorCode); } if (_folder.Repository.ObjectFactory.FileSystemProvider.FileProvider.Exists(this.FilePath)) { _existinglFilePath = this.FilePath; } else { _dataItems = new List <IDataItem>(); } _isSorted = true; this.EqualTimestampItemsComparer = equalTimestampedItemsComparer; FirstItemTimestamp = DateTime.MaxValue; LastItemTimestamp = DateTime.MinValue; }
/// <summary> /// Register encryptor. /// </summary> /// <param name="coder"> /// New encryptor to be registered. /// </param> /// <param name="replaceExisting"> /// Whether to substitute already registered encryptor with the same key (<code>coder.KeyCode</code>). /// </param> /// <remarks> /// The coder will be used to encrypt/decrypt all data files having encryptor key (<see cref="IRepositoryFileName.EncryptorCode"/> /// equal to <code>coder.KeyCode</code>, which is the coder's unique key. /// The method may be called before setting <see cref="Repository"/>. /// Encryptor must be registered before configuring repository folders to use it, <see cref="IRepositoryFolder.IFolderProperties"/>, /// <see cref="IFolderProperties.Encryptor"/>. /// </remarks> public virtual void AddEncryptor(ICoder coder, bool replaceExisting) { if (Repository != null) { CheckHelper.CheckRepositoryNotDisposed(Repository); } Util.Check.RequireArgumentNotNull(coder, "coder"); CheckHelper.CheckRealCoderCode(coder.KeyCode); string code = NormalizeCoderCode(coder.KeyCode); Check.DoCheckArgument(replaceExisting || !IsCompressorRegistered(code), () => StorageResources.DuplicateEncryptorCode); if (replaceExisting) { _encryptors[code] = coder; } else { _encryptors.Add(code, coder); } }
/// <summary> /// Register compressor. /// </summary> /// <param name="coder"> /// New compressor to be registered. /// </param> /// <param name="replaceExisting"> /// Whether to substitute already registered compressor with the same key (<code>coder.KeyCode</code>). /// </param> /// <remarks> /// The coder will be used to compress/decompress all data files having compressor key (<see cref="IRepositoryFileName.CompressorCode"/> /// equal to <code>coder.KeyCode</code>, which is the coder's unique key. /// The method may be called before setting <see cref="Repository"/>. /// Compressor must be registered before configuring repository folders to use it, <see cref="IRepositoryFolder.IFolderProperties"/>, /// <see cref="IFolderProperties.Compressor"/>. /// </remarks> public virtual void AddCompressor(ICoder coder, bool replaceExisting) { if (Repository != null) { CheckHelper.CheckRepositoryNotDisposed(Repository); } Check.DoRequireArgumentNotNull(coder, "coder"); CheckHelper.CheckRealCoderCode(coder.KeyCode); string code = NormalizeCoderCode(coder.KeyCode); Check.DoAssertLambda(replaceExisting || !IsCompressorRegistered(code) , () => new ArgumentException(StorageResources.DuplicateCompressorCode)); if (replaceExisting) { _compressors[code] = coder; } else { _compressors.Add(code, coder); } }
public static void Decoded(ICoder coder, string inputFileName, string outputFileName, Action<int> progress) { Coded(coder, inputFileName, outputFileName, progress); }
public void HandleMessage(Message readMessage, Context context, ICoder coder) { if (readMessage.Template.HasAttribute(ResetProperty)) coder.Reset(); }
public void HandleMessage(Message readMessage, Context context, ICoder coder) { coder.Reset(); }