public void InvalidateReputationsFromFiles(IEnumerable <string> files) { lvLoadedDocuments.Items.Clear(); lbTotalFiles.Text = TotalFormatter.FormatTotalFiles(0); rcGiven.Clear(); rcReceived.Clear(); rcDifference.Clear(); var parsed = files. Select(f => PageParser.Parse(f, PageReadType.FromFile)); foreach (var page in parsed) { if (page.Type == TransactionType.Unknown) { continue; } lvLoadedDocuments.Items.Add(page.ToPageViewItem()); switch (page.Type) { case TransactionType.Given: rcGiven.AddRange(page.Reputations); break; case TransactionType.Received: rcReceived.AddRange(page.Reputations); break; } } rcDifference.AddRange(Differentiator.Differenciate(rcGiven.Reputations, rcReceived.Reputations).ToArray()); lbTotalFiles.Text = TotalFormatter.FormatTotalFiles(lvLoadedDocuments.Items.Count); }
private PooledSocket(Socket socket, SocketPool pool, TotalFormatter formatter) { this.formatter = formatter; messageStream = new MemoryStream(); this.socket = socket; writeLock = new object(); this.pool = pool; socket.SendTimeout = 1000; //1 seconds :| is it okie? socket.NoDelay = true; socket.DontFragment = true; socket.LingerState.Enabled = false; ReadBuffer(4, HEADER); }
private PooledSocket(Socket socket, SocketPool pool, TotalFormatter formatter) { this.formatter = formatter; messageStream = new MemoryStream(); this.socket = socket; writeLock = new object(); this.pool = pool; socket.SendTimeout = 1000; //1 seconds :| is it okie? socket.NoDelay = true; socket.DontFragment = true; socket.LingerState.Enabled = false; ReadBuffer(4, HEADER); }
public SocketPool(ServiceContainer container, EndPoint endPoint) { formatter = new TotalFormatter(1000); container.Pool = this; poolSize = Int32.Parse(ConfigurationManager.AppSettings["NTS_MIN_POOL_SIZE"]); pooledSockets = new List <PooledSocket>(poolSize); this.container = container; endpoint = endPoint; NetworkListener = new NetworkListner(); waitingCallback = new Dictionary <long, WaitCallback>(); waitingContext = new Dictionary <long, object>(); waitingCallbackLock = new ReaderWriterLockSlim(); waitHandles = new Dictionary <long, SynchResult>(); waitHandlesLock = new ReaderWriterLockSlim(); pooledSocketsLock = new ReaderWriterLockSlim(); Connect(); }
internal SocketPool(ServiceContainer container, Socket socket) { formatter = new TotalFormatter(1000); container.Pool = this; connected = true; poolSize = 1; this.container = container; endpoint = socket.RemoteEndPoint; NetworkListener = new NetworkListner(); waitingCallback = new Dictionary <long, WaitCallback>(); waitingContext = new Dictionary <long, object>(); waitingCallbackLock = new ReaderWriterLockSlim(); waitHandles = new Dictionary <long, SynchResult>(); waitHandlesLock = new ReaderWriterLockSlim(); pooledSocketsLock = new ReaderWriterLockSlim(); pooledSockets = new List <PooledSocket>(poolSize) { PooledSocket.CreateNewSocket(socket, this, formatter) }; }
public SocketPool(int poolSize, ServiceContainer owner, string host) { formatter = new TotalFormatter(1000); owner.Pool = this; this.poolSize = poolSize; pooledSockets = new List <PooledSocket>(poolSize); container = owner; if (host != null) { endpoint = GetEndPoint(host); } else { throw new ArgumentNullException("Host cannot be null."); } NetworkListener = new NetworkListner(); waitingCallback = new Dictionary <long, WaitCallback>(); waitingContext = new Dictionary <long, object>(); waitHandles = new Dictionary <long, SynchResult>(); waitingCallbackLock = new ReaderWriterLockSlim(); pooledSocketsLock = new ReaderWriterLockSlim(); waitHandlesLock = new ReaderWriterLockSlim(); Connect(); }
private void InvalidateLabel() { lbTotal.Text = TotalFormatter.FormatTotalTransaction(_reputations, _type); }
public static PooledSocket CreateNewSocket(Socket socket, SocketPool pool, TotalFormatter formatter) { return(new PooledSocket(socket, pool, formatter)); }
public static PooledSocket CreateNewSocket(string host, int port, SocketPool pool, TotalFormatter formatter) { try { var socket = new Socket(AddressFamily.InterNetwork, SocketType.Stream, ProtocolType.Tcp); socket.Connect(host, port); return(new PooledSocket(socket, pool, formatter)); } catch { return(null); } }
public static PooledSocket CreateNewSocket(Socket socket, SocketPool pool, TotalFormatter formatter) { return new PooledSocket(socket, pool, formatter); }
public static PooledSocket CreateNewSocket(string host, int port, SocketPool pool, TotalFormatter formatter) { try { var socket = new Socket(AddressFamily.InterNetwork, SocketType.Stream, ProtocolType.Tcp); socket.Connect(host, port); return new PooledSocket(socket, pool, formatter); } catch { return null; } }