title: Design pattern for dynamic C# object
body: <p>I have a queue that processes objects in a while loop. They are added asynchronously somewhere.. like this:</p>
  
  <pre><code>myqueue.pushback(String value);
  </code></pre>
  
  <p>And they are processed like this:   </p>
  
  <pre><code>while(true)
  {
      String path =  queue.pop();
      if(process(path))
      {
          Console.WriteLine("Good!");
      }
      else
      {
          queue.pushback(path);
      }
  }
  </code></pre>
  
  <p>Now, the thing is that I'd like to modify this to support a TTL-like (time to live) flag, so the file path would be added o more than n times.</p>
  
  <p><strong>How could I do this, while keeping the <code>bool process(String path)</code> function signature?</strong> I don't want to modify that. </p>
  
  <p>I thought about holding a map, or a list that counts how many times the process function returned false for a path and drop the path from the list at the n-th return of false. I wonder how can this be done more dynamically, and preferably I'd like the TTL to automatically decrement itself at each new addition to the process. I hope I am not talking trash. 
  Maybe using something like this</p>
  
  <pre><code>class JobData
  {
     public string path;
     public short ttl;
  
     public  static implicit operator String(JobData jobData) {jobData.ttl--; return jobData.path;}
  }
  </code></pre>