title: Preventing an object from being altered after it enters a certain state? (C#)
body: <p>I have a use case that I've never really dealt with before. I have an object that after the user clicks "Save" should not be changed. Initially I created two objects, <code>DraftObject</code> and <code>SavedObject</code>. For the latter I created a constructor that only accepted the DraftObject and set each property as protected set.</p>
  
  <p>This works but does not seem ideal. It seems like I should be able to set a property on my object that controls whether the other fields are editable. What's the best way to do this? Forgive my pseudo-code, but this is what I was toying with:</p>
  
  <pre><code>public class MySpecialObject {
          public virtual string MyProperty { get { return MyProperty; } 
              set {
                  if (State == "Locked")
                  {
                      return;
                  } else
                  {
                      MyProperty = MyProperty;
                  }
              }
           public virtual string State { get { return State; }
              set {
                   if (State == "Locked")
                   {
                       return;
                   } else
                   { 
                     State = State;
                   }
              }
  </code></pre>
  
  <p>This seems ugly, especially if I have to do this to every single property in my class. There's got to be a better way to do this, any ideas?</p>