private void SetDefaultClientProperties(IDictionary <string, object> clientProperties)
        {
            string applicationNameAndPath = null;

#if !NETFX
            var version = this.GetType().GetTypeInfo().Assembly.GetName().Version.ToString();
#else
            var version = Assembly.GetExecutingAssembly().GetName().Version.ToString();
#endif
            applicationNameAndPath = Environment.GetCommandLineArgs()[0];

            var applicationName = "unknown";
            var applicationPath = "unknown";
            if (!string.IsNullOrWhiteSpace(applicationNameAndPath))
            {
                // Note: When running the application in an Integration Services Package (SSIS) the
                // Environment.GetCommandLineArgs()[0] can return null, and therefor it is not possible to get
                // the filename or directory name.
                try
                {
                    // Will only throw an exception if the applicationName contains invalid characters, is empty, or too long
                    // Silently catch the exception, as we will just leave the application name and path to "unknown"
                    applicationName = Path.GetFileName(applicationNameAndPath);
                    applicationPath = Path.GetDirectoryName(applicationNameAndPath);
                }
                catch (ArgumentException) { }
                catch (PathTooLongException) { }
            }

            var hostname = Environment.MachineName;

            var product  = Product ?? applicationName;
            var platform = Platform ?? hostname;
            var name     = Name ?? applicationName;

            AddValueIfNotExists(clientProperties, "client_api", "EasyNetQ");
            AddValueIfNotExists(clientProperties, "product", product);
            AddValueIfNotExists(clientProperties, "platform", platform);
            AddValueIfNotExists(clientProperties, "version", version);
            AddValueIfNotExists(clientProperties, "connection_name", name);
            AddValueIfNotExists(clientProperties, "easynetq_version", version);
            AddValueIfNotExists(clientProperties, "application", applicationName);
            AddValueIfNotExists(clientProperties, "application_location", applicationPath);
            AddValueIfNotExists(clientProperties, "machine_name", hostname);
            AddValueIfNotExists(clientProperties, "user", UserName);
            AddValueIfNotExists(clientProperties, "connected", DateTime.UtcNow.ToString("u")); // UniversalSortableDateTimePattern: yyyy'-'MM'-'dd HH':'mm':'ss'Z'
            AddValueIfNotExists(clientProperties, "requested_heartbeat", RequestedHeartbeat.ToString());
            AddValueIfNotExists(clientProperties, "timeout", Timeout.ToString());
            AddValueIfNotExists(clientProperties, "publisher_confirms", PublisherConfirms.ToString());
            AddValueIfNotExists(clientProperties, "persistent_messages", PersistentMessages.ToString());
        }
        private void SetClientDefaultProperties()
        {
            var clientProperties       = new Dictionary <string, object>();
            var version                = Assembly.GetExecutingAssembly().GetName().Version.ToString();
            var applicationNameAndPath = Environment.GetCommandLineArgs()[0];

            var applicationName = "unknown";
            var applicationPath = "unknown";

            if (!string.IsNullOrWhiteSpace(applicationNameAndPath))
            {
                // Note: When running the application in an Integration Services Package (SSIS) the
                // Environment.GetCommandLineArgs()[0] can return null, and therefor it is not possible to get
                // the filename or directory name.
                try
                {
                    // Will only throw an exception if the applicationName contains invalid characters, is empty, or too long
                    // Silently catch the exception, as we will just leave the application name and path to "unknown"
                    applicationName = Path.GetFileName(applicationNameAndPath);
                    applicationPath = Path.GetDirectoryName(applicationNameAndPath);
                }
                catch (ArgumentException) { }
                catch (PathTooLongException) { }
            }

            var hostname = Environment.MachineName;
            var product  = applicationName;
            var platform = hostname;

            clientProperties.Add("product", product);
            clientProperties.Add("platform", platform);
            clientProperties.Add("application", applicationName);
            clientProperties.Add("application_location", applicationPath);
            clientProperties.Add("machine_name", hostname);
            clientProperties.Add("connected", DateTimeOffset.Now.ToString("yyyy-MM-dd HH:mm:ss"));
            clientProperties.Add("requested_heartbeat", RequestedHeartbeat.ToString());
            clientProperties.Add("timeout", Timeout.ToString());
            clientProperties.Add("publisher_confirms", PublisherConfirms.ToString());
            clientProperties.Add("persistent_messages", PersistentMessages.ToString());

            ClientProperties.AddRange(clientProperties);
        }
 public void SetUp()
 {
     channel = MockRepository.GenerateStub<IModel>();
     publisherConfirms = new PublisherConfirms();
 }
Exemple #4
0
 public void SetUp()
 {
     channel           = MockRepository.GenerateStub <IModel>();
     publisherConfirms = new PublisherConfirms();
 }