Last active
April 28, 2017 21:01
-
-
Save Hallmanac/00946bfa7e028cee3a313f1c445ba216 to your computer and use it in GitHub Desktop.
A C# class holding constants of all US States surfaced as an object named UsState
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
using System.Collections.Generic; | |
using System.Linq; | |
namespace Hallmanac | |
{ | |
public class AllUsStates | |
{ | |
public static UsState Alabama { get; } = new UsState("a1103958-42c9-4fda-ab46-a04d41a4783b", 1, "Alabama", "AL"); | |
public static UsState Alaska { get; } = new UsState("afa95187-e5a6-44c6-baf2-0dbb3dcc93b1", 2, "Alaska", "AK"); | |
public static UsState Arizona { get; } = new UsState("c090438e-5f7f-427f-a191-d6ea1be8185b", 3, "Arizona", "AZ"); | |
public static UsState Arkansas { get; } = new UsState("cb4997a8-9aaf-401e-ad35-77677a62aae5", 4, "Arkansas", "AR"); | |
public static UsState California { get; } = new UsState("c1711df0-c7c8-4a86-ad7c-8b7b0e86c8b6", 5, "California", "CA"); | |
public static UsState Colorado { get; } = new UsState("139d236d-dcf1-49b1-8085-d1aba166c0c8", 6, "Colorado", "CO"); | |
public static UsState Connecticut { get; } = new UsState("9fea97d0-413d-411f-9707-5cbb9a3db3d4", 7, "Connecticut", "CO"); | |
public static UsState Delaware { get; } = new UsState("52153952-664f-479b-be79-e5360cbc87fb", 8, "Delaware", "DE"); | |
public static UsState Florida { get; } = new UsState("1d559909-6cf0-4a4d-848e-acfa82e492b5", 9, "Florida", "FL"); | |
public static UsState Georgia { get; } = new UsState("e14780e0-46a4-4648-90bd-b09cd9125bc9", 10, "Georgia", "GA"); | |
public static UsState Hawaii { get; } = new UsState("6a801594-412b-4e8e-bbbf-8ddef3b9d744", 11, "Hawaii", "HI"); | |
public static UsState Idaho { get; } = new UsState("7369028a-377a-4737-aed6-99fbba9a402f", 12, "Idaho", "ID"); | |
public static UsState Illinois { get; } = new UsState("78865093-d766-461c-8dec-4a6b3539055c", 13, "Illinois", "IL"); | |
public static UsState Indiana { get; } = new UsState("cfe7ff36-b920-45e6-98d1-47f58a3d7cc4", 14, "Indiana", "IN"); | |
public static UsState Iowa { get; } = new UsState("1d7f54ed-b8c5-4a76-a3e8-22b464196eb2", 15, "Iowa", "IA"); | |
public static UsState Kansas { get; } = new UsState("65ce4ce5-2a02-4f87-8f7a-632401eef50d", 16, "Kansas", "KS"); | |
public static UsState Kentucky { get; } = new UsState("6b4d3284-519b-4156-850c-fc2588a8124e", 17, "Kentucky", "KY"); | |
public static UsState Louisiana { get; } = new UsState("74bb8495-b1a3-461d-8540-dbc58693c21f", 18, "Louisiana", "LA"); | |
public static UsState Maine { get; } = new UsState("f9a8dbae-63c7-46a7-8d9f-bf59ea683230", 19, "Maine", "ME"); | |
public static UsState Maryland { get; } = new UsState("d69b7f7b-0930-4e3b-ac05-a29db4c5810b", 20, "Maryland", "MD"); | |
public static UsState Massachusetts { get; } = new UsState("14a555fd-e2c3-4e58-8add-47b95d1dcf07", 21, "Massachusetts", "MA"); | |
public static UsState Michigan { get; } = new UsState("098798f8-4b35-4556-9151-6d2ebda1acea", 22, "Michigan", "MI"); | |
public static UsState Minnesota { get; } = new UsState("1d2cd5fc-a6f4-4b84-a35c-5cf48e0be757", 23, "Minnesota", "MN"); | |
public static UsState Mississippi { get; } = new UsState("7b5deb60-c5da-4989-8d59-d66b781322e4", 24, "Mississippi", "MS"); | |
public static UsState Missouri { get; } = new UsState("56fd78ee-7e45-4aeb-b99f-af2a6a6f037c", 25, "Missouri", "MO"); | |
public static UsState Montana { get; } = new UsState("b2ccd658-8088-4b62-a02e-76dedc0b6ac7", 26, "Montana", "MT"); | |
public static UsState Nebraska { get; } = new UsState("0899173b-a10f-4318-895e-04c24e28d8b6", 27, "Nebraska", "NE"); | |
public static UsState Nevada { get; } = new UsState("de09f813-04fe-4135-bfbe-a7b26680f472", 28, "Nevada", "NV"); | |
public static UsState NewHampshire { get; } = new UsState("f1c20026-f7a0-453b-8706-01466114bd79", 29, "New Hampshire", "NH"); | |
public static UsState NewJersey { get; } = new UsState("dbd2959d-d554-4abe-b435-e91534997dc6", 30, "New Jersey", "NJ"); | |
public static UsState NewMexico { get; } = new UsState("71c99e22-773f-474f-9cb6-af42e5f344a1", 31, "New Mexico", "NM"); | |
public static UsState NewYork { get; } = new UsState("f2f943b7-1653-4e6c-8536-5b0933717384", 32, "New York", "NY"); | |
public static UsState NorthCarolina { get; } = new UsState("096830c5-a7f6-4440-b630-2a892ae5e177", 33, "North Carolina", "NC"); | |
public static UsState NorthDakota { get; } = new UsState("8ae5a0d3-a655-46dd-89a9-ed00f5e8233f", 34, "North Dakota", "ND"); | |
public static UsState Ohio { get; } = new UsState("2b83a12a-b420-4756-b39b-316b991b5f02", 35, "Ohio", "OH"); | |
public static UsState Oklahoma { get; } = new UsState("0838c76b-c31a-43fb-8049-74e62d642e60", 36, "Oklahoma", "OK"); | |
public static UsState Oregon { get; } = new UsState("16f8d090-09ed-457a-8f8d-3d0a509bc35f", 37, "Oregon", "OR"); | |
public static UsState Pennsylvania { get; } = new UsState("c930577b-dd97-4aa4-b79d-219b3fe83987", 38, "Pennsylvania", "PA"); | |
public static UsState RhodeIsland { get; } = new UsState("376297eb-cd0b-4fdf-8adb-00db8e4f7f80", 39, "Rhode Island", "RI"); | |
public static UsState SouthCarolina { get; } = new UsState("c9b5ac33-c7ab-47b3-a244-70bd37ffa74c", 40, "South Carolina", "SC"); | |
public static UsState SouthDakota { get; } = new UsState("5ff1d906-4d65-4ae6-81c3-26583146ad19", 41, "South Dakota", "SD"); | |
public static UsState Tennessee { get; } = new UsState("b93b2c4d-ff02-4090-8975-d52a4af24951", 42, "Tennessee", "TN"); | |
public static UsState Texas { get; } = new UsState("f0c79626-dadd-45aa-ac1f-607aa2e34cab", 43, "Texas", "TX"); | |
public static UsState Utah { get; } = new UsState("d4d2328a-a458-4087-aac4-3bc7416bf250", 44, "Utah", "UT"); | |
public static UsState Vermont { get; } = new UsState("2fdf9ed6-4493-4eab-8418-238f7ae69bc1", 45, "Vermont", "VT"); | |
public static UsState Virginia { get; } = new UsState("3d51e651-997a-48cf-a28a-d8224b479f1d", 46, "Virginia", "VA"); | |
public static UsState Washington { get; } = new UsState("12b84cad-fdba-4a9b-a2c1-cb6ca9e1dab7", 47, "Washington", "WA"); | |
public static UsState WestVirginia { get; } = new UsState("deca4ce7-f063-45bd-97b0-f5b5b9dfbc12", 48, "West Virginia", "WV"); | |
public static UsState Wisconsin { get; } = new UsState("956ed10b-52f8-4bfc-b3ff-502d2ac8b5a8", 49, "Wisconsin", "WI"); | |
public static UsState Wyoming { get; } = new UsState("d9a99f15-7d87-4b59-a262-523f47e8c1f1", 50, "Wyoming", "WY"); | |
public static List<UsState> GetAllStates() | |
{ | |
var allUsStates = new AllUsStates(); | |
var states = typeof(AllUsStates) | |
.GetProperties() | |
.Where(p => p.CanRead && p.GetGetMethod().IsPublic && (p.GetValue(allUsStates) as UsState) != null) | |
.Select(p => p.GetValue(allUsStates) as UsState) | |
.ToList(); | |
return states; | |
} | |
} | |
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
namespace Hallmanac | |
{ | |
public class UsState | |
{ | |
private DateTimeOffset _createdOn; | |
private DateTimeOffset _lastModifiedOn; | |
public UsState(){} | |
public UsState(string id, int indexId, string name, string abbreviation) | |
{ | |
Id = id; | |
IndexId = indexId; | |
FullName = name; | |
Abbreviation = abbreviation; | |
} | |
public UsState(UsState state) | |
{ | |
Id = state.Id; | |
IndexId = state.IndexId; | |
FullName = state.FullName; | |
Abbreviation = state.Abbreviation; | |
} | |
public string FullName { get; set; } | |
public string Abbreviation { get; set; } | |
public string Id { get; set; } = Guid.NewGuid().ToString().ToLower(); | |
public int IndexId { get; set; } | |
public DateTimeOffset CreatedOn { get => _createdOn == default(DateTimeOffset) ? DateTimeOffset.UtcNow : _createdOn; set => _createdOn = value; } | |
public string CreatedByUserId { get; set; } | |
public DateTimeOffset LastModifiedOn { get => _lastModifiedOn == default(DateTimeOffset) ? CreatedOn : _lastModifiedOn; set => _lastModifiedOn = value; } | |
public string ModifiedByUserId { get; set; } | |
public bool IsDeleted { get; set; } | |
public override string ToString() | |
{ | |
return $"{Abbreviation} - {FullName}"; | |
} | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment