Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

CFX.Structurs.ValidationType mark it as flags for better coding #126

Open
Siox0911 opened this issue May 5, 2021 · 0 comments
Open

CFX.Structurs.ValidationType mark it as flags for better coding #126

Siox0911 opened this issue May 5, 2021 · 0 comments

Comments

@Siox0911
Copy link
Contributor

Siox0911 commented May 5, 2021

Hello together

Currently I am writing some code. But the enum ValidationType is strange. We can use multiple validation types in ValidateUnits RR as a list. Can we change the enum to a flagged enum. Also

public enum ValidationType
    {
        /// <summary>
        /// A validation that ensures a unit is at the proper step in the route, and has completed all
        /// pre-requisite steps.
        /// </summary>
        UnitRouteValidation,
        /// <summary>
        /// A validation that ensures a unit is not in a failed or error condition
        /// </summary>
        UnitStatusValidation,
        /// <summary>
        /// A validation that ensures a unit and ALL of its sub-assemblies are not in a failed or error condition
        /// </summary>
        UnitAndSubsStatusValidation,
        /// <summary>
        /// Validates that the trace data has been recived for this unit from the sender by a factory level software system
        /// </summary>
        UnitTraceValidation,
        /// <summary>
        /// All known validations should be performed
        /// </summary>
        All
    }

to

[Flags]
public enum ValidationType
    {
        /// <summary>
        /// A validation that ensures a unit is at the proper step in the route, and has completed all
        /// pre-requisite steps.
        /// </summary>
        UnitRouteValidation = 1,
        /// <summary>
        /// A validation that ensures a unit is not in a failed or error condition
        /// </summary>
        UnitStatusValidation = 2,
        /// <summary>
        /// A validation that ensures a unit and ALL of its sub-assemblies are not in a failed or error condition
        /// </summary>
        UnitAndSubsStatusValidation = 4,
        /// <summary>
        /// Validates that the trace data has been recived for this unit from the sender by a factory level software system
        /// </summary>
        UnitTraceValidation = 8,
        /// <summary>
        /// All known validations should be performed
        /// </summary>
        All = 16 //this can be deleted
    }

So you can very easy program some tests with

var myRequestedValidations = ValidationType.UnitRouteValidation | ValidationType.UnitStatusValidation;

myRequestedValidations is now 3, also 1 + 2.

Check one of this validations

if(myRequestedValidations.HasFlag(ValidationType.UnitRouteValidation))
{
    //Check unit route
}

This is more clearly like a List of enums.

Greatings

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant