<commit_before>using System;
using System.Messaging;
using Rhino.ServiceBus.Exceptions;

namespace Rhino.ServiceBus.Msmq
{
	public class MsmqUtil
	{
		public static QueueInfo GetQueuePath(Endpoint endpoint)
		{
			var uri = endpoint.Uri;
			if (uri.AbsolutePath.IndexOf("/", 1) >= 0)
			{
				throw new InvalidOperationException(
					"Invalid enpoint url : " + uri + Environment.NewLine +
					"Queue Endpoints can't have a child folders (including 'public')" + Environment.NewLine +
					"Good: 'msmq://machinename/queue_name'." + Environment.NewLine +
					" Bad: msmq://machinename/round_file/queue_name"
					);
			}

			string hostName = uri.Host;
			if (string.Compare(hostName, ".") == 0 ||
				string.Compare(hostName, Environment.MachineName, true) == 0 ||
				string.Compare(hostName, "localhost", true) == 0)
			{
				return  new QueueInfo
				{
					IsLocal = true,
					QueuePath = @".\private$\" + uri.AbsolutePath.Substring(1),
                    QueueUri = uri
				};
			}

			return new QueueInfo
			{
				IsLocal = false,
				QueuePath = "FormatName:DIRECT=OS:" + hostName + @"\private$\" + uri.AbsolutePath.Substring(1),
                QueueUri = uri
			};
		}

		public static Uri GetQueueUri(MessageQueue queue)
		{
			if (queue == null)
				return null;
			return new Uri("msmq://" + queue.MachineName + "/" +
				queue.QueueName.Split('\\')[1]);
		}

		public static MessageQueue CreateQueue(string queuePath, QueueAccessMode accessMode)
		{
			try
			{
				if (MessageQueue.Exists(queuePath) == false)
				{
					try
					{<commit_msg>Generate TCP instead of OS MSMQ url.<commit_after>using System;
using System.Messaging;
using Rhino.ServiceBus.Exceptions;

namespace Rhino.ServiceBus.Msmq
{
	public class MsmqUtil
	{
		public static QueueInfo GetQueuePath(Endpoint endpoint)
		{
			var uri = endpoint.Uri;
			if (uri.AbsolutePath.IndexOf("/", 1) >= 0)
			{
				throw new InvalidOperationException(
					"Invalid enpoint url : " + uri + Environment.NewLine +
					"Queue Endpoints can't have a child folders (including 'public')" + Environment.NewLine +
					"Good: 'msmq://machinename/queue_name'." + Environment.NewLine +
					" Bad: msmq://machinename/round_file/queue_name"
					);
			}

			string hostName = uri.Host;
			if (string.Compare(hostName, ".") == 0 ||
				string.Compare(hostName, Environment.MachineName, true) == 0 ||
				string.Compare(hostName, "localhost", true) == 0)
			{
				return  new QueueInfo
				{
					IsLocal = true,
					QueuePath = @".\private$\" + uri.AbsolutePath.Substring(1),
                    QueueUri = uri
				};
			}

			return new QueueInfo
			{
				IsLocal = false,
				QueuePath = "FormatName:DIRECT=TCP:" + hostName + @"\private$\" + uri.AbsolutePath.Substring(1),
                QueueUri = uri
			};
		}

		public static Uri GetQueueUri(MessageQueue queue)
		{
			if (queue == null)
				return null;
			return new Uri("msmq://" + queue.MachineName + "/" +
				queue.QueueName.Split('\\')[1]);
		}

		public static MessageQueue CreateQueue(string queuePath, QueueAccessMode accessMode)
		{
			try
			{
				if (MessageQueue.Exists(queuePath) == false)
				{
					try
					{
{'fraction_non_alphanumeric': 0.1311944091486658, 'fraction_numerical': 0.005082592121982211, 'mean_word_length': 2.8590686274509802, 'pattern_counts': {'":': 0, '<': 3, '<?xml version=': 0, '>': 5, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '3308959', 'n_tokens_mistral': 1263, 'n_tokens_neox': 1005, 'n_words': 224}