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


C# NamespaceManager类代码示例

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


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


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