title: Getter and Setter in generic interface - is this possible?
body: <p>Still learning my ways around C# generics... is it possible to achieve this functionality?</p>
  
  <pre><code>public interface ISetting&lt;T&gt;
  {
      void SetSettings(T obj);
      // myTypeHere GetSettings(T obj);
  }
  
  public class RadDockSetting : ISetting&lt;CormantRadDock&gt;
  {
      public RadDockSetting()
      {
      }
  
      public RadDockSetting GetSettings(CormantRadDock dock)
      {
      }
  
      public void SetSettings(CormantRadDock dock)
      {
      }
   }
  </code></pre>
  
  <p>I realize this is a counter-intuitive way to be using a Getter -- shouldn't have to pass anything to it. What I'm doing is creating an object, RadDockSetting, that stores the relevant properties of the CormantRadDock -- and then returns the 'got' settings.</p>
  
  <p>GetSettings is <em>currently</em> a static method, but I realize this will need to be refactored in order to allow implementing a getter from the interface. Maybe once this occurs the 'weirdness' of the getter will fall away?</p>
  
  <p>So, a little background on all of this:</p>
  
  <p>I started with a class that had a lot of 'copy/pasted' functions. These functions were in charge of saving and removing controls from a manager. When I realized this I set out trying to make these functions more generic. I succeeded, with SO's help, in making remove generic.</p>
  
  <p>For reference, here is remove:</p>
  
  <pre><code>public static void Remove&lt;T&gt;(string controlID) where T: new()
  {
      Logger.InfoFormat("Removing control {0}", controlID);
      T states = RadControlStates.GetStates&lt;T&gt;();
      (states as IDictionary).Remove(controlID);
      RadControlStates.SetStates&lt;T&gt;(states);
  }
  </code></pre>
  
  <p>and it is called like so: <code>RadControlSave.Remove&lt;SerializableDictionary&lt;string, RadPaneSetting&gt;&gt;(ID);</code></p>
  
  <p>Now, I am trying to extend this genericness to the rest of the methods -- the savers. Here's how one of these methods looks currently:</p>
  
  <pre><code>public static void SavePane(CormantRadPane pane)
  {
      Logger.InfoFormat("Saving pane {0}", pane.ID);
      RadPaneSetting paneSettings = RadPaneSetting.GetSettings(pane);
      SerializableDictionary&lt;string, RadPaneSetting&gt; paneStates = RadControlStates.GetStates&lt;SerializableDictionary&lt;string, RadPaneSetting&gt;&gt;();
  
      bool paneIsKnown = paneStates.ContainsKey(paneSettings.ID);
  
      if (paneIsKnown)
      {
          Logger.Debug("Pane is known. Overwriting data.");
          paneStates[paneSettings.ID] = paneSettings;
      }
      else
      {
          Logger.Debug("Pane is unknown. Saving data.");
          paneStates.Add(paneSettings.ID, paneSettings);
      }
  
      RadControlStates.SetStates&lt;SerializableDictionary&lt;string, RadPaneSetting&gt;&gt;(paneStates);
  }
  </code></pre>
  
  <p>At the start of this code block there is a call to "RadPaneSetting.GetSettings(pane)".</p>
  
  <p>RadPaneSettings implements the ISettings interface. Here is ISetting's setter being used.</p>
  
  <pre><code>/// &lt;summary&gt;
  /// Recreates a dashboard control based off of its settings.
  /// &lt;/summary&gt;
  /// &lt;typeparam name="T"&gt; The type of control to be recreated. &lt;/typeparam&gt;
  /// &lt;param name="settings"&gt; The known settings needed to recreate the control.&lt;/param&gt;
  /// &lt;returns&gt; The recreated control. &lt;/returns&gt;
  public static T Recreate&lt;T&gt;(ISetting&lt;T&gt; settings) where T : new()
  {
      T _control = new T();
      settings.SetSettings(_control);
      Logger.DebugFormat("Recreated control {0}", (_control as Control).ID);
      return _control;
  }
  </code></pre>