/// <summary> /// Iterates over all non-nullable class properties and adds them to the <see cref="MethodParamsGroup"/> collection. /// </summary> /// <returns>A <see cref="MethodParamsGroup"/> instance containing all the non-nullable properties of the current class.</returns> public MethodParams GetParams() { var mp = new MethodParams(); #if WINDOWS_UWP81 || PORTABLE_LIB var properties = GetType().GetTypeInfo().DeclaredProperties.Where(propInfo => propInfo.CanRead); #else var properties = GetType().GetProperties(BindingFlags.Public).Where(prop => prop.CanRead); #endif foreach (var prop in properties) { var mpa = prop.GetCustomAttribute<MethodParamAttribute>(true); mp.Add(mpa.Name, prop.GetValue(this), mpa.IsRequired, mpa.Extra); } return mp; }
public static void Main() { string myChoice; MethodParams mp = new MethodParams(); do { // show menu and get input from user myChoice = mp.getChoice(); // Make a decision based on the user's choice mp.makeDecision(myChoice); // Pause to allow the user to see the results Console.Write("Press Enter key to continue..."); Console.ReadLine(); Console.WriteLine(); } while (myChoice != "Q" && myChoice != "q"); // Keep going until the user wants to quit }