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

C# NamespaceManager类代码示例

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

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



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

示例1: GetNamespaceManagerWithCustomCredentials

 public static NamespaceManager GetNamespaceManagerWithCustomCredentials(NetworkCredential credential)
 {
     Uri httpsUri = ServiceBusHelper.GetLocalHttpsEndpoint();
     TokenProvider tokenProvider = TokenProvider.CreateOAuthTokenProvider(new Uri[] { httpsUri }, credential);
     NamespaceManager nsManager = new NamespaceManager(httpsUri, tokenProvider);
     return nsManager;
 }
开发者ID:nordvall,项目名称:letterbox,代码行数:7,代码来源:NamespaceManagerTests.cs


示例2: theres_a_namespace_manager_available

        public void theres_a_namespace_manager_available()
        {
            var mf = TestConfigFactory.CreateMessagingFactory();
            nm = TestConfigFactory.CreateNamespaceManager(mf);

            _formatter = new AzureServiceBusMessageNameFormatter();
        }
开发者ID:keej,项目名称:MassTransit-AzureServiceBus,代码行数:7,代码来源:Interop_topic_spec.cs


示例3: CreateTopicsAndSubscriptions

        static void CreateTopicsAndSubscriptions(NamespaceManager namespaceManager)
        {
            Console.WriteLine("\nCreating a topic and 3 subscriptions.");

            // Create a topic and 3 subscriptions.
            TopicDescription topicDescription = namespaceManager.CreateTopic(Program.TopicName);
            Console.WriteLine("Topic created.");

            // Create a subscription for all messages sent to topic.
            namespaceManager.CreateSubscription(topicDescription.Path, SubsNameAllMessages, new TrueFilter());
            Console.WriteLine("Subscription {0} added with filter definition set to TrueFilter.", Program.SubsNameAllMessages);

            // Create a subscription that'll receive all orders which have color "blue" and quantity 10.
            namespaceManager.CreateSubscription(topicDescription.Path, SubsNameColorBlueSize10Orders, new SqlFilter("color = 'blue' AND quantity = 10"));
            Console.WriteLine("Subscription {0} added with filter definition \"color = 'blue' AND quantity = 10\".", Program.SubsNameColorBlueSize10Orders);

            //var ruleDesc = new RuleDescription();
            //ruleDesc.Filter = new CorrelationFilter("high");
            //ruleDesc.Action = new SbAction();

            // Create a subscription that'll receive all high priority orders.
            namespaceManager.CreateSubscription(topicDescription.Path, SubsNameHighPriorityOrders, new CorrelationFilter("high"));
            Console.WriteLine("Subscription {0} added with correlation filter definition \"high\".", Program.SubsNameHighPriorityOrders);

            Console.WriteLine("Create completed.");
        }
开发者ID:Srinivasanks23,项目名称:ServiceBusSandbox,代码行数:26,代码来源:Program.cs


示例4: QueueShouldExistAsync

 private async static Task QueueShouldExistAsync(NamespaceManager ns, QueueDescription queueDescription)
 {
     if (!await ns.QueueExistsAsync(queueDescription.Path))
     {
         throw new MessagingEntityNotFoundException("Queue: " + queueDescription.Path);
     }
 }
开发者ID:RobinSoenen,项目名称:RedDog,代码行数:7,代码来源:MessagingFactoryQueueExtensions.cs


示例5: ServiceBusConnectionContext

        public ServiceBusConnectionContext(ServiceBusScaleoutConfiguration configuration,
                                           NamespaceManager namespaceManager,
                                           IList<string> topicNames,
                                           TraceSource traceSource,
                                           Action<int, IEnumerable<BrokeredMessage>> handler,
                                           Action<int, Exception> errorHandler,
                                           Action<int> openStream)
        {
            if (topicNames == null)
            {
                throw new ArgumentNullException("topicNames");
            }

            _namespaceManager = namespaceManager;
            _configuration = configuration;

            _subscriptions = new SubscriptionContext[topicNames.Count];
            _topicClients = new TopicClient[topicNames.Count];

            _trace = traceSource;

            TopicNames = topicNames;
            Handler = handler;
            ErrorHandler = errorHandler;
            OpenStream = openStream;

            TopicClientsLock = new object();
            SubscriptionsLock = new object();
        }
开发者ID:nsavga,项目名称:SignalR,代码行数:29,代码来源:ServiceBusConnectionContext.cs


示例6: Initialize

        public void Initialize()
        {
            var retryStrategy = new Incremental(3, TimeSpan.FromMilliseconds(100), TimeSpan.FromSeconds(1));
            var retryPolicy = new RetryPolicy<ServiceBusTransientErrorDetectionStrategy>(retryStrategy);
            var tokenProvider = TokenProvider.CreateSharedSecretTokenProvider(settings.TokenIssuer, settings.TokenAccessKey);
            var serviceUri = ServiceBusEnvironment.CreateServiceUri(settings.ServiceUriScheme, settings.ServiceNamespace, settings.ServicePath);
            var namespaceManager = new NamespaceManager(serviceUri, tokenProvider);

            this.settings.Topics.AsParallel().ForAll(topic =>
            {
                retryPolicy.ExecuteAction(() => CreateTopicIfNotExists(namespaceManager, topic));
                topic.Subscriptions.AsParallel().ForAll(subscription =>
                {
                    retryPolicy.ExecuteAction(() => CreateSubscriptionIfNotExists(namespaceManager, topic, subscription));
                    retryPolicy.ExecuteAction(() => UpdateRules(namespaceManager, topic, subscription));
                });
            });

            // Execute migration support actions only after all the previous ones have been completed.
            foreach (var topic in this.settings.Topics)
            {
                foreach (var action in topic.MigrationSupport)
                {
                    retryPolicy.ExecuteAction(() => UpdateSubscriptionIfExists(namespaceManager, topic, action));
                }
            }

            this.initialized = true;
        }
开发者ID:TiagoTerra,项目名称:cqrs-journey,代码行数:29,代码来源:ServiceBusConfig.cs


示例7: OnStart

        public override bool OnStart()
        {
            ServicePointManager.DefaultConnectionLimit = 12;

            var connectionString = CloudConfigurationManager.GetSetting("topicConnectionString");
            var topicName = CloudConfigurationManager.GetSetting("topicName");

            _nsMgr = NamespaceManager.CreateFromConnectionString(connectionString);

            if (!_nsMgr.TopicExists(topicName))
            {
                _nsMgr.CreateTopic(topicName);
            }

            if (!_nsMgr.SubscriptionExists(topicName, "audit"))
            {
                _nsMgr.CreateSubscription(topicName, "audit");
            }

            _client = SubscriptionClient.CreateFromConnectionString(connectionString, topicName, "audit", ReceiveMode.ReceiveAndDelete);

            var result = base.OnStart();

            Trace.TraceInformation("NTM.Auditing has been started");

            return result;
        }
开发者ID:jplane,项目名称:AzureATLMeetup,代码行数:27,代码来源:WorkerRole.cs


示例8: Init

        public async void Init(MessageReceived messageReceivedHandler) {
            this.random = new Random();

            //ServiceBusEnvironment.SystemConnectivity.Mode = ConnectivityMode.AutoDetect;
            
            // Tcp mode does not work when I run in a VM (VirtualBox) and the host 
            // is using a wireless connection. Hard coding to Http.
            ServiceBusEnvironment.SystemConnectivity.Mode = ConnectivityMode.Http;

            string connectionString = CloudConfigurationManager.GetSetting("Microsoft.ServiceBus.ConnectionString");
            this.factory = MessagingFactory.CreateFromConnectionString(connectionString);
            this.namespaceManager = NamespaceManager.CreateFromConnectionString(connectionString);

            if (!namespaceManager.TopicExists(topicName)) {
                namespaceManager.CreateTopic(topicName);
            }

            this.subscriptionName = Guid.NewGuid().ToString();

            // Not needed really, it's a GUID...
            if (!namespaceManager.SubscriptionExists(topicName, subscriptionName)) {
                namespaceManager.CreateSubscription(topicName, subscriptionName);
            }

            this.topicClient = factory.CreateTopicClient(topicName);

            this.subClient = factory.CreateSubscriptionClient(topicName, subscriptionName);

            while (true) {
                await ReceiveMessageTaskAsync(messageReceivedHandler);
            }
        }
开发者ID:DonKarlssonSan,项目名称:CumulusChat,代码行数:32,代码来源:ChatApplication.cs


示例9: EventHubViewModel

 public EventHubViewModel(string eventHubName, NamespaceManager nsm)
 {
     _nsm = nsm;
     EventHubName = eventHubName;
     Partitions = new ObservableCollection<PartitionViewModel>();
     ConsumerGroups = new ObservableCollection<string>();
 }
开发者ID:bennage,项目名称:eventhub-visualizer,代码行数:7,代码来源:EventHubViewModel.cs


示例10: ServiceBusConnection

        public ServiceBusConnection(ServiceBusScaleoutConfiguration configuration, TraceSource traceSource)
        {
            _trace = traceSource;
            _connectionString = configuration.BuildConnectionString();

            try
            {
                _namespaceManager = NamespaceManager.CreateFromConnectionString(_connectionString);
                _factory = MessagingFactory.CreateFromConnectionString(_connectionString);

                if (configuration.RetryPolicy != null)
                {
                    _factory.RetryPolicy = configuration.RetryPolicy;
                }
                else
                {
                    _factory.RetryPolicy = RetryExponential.Default;
                }
            }
            catch (ConfigurationErrorsException)
            {
                _trace.TraceError("The configured Service Bus connection string contains an invalid property. Check the exception details for more information.");
                throw;
            }

            _backoffTime = configuration.BackoffTime;
            _idleSubscriptionTimeout = configuration.IdleSubscriptionTimeout;    
            _configuration = configuration;
        }
开发者ID:GaneshBachhao,项目名称:SignalR,代码行数:29,代码来源:ServiceBusConnection.cs


示例11: Main

        static void Main(string[] args)
        {
            try
            {
                // Connection String as can be found on the azure portal https://manage.windowsazure.com/microsoft.onmicrosoft.com#Workspaces/ServiceBusExtension/namespaces
                // 
                // The needed Shared access policy is Manage, this can either be the RootManageSharedAccessKey or one create with Manage priviledges
                // "Endpoint = sb://NAMESPACE.servicebus.windows.net/;SharedAccessKeyName=RootManageSharedAccessKey;SharedAccessKey=THISISMYKEY";
                var policyName = "RootManageSharedAccessKey";
                var policySharedAccessKey = "THISISMYKEY";
                var serviceBusNamespace = "NAMESPACE";
                var credentials = TokenProvider.CreateSharedAccessSignatureTokenProvider(policyName, policySharedAccessKey);

                // access the namespace
                var serviceBusUri = ServiceBusEnvironment.CreateServiceUri("sb", serviceBusNamespace, string.Empty);
                var manager = new NamespaceManager(serviceBusUri, credentials);

                // Create the eventhub if needed
                var description = manager.CreateEventHubIfNotExists("MyHub");
                Console.WriteLine("AT: " + description.CreatedAt + " EventHub:" + description.Path + " Partitions: " + description.PartitionIds);
            }
            catch (Exception e)
            {
                Console.WriteLine(e.ToString());
            }
            Console.ReadLine();
        }
开发者ID:sideshowcoder,项目名称:CreateEventHub,代码行数:27,代码来源:Program.cs


示例12: ServiceBusOperator

 /// <summary>
 /// 
 /// </summary>
 /// <param name="connectionString"></param>
 /// <param name="longPollingTimeout"></param>
 /// Turn it on if you know the limit will not be reached</param>
 public ServiceBusOperator(string connectionString, 
     TimeSpan longPollingTimeout)
 {
     _longPollingTimeout = longPollingTimeout;
     _namespaceManager = NamespaceManager.CreateFromConnectionString(connectionString);
     _clientProvider = new ClientProvider(connectionString, true);
 }
开发者ID:FeodorFitsner,项目名称:BeeHive,代码行数:13,代码来源:ServiceBusOperator.cs


示例13: Main

        public static void Main(string[] args)
        {
            ServiceNamespace = ConfigurationManager.AppSettings["ServiceNamespace"];
            // Issuer key
            sasKeyValue = ConfigurationManager.AppSettings["SASKey"];            

            // Create management credentials
            TokenProvider credentials = TokenProvider.CreateSharedAccessSignatureTokenProvider(sasKeyName, sasKeyValue);
            NamespaceManager namespaceClient = 
                new NamespaceManager(
                    ServiceBusEnvironment.CreateServiceUri("sb", ServiceNamespace, string.Empty), 
                    credentials);
            QueueDescription myQueue;
            if (!namespaceClient.QueueExists(QUEUE))
            {
                myQueue = namespaceClient.CreateQueue(QUEUE);
            }
            MessagingFactory factory = MessagingFactory.Create(ServiceBusEnvironment.CreateServiceUri("sb", ServiceNamespace, string.Empty), credentials);
            QueueClient myQueueClient = factory.CreateQueueClient(QUEUE);

            // Send message
            Poco poco = new Poco();
            poco.Id = "001";
            poco.content = "This is some content";
            BrokeredMessage message = new BrokeredMessage();
            message.Properties.Add("Id", poco.Id);
            message.Properties.Add("Content", poco.content);
            myQueueClient.Send(message);
        }
开发者ID:martin-chambers,项目名称:ContinuousWebJob,代码行数:29,代码来源:Program.cs


示例14: TopicShouldExistAsync

 private async static Task TopicShouldExistAsync(NamespaceManager ns, TopicDescription topicDescription)
 {
     if (!await ns.TopicExistsAsync(topicDescription.Path))
     {
         throw new MessagingEntityNotFoundException("Topic: " + topicDescription.Path);
     }
 }
开发者ID:RobinSoenen,项目名称:RedDog,代码行数:7,代码来源:MessagingFactoryTopicExtensions.cs


示例15: Main

        static void Main(string[] args)
        {
            GetUserCredentials();
            TokenProvider tokenProvider = null;
            Uri serviceUri = null;
            CreateTokenProviderAndServiceUri(out tokenProvider, out serviceUri);

            NamespaceManager namespaceManager = new NamespaceManager(serviceUri, tokenProvider);
            Console.WriteLine("Creating Topic 'IssueTrackingTopic'...");
            if (namespaceManager.TopicExists("IssueTrackingTopic"))
                namespaceManager.DeleteTopic("IssueTrackingTopic");

            MessagingFactory factory = null;
            TopicDescription myTopic = namespaceManager.CreateTopic(TopicName);
            // Criar duas Subscrições
            Console.WriteLine("Creating Subscriptions 'AuditSubscription' and 'AgentSubscription'...");
            SubscriptionDescription myAuditSubscription = namespaceManager.CreateSubscription((myTopic.Path, "AuditSubscription");
            SubscriptionDescription myAgentSubscription = namespaceManager.CreateSubscription(myTopic.Path, "AgentSubscription");
            TopicClient myTopicClient = CreateTopicClient(serviceUri, tokenProvider, myTopic, out factory);
            List<BrokeredMessage> messageList = new List<BrokeredMessage>();
            messageList.Add(CreateIssueMessage("1", "First message information"));
            messageList.Add(CreateIssueMessage("2", "Second message information"));
            messageList.Add(CreateIssueMessage("3", "Third message information"));
            Console.WriteLine("\nSending messages to topic...");
            SendListOfMessages(messageList, myTopicClient);

            Console.WriteLine("\nFinished sending messages, press ENTER to clean up and exit.");
            myTopicClient.Close();
            Console.ReadLine();
            namespaceManager.DeleteTopic(TopicName);
        }
开发者ID:sandrapatfer,项目名称:PROMPT11-10-CloudComputing.sandrapatfer,代码行数:31,代码来源:Program.cs


示例16: ServiceBusArgumentsDisplayTestsFixture

        public ServiceBusArgumentsDisplayTestsFixture()
            : base(cleanStorageAccount: true)
        {
            _hostConfiguration = new JobHostConfiguration(StorageAccount.ConnectionString)
            {
                TypeLocator = new ExplicitTypeLocator(
                    typeof(ServiceBusArgumentsDisplayFunctions),
                    typeof(DoneNotificationFunction))
            };

            #if VNEXT_SDK
            ServiceBusConfiguration serviceBusConfig = new ServiceBusConfiguration();
            serviceBusConfig.ConnectionString = ServiceBusAccount;
            _serviceBusConnectionString = serviceBusConfig.ConnectionString;
            _hostConfiguration.UseServiceBus(serviceBusConfig);
            #else
            _serviceBusConnectionString = ServiceBusAccount;
            _hostConfiguration.ServiceBusConnectionString = _serviceBusConnectionString;
            #endif

            _namespaceManager = NamespaceManager.CreateFromConnectionString(_serviceBusConnectionString);

            // ensure we're starting in a clean state
            CleanServiceBusQueues();

            // now run the entire end to end scenario, causing all the job functions
            // to be invoked
            RunEndToEnd();
        }
开发者ID:farukc,项目名称:azure-webjobs-sdk-dashboard-tests,代码行数:29,代码来源:ServiceBusArgumentsDisplayFixture.cs


示例17: Main

		static void Main()
		{
			_servicesBusConnectionString = AmbientConnectionStringProvider.Instance.GetConnectionString(ConnectionStringNames.ServiceBus);
			namespaceManager = NamespaceManager.CreateFromConnectionString(_servicesBusConnectionString);

			if (!namespaceManager.QueueExists(nameof(Step1)))
			{
				namespaceManager.CreateQueue(nameof(Step1));
			}
			if (!namespaceManager.QueueExists(nameof(Step2)))
			{
				namespaceManager.CreateQueue(nameof(Step2));
			}

			JobHostConfiguration config = new JobHostConfiguration();
			config.UseServiceBus();



			var host = new JobHost(config);

			CreateStartMessage();

			host.RunAndBlock();
		}
开发者ID:Cognim,项目名称:Azure-webjobs-and-service-bus-tryout,代码行数:25,代码来源:Program.cs


示例18: CreateEventHubAsync

        public async Task<EventHubDescription> CreateEventHubAsync()
        {

            string serviceBusNamespace = "iotmc-ns";
            string serviceBusManageKey = "<< Add your SAS here >>";
            string eventHubName = "IoTMC";
            string eventHubSASKeyName = "Device01";

            Uri serviceBusUri = ServiceBusEnvironment.CreateServiceUri("sb", serviceBusNamespace, string.Empty);
            TokenProvider tokenProvider = TokenProvider.CreateSharedAccessSignatureTokenProvider("RootManageSharedAccessKey", serviceBusManageKey);
            NamespaceManager nameSpaceManager = new NamespaceManager(string.Format("//{0}/", serviceBusUri.Host), tokenProvider);
            string eventHubKey = SharedAccessAuthorizationRule.GenerateRandomKey();

            EventHubDescription eventHubDescription = new EventHubDescription(eventHubName)
            {
                PartitionCount = 8,
                MessageRetentionInDays = 1
            };
            SharedAccessAuthorizationRule eventHubSendRule = new SharedAccessAuthorizationRule(eventHubSASKeyName, eventHubKey, new[] { AccessRights.Send, AccessRights.Listen });
            eventHubDescription.Authorization.Add(eventHubSendRule);
            eventHubDescription = await nameSpaceManager.CreateEventHubIfNotExistsAsync(eventHubDescription);

            string eventHubSASKey = ((SharedAccessAuthorizationRule)eventHubDescription.Authorization.First()).PrimaryKey;

            return eventHubDescription;
        }
开发者ID:HydAu,项目名称:IoTMasterClass,代码行数:26,代码来源:SBAdmin.cs


示例19: ReliableClientBase

 public ReliableClientBase(string sbNamespace, TokenProvider tokenProvider, string path, RetryPolicy<ServiceBusTransientErrorDetectionStrategy> policy)
 {
     mRetryPolicy = policy;
     Uri address = ServiceBusEnvironment.CreateServiceUri("sb", sbNamespace, string.Empty);
     mNamespaceManager = new NamespaceManager(address, tokenProvider);
     mMessagingFactory = MessagingFactory.Create(address, tokenProvider);
 }
开发者ID:HaishiBai,项目名称:ReliableServiceBusClients,代码行数:7,代码来源:ReliableClientBase.cs


示例20: SubscriptionShouldExistAsync

 private async static Task SubscriptionShouldExistAsync(NamespaceManager ns, SubscriptionDescription subscriptionDescription)
 {
     if (!await ns.SubscriptionExistsAsync(subscriptionDescription.TopicPath, subscriptionDescription.Name))
     {
         throw new MessagingEntityNotFoundException("Subscription: " + subscriptionDescription.TopicPath + "/" + subscriptionDescription.Name);
     }
 }
开发者ID:RobinSoenen,项目名称:RedDog,代码行数:7,代码来源:MessagingFactorySubscriptionExtensions.cs



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


鲜花

握手

雷人

路过

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

请发表评论

全部评论

专题导读
上一篇:
C# Nancy类代码示例发布时间:2022-05-24
下一篇:
C# NamespaceDeclaration类代码示例发布时间: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