/// <summary> /// This constructor is typically used to load or create a new /// profile file separate from the default profile file for the /// application (using the default profile file format). /// </summary> /// <param name="asPathFile"> /// This is the location of the profile file to be loaded. /// </param> /// <param name="aeFileCreateAction"> /// This enum indicates how to handle the automatic creation of /// the profile file to be loaded, if it doesn't already exist. /// </param> public tvProfile( String asPathFile , tvProfileFileCreateActions aeFileCreateAction ) : this(asPathFile , aeFileCreateAction , false) { }
/// <summary> /// This is the minimal profile constructor. /// /// This constructor is typically used to create an empty profile /// object to be populated manually (ie. with <see cref="Add(String, Object)"/> calls). /// /// It is also used in lieu of the main constructor when command /// line overrides are not permitted. /// /// The default constructor is a shortcut to this one using the arguments /// "NoDefaultFile" and "NoFileCreate". /// </summary> /// <param name="aeDefaultFileAction"> /// This enum indicates how to handle automatic loading and saving /// of the default profile file. /// </param> /// <param name="aeFileCreateAction"> /// This enum indicates how to handle the automatic creation of /// the default profile file, if it doesn't already exist. /// </param> public tvProfile( tvProfileDefaultFileActions aeDefaultFileAction , tvProfileFileCreateActions aeFileCreateAction ) { this.eDefaultFileAction = aeDefaultFileAction; this.eFileCreateAction = aeFileCreateAction; if ( tvProfileDefaultFileActions.AutoLoadSaveDefaultFile == aeDefaultFileAction ) { this.Load(this.sDefaultPathFile, tvProfileLoadActions.Overwrite); } else { this.bAddStandardDefaults = false; } }
/// <summary> /// This constructor is typically used to load or create a new /// profile file separate from the default profile file for the /// application. /// </summary> /// <param name="asPathFile"> /// This is the location of the profile file to be loaded. /// </param> /// <param name="aeFileCreateAction"> /// This enum indicates how to handle the automatic creation of /// the profile file to be loaded, if it doesn't already exist. /// </param> /// <param name="abUseXmlFiles"> /// If true, XML file format will be used. If false, line delimited /// "command line" format will be used (the default format). /// </param> public tvProfile( String asPathFile , tvProfileFileCreateActions aeFileCreateAction , bool abUseXmlFiles ) : this() { this.eFileCreateAction = aeFileCreateAction; this.bUseXmlFiles = abUseXmlFiles; this.Load(asPathFile, tvProfileLoadActions.Overwrite); }
/// <summary> /// This constructor is the shortcut to the main constructor /// using the default profile file format. /// </summary> /// <param name="asCommandLineArray"> /// This string array is typically passed from the environment to the /// running application (eg. from Environment.GetCommandLineArgs() ). /// It is merged with the default profile file or any other profile /// found within the list of command line arguments. /// </param> /// <param name="aeDefaultFileAction"> /// This enum indicates how to handle automatic loading and saving /// of the default profile file. /// </param> /// <param name="aeFileCreateAction"> /// This enum indicates how to handle the automatic creation of /// the default profile file, if it doesn't already exist. /// </param> public tvProfile( String[] asCommandLineArray , tvProfileDefaultFileActions aeDefaultFileAction , tvProfileFileCreateActions aeFileCreateAction ) : this(asCommandLineArray , aeDefaultFileAction , aeFileCreateAction , false) { }
/// <summary> /// This is the main constructor used with abitrary XML documents. /// /// This constructor (or one of its shortcuts) is typically used at /// the top of an application during initialization. /// /// The profile is first initialized using the aeDefaultFileAction /// enum. Then any command line arguments (typically passed from /// the environment) are merged into the profile. This way command /// line arguments override properties in the profile file. /// /// Initialization of the profile is done by first loading /// properties from an existing default profile file. /// /// The aeFileCreateAction enum enables a new profile file to be /// created (with or without prompting), if it doesn't already exist /// and then filled with default settings. /// </summary> /// <param name="asCommandLineArray"> /// This string array is typically passed from the environment to the /// running application (eg. from Environment.GetCommandLineArgs() ). /// It is merged with the default profile file or any other profile /// found within the list of command line arguments. /// </param> /// <param name="aeDefaultFileAction"> /// This enum indicates how to handle automatic loading and saving /// of the default profile file. /// </param> /// <param name="aeFileCreateAction"> /// This enum indicates how to handle the automatic creation of /// the default profile file, if it doesn't already exist. /// </param> /// <param name="asXmlFile"> /// This is the path/file that contains the XML to load. /// </param> /// <param name="asXmlXpath"> /// This is the Xpath into asXmlFile that contains the profile. /// </param> /// <param name="asXmlKeyKey"> /// This is the "Key" key used to find name attributes in asXmlXpath. /// </param> /// <param name="asXmlValueKey"> /// This is the "Value" key used to find value attributes in asXmlXpath. /// </param> public tvProfile( String[] asCommandLineArray , tvProfileDefaultFileActions aeDefaultFileAction , tvProfileFileCreateActions aeFileCreateAction , String asXmlFile , String asXmlXpath , String asXmlKeyKey , String asXmlValueKey ) { this.sInputCommandLineArray = asCommandLineArray; this.eDefaultFileAction = aeDefaultFileAction; this.eFileCreateAction = aeFileCreateAction; this.sXmlXpath = asXmlXpath; this.sXmlKeyKey = asXmlKeyKey; this.sXmlValueKey = asXmlValueKey; this.bUseXmlFiles = true; this.ReplaceDefaultProfileFromCommandLine(asCommandLineArray); if ( this.bExit ) { return; } // "bDefaultFileReplaced = True" means that a replacement profile file has been passed on // the command line. Consequently, no attempt to load the default profile file should be made. if ( !this.bDefaultFileReplaced && tvProfileDefaultFileActions.NoDefaultFile != aeDefaultFileAction ) { this.Load(asXmlFile, tvProfileLoadActions.Overwrite); if ( this.bExit ) { return; } this.LoadFromCommandLineArray(asCommandLineArray, tvProfileLoadActions.Merge); } bool lbShowProfile = false; if ( mbAddStandardDefaults || this.ContainsKey("-ShowProfile") ) { lbShowProfile = this.bValue("-ShowProfile", false); } if ( lbShowProfile ) { if ( DialogResult.Cancel == MessageBox.Show(this.sCommandLine(), this.sLoadedPathFile, MessageBoxButtons.OKCancel) ) { this.bExit = true; } } }