Beispiel #1
0
        /// <summary>
        /// Return the module connection string
        /// Retrieving the information from the module configuration or by connecting the IoT hub and asking for it
        /// </summary>
        /// <returns>Connection string</returns>
        private static string ProvideModuleConnectionString()
        {
            AuthenticationData authConfig = LocalIoTHubConfiguration.Authentication;

            AuthenticationMethodProviderBase authenticationMethodProvider;

            switch (authConfig.Identity)
            {
            case AuthenticationIdentity.Module:
                authenticationMethodProvider = new AuthenticationMethodProviderFromModule(authConfig);
                break;

            case AuthenticationIdentity.Device:
                authenticationMethodProvider = new AuthenticationMethodProviderFromDevice(authConfig);
                break;

            case AuthenticationIdentity.DPS:
                authenticationMethodProvider = new AuthenticationMethodProviderFromDPS(authConfig);
                break;

            default:
                throw new ArgumentOutOfRangeException(paramName: "identity", message: "Authentication Identity error");
            }

            return(authenticationMethodProvider.GetConnectionString());
        }
Beispiel #2
0
        /// <summary>
        /// Return the module connection string
        /// Retrieving the information from the module configuration or by connecting the IoT hub and asking for it
        /// </summary>
        /// <returns>Connection string</returns>
        private static string ProvideModuleConnectionString()
        {
            AuthenticationData authConfig = LocalIoTHubConfiguration.Authentication;

            AuthenticationMethodProviderBase authenticationMethodProvider;

            if (authConfig.Identity == AuthenticationIdentity.Module)
            {
                authenticationMethodProvider = new AuthenticationMethodProviderFromModule(authConfig);
            }
            else //(authConfig.Identity == AuthenticationIdentity.Device)
            {
                authenticationMethodProvider = new AuthenticationMethodProviderFromDevice(authConfig);
            }

            authenticationMethodProvider.ValidateConfiguration(authConfig);
            return(authenticationMethodProvider.GetConnectionString());
        }