Ejemplo n.º 1
0
        public static Employee Parse
        (
            String employeeString,
            ValidationFailureAction onFailure = ValidationFailureAction.Ignore)
        {
            Employee ret = null;

            if (!String.IsNullOrWhiteSpace(employeeString))
            {
                if (CommonRegex.EmployeeAliasRegex.IsMatch(employeeString))
                {
                    ret = new Employee(Alias.Parse(employeeString));
                }
                else if (CommonRegex.EmployeeStringRegex.IsMatch(employeeString))
                {
                    // Dave Tamasi (DTAMASI)
                    String[] split    = employeeString.Split(new char[] { '(' });
                    Alias    alias    = Alias.Parse(split[1].Replace(")", String.Empty));
                    String   fullName = split[0].Trim();
                    ret = new Employee(alias, fullName);
                }
                else if (CommonRegex.EmployeeNameRegex.IsMatch(employeeString))
                {
                    ret = new Employee(employeeString);
                }
            }

            return(ret);
        }
Ejemplo n.º 2
0
 /// <summary>
 /// </summary>
 /// <param name="nodePath"></param>
 /// <param name="onFailure"></param>
 /// <param name="autoCorrect">
 /// If true, will trim and lowercase the depotFilePath argument, assuming all other checks pass
 /// </param>
 private FailureBucket
 (
     string failureBucketString,
     ValidationFailureAction onFailure = ValidationFailureAction.Pivot)
 {
     this.failureBucketString = failureBucketString;
 }
Ejemplo n.º 3
0
        public static Boolean IsValidSddlString
        (
            ref string sddlString,
            ValidationFailureAction onFailure = ValidationFailureAction.Pivot)
        {
            Boolean isValid = false;

            if (!string.IsNullOrEmpty(sddlString) && CommonRegex.SddlStringRegex.IsMatch(sddlString))
            {
                isValid = true;
            }

            if (!isValid && onFailure != ValidationFailureAction.Ignore)
            {
                string message = string.Format("Invalid SddlString: {0}", sddlString);

                if (onFailure == ValidationFailureAction.Throw ||
                    (!Constants.IS_DEBUG_MODE && onFailure == ValidationFailureAction.Pivot))
                {
                    throw new ScarabException(message);
                }
                else if (onFailure == ValidationFailureAction.Assert ||
                         (Constants.IS_DEBUG_MODE && onFailure == ValidationFailureAction.Pivot))
                {
                    Debug.Fail(message);
                }
                else
                {
                    Framework.Common.WriteLine(message);
                }
            }

            return(isValid);
        }
Ejemplo n.º 4
0
 /// <summary>
 /// Parses a string and, if it's a valid area path, returns an AreaPath object,
 /// NULL otherwise.  The default is to ignore null or invalid input, but this can
 /// be set via the ValidationFailureAction at onFailure.
 /// </summary>
 public static AreaPath Parse
 (
     String areaPathString,
     ValidationFailureAction onFailure = ValidationFailureAction.Ignore)
 {
     return(new AreaPath(areaPathString, onFailure));
 }
Ejemplo n.º 5
0
 private Alias
 (
     string aliasString,
     ValidationFailureAction onFailure = ValidationFailureAction.Pivot)
 {
     IsValidAlias(ref aliasString, onFailure);
     this.aliasString = aliasString;
 }
Ejemplo n.º 6
0
 /// <summary>
 /// </summary>
 /// <param name="nodePath"></param>
 /// <param name="onFailure"></param>
 /// <param name="autoCorrect">
 /// If true, will trim and lowercase the depotFilePath argument, assuming all other checks pass
 /// </param>
 private AreaPath
 (
     string areaPathString,
     ValidationFailureAction onFailure = ValidationFailureAction.Pivot)
 {
     IsValidAreaPath(ref areaPathString, onFailure);
     this.areaPathString = areaPathString;
 }
Ejemplo n.º 7
0
 /// <summary>
 ///
 /// </summary>
 private SddlString
 (
     string sddlString,
     ValidationFailureAction onFailure = ValidationFailureAction.Pivot)
 {
     IsValidSddlString(ref sddlString, onFailure);
     this.sddlString = sddlString;
 }
Ejemplo n.º 8
0
        /// <summary>
        /// </summary>
        /// <param name="nodePath"></param>
        /// <param name="onFailure"></param>
        private CanonicalFilePath
        (
            String cfpString,
            ValidationFailureAction onFailure = ValidationFailureAction.Pivot)
        {
            IsValid(ref cfpString, onFailure);
            this.cfpString = cfpString;

            this.match = CommonRegex.CanonicalFilePathRegex.Match(this.cfpString);
            Debug.Assert(this.match.Success);
        }
Ejemplo n.º 9
0
        public static Boolean IsValidAlias
        (
            ref string aliasString,
            ValidationFailureAction onFailure = ValidationFailureAction.Pivot)
        {
            Boolean isValid = true;

            if (string.IsNullOrEmpty(aliasString))
            {
                isValid = false;
            }
            else
            {
                aliasString = aliasString.ToUpper();

                if (!CommonRegex.EmployeeAliasRegex.IsMatch(aliasString))
                {
                    isValid = false;
                }
            }

            if (!isValid && onFailure != ValidationFailureAction.Ignore)
            {
                string message = string.Format("Invalid Alias: {0}", aliasString);

                if (onFailure == ValidationFailureAction.Throw ||
                    (!Constants.IS_DEBUG_MODE && onFailure == ValidationFailureAction.Pivot))
                {
                    throw new ScarabException(message);
                }
                else if (onFailure == ValidationFailureAction.Assert ||
                         (Constants.IS_DEBUG_MODE && onFailure == ValidationFailureAction.Pivot))
                {
                    Debug.Fail(message);
                }
                else
                {
                    Framework.Common.WriteLine(message);
                }
            }

            return(isValid);
        }
Ejemplo n.º 10
0
        public static Boolean IsValidFailureBucket
        (
            ref string failureBucketString,
            ValidationFailureAction onFailure = ValidationFailureAction.Pivot)
        {
            // TODO Pri 3 Use a regex?

            Boolean isValid = true;

            if (string.IsNullOrEmpty(failureBucketString))
            {
                isValid = false;
            }
            else if (!CommonRegex.FailureBucketRegex.IsMatch(failureBucketString))
            {
                isValid = false;
            }

            if (!isValid && onFailure != ValidationFailureAction.Ignore)
            {
                string message = string.Format("Invalid FailureBucket: {0}", failureBucketString);

                if (onFailure == ValidationFailureAction.Throw ||
                    (!Constants.IS_DEBUG_MODE && onFailure == ValidationFailureAction.Pivot))
                {
                    throw new ScarabException(message);
                }
                else if (onFailure == ValidationFailureAction.Assert ||
                         (Constants.IS_DEBUG_MODE && onFailure == ValidationFailureAction.Pivot))
                {
                    Debug.Fail(message);
                }
                else
                {
                    Framework.Common.WriteLine(message);
                }
            }

            return(isValid);
        }
Ejemplo n.º 11
0
        public static Boolean IsValid
        (
            ref String cfpString,
            ValidationFailureAction onFailure = ValidationFailureAction.Pivot)
        {
            Boolean isValid = true;

            if (String.IsNullOrEmpty(cfpString))
            {
                isValid = false;
            }
            else if (!CommonRegex.CanonicalFilePathRegex.IsMatch(cfpString))
            {
                isValid = false;
            }

            if (!isValid && onFailure != ValidationFailureAction.Ignore)
            {
                String message = String.Format("Invalid CanonicalFilePath: {0}", cfpString);

                if (onFailure == ValidationFailureAction.Throw ||
                    (!Constants.IS_DEBUG_MODE && onFailure == ValidationFailureAction.Pivot))
                {
                    throw new ArgumentException(message, nameof(cfpString));
                }
                else if (onFailure == ValidationFailureAction.Assert ||
                         (Constants.IS_DEBUG_MODE && onFailure == ValidationFailureAction.Pivot))
                {
                    Debug.Fail(message);
                }
                else
                {
                    Framework.Common.WriteLine(message);
                }
            }

            return(isValid);
        }
Ejemplo n.º 12
0
 public static CanonicalFilePath Parse(String canonicalFilePathString,
                                       ValidationFailureAction onFailure = ValidationFailureAction.Pivot)
 {
     return(new CanonicalFilePath(canonicalFilePathString, onFailure));
 }