private void OpenCore(TimeSpan timeout)
 {
     PeerMaintainer maintainer;
     TimeoutHelper helper = new TimeoutHelper(timeout);
     lock (this.ThisLock)
     {
         if (this.ListenUri == null)
         {
             throw System.ServiceModel.DiagnosticUtility.ExceptionUtility.ThrowHelperError(new InvalidOperationException(System.ServiceModel.SR.GetString("ListenUriNotSet", new object[] { base.GetType() })));
         }
         this.meshId = this.ListenUri.Host;
         byte[] buffer = new byte[8];
         ulong id = 0L;
         do
         {
             CryptoHelper.FillRandomBytes(buffer);
             for (int i = 0; i < 8; i++)
             {
                 id |= buffer[i] << (i * 8);
             }
         }
         while (id == 0L);
         this.traceRecord = new PeerNodeTraceRecord(id, this.meshId);
         if (System.ServiceModel.DiagnosticUtility.ShouldTraceInformation)
         {
             TraceUtility.TraceEvent(TraceEventType.Information, 0x40040, System.ServiceModel.SR.GetString("TraceCodePeerNodeOpening"), this.traceRecord, this, null);
         }
         this.config = new PeerNodeConfig(this.meshId, id, this.resolver, this.messagePropagationFilter, this.encoder, this.ListenUri, this.listenIPAddress, this.port, this.maxReceivedMessageSize, this.minNeighbors, this.idealNeighbors, this.maxNeighbors, this.maxReferrals, this.connectTimeout, this.maintainerInterval, this.securityManager, this.readerQuotas, this.maxBufferPoolSize, this.MaxSendQueue, this.MaxReceiveQueue);
         if (this.listenIPAddress != null)
         {
             this.ipHelper = new PeerIPHelper(this.listenIPAddress);
         }
         else
         {
             this.ipHelper = new PeerIPHelper();
         }
         this.bufferManager = BufferManager.CreateBufferManager(0x40L * this.config.MaxReceivedMessageSize, (int) this.config.MaxReceivedMessageSize);
         this.neighborManager = new PeerNeighborManager(this.ipHelper, this.config, this);
         this.flooder = PeerFlooder.CreateFlooder(this.config, this.neighborManager, this);
         this.maintainer = new PeerMaintainer(this.config, this.neighborManager, this.flooder);
         this.connector = new PeerConnector(this.config, this.neighborManager, this.maintainer);
         Dictionary<System.Type, object> serviceHandlers = this.serviceHandlers;
         if (serviceHandlers == null)
         {
             serviceHandlers = new Dictionary<System.Type, object>();
             serviceHandlers.Add(typeof(IPeerConnectorContract), this.connector);
             serviceHandlers.Add(typeof(IPeerFlooderContract<Message, UtilityInfo>), this.flooder);
         }
         this.service = new PeerService(this.config, new PeerService.ChannelCallback(this.neighborManager.ProcessIncomingChannel), new PeerService.GetNeighborCallback(this.neighborManager.GetNeighborFromProxy), serviceHandlers, this);
         this.securityManager.MeshId = this.meshId;
         this.service.Open(helper.RemainingTime());
         this.neighborManager.NeighborClosed += new EventHandler<PeerNeighborCloseEventArgs>(this.OnNeighborClosed);
         this.neighborManager.NeighborClosing += new EventHandler<PeerNeighborCloseEventArgs>(this.OnNeighborClosing);
         this.neighborManager.NeighborConnected += new EventHandler(this.OnNeighborConnected);
         this.neighborManager.NeighborOpened += new EventHandler(this.SecurityManager.OnNeighborOpened);
         this.securityManager.OnNeighborAuthenticated = (EventHandler) Delegate.Combine(this.securityManager.OnNeighborAuthenticated, new EventHandler(this.OnNeighborAuthenticated));
         this.neighborManager.Online += new EventHandler(this.FireOnline);
         this.neighborManager.Offline += new EventHandler(this.FireOffline);
         this.ipHelper.AddressChanged += new EventHandler(this.stateManager.OnIPAddressesChanged);
         this.ipHelper.Open();
         PeerNodeAddress address = new PeerNodeAddress(this.service.GetListenAddress(), this.ipHelper.GetLocalAddresses());
         this.config.SetListenAddress(address);
         this.neighborManager.Open(this.service.Binding, this.service);
         this.connector.Open();
         this.maintainer.Open();
         this.flooder.Open();
         this.isOpen = true;
         this.completeTraceRecord = new PeerNodeTraceRecord(id, this.meshId, address);
         maintainer = this.maintainer;
         this.openException = null;
     }
     if (this.isOpen)
     {
         maintainer.ScheduleConnect(new PeerMaintainerBase<ConnectAlgorithms>.ConnectCallback(this.OnConnectionAttemptCompleted));
     }
 }