• 设为首页
  • 点击收藏
  • 手机版
    手机扫一扫访问
    迪恩网络手机版
  • 关注官方公众号
    微信扫一扫关注
    公众号

C# Listener类代码示例

原作者: [db:作者] 来自: [db:来源] 收藏 邀请

本文整理汇总了C#中Listener的典型用法代码示例。如果您正苦于以下问题:C# Listener类的具体用法?C# Listener怎么用?C# Listener使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。



Listener类属于命名空间,在下文中一共展示了Listener类的20个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于我们的系统推荐出更棒的C#代码示例。

示例1: Execute

        public void Execute(Listener listener, params Type[] candidateTypes)
        {
            foreach (var testClass in Classes.Filter(candidateTypes))
            {
                var methods = Methods.Filter(testClass);

                var cases = methods.SelectMany(method => CasesForMethod(testClass, method)).ToArray();
                var casesBySkipState = cases.ToLookup(CaseExecution.SkipPredicate);
                var casesToSkip = casesBySkipState[true];
                var casesToExecute = casesBySkipState[false];
                foreach (var @case in casesToSkip)
                    listener.CaseSkipped(@case);

                var caseExecutions = casesToExecute.Select(@case => new CaseExecution(@case)).ToArray();
                if (!caseExecutions.Any())
                    continue;

                ClassExecution.Behavior.Execute(testClass, this, caseExecutions);

                foreach (var caseExecution in caseExecutions)
                {
                    if (caseExecution.Exceptions.Any())
                        listener.CaseFailed(new FailResult(caseExecution));
                    else
                        listener.CasePassed(new PassResult(caseExecution));
                }
            }
        }
开发者ID:jrios,项目名称:fixie,代码行数:28,代码来源:Convention.cs


示例2: ServerChat

 public ServerChat()
 {
     InitializeComponent();
     _pChat = new PrivateChat(this);
     _listener = new Listener(2016);
     _listener.SocketAccepted += ListenerSocketAccept;
 }
开发者ID:Alex-Pedersen,项目名称:CeradChat,代码行数:7,代码来源:serverChat.cs


示例3: MessagePump

 public MessagePump( Listener l )
 {
     m_Listeners = new Listener[]{ l };
     m_Queue = new Queue();
     m_Throttled = new Queue();
     m_Peek = new byte[4];
 }
开发者ID:BackupTheBerlios,项目名称:sunuo-svn,代码行数:7,代码来源:MessagePump.cs


示例4: Start

        public void Start()
        {
            var cfg = Config.Load();

            runner = new Listener(ListenerCallback, "http://*:" + cfg.HttpPort + "/");
            runner.Run();
        }
开发者ID:TilmannBach,项目名称:cloudmusic2upnp,代码行数:7,代码来源:WebServer.cs


示例5: Listen_AnonymousData_Ok

        public async Task Listen_AnonymousData_Ok(
            [Frozen]HttpRequestMessage request,
            Func<HttpRequestMessage> requestProvider,
            [Frozen]Mock<IStreamingUtils> streamingUtils, 
            [Frozen]Mock<IHttpUtils> httpUtils,
            Listener sut)
        {
            //Arrange
            var twits = new[] {"Твиттер это ниочень", "Вот мой мир -- другое дело", "круче только одноклассники"};
            var concatenatedTwits = string.Join('\n'.ToString(), twits);
            var stream = new MemoryStream(Encoding.UTF8.GetBytes(concatenatedTwits));
            var reader = new StreamReader(stream, Encoding.GetEncoding("utf-8"));

            httpUtils.Setup(a => a.UnescapeUnicode(It.IsAny<string>())).Returns((string r) => r);
            streamingUtils.Setup(a => a.GetReader(It.IsAny<HttpRequestMessage>())).ReturnsAsync(reader);
            var results = new List<string>();
            Action<string> processRequest = a => results.Add(a);

            //Act
            await sut.Listen(requestProvider, processRequest);

            //Assert
            streamingUtils.Verify(a => a.GetReader(request), Times.Once);
            results.ShouldAllBeEquivalentTo(twits);
        }
开发者ID:MiningCat,项目名称:AwesomeTwitterClient,代码行数:25,代码来源:StreamListnerTests.cs


示例6: ClientSocketManager

        /// <summary>
        /// 
        /// </summary>
        internal ClientSocketManager( Listener listener, ServiceHandler serviceHandler, ReceiveQueue receiveBuffer )
        {
            if ( listener == null )
                throw new ArgumentNullException( "listener", "ClientSocketHandler.ClientSocketManager(...) - listener == null error!" );

            if ( serviceHandler == null )
                throw new ArgumentNullException( "serviceHandler", "ClientSocketHandler.ClientSocketManager(...) - serviceHandle == null error!" );

            if ( receiveBuffer == null )
                throw new ArgumentNullException( "receiveBuffer", "ClientSocketHandler.ClientSocketManager(...) - receiveBuffer == null error!" );

            m_Listener = listener;
            m_ServiceHandle = serviceHandler;
            m_ReceiveBuffer = receiveBuffer;
            {
                // �������
                m_ReceiveBuffer.Clear();
            }

            m_ServiceHandle.EventProcessData += OnListenerProcessMessageBlock;
            m_ServiceHandle.EventDisconnect += OnListenerDisconnect;

            // ��ʼ������ ��ʾ��û���ù�Free(...)����
            m_LockFree.SetValid();
        }
开发者ID:zaq1xsw,项目名称:DogSE,代码行数:28,代码来源:ClientSocketManager.cs


示例7: Add

		public Listener Add (string messageType, int controlIndex, string forwardToMethod)
		{
			Listener listener = new Listener (messageType, controlIndex, forwardToMethod);
			Add (listener);
			m_Dirty = true;
			return listener;
		}
开发者ID:JChan106,项目名称:HACKPOLY16,代码行数:7,代码来源:BCListener.cs


示例8: Initialize

        public override HResult Initialize()
        {
            try
            {
                var hr = base.Initialize();

                if (ErrorUtil.Failure(hr))
                    return hr;

                ErrorUtil.ThrowOnFailure(Frame.SetCaption(Labels.FindResults));

                _editor = new NiEditor
                {
                    Site = new SiteProxy(this),
                    Dock = DockStyle.Fill
                };

                ErrorUtil.ThrowOnFailure(_editor.TextBuffer.SetStateFlags(
                    NiTextBufferState.ReadOnly
                ));
                ErrorUtil.ThrowOnFailure(_editor.TextBuffer.SetLanguageServiceID(
                    new Guid(NiConstants.LanguageServiceDefault)
                ));

                _listener = new Listener(this);

                Controls.Add(_editor);

                return HResult.OK;
            }
            catch (Exception ex)
            {
                return ErrorUtil.GetHResult(ex);
            }
        }
开发者ID:netide,项目名称:netide,代码行数:35,代码来源:FindResultsWindow.cs


示例9: Subscribe

 public void Subscribe(AppEventType type, Listener listener)
 {
     if (!listenersMap.ContainsKey(type))
         listenersMap.Add(type, new Listener(listener));
     else
         listenersMap[type] += listener;
 }
开发者ID:shaorouge,项目名称:AdvancedDataStructure,代码行数:7,代码来源:EventBus.cs


示例10: Main

        public static void Main()
        {
            var serverAddress = ConfigurationManager.AppSettings.Get("ServerAddress");
            var serverPort = int.Parse(ConfigurationManager.AppSettings.Get("ServerPort"));

            var clientAddress = ConfigurationManager.AppSettings.Get("ClientAddress");
            var clientPort = int.Parse(ConfigurationManager.AppSettings.Get("ClientPort"));

            var cs = new UdpClientServer();
            var serverChannel = new UdpCommunicationChannel(cs, new ChannelConfig { Address = serverAddress, Port = serverPort });
            var clientChannel = new UdpCommunicationChannel(cs, new ChannelConfig { Address = clientAddress, Port = clientPort });

            _userService = new GitHubUserSearchService(new HttpClientFactory());
            _githubBrowser = new GithubBrowser(new HttpClientFactory());

            var userListener = new Listener<UserQuery, UserResponse>(clientChannel, serverChannel);
            userListener.ListenObservable(GetUser);

            var repoListener = new Listener<RepoQuery, RepoResponse>(clientChannel, serverChannel);
            repoListener.ListenObservable(GetRepo);

            var favListener = new Listener<FavQuery, FavResponse>(clientChannel, serverChannel);
            favListener.ListenObservable(AddToFav);

            var publisher = new Publisher<RepoNotification>(serverChannel);
            _githubBrowser.NewCommitsFeed
                .Select(c => new RepoNotification { Commit = c })
                .Subscribe(publisher);

            Console.ReadLine();
        }
开发者ID:pgdotnet,项目名称:RxWorkshop,代码行数:31,代码来源:Program.cs


示例11: Listen

 /// <summary>
 /// Registers a listener instance with the broker
 /// </summary>
 /// <param name="address">
 /// The address of the listener
 /// </param>
 /// <param name="listener">
 /// The listener to register
 /// </param>
 public static void Listen(Uri address, Listener listener)
 {
     if (!listeners.TryAdd(address, listener))
     throw new InvalidOperationException(
        String.Format("A listener already exists for address {0}", address)
     );
 }
开发者ID:modulexcite,项目名称:WcfEx,代码行数:16,代码来源:Broker.cs


示例12: UpdaterService

        public async Task UpdaterService()
        {
            var exportProvider = TestHostServices.CreateMinimalExportProvider();

            var workspace = new AdhocWorkspace(TestHostServices.CreateHostServices(exportProvider));
            workspace.Options = workspace.Options.WithChangedOption(RemoteHostOptions.SolutionChecksumMonitorBackOffTimeSpanInMS, 1);

            var listener = new Listener();
            var analyzerReference = new AnalyzerFileReference(typeof(object).Assembly.Location, new NullAssemblyAnalyzerLoader());

            var service = CreateRemoteHostClientService(workspace, SpecializedCollections.SingletonEnumerable<AnalyzerReference>(analyzerReference), listener);

            service.Enable();

            // make sure client is ready
            var client = await service.GetRemoteHostClientAsync(CancellationToken.None);

            // add solution
            workspace.AddSolution(SolutionInfo.Create(SolutionId.CreateNewId(), VersionStamp.Default));

            var listeners = exportProvider.GetExports<IAsynchronousOperationListener, FeatureMetadata>();
            var workspaceListener = listeners.First(l => l.Metadata.FeatureName == FeatureAttribute.Workspace).Value as IAsynchronousOperationWaiter;

            // wait for listener
            await workspaceListener.CreateWaitTask();
            await listener.CreateWaitTask();

            // checksum should already exist
            SolutionStateChecksums checksums;
            Assert.True(workspace.CurrentSolution.State.TryGetStateChecksums(out checksums));

            service.Disable();
        }
开发者ID:XieShuquan,项目名称:roslyn,代码行数:33,代码来源:RemoteHostClientServiceFactoryTests.cs


示例13: Log

        /// <summary>
        /// Initializes a new instance of the Log class.
        /// </summary>
        /// <param name="core">The core instance.</param>
        public Log(StyleCopCore core)
        {
            Param.AssertNotNull(core, "core");

            object data = core.Registry.CUGetValue("Logging");
            if (data != null)
            {
                try
                {
                    int level = (int)data;
                    if (level > 0)
                    {
                        this.logLevel = StyleCopLogLevel.High;
                    }
                }
                catch (FormatException)
                {
                    // Do nothing here since data is registry is invalid.
                }
            }

            if (this.logLevel != StyleCopLogLevel.None)
            {
                this.listener = new Listener();
                Trace.Listeners.Add(this.listener);
            }
        }
开发者ID:jonthegiant,项目名称:StyleCop,代码行数:31,代码来源:Log.cs


示例14: Main

        static void Main(string[] args)
        {
            using (_store = new AsyncStore<Result>("results"))
            using (_frontier = new AsyncStore<FetchTarget>("frontier"))
            {
                var seeds = new[]
                {
                    "http://www.microsoft.com",
                    "http://www.theguardian.com/",
                    "http://www.reddit.com",
                };

                foreach (var seed in seeds)
                {
                    _frontier.Set(seed, new FetchTarget
                    {
                        Level = 1,
                        Uri = new Uri(seed)
                    });
                }

                var listener = new Listener<FetchResult>(x => System.Console.WriteLine("[FETCHED]: {0}", x.ResponseUri));

                var crawler = Crawler.Get(new HtmlAgilityPack.DocumentFactory(), _store, _frontier);

                crawler.Fetcher.SendTo(listener);

                SetConsoleCtrlHandler(x => Handler(crawler, x), true);

                crawler.Start();
            }
        }
开发者ID:repne,项目名称:happyface,代码行数:32,代码来源:Program.cs


示例15: Main

        public static void Main(string[] args)
        {
            for (int i = 0; i < args.Length; i++) {
                switch(args[i]) {
                    case "-p":
                        if (!int.TryParse(args[++i], out port)) {
                            Environment.Exit(-1);
                        }
                        break;
                    case "-s":
                        documentroot = args[++i];
                        break;
                }
            }
            if (args.Contains("--version")) {
                Console.WriteLine("Hermione HTTP Server version {0}", Listener.version);
                return;
            }
            Listener listener = new Listener(host, port);
            if (documentroot != String.Empty) {
                listener.ServerRoot = documentroot;
            }
            listener.Start();

            Environment.Exit(0);
        }
开发者ID:svkampen,项目名称:Hermione,代码行数:26,代码来源:Hermione.cs


示例16: MessagePump

        public MessagePump()
        {
            IPEndPoint[] ipep = Listener.EndPoints;

            m_Listeners = new Listener[ipep.Length];

            bool success = false;

            do {
                for (int i = 0; i < ipep.Length; i++) {
                    Listener l = new Listener(ipep[i]);
                    if (!success && l != null)
                        success = true;
                    m_Listeners[i] = l;
                }

                if (!success) {
                    Console.WriteLine("Retrying...");
                    Thread.Sleep(10000);
                }
            } while (!success);

			m_Queue = new Queue<NetState>();
			m_WorkingQueue = new Queue<NetState>();
			m_Throttled = new Queue<NetState>();
			m_Peek = new byte[4];
		}
开发者ID:FreeReign,项目名称:imaginenation,代码行数:27,代码来源:MessagePump.cs


示例17: Main

        static void Main(string[] args)
        {
            Logs.AddConsoleAppender();

            //  注册网络消息
            packetHandlersManager.Register((ushort) OpCode.Login, OnLogin);
            packetHandlersManager.Register((ushort)OpCode.SendMessage, OnSendMessage);
            packetHandlersManager.Register((ushort)OpCode.RecvPrivateMessage, OnSendPrivateMessage);

            var servers = new Listener<Session>();
            servers.SocketConnect += OnSocketConnect;
            servers.SocketDisconnect += OnSocketDisconnect;
            servers.SocketRecv += OnSocketRecv;
            servers.StartServer(10086);

            Logs.Info("服务器启动,等待客户端连接。按Esc键退出");
            while (true)
            {
                var key = Console.ReadKey();
                if (key.Key == ConsoleKey.Escape)
                    break;

                Thread.Sleep(100);
            }
        }
开发者ID:RainsSoft,项目名称:DogSE,代码行数:25,代码来源:Program.cs


示例18: Main

 static void Main(string[] args)
 {
     Timer t = new Timer();
     Listener listen = new Listener();
     listen.Subscribe(t);
     t.StartTimer();
 }
开发者ID:valkanov,项目名称:TelerikAcademy,代码行数:7,代码来源:TimerEvent.cs


示例19: addEventListener

		/**
		 * <p>Adds an event listener that will be run when this confidence object is updated. The listener will be locked and
		 * is likely to be invoked on a peer thread.</p>
		 * 
		 * <p>Note that this is NOT called when every block arrives. Instead it is called when the transaction
		 * transitions between confidence states, ie, from not being seen in the chain to being seen (not necessarily in 
		 * the best chain). If you want to know when the transaction gets buried under another block, implement a
		 * {@link BlockChainListener}, attach it to a {@link BlockChain} and then use the getters on the
		 * confidence object to determine the new depth.</p>
		 */
		public synchronized void addEventListener(Listener listener) {
			Preconditions.checkNotNull(listener);
			if (listeners == null)
				listeners = new ArrayList<Listener>(2);
			// Dedupe registrations. This makes the wallet code simpler.
			if (!listeners.contains(listener))
				listeners.add(listener);
		}
开发者ID:knocte,项目名称:BitcoinDotNet,代码行数:18,代码来源:TransactionConfidence.cs


示例20: RemoveBinding

 public void RemoveBinding()
 {
     Assert.AreEqual(new IPEndPoint(IPAddress.Parse("127.0.0.1"), 21), new IPEndPoint(IPAddress.Parse("127.0.0.1"), 21));
     var listener = new Listener();
     listener.AddBinding(new IPEndPoint(IPAddress.Parse("127.0.0.1"), 21));
     listener.RemoveBinding(new IPEndPoint(IPAddress.Parse("127.0.0.1"), 21));
     Assert.AreEqual(0, listener.Bindings.Count);
 }
开发者ID:xxjeng,项目名称:nuxleus,代码行数:8,代码来源:ListenerBindingTestFixture.cs



注:本文中的Listener类示例整理自Github/MSDocs等源码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。


鲜花

握手

雷人

路过

鸡蛋
该文章已有0人参与评论

请发表评论

全部评论

专题导读
上一篇:
C# ListenerForUnitTests类代码示例发布时间:2022-05-24
下一篇:
C# ListViewModel类代码示例发布时间:2022-05-24
热门推荐
阅读排行榜

扫描微信二维码

查看手机版网站

随时了解更新最新资讯

139-2527-9053

在线客服(服务时间 9:00~18:00)

在线QQ客服
地址:深圳市南山区西丽大学城创智工业园
电邮:jeky_zhao#qq.com
移动电话:139-2527-9053

Powered by 互联科技 X3.4© 2001-2213 极客世界.|Sitemap