private void Reset() { caption = string.Empty; text = string.Empty; outputFilePath = string.Empty; buttons = 0; boxIcon = 0; defaultButton = 0; expectingCaption = false; expectingText = false; expectingOutputFilePath = false; expectingBoxIcon = false; expectingButtons = false; expectingDefaultButton = false; expectingMaximumWidth = false; captionSet = false; textSet = false; outputFilePathSet = false; boxIconSet = false; buttonsSet = false; defaultButtonSet = false; maximumWidthSet = false; basicThemeSet = false; helpSet = false; helpButtonSet = false; noWrapSet = false; hasArguments = false; thisTestSet = false; }
private void Evaluate() { foreach (string arg in arguments) { string argument = arg; hasArguments = true; if (argument == "-c" || argument == "/c") { if (captionSet || expectingCaption) { throw new ApplicationException(Properties.Resources.ExceptionMessageC); } if (expectingText || expectingOutputFilePath || expectingBoxIcon || expectingButtons || expectingDefaultButton || expectingMaximumWidth || helpSet || thisTestSet) { throw new ApplicationException(Properties.Resources.ExceptionMessageM); } expectingCaption = true; } else if (argument == "-t" || argument == "/t") { if (textSet || expectingText) { throw new ApplicationException(Properties.Resources.ExceptionMessageT); } if (expectingCaption || expectingOutputFilePath || expectingBoxIcon || expectingButtons || expectingDefaultButton || expectingMaximumWidth || helpSet || thisTestSet) { throw new ApplicationException(Properties.Resources.ExceptionMessageM); } expectingText = true; } else if (argument == "-o" || argument == "/o") { if (outputFilePathSet || expectingOutputFilePath) { throw new ApplicationException(Properties.Resources.ExceptionMessageO); } if (expectingCaption || expectingText || expectingBoxIcon || expectingButtons || expectingDefaultButton || expectingMaximumWidth || helpSet || thisTestSet) { throw new ApplicationException(Properties.Resources.ExceptionMessageM); } expectingOutputFilePath = true; } else if (argument == "-b" || argument == "/b") { if (buttonsSet || expectingButtons) { throw new ApplicationException(Properties.Resources.ExceptionMessageB); } if (expectingCaption || expectingText || expectingOutputFilePath || expectingBoxIcon || expectingDefaultButton || expectingMaximumWidth || helpSet || thisTestSet) { throw new ApplicationException(Properties.Resources.ExceptionMessageM); } expectingButtons = true; } else if (argument == "-i" || argument == "/i") { if (boxIconSet || expectingBoxIcon) { throw new ApplicationException(Properties.Resources.ExceptionMessageI); } if (expectingCaption || expectingText || expectingOutputFilePath || expectingButtons || expectingDefaultButton || expectingMaximumWidth || helpSet || thisTestSet) { throw new ApplicationException(Properties.Resources.ExceptionMessageM); } expectingBoxIcon = true; } else if (argument == "-d" || argument == "/d") { if (defaultButtonSet || expectingDefaultButton) { throw new ApplicationException(Properties.Resources.ExceptionMessageD); } if (expectingCaption || expectingText || expectingOutputFilePath || expectingBoxIcon || expectingButtons || expectingMaximumWidth || helpSet || thisTestSet) { throw new ApplicationException(Properties.Resources.ExceptionMessageM); } expectingDefaultButton = true; } else if (argument == "-m" || argument == "/m") { if (maximumWidthSet || expectingMaximumWidth) { throw new ApplicationException(Properties.Resources.ExceptionMessageW); } if (expectingCaption || expectingText || expectingOutputFilePath || expectingBoxIcon || expectingButtons || expectingDefaultButton || helpSet || thisTestSet) { throw new ApplicationException(Properties.Resources.ExceptionMessageM); } expectingMaximumWidth = true; } else if (argument == "-e" || argument == "/e") { if (helpSet || thisTestSet || expectingCaption || expectingText || expectingOutputFilePath || expectingBoxIcon || expectingButtons || expectingDefaultButton || expectingMaximumWidth) { throw new ApplicationException(Properties.Resources.ExceptionMessageM); } helpButtonSet = true; } else if (argument == "-w" || argument == "/w") { if (helpSet || thisTestSet || expectingCaption || expectingText || expectingOutputFilePath || expectingBoxIcon || expectingButtons || expectingDefaultButton || expectingMaximumWidth) { throw new ApplicationException(Properties.Resources.ExceptionMessageM); } noWrapSet = true; } else if (argument == "-s" || argument == "/s") { if (helpSet || thisTestSet || expectingCaption || expectingText || expectingOutputFilePath || expectingBoxIcon || expectingButtons || expectingDefaultButton || expectingMaximumWidth) { throw new ApplicationException(Properties.Resources.ExceptionMessageM); } basicThemeSet = true; } else if (argument == "-h" || argument == "/h" || argument == "-?" || argument == "/?") { if (captionSet || textSet || outputFilePathSet || boxIconSet || buttonsSet || defaultButtonSet || maximumWidthSet || helpSet || thisTestSet || helpButtonSet || noWrapSet || expectingCaption || expectingText || expectingOutputFilePath || expectingBoxIcon || expectingButtons || expectingDefaultButton || expectingMaximumWidth || basicThemeSet) { throw new ApplicationException(Properties.Resources.ExceptionMessageM); } helpSet = true; } else if (argument == "-T" || argument == "/T") { if (captionSet || textSet || outputFilePathSet || boxIconSet || buttonsSet || defaultButtonSet || maximumWidthSet || helpSet || thisTestSet || helpButtonSet || noWrapSet || expectingCaption || expectingText || expectingOutputFilePath || expectingBoxIcon || expectingButtons || expectingDefaultButton || expectingMaximumWidth || basicThemeSet) { throw new ApplicationException(Properties.Resources.ExceptionMessageM); } thisTestSet = true; } else if (expectingCaption) { caption = argument; expectingCaption = false; captionSet = true; } else if (expectingText) { text = argument; expectingText = false; textSet = true; } else if (expectingOutputFilePath) { outputFilePath = argument; expectingOutputFilePath = false; outputFilePathSet = true; } else if (expectingButtons) { buttons = (MessageForm.Buttons) int.Parse(argument); expectingButtons = false; buttonsSet = true; } else if (expectingBoxIcon) { boxIcon = (MessageForm.BoxIcon) int.Parse(argument); expectingBoxIcon = false; boxIconSet = true; } else if (expectingDefaultButton) { defaultButton = (MessageForm.DefaultButton) int.Parse(argument); expectingDefaultButton = false; defaultButtonSet = true; } else if (expectingMaximumWidth) { maximumWidth = int.Parse(argument); expectingMaximumWidth = false; maximumWidthSet = true; } else if (argument.StartsWith("-") || argument.StartsWith("/")) { throw new ApplicationException(Properties.Resources.ExceptionMessageU); } else { throw new ApplicationException(Properties.Resources.ExceptionMessageM); } } if (expectingCaption || expectingText || expectingOutputFilePath || expectingBoxIcon || expectingButtons || expectingDefaultButton || expectingMaximumWidth) { throw new ApplicationException(Properties.Resources.ExceptionMessageM); } if (hasArguments && !textSet && !helpSet && !thisTestSet) { throw new ApplicationException(Properties.Resources.ExceptionMessageS); } }