Created
January 24, 2011 18:03
-
-
Save Vaccano/793623 to your computer and use it in GitHub Desktop.
TFSAccess.cs
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; | |
using Microsoft.TeamFoundation.Client; | |
using Microsoft.TeamFoundation.WorkItemTracking.Client; | |
namespace TFSEvents | |
{ | |
/// <summary> | |
/// Singleton Used to access TFS Data. This keeps us from connecting each and every time we get an update. | |
/// </summary> | |
public class Store | |
{ | |
private readonly string _tfsServerUrl; | |
public Store(string tfsServerUrl) | |
{ | |
_tfsServerUrl = tfsServerUrl; | |
} | |
private TFSAccess _access; | |
public TFSAccess Access | |
{ | |
get { return _access ?? (_access = new TFSAccess(_tfsServerUrl)); } | |
} | |
} | |
/// <summary> | |
/// Don't use this class directly. Use the StoreSingleton. | |
/// </summary> | |
public class TFSAccess | |
{ | |
private readonly WorkItemStore _store; | |
public TFSAccess(string tfsUri) | |
{ | |
TfsTeamProjectCollection tfs = new TfsTeamProjectCollection(new Uri(tfsUri)); | |
_store = (WorkItemStore)tfs.GetService(typeof(WorkItemStore)); | |
} | |
public WorkItem GetWorkItem(int workItemId) | |
{ | |
return _store.GetWorkItem(workItemId); | |
} | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment