Exemplo n.º 1
0
        public static bool TryParse(ref string error, string input, out FileFromInputDirectory output)
        {
            var length            = input.Length;
            var invalidCharacters = Path.GetInvalidPathChars();

            for (int i = 0; i < length; i++)
            {
                var c = input[i];
                for (int j = 0; j < invalidCharacters.Length; j++)
                {
                    if (c == invalidCharacters[j])
                    {
                        error  = "At position " + i + ", we found an invalid character '" + invalidCharacters[j] + "'!";
                        output = null;
                        return(false);
                    }
                }
            }
            output = new FileFromInputDirectory()
            {
                FileName = input
            };

            return(true);
        }
Exemplo n.º 2
0
        public static bool TryParse(ref string error, string input, out FileFromInputDirectory output)
        {
            var length = input.Length;
            var invalidCharacters = Path.GetInvalidPathChars();
            for ( int i = 0; i < length; i++ )
            {
                var c = input[i];
                for ( int j = 0; j < invalidCharacters.Length; j++ )
                {
                    if ( c == invalidCharacters[j] )
                    {
                        error = "At position " + i + ", we found an invalid character '" + invalidCharacters[j] + "'!";
                        output = null;
                        return false;
                    }
                }
            }
            output = new FileFromInputDirectory() { FileName = input };

            return true;
        }