public StreetName Clone() { // Create New Object StreetName newStreetName = (StreetName)this.MemberwiseClone(); // Return Cloned Object return(newStreetName); }
/// <summary> /// event is fired when the 'ImportStreetNamesButton' is clicked. /// </summary> private void ImportStreetNamesButton_Click(object sender, EventArgs e) { // locals bool saved = false; string fileName = ""; string temp = ""; try { // get the text of the StreetNames.txt file string streetNamesTextFile = StreetNamesControl.Text; // attempt to read all the text string textFileContents = File.ReadAllText(streetNamesTextFile); // If the textFileContents string exists if (TextHelper.Exists(textFileContents)) { // create the fileInfo FileInfo fileInfo = new FileInfo(streetNamesTextFile); // set the name of the file fileName = fileInfo.Name; // get the text lines (this file is one entry per row) List <TextLine> lines = WordParser.GetTextLines(textFileContents); // If the lines collection exists and has one or more items if (ListHelper.HasOneOrMoreItems(lines)) { // Setup Graph3 Graph3.Visible = true; Graph3.Maximum = lines.Count; Graph3.Value = 0; // refresh everything Refresh(); // Create a new instance of a 'Gateway' object. Gateway gateway = new Gateway(); // Iterate the collection of TextLine objects foreach (TextLine line in lines) { // get the current line temp = line.Text.Trim(); // Create a StreetName instance dataObjects.StreetName streetName = new dataObjects.StreetName(); // set the LastName streetName.Name = line.Text.Trim(); // save this LastName saved = gateway.SaveStreetName(ref streetName); // if the value for saved is true if (saved) { // increment the value for Graph3 Graph3.Value++; } } // Show finished MessageBoxHelper.ShowMessage("The file '" + fileName + "' has been imported.", "Import Complete"); } } else { // Show an error MessageBoxHelper.ShowMessage("The selected import file could not be read.", "Import File Error"); } } catch (Exception error) { // for debugging only DebugHelper.WriteDebugError("ImportStreetnamesButton_Click", this.Name, error); } }