dotnet authentication parameters

 

Leader raised a demand, the front end of the passed parameters, we want to test whether the parameters are passed over, so I wrote a special tool to verify a class, call enough.

The first parameter is transmitted to the front end package Controller entity class, the second parameter for the entity classes which parameters need to be validated, with the package list.

I need to verify the configuration parameters unified wrote a class, similar to the following format:

1   public const string COURSE_ADD_PARAM = "courseName;auditor;author;" +
2             "courseDuration;teachingMethodId;courseUserId;courseLink;effectiveTime;" +
3             "expiryTime;coursePurpose;chapterCode;skillLevel";

Then According; segmentation, a method to get the list passed like.

. 1    / * 
2           * @Description: the test of the properties specified parameter is empty
 3           * If the specified parameter as long as any empty return property to false
 . 4           * If all of the specified property is not empty return parameter to true
 . 5           * T @Param T, List <String> List
 . 6           * / 
. 7          public  static Boolean VerificationParam <T> (T T, List < String > List)
 . 8          {
 . 9            
10              IF (T == null )
 . 11              {
 12 is                  return  to false ;
 13 is              }
 14             System.Reflection.PropertyInfo[] properties = t.GetType().GetProperties(System.Reflection.BindingFlags.Instance | System.Reflection.BindingFlags.Public);
15 
16             if (properties.Length <= 0)
17             {
18                 return false;
19             }
20 
21             foreach (System.Reflection.PropertyInfo item in properties)
22             {
23                 string name = item.Name;
24                 object value = item.GetValue(t, null);
25                 if (value == null && list.Contains(name))
26                 {
27                     return false;
28                 }
29                
30             }
31            
32             return true;
33         }

 

Guess you like

Origin www.cnblogs.com/battlecry/p/11359240.html