Dev2.PathOperations.Dev2ActivityIOPathUtils.ExtractPathType C# (CSharp) Method

ExtractPathType() public static method

public static ExtractPathType ( string path ) : enActivityIOPathType
path string
return enActivityIOPathType
        public static enActivityIOPathType ExtractPathType(string path)
        {
            enActivityIOPathType result = enActivityIOPathType.Invalid;

            Array vals = Enum.GetValues(typeof(enActivityIOPathType));

            int pos = 0;

            while(pos < vals.Length && result == enActivityIOPathType.Invalid)
            {
                string toCheck = vals.GetValue(pos) + ":";
                string checkPath = path.ToUpper();
                if(checkPath.StartsWith(toCheck))
                {
                    result = (enActivityIOPathType)vals.GetValue(pos);
                }

                pos++;
            }
            return result;
        }
    }

Usage Example

        /// <summary>
        /// Return an IActivityIOPath based upont the path string
        /// </summary>
        /// <param name="path"></param>
        /// <returns></returns>
        public static IActivityIOPath CreatePathFromString(string path, string user, string pass, bool IsNotCertVerifiable)
        {
            // Fetch path type
            enActivityIOPathType type = Dev2ActivityIOPathUtils.ExtractPathType(path);

            if (type == enActivityIOPathType.Invalid)
            {
                // Default to file system
                type = enActivityIOPathType.FileSystem;
            }

            return(new Dev2ActivityIOPath(type, path, user, pass, IsNotCertVerifiable));
        }
All Usage Examples Of Dev2.PathOperations.Dev2ActivityIOPathUtils::ExtractPathType