/// <summary>
        /// Create an Environment, using default values where applicable.
        /// </summary>
        /// <param name="applicationKey">Application key.</param>
        /// <param name="authenticationMethod">Authentication method.</param>
        /// <param name="consumerName">Consumer name.</param>
        /// <param name="solutionId">Solution ID.</param>
        /// <param name="dataModelNamespace">Data model namespace.</param>
        /// <param name="supportedInfrastructureVersion">Supported infrastructure version.</param>
        /// <param name="transport">Transport.</param>
        /// <param name="productName">Product name.</param>
        /// <returns>An Environment.</returns>
        private static environmentType CreateDefaultEnvironmentType(
            string applicationKey,
            string authenticationMethod           = null,
            string consumerName                   = null,
            string solutionId                     = null,
            string dataModelNamespace             = null,
            string supportedInfrastructureVersion = null,
            string transport   = null,
            string productName = null)
        {
            var applicationInfo = new applicationInfoType {
                applicationKey = applicationKey
            };

            if (!string.IsNullOrWhiteSpace(dataModelNamespace))
            {
                applicationInfo.dataModelNamespace = dataModelNamespace;
            }

            applicationInfo.supportedInfrastructureVersion =
                string.IsNullOrWhiteSpace(supportedInfrastructureVersion)
                    ? DefaultSupportedInfrastructureVersion
                    : supportedInfrastructureVersion;

            if (!string.IsNullOrWhiteSpace(transport))
            {
                applicationInfo.transport = transport;
            }

            if (!string.IsNullOrWhiteSpace(productName))
            {
                var productIdentity = new productIdentityType {
                    productName = productName
                };
                applicationInfo.applicationProduct = productIdentity;
            }

            var environmentType = new environmentType
            {
                applicationInfo      = applicationInfo,
                authenticationMethod = string.IsNullOrWhiteSpace(authenticationMethod)
                    ? DefaultAuthenticationMethod
                    : authenticationMethod,
                consumerName = string.IsNullOrWhiteSpace(consumerName) ? DefaultConsumerName : consumerName
            };

            if (!string.IsNullOrWhiteSpace(solutionId))
            {
                environmentType.solutionId = solutionId;
            }

            return(environmentType);
        }
Example #2
0
        /// <summary>
        /// Create an Environment, using default values where applicable.
        /// </summary>
        /// <param name="applicationKey">Application key.</param>
        /// <param name="authenticationMethod">Authentication method.</param>
        /// <param name="consumerName">Consumer name.</param>
        /// <param name="solutionId">Solution ID.</param>
        /// <param name="dataModelNamespace">Data model namespace.</param>
        /// <param name="supportedInfrastructureVersion">Supported infrastructure version.</param>
        /// <param name="transport">Transport.</param>
        /// <param name="productName">Product name.</param>
        /// <returns>An Environment.</returns>
        private environmentType CreateDefaultEnvironmentType
            (string applicationKey,
            string authenticationMethod           = null,
            string consumerName                   = null,
            string solutionId                     = null,
            string dataModelNamespace             = null,
            string supportedInfrastructureVersion = null,
            string transport   = null,
            string productName = null)
        {
            applicationInfoType applicationInfo = new applicationInfoType();

            applicationInfo.applicationKey = applicationKey;

            if (!String.IsNullOrWhiteSpace(dataModelNamespace))
            {
                applicationInfo.dataModelNamespace = dataModelNamespace;
            }

            if (String.IsNullOrWhiteSpace(supportedInfrastructureVersion))
            {
                applicationInfo.supportedInfrastructureVersion = defaultSupportedInfrastructureVersion;
            }
            else
            {
                applicationInfo.supportedInfrastructureVersion = supportedInfrastructureVersion;
            }

            if (!String.IsNullOrWhiteSpace(transport))
            {
                applicationInfo.transport = transport;
            }

            if (!String.IsNullOrWhiteSpace(productName))
            {
                productIdentityType productIdentity = new productIdentityType();
                productIdentity.productName        = productName;
                applicationInfo.applicationProduct = productIdentity;
            }

            environmentType environmentType = new environmentType();

            environmentType.applicationInfo = applicationInfo;

            if (String.IsNullOrWhiteSpace(authenticationMethod))
            {
                environmentType.authenticationMethod = defaultAuthenticationMethod;
            }
            else
            {
                environmentType.authenticationMethod = authenticationMethod;
            }

            if (String.IsNullOrWhiteSpace(consumerName))
            {
                environmentType.consumerName = defaultConsumerName;
            }
            else
            {
                environmentType.consumerName = consumerName;
            }

            if (!String.IsNullOrWhiteSpace(solutionId))
            {
                environmentType.solutionId = solutionId;
            }

            return(environmentType);
        }