26.04.2015 Views

Team Development with Visual Studio Team Foundation Server

Team Development with Visual Studio Team Foundation Server

Team Development with Visual Studio Team Foundation Server

SHOW MORE
SHOW LESS

Create successful ePaper yourself

Turn your PDF publications into a flip-book with our unique Google optimized e-Paper software.

This string identifies the type of policy. It is displayed in the<br />

// policy list when you add a new policy to a <strong>Team</strong> Project.<br />

public override string Type<br />

{<br />

get { return "Check for Comments Policy"; }<br />

}<br />

// This string is a description of the type of policy. It is displayed<br />

// when you select the policy in the Add Check-in Policy dialog box.<br />

public override string TypeDescription<br />

{<br />

get { return "This policy will prompt the user to decide whether or not they should be allowed to check in."; }<br />

}<br />

// This method is called by the policy framework when you create<br />

// a new check-in policy or edit an existing check-in policy.<br />

// You can use this to display a UI specific to this policy type<br />

// allowing the user to change the parameters of the policy.<br />

public override bool Edit(IPolicyEditArgs args)<br />

{<br />

// Do not need any custom configuration<br />

return true;<br />

}<br />

// This method performs the actual policy evaluation.<br />

// It is called by the policy framework at various points in time<br />

// when policy should be evaluated. In this example, the method<br />

// is invoked when various asyc events occur that may have<br />

// invalidated the current list of failures.<br />

public override PolicyFailure[] Evaluate()<br />

{<br />

string proposedComment = PendingCheckin.PendingChanges.Comment;<br />

if (String.IsNullOrEmpty(proposedComment))<br />

{<br />

return new PolicyFailure[] {<br />

new PolicyFailure("Please provide some comments about your check-in", this) };<br />

}<br />

else<br />

{<br />

return new PolicyFailure[0];<br />

}<br />

}<br />

// This method is called if the user double-clicks on<br />

// a policy failure in the UI. In this case a message telling the user<br />

// to supply some comments is displayed.<br />

public override void Activate(PolicyFailure failure)<br />

{<br />

MessageBox.Show("Please provide comments for your check-in.", "How to fix your policy failure");<br />

}<br />

// This method is called if the user presses F1 when a policy failure<br />

// is active in the UI. In this example, a message box is displayed.<br />

public override void DisplayHelp(PolicyFailure failure)<br />

{<br />

MessageBox.Show("This policy helps you to remember to add comments to your check-ins.", "Prompt Policy<br />

Help");<br />

}<br />

}

Hooray! Your file is uploaded and ready to be published.

Saved successfully!

Ooh no, something went wrong!