Exemplo n.º 1
0
 /// <summary>
 /// Make sure all required fields got hit.
 /// </summary>
 private void CheckRequired()
 {
     MemberInfo[] mis = GetCommandLineMembers();
     foreach (MemberInfo mi in mis)
     {
         CommandLineAttribute cla = GetOption(mi);
         if (cla.Required && (GetValue(mi) == null))
         {
             throw new ArgumentException("Did not provide required parameter: ", mi.Name);
         }
     }
 }
Exemplo n.º 2
0
 /// <summary>
 /// Look at myself, to see if there are any command line
 /// parameter fields or properties.
 /// </summary>
 private void SetFlags()
 {
     if (m_flags.Count != 0)
     {
         return;
     }
     MemberInfo[] mis = GetCommandLineMembers();
     foreach (MemberInfo mi in mis)
     {
         CommandLineAttribute cla = GetOption(mi);
         string cf = cla.CommandFlag;
         // If no CommandFlag specified, use the member name.
         if (cf == null)
         {
             cf = mi.Name;
         }
         // make sure required parameters are initialized to null.
         if (cla.Required && (GetValue(mi) != null))
         {
             throw new ArgumentException("Must provide null initial value for required parameters: ", mi.Name);
         }
         m_flags[cf] = mi;
     }
 }