当前位置: 首页>>代码示例>>C#>>正文


C# Publisher.Publish方法代码示例

本文整理汇总了C#中Publisher.Publish方法的典型用法代码示例。如果您正苦于以下问题:C# Publisher.Publish方法的具体用法?C# Publisher.Publish怎么用?C# Publisher.Publish使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在Publisher的用法示例。


在下文中一共展示了Publisher.Publish方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。

示例1: Run

        private static void Run()
        {
            using (var countdown = new CountdownEvent(2))
            {
                var subscriber = new Subscriber(MqttBrokerAddress, MqttBrokerPort);
                subscriber.Subscribe(Topic.Hello, Topic.Goodbye);
                subscriber.OnMessage += (topic, payload) =>
                {
                    if (topic == Topic.Hello)
                    {
                        var msg = JsonConvert.DeserializeObject<HelloMessage>(payload);
                        _log.Info("Topic: " + topic);
                        _log.Info("Message: " + msg);
                        countdown.Signal();
                    }
                    else if (topic == Topic.Goodbye)
                    {
                        var msg = JsonConvert.DeserializeObject<GoodbyeMessage>(payload);
                        _log.Info("Topic: " + topic);
                        _log.Info("Message: " + msg);
                        countdown.Signal();
                    }
                };

                var publisher = new Publisher(MqttBrokerAddress, MqttBrokerPort);
                publisher.Publish(Topic.Hello, new HelloMessage() { Name = "John Smith", Date = DateTime.Now });
                publisher.Publish(Topic.Goodbye, new GoodbyeMessage() { Name = "Jane Smith", Date = DateTime.Now });
                countdown.Wait();
            }
        }
开发者ID:yksz,项目名称:samples,代码行数:30,代码来源:Program.cs

示例2: Publish_will_send_the_message_to_listner

        public void Publish_will_send_the_message_to_listner()
        {
            var assignee = new SimpleAssignee();
            var publishWay = new SimpleDispatcher();
            var handler = new TestHandler();
            var message = new TestMessage();
            var publisher = new Publisher(assignee, publishWay);

            assignee.Subscribe(handler);

            publisher.Publish(message);

            Assert.That(handler.TestMessage, Is.SameAs(message));
        }
开发者ID:solyutor,项目名称:Solyutor.EventPublisher,代码行数:14,代码来源:PublisherTest.cs

示例3: Publisher_publishes_to_any_subscribers

        public void Publisher_publishes_to_any_subscribers()
        {
            var publisher = new Publisher<string>();

            publisher.Publish("test");

            int ncalls = 0;
            Subscriber<string> subscriber = (string val) =>
            {
                Assert.Equal("publish", val);
                ++ncalls;
            };
            publisher.Subscribe(subscriber);

            Assert.Equal(0, ncalls);
            publisher.Publish("publish");
            Assert.Equal(1, ncalls);

            publisher.Unsubscribe(subscriber);

            Assert.Equal(1, ncalls);
            publisher.Publish("no one subscribes");
            Assert.Equal(1, ncalls);
        }
开发者ID:kamichidu,项目名称:cs-sawara.pubsub,代码行数:24,代码来源:PublisherTest.cs

示例4: Main

        public static void Main()
        {
            var publishKey = "pub-c-aa7e75ee-ca5f-40ef-95c9-fe28cd6830f6";
            var subscribeKey = "sub-c-9fe7c32e-8c77-11e5-84ee-0619f8945a4f";
            var secretKey = "sec-c-YmVlY2I1YTAtNzQwYi00NjI2LTg2MmMtYzhhNTRkNDViZmFk";
            var channel = "radio";
            Publisher pubnub = new Publisher(publishKey, subscribeKey, secretKey);

            while (true)
            {
                Console.WriteLine("Enter message:");
                var message = Console.ReadLine();

                pubnub.Publish(channel, message);
            }
        }
开发者ID:juvemar,项目名称:WebApi-Cloud-Wcf,代码行数:16,代码来源:Startup.cs

示例5: PublishMessageToWebSync

        public void PublishMessageToWebSync(string message, string channel)
        {
            //verify WebSyncURL ends with "/"
            if (!WebSyncURL.EndsWith("/")) WebSyncURL += "/";

            //verify WebSyncChannel starts with "/"
            if (!WebSyncChannel.StartsWith("/")) WebSyncChannel = "/" + WebSyncChannel;

            Publisher publisher = new Publisher(new PublisherArgs
            {
                RequestUrl = this.WebSyncURL + "request.ashx"
            });

            var publication = publisher.Publish(new Publication
             {
                 Channel = channel,
                 DataJson = JSON.Serialize(new Payload { Text = message, Source = "NLog", Time = DateTime.Now })
             });

            if (publication.Successful == false)
            {
                Console.WriteLine("Could not publish: " + publication.Error);
            }
        }
开发者ID:stevesloka,项目名称:WebSync-NLog-Target,代码行数:24,代码来源:WebSyncLogger.cs

示例6: PublishData

 /// <summary>Publish data to CMS.</summary>
 /// <param name="item">Data item.</param>
 /// <param name="language">Date item language.</param>
 /// <param name="dbMaster">Database source.</param>
 /// <param name="dbWeb">Database target.</param>
 public void PublishData(Sitecore.Data.Items.Item item, Sitecore.Globalization.Language language, Sitecore.Data.Database dbMaster, Sitecore.Data.Database dbWeb)
 {
     // Use CMS security disabler to allow changes.
     using(new SecurityDisabler()) {
     PublishOptions opt = new PublishOptions(dbMaster, dbWeb, PublishMode.SingleItem, language, DateTime.Now);
     opt.RootItem = item;
     opt.Deep = false;
     Publisher pub = new Publisher(opt);
     pub.Publish();
     }
 }
开发者ID:diehard,项目名称:web-aspnet-sandbox-sitecore,代码行数:16,代码来源:PostLayout.ashx.cs

示例7: Publish

        public string Publish(string sourceDatabaseName, string[] targetNames = null, string[] languageNames = null)
        {
            var publisher = new Publisher();

            return publisher.Publish(sourceDatabaseName, targetNames, languageNames);
        }
开发者ID:Fortis-Collection,项目名称:Toolcore,代码行数:6,代码来源:Publishing.asmx.cs

示例8: PublishItem

        public static void PublishItem(Item item, Database database)
        {
            PublishOptions publishOptions = new PublishOptions
            (
                item.Database,
                database,
                Sitecore.Publishing.PublishMode.SingleItem,
                item.Language,
                DateTime.Now
            );

            Publisher publisher = new Publisher(publishOptions);
            publisher.Options.RootItem = item;
            publisher.Publish();
        }
开发者ID:D0cNet,项目名称:UnderstoodDotOrg.sln,代码行数:15,代码来源:CommonSenseImportHelper.cs

示例9: Publish

 public static void Publish(this Item item, bool deep)
 {
     var publishOptions = new PublishOptions(item.Database,
                                             Database.GetDatabase("web"),
                                             PublishMode.SingleItem,
                                             item.Language,
                                             DateTime.Now);
     var publisher = new Publisher(publishOptions);
     publisher.Options.RootItem = item;
     publisher.Options.Deep = deep;
     publisher.Publish();
 }
开发者ID:hnielsen,项目名称:Sitecore.Extensions,代码行数:12,代码来源:ItemExtensions.cs

示例10: PublishFiles

        /// <summary>
        /// Publishes the selected files.
        /// </summary>
        private void PublishFiles()
        {
            Project project = GetProjectForSelection();
            ProjectSettings settings = SettingsStore.Get(project);
            if (settings == null)
                return;

            // check if already publishing
            if (Publisher.CheckIsPublishing())
                return;

            // check config
            if (!CheckConfiguration(project, settings))
                return;

            Publisher publisher = new Publisher(settings);
            publisher.Publish(dte.SelectedItems);
        }
开发者ID:ivan-korshun,项目名称:VS-PublishExtensions2013,代码行数:21,代码来源:PublishMenu.cs

示例11: PublishActiveFile

        /// <summary>
        /// Publishes the file that is active in the editor.
        /// </summary>
        private void PublishActiveFile()
        {
            Document doc = Globals.ActiveDocument;
            if (doc == null)
                return;

            // does the document have a project item assigned?
            if (doc.ProjectItem is ProjectItem)
            {
                Project project = doc.ProjectItem.ContainingProject;
                ProjectSettings settings = SettingsStore.Get(project);
                if (settings == null)
                    return;

                // check if already publishing
                if (Publisher.CheckIsPublishing())
                    return;

                // check config
                if (!CheckConfiguration(project, settings))
                    return;

                // ask if we should really publish
                MessageBoxResult result = MessageBox.Show(
                    "Do you want to publish the following file?" +
                    Environment.NewLine + Environment.NewLine +
                    "File: " + doc.ProjectItem.GetRelativePath() + Environment.NewLine +
                    "Location: " + settings.GetPublishLocation(),
                    "Confirm Publish",
                    MessageBoxButton.YesNo,
                    MessageBoxImage.Question,
                    MessageBoxResult.Yes);

                if (result != MessageBoxResult.Yes)
                    return;

                Publisher publisher = new Publisher(settings);
                publisher.Publish(doc.ProjectItem);
            }
        }
开发者ID:ivan-korshun,项目名称:VS-PublishExtensions2013,代码行数:43,代码来源:PublishMenu.cs

示例12: PublishTours

 private static void PublishTours(Item itmToBePublished)
 {
     PublishOptions pubOptsTours = new PublishOptions(dbMaster, dbWeb, PublishMode.Smart, Sitecore.Globalization.Language.Predefined.English, System.DateTime.Now);
       pubOptsTours.RootItem = itmToBePublished;
       Publisher pub = new Publisher(pubOptsTours);
       pub.Options.Deep = true;
       pub.Publish();
 }
开发者ID:paul-at-gruden,项目名称:Test,代码行数:8,代码来源:XmlDataImport.cs

示例13: PublishItem

 private static void PublishItem(Item itmToBePublished)
 {
     Publisher pub = new Publisher(pubOpts);
       pub.Options.RootItem = itmToBePublished;
       pub.Options.Deep = false;
       pub.Publish();
 }
开发者ID:paul-at-gruden,项目名称:Test,代码行数:7,代码来源:XmlDataImport.cs

示例14: PublishGoogleProductFeedXMLItem

        /// <summary>
        /// Publish Google Product Feed XML Item
        /// </summary>
        /// <param name="item"></param>
        /// <param name="isPublishAsync"></param>
        public static void PublishGoogleProductFeedXMLItem(Item googleProductFeedXMLItem, Database masterDb, bool isPublishAsync, Database TargetDb)
        {
            try
            {
                PublishOptions publishOptions = new PublishOptions(masterDb,
                                                                   TargetDb,
                                                                   Sitecore.Publishing.PublishMode.SingleItem,
                                                                   googleProductFeedXMLItem.Language,
                                                                   System.DateTime.Now);

                Publisher publisher = new Publisher(publishOptions);
                publisher.Options.RootItem = googleProductFeedXMLItem;
                publisher.Options.Deep = false;

                if (isPublishAsync)
                    publisher.PublishAsync();
                else
                    publisher.Publish();
            }
            catch (Exception ex)
            {
                Log.Error("Error in PublishGoogleProductFeedXMLItem(). Item ID: " + googleProductFeedXMLItem.ID, ex, typeof(GoogleProductFeedCreation));
            }
        }
开发者ID:nikkipunjabi,项目名称:GoogleProductFeed,代码行数:29,代码来源:GoogleProductFeedCreation.cs

示例15: PublishOneItem

 private static void PublishOneItem(Item item)
 {
     Language language = Context.Language;
     Database database = Factory.GetDatabase("master");
     Database database2 = Factory.GetDatabase("web");
     Publisher publisher = new Publisher(new PublishOptions(database, database2, PublishMode.SingleItem, language, DateTime.Now)
     {
         RootItem = item,
         Deep = true,
         RepublishAll = true
     });
     publisher.Publish();
 }
开发者ID:JimmieOverby,项目名称:SitecorePhotoAlbum,代码行数:13,代码来源:PhotoAlbumObject.cs


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