Example #1
0
        /// <summary>
        /// Parse the reader type from the specified string value.
        /// </summary>
        /// <param name="type">Type place holder</param>
        /// <param name="value">String value to parse</param>
        /// <returns>Parsed Enum value</returns>
        public static EReaderType Parse(this EReaderType type, string value)
        {
            Preconditions.CheckArgument(value);

            value = value.Trim().ToUpper();
            return((EReaderType)Enum.Parse(typeof(EReaderType), value));
        }
Example #2
0
        /// <summary>
        /// Get the URI Scheme for this Reader Type.
        /// </summary>
        /// <param name="type">Reader Type</param>
        /// <returns>URI Scheme</returns>
        public static string GetURIScheme(EReaderType type)
        {
            switch (type)
            {
            case EReaderType.FILE:
                return(Uri.UriSchemeFile);

            case EReaderType.FTP:
                return(Uri.UriSchemeFtp);

            case EReaderType.HTTP:
                return(Uri.UriSchemeHttp);

            case EReaderType.HTTPS:
                return(Uri.UriSchemeHttps);

            case EReaderType.SFTP:
                return(Uri.UriSchemeFtp);
            }
            return(null);
        }
Example #3
0
        /// <summary>
        /// Get a new instance of a Configuration reader. Type of reader is determined based on the
        /// SCHEME of the URI.
        /// SCHEME = "http", TYPE = HTTP
        /// SCHEME = "file", type = File
        /// </summary>
        /// <param name="source">URI to get the input from.</param>
        /// <returns>Configuration Reader instance</returns>
        public static AbstractReader GetReader(Uri source)
        {
            Preconditions.CheckArgument(source);

            EReaderType type = ReaderTypeHelper.ParseFromUri(source);

            if (type != EReaderType.Unknown)
            {
                if (type == EReaderType.HTTP || type == EReaderType.HTTPS)
                {
                    return(new RemoteReader(source));
                }
                else if (type == EReaderType.FILE)
                {
                    return(new FileReader(source));
                }
                else if (type == EReaderType.FTP)
                {
                    return(new FtpRemoteReader(source));
                }
            }
            return(null);
        }