public static VoterIdType getVoterType(string val) { VoterIdType voterIdType = new VoterIdType(); if (val == "driverslicense") { voterIdType = VoterIdType.driverslicense; } else if (val == "localvoterregistrationid") { voterIdType = VoterIdType.localvoterregistrationid; } else if (val == "ssn") { voterIdType = VoterIdType.ssn; } else if (val == "ssn4") { voterIdType = VoterIdType.ssn4; } else if (val == "other") { voterIdType = VoterIdType.other; } else { voterIdType = VoterIdType.unknown; } return(voterIdType); }
public static void getXML() { XmlSerializer xmlSerializer = new XmlSerializer(typeof(VoterRecordsRequest)); VoterRecordsRequest recordsRequest = new VoterRecordsRequest(); Voter voter = new Voter(); Name name = new Name() { FirstName = "John", LastName = "Smith", FullName = "John S. Smith" }; name.MiddleName = new string[1]; name.MiddleName[0] = "S"; voter.Name = name; voter.DateOfBirthSpecified = true; voter.DateOfBirth = Convert.ToDateTime("01/01/1999"); VoterId voterId = new VoterId(); voterId.DateOfIssuanceSpecified = true; voterId.DateOfIssuance = Convert.ToDateTime("01/01/2015"); voterId.StringValue = "Z666776677"; VoterIdType type = VoterIdType.driverslicense; voterId.Type = type; VoterId voterid2 = new VoterId(); voterid2.StringValue = "1234"; VoterIdType type2 = VoterIdType.ssn4; voterid2.Type = type2; voter.VoterId = new VoterId[2]; voter.VoterId[0] = voterId; voter.VoterId[1] = voterid2; //voter.ResidenceAddress.NumberedThoroughfareAddress_type.CompleteAddressNumber = "4868"; //voter.ResidenceAddress.NumberedThoroughfareAddress_type.CompleteStreetName = "Bonnie Brae Rd"; //voter.ResidenceAddress.NumberedThoroughfareAddress_type.CompleteSubaddress = "Richmond, VA 23234"; recordsRequest.Type = new VoterRequestType[1]; recordsRequest.Type[0] = VoterRequestType.lookup; recordsRequest.Issuer = "Third-Party Issuer"; recordsRequest.RequestMethod = RequestMethod.other; recordsRequest.Subject = voter; recordsRequest.GeneratedDate = DateTime.Now; TextWriter write = new StreamWriter("C:\\dev\\vriout.xml"); xmlSerializer.Serialize(write, recordsRequest); }