Archive for the 'development' Category
TS - HowTo - Add TS build number to your assembly
Vertigo Software has a really good post on how to do this - Adding the Build Number to your Team Build binaries.
No commentsCode Monkey Like Fritos
Yay, Jonathan Coulton’s “Code Monkey Like Fritos” with interpretive dance. Also “Naruto Code Monkey” and “Code Monkey Unplugged“.
Oh yeah, don’t forget “Speed Code Monkey“.
PS. It seems like I am the last one to the “Code Monkey” bandwagon, but it is still awesome. I’d better go get some fritos right now.
No commentsAnother great Team System Blog
Hey everybody, here is another great Team System Blog from Vertigo Software - Visual Studio Team System: tips, tricks and techniques.
No commentsTFS - HowTo - Get a list of users and pending changes
using System; using System.Collections.Generic; using Microsoft.TeamFoundation.Client; using Microsoft.TeamFoundation.VersionControl.Client; namespace SashaSydoruk { internal class Example { private static Dictionary<string, List<string>> pendingChanges = new Dictionary<string, List<string>>(); public static void Main() { TeamFoundationServer tfs = TeamFoundationServerFactory.GetServer(“tfsserver”); VersionControlServer vcs = (VersionControlServer) tfs.GetService(typeof(VersionControlServer)); PendingSet[] sets = vcs.GetPendingSets(new String[] {“$/”}, RecursionType.Full); foreach(PendingSet set in sets) { foreach(PendingChange pc in set.PendingChanges) { AddPendingChange(set.OwnerName, pc.LocalItem); } } List<string> userNames = new List<string>(pendingChanges.Keys); userNames.Sort(); foreach(string userName in userNames) { pendingChanges[userName].Sort(); Console.ForegroundColor = ConsoleColor.Green; Console.WriteLine(userName); Console.ResetColor(); foreach(string fileName in pendingChanges[userName]) { Console.WriteLine(fileName); } Console.WriteLine(); Console.WriteLine(); } Console.ReadKey(); } private static void AddPendingChange(string username, string filename) { if(!pendingChanges.ContainsKey(username)) { pendingChanges[username] = new List<string>(); } pendingChanges[username].Add(filename); } } }No comments
TFS - HowTo - Get A List Of Projects in TFS
using System; using System.Collections.Generic; using Microsoft.TeamFoundation.Client; using Microsoft.TeamFoundation.Server; namespace SashaSydoruk { internal class Example { public static void Main() { TeamFoundationServer tfs = TeamFoundationServerFactory.GetServer(“tfsserver”); ICommonStructureService css = (ICommonStructureService) tfs.GetService(typeof(ICommonStructureService)); List<string> projects = new List<string>(); foreach(ProjectInfo projectInfo in css.ListAllProjects()) { projects.Add(projectInfo.Name); } projects.Sort(); foreach(string projectName in projects) { Console.WriteLine(projectName); } Console.ReadKey(); } } }No comments
scRUBYt - this looks really amazing…
scRUBYt! is a simple to learn and use, yet powerful web scraping toolkit written in Ruby.
No comments70-510: TS: Visual Studio 2005 Team Foundation Server - Here I come
While I was getting ready to take my 70-528, I received an interesting email from Microsoft. Apparently the beta exam of 70-510: TS: Visual Studio 2005 Team Foundation Server is out and I am invited to take it for free. How awesome is that?
More information about 70-510 can be found here - Preparation Guide for Exam 70-510
There are a couple of issues that concern me:
- Lack of study materials. There is no official study guide published yet.
- Lack of time to get ready for the exam. I need to take the exam within a month or so which is usually enough time, but with 2 kids it is kind of tough…
Anyway, I have already investigated some books that will server as study guides. I will keep posting about my experience preparing for the exam.
I am really sorry 70-528, but you will have to wait.
No comments“Ambiguous match found” in a Web Control - a Possible Bug
If you use ASP.NET AJAX you might come up with this error popup - “Ambiguous match found”.
The issue here is that you have 2 variables that are named the same but have different casing. You have to rename the variables to have different names. Changing from protected to private will not help.
More info can be found at Eran Sandler’s blog - “Ambiguous match found” in a Web Control - a Possible Bug.
Eran Sandler’s blog - Subscribed!
1 commentHow to instantiate templates (properly)
Something for myself to bookmark. Here is a really good article describing the right way to instantiate templates in asp.net controls.
Every time a control is added to a parent control the child control will immediately “catch up” to the lifecycle point of the parent control. The control lifecycle includes the familiar Init, Load, PreRender, and a number of other lifecycle stages related to state management. When a template is instantiated through a call to InstantiateIn, all that happens (typically) is that the controls in the template are instantiated one by one, and added to the container that you passed in to InstantiateIn, again one by one.
How to instantiate templates (properly)
I also subscribed to the blog and waiting for more good articles.
No commentsHowTo - CompositeControl with a TextBox and a bunch of Validators
Here is an example of how I create composite controls in small server control library. It is pretty handy. With controls like this you can say something like this:
<csc:textbox id=”customServerControl1″ minlength=”4″ maxlength=”10″ required=”true” runat=”server” />
And that’s it! The composite control will automatically add the required validators and will create appropriate error messages!
Here is the source code:
using System; using System.Security.Permissions; using System.Web; using System.Web.UI; using System.Web.UI.WebControls; namespace SashaSydoruk.Web.UI.WebControls { [AspNetHostingPermission(SecurityAction.Demand, Level = AspNetHostingPermissionLevel.Minimal)] [AspNetHostingPermission(SecurityAction.InheritanceDemand, Level = AspNetHostingPermissionLevel.Minimal)] [ToolboxData("< {0}:textbox required=\"false\" runat=\"server\" />")] [ValidationProperty("Text")] public class TextBox : CompositeControl { protected System.Web.UI.WebControls.TextBox _textBox = null; protected RequiredFieldValidator _reqValidator = null; protected RegularExpressionValidator _regExValidator = null; protected TextBoxLengthValidator _lengthValidator = null; protected string _regExValidatorErrorMessage = string.Empty; #region Constructors public TextBox() { EnsureChildControls(); } #endregion #region Error Messages public const string REQUIRED = “is a required field.”; public const string REGEX = “is invalid.”; public const string LENGTH = “length has to be {0} to {1} characters long”; #endregion #region Public Properties public System.Web.UI.WebControls.TextBox InnerTextBox { get { return _textBox; } } public RequiredFieldValidator InnerRequiredFieldValidator { get { return _reqValidator; } } public RegularExpressionValidator InnerRegularExpressionValidator { get { return _regExValidator; } } public TextBoxLengthValidator InnerTextBoxLengthValidator { get { return _lengthValidator; } } public TextBoxMode TextMode { get { return _textBox.TextMode; } set { _textBox.TextMode = value; } } public bool ReadOnly { get { object o = ViewState["ReadOnly"]; if(o == null) { return false; } else { return bool.Parse(o.ToString()); } } set { ViewState["ReadOnly"] = value; } } public int MaxLength { get { return _lengthValidator.MaximumLength; } set { _lengthValidator.MaximumLength = value; SetupValidators(); } } public int MinLength { get { return _lengthValidator.MinimumLength; } set { _lengthValidator.MinimumLength = value; SetupValidators(); } } public string RegularExpression { get { return _regExValidator.ValidationExpression; } set { _regExValidator.ValidationExpression = value; SetupValidators(); } } public string DisplayName { get { object o = ViewState["DisplayName"]; if(o == null) { return string.Empty; } else { return o.ToString(); } } set { ViewState["DisplayName"] = value; SetupValidators(); } } public bool Required { get { return _reqValidator.Visible; } set { _reqValidator.Visible = value; SetupValidators(); } } public virtual string Text { get { return _textBox.Text; } set { _textBox.Text = value; } } #endregion protected override void OnInit(EventArgs e) { EnsureChildControls(); base.OnInit(e); } protected override void Render(HtmlTextWriter writer) { _textBox.Width = Width; _textBox.Height = Height; _textBox.RenderControl(writer); _reqValidator.RenderControl(writer); _lengthValidator.RenderControl(writer); _regExValidator.RenderControl(writer); } protected override void CreateChildControls() { Controls.Clear(); _textBox = new System.Web.UI.WebControls.TextBox(); _textBox.ID = “textBox”; Controls.Add(_textBox); //Add required validator _reqValidator = new RequiredFieldValidator(); Controls.Add(_reqValidator); //Add length validator _lengthValidator = new TextBoxLengthValidator(); Controls.Add(_lengthValidator); //Add RegularExpression validator _regExValidator = new RegularExpressionValidator(); Controls.Add(_regExValidator); if(Width.Value == 0) { _textBox.Width = Unit.Pixel(170); } Required = false; SetupValidators(); } private void SetupValidators() { _reqValidator.Display = ValidatorDisplay.None; _reqValidator.ControlToValidate = _textBox.ID; _lengthValidator.Display = ValidatorDisplay.None; _lengthValidator.ControlToValidate = _textBox.ID; _regExValidator.Display = ValidatorDisplay.None; _regExValidator.ControlToValidate = _textBox.ID; if(MaxLength > 0) { _textBox.MaxLength = MaxLength; } _lengthValidator.Visible = (MaxLength > 0 || MinLength > 0); _regExValidator.Visible = RegularExpression.Length > 0; _reqValidator.ErrorMessage = DisplayName + ” “ + REQUIRED; if(MinLength == 0 && MaxLength > 0) { _lengthValidator.ErrorMessage = DisplayName + ” “ + string.Format(“is too long. {0} characters max.”, MaxLength); } else if(MinLength > 0 && MaxLength == 0) { _lengthValidator.ErrorMessage = DisplayName + ” “ + string.Format(“is too short. {0} characters min.”, MinLength); } else if(MinLength > 0 && MaxLength > 0) { _lengthValidator.ErrorMessage = DisplayName + ” “ + string.Format(“has to be {0} to {1} characters long.”, MinLength, MaxLength); } else if(MinLength > 0 && MaxLength > 0 && MinLength == MaxLength) { _lengthValidator.ErrorMessage = DisplayName + ” “ + string.Format(“has to be {0} characters long.”, MinLength); } _regExValidator.ErrorMessage = DisplayName + ” “ + REGEX; } } }