.NET Evangelist - Abi Bellamkonda

Friday, July 22, 2005

Stranger's Email of Today

Arief ZJ wrote: Dear Mr. Abishek Bellamkonda, I read your blog saying that u got an offer from EDS for .NET related job long time ago. May I know how well software development in this company. Bcos normally, most big company that I knew just bought a ready-made software and just use it instead of developing new one. Reason why I'm asking this is bcos... I am a .NET developer as well and I'm thinking of applying a position in EDS in my country... but I'm worry if there's no development activities in the company. If there aren't, there will be no 'exercise' for my .NET development :( Looking forward for your reply. Thanx ajak937



Hi, EDS does development, i would say it is purely based on development. It is a consulting house, like IBM. In australia it is a competitor to IBM, fujitsu and so on. Yes they are BIG. They do purchase software, but they also develop for clients. EDS is american company. As all bigger companies will be both good and bad things about it. Just apply it mate, then think of joining or not when you finally get it. People are reading my Blog.

Thursday, July 07, 2005

Today's Mr. Stranger Email

I received an email straight into my yahoo email today. This happens once a forthnight. I usually answer people and forget about it, i think i will blog the emails, as it might help others. "i like dotnet technology very much" while studying .net i am very much intrested in evey dot net topic now after completing the course i forgot every thing now even i am unable to recollect all the info regarding the past topics now what i want to do to recollect all the lost info.or i want to study for one more time why this happen i dont know exactly . i am afraid to tell all this info to you! give ur sugg. how to learn .net to master in that what are the steps to become the master in .net This person is a newbie to .NET world and he has learn't it, but lost touch with it. I think development is like Mathematics, if you don't practice it regularly, you will loose it. How do you keep in touch with it? I once gave a suggestion regarding this on server side .net, click here to see it. I think there are few methods to learn technical stuff...

  1. Subscribe to news letters. For .NET the below are usually good...
  2. Reading questions and answers in Forums will help lot. Go to sites like http://www.asp.net, http://www.theserverside.net, http://www.dotnetjunkies.com and http://www.dotnetspider.com
  3. Blog It !If you learn anything new on a day just write it down in your blog (create a blog in sites like http://www.blogger.com). Read popular peoples blog. Once you get your blog, it is like a big repository of source code for you. Whenever you want a code, you will just go to your blog and retrieve it. Say for example I got to http://www.abibaby.blogspot.com to get the code I want as I created it before. If i encounter a weird problem with my team, i will write the solution in the blog. If someone has the same problem, i can just send him the link and ask him to use it as a fix.

Saturday, July 02, 2005

Visual Studio .NET "Code Complete" Macro FREE

Ok i think the version 1.0 of the Macro i was thinking my my mind is ready for using/modifcation/stealing/sharing now. What new features does it include? It will replace a shortcut(say 'fi') with code block (a for i loop). User can configure his own list of code blocks and shortcuts assigning them with file types. Code blocks may contain multiple variables with default values, in such cases a window will pop up asking the user for value to be replaced in case of variables. Macro will take that user entered value and replace variable with text in the code block. This will be written into the files. Copyright? Ok this is it, anyone can use, share, copy, modify, steal and whatever you call it ! Cost?? Ok give $100 to charity, if you can, otherwise give $0 for charity. Yes, its absolutely FREE for all. I am not responsible for any miss use or failures. The below is the code...

CodeCompletion.vb
Imports EnvDTE Imports System.Diagnostics Imports System.Xml 'Imports System.Drawing 'Imports System.Drawing.Design Imports System.Data Imports Microsoft.Win32 'Used to read registry Imports System.Windows.Forms Imports System.Collections Imports System.ComponentModel Public Module CodeCompletion #Region "Config Settings" 'If you don't want caching, set it to false Private Const CacheXmlInMemory As Boolean = False Private Const CursorText As String = "~~" #End Region '''Completes the code by replacing your shortcut with the code block available in your configuration Public Sub Complete() 'DTE.Events.MiscFilesEvents() Dim selection As TextSelection = DTE.ActiveDocument.Selection Dim startPt As EditPoint = selection.TopPoint.CreateEditPoint() Dim endPt As TextPoint = selection.BottomPoint 'selection.MoveToDisplayColumn(endPt.Line, endPt.DisplayColumn - 2) Dim endCol As Integer = endPt.DisplayColumn 'MessageBox.Show(selection.Text.Length) If selection.Text.Length = 0 Then selection.WordLeft(True, 1) 'Replacement will occur here ApplyTemplate(selection) 'startPt.MoveToAbsoluteOffset(-1) 'selection.Text.IndexOf("~~")) End Sub Private configForm As CodeCompletionConfig '''Confiures your Code snippets Public Sub Configure() If Not configForm Is Nothing Then Exit Sub configForm = New CodeCompletionConfig configForm.CodeTemplateFileName = CodeTemplateFileName configForm.LoadDataSet() Application.Run(configForm) configForm = Nothing End Sub #Region "Helper functions" 'Get Xml document from Cache Private CodeTemplateXmlDocument As XmlDocument = Nothing #Region "Get Code Template Xml Document" #Region "Template File Name" Private _codeTemplateFileName As String = "" Private ReadOnly Property CodeTemplateFileName() As String Get If _codeTemplateFileName = String.Empty Then Dim pRegKey As RegistryKey = Registry.LocalMachine pRegKey = pRegKey.OpenSubKey("SOFTWARE\\Microsoft\\VisualStudio\\7.1") Dim folder As Object = pRegKey.GetValue("InstallDir") CodeTemplateXmlDocument = New XmlDocument _codeTemplateFileName = folder & "CodeTemplates.xml" End If Return _codeTemplateFileName End Get End Property #End Region Private Sub GetXmlDocument() If Not CodeTemplateXmlDocument Is Nothing Then If Not CodeTemplateXmlDocument.InnerXml = "" Then Exit Sub CodeTemplateXmlDocument = New XmlDocument CodeTemplateXmlDocument.Load(CodeTemplateFileName) 'I dont know why this does not load 1st time If CodeTemplateXmlDocument.InnerXml = "" Then CodeTemplateXmlDocument.Load(CodeTemplateFileName) End Sub #End Region Private Sub ApplyTemplate(ByVal selection As TextSelection) 'Get Xml Document GetXmlDocument() 'If template is NOT available then exit Dim codeTemplateNode As XmlNode = GetCodeTemplateNode(selection) If codeTemplateNode Is Nothing Then Exit Sub 'If template is available then replace Dim completeReplacementText As String = codeTemplateNode.SelectSingleNode("Code").InnerText() Dim variableNodes As XmlNodeList = codeTemplateNode.SelectNodes("Variable") If variableNodes.Count > 0 Then IsAborted = True completeReplacementText = GetReplacementText(completeReplacementText, variableNodes) If IsAborted Then Exit Sub End If End If Dim replacementText As String = completeReplacementText.Replace(CursorText, "") selection.Text = replacementText If Not CacheXmlInMemory Then CodeTemplateXmlDocument = Nothing Dim startPt As EditPoint = selection.TopPoint.CreateEditPoint() selection.MoveToDisplayColumn(startPt.Line, startPt.DisplayColumn - (replacementText.Length - completeReplacementText.IndexOf(CursorText))) End Sub Private Function GetCodeTemplateNode(ByVal selection As TextSelection) As XmlNode 'Get File Extension Dim fileName As String = DTE.ActiveDocument.Name Dim extension As String = fileName.Substring(fileName.LastIndexOf(".") + 1) 'Prepare xPath Dim xPath As String = String.Format("/CodeTemplates/CodeTemplateSet[FileType[@Extension='{0}']]/CodeTemplate[@ShortCut='{1}']", extension, selection.Text.Trim()) Return CodeTemplateXmlDocument.SelectSingleNode(xPath) End Function Private variableEntryForm As CodeCompletionVariableEntry Private IsAborted As Boolean = True Private Function GetReplacementText(ByVal replacementText As String, ByVal variableNodes As XmlNodeList) As String 'If Not variableEntryForm Is Nothing Then Return replacementText variableEntryForm = New CodeCompletionVariableEntry variableEntryForm.CodeTemplateVariablesNodes = variableNodes variableEntryForm.ReplacementText = replacementText variableEntryForm.AddVariableControls() Application.Run(variableEntryForm) replacementText = variableEntryForm.ReplacementText If variableEntryForm.DialogResult = DialogResult.OK Then IsAborted = False End If 'Kill The form variableEntryForm = Nothing Return replacementText End Function #End Region End Module
CodeCompletionConfig.vb
Imports System.Data Imports System.Windows.Forms Imports System.Xml Public Class CodeCompletionConfig Inherits System.Windows.Forms.Form #Region "Windows Form Designer generated code" Public Sub New() MyBase.New() 'This call is required by the Windows Form Designer. InitializeComponent() 'Add any initialization after the InitializeComponent() call End Sub 'Form overrides dispose to clean up the component list. Protected Overloads Overrides Sub Dispose(ByVal disposing As Boolean) If disposing Then If Not (components Is Nothing) Then components.Dispose() End If End If MyBase.Dispose(disposing) End Sub 'Required by the Windows Form Designer Private components As System.ComponentModel.IContainer 'NOTE: The following procedure is required by the Windows Form Designer 'It can be modified using the Windows Form Designer. 'Do not modify it using the code editor. Friend WithEvents LoadBtn As System.Windows.Forms.Button Friend WithEvents SaveBtn As System.Windows.Forms.Button Friend WithEvents CancelBtn As System.Windows.Forms.Button Friend WithEvents ExitBtn As System.Windows.Forms.Button Friend WithEvents Grid As System.Windows.Forms.DataGrid Friend ds As DataSet Private Sub InitializeComponent() Me.ds = New System.Data.DataSet Me.Grid = New System.Windows.Forms.DataGrid Me.LoadBtn = New System.Windows.Forms.Button Me.SaveBtn = New System.Windows.Forms.Button Me.CancelBtn = New System.Windows.Forms.Button Me.ExitBtn = New System.Windows.Forms.Button CType(Me.ds, System.ComponentModel.ISupportInitialize).BeginInit() CType(Me.Grid, System.ComponentModel.ISupportInitialize).BeginInit() Me.SuspendLayout() ' 'ds ' Me.ds.DataSetName = "NewDataSet" Me.ds.Locale = New System.Globalization.CultureInfo("en-AU") ' 'Grid ' Me.Grid.DataMember = "" Me.Grid.DataSource = Me.ds Me.Grid.Dock = System.Windows.Forms.DockStyle.Bottom Me.Grid.HeaderForeColor = System.Drawing.SystemColors.ControlText Me.Grid.Location = New System.Drawing.Point(0, 46) Me.Grid.Name = "Grid" Me.Grid.Size = New System.Drawing.Size(736, 392) Me.Grid.TabIndex = 0 ' 'LoadBtn ' Me.LoadBtn.Font = New System.Drawing.Font("Lucida Sans", 9.75!, System.Drawing.FontStyle.Bold, System.Drawing.GraphicsUnit.Point, CType(0, Byte)) Me.LoadBtn.Location = New System.Drawing.Point(8, 8) Me.LoadBtn.Name = "LoadBtn" Me.LoadBtn.Size = New System.Drawing.Size(144, 32) Me.LoadBtn.TabIndex = 1 Me.LoadBtn.Text = "&Load" ' 'SaveBtn ' Me.SaveBtn.Font = New System.Drawing.Font("Lucida Sans", 9.75!, System.Drawing.FontStyle.Bold, System.Drawing.GraphicsUnit.Point, CType(0, Byte)) Me.SaveBtn.Location = New System.Drawing.Point(200, 8) Me.SaveBtn.Name = "SaveBtn" Me.SaveBtn.Size = New System.Drawing.Size(144, 32) Me.SaveBtn.TabIndex = 2 Me.SaveBtn.Text = "&Save" ' 'CancelBtn ' Me.CancelBtn.Font = New System.Drawing.Font("Lucida Sans", 9.75!, System.Drawing.FontStyle.Bold, System.Drawing.GraphicsUnit.Point, CType(0, Byte)) Me.CancelBtn.Location = New System.Drawing.Point(392, 8) Me.CancelBtn.Name = "CancelBtn" Me.CancelBtn.Size = New System.Drawing.Size(144, 32) Me.CancelBtn.TabIndex = 3 Me.CancelBtn.Text = "&Cancel" ' 'ExitBtn ' Me.ExitBtn.DialogResult = System.Windows.Forms.DialogResult.Cancel Me.ExitBtn.Font = New System.Drawing.Font("Lucida Sans", 9.75!, System.Drawing.FontStyle.Bold, System.Drawing.GraphicsUnit.Point, CType(0, Byte)) Me.ExitBtn.Location = New System.Drawing.Point(584, 8) Me.ExitBtn.Name = "ExitBtn" Me.ExitBtn.Size = New System.Drawing.Size(144, 32) Me.ExitBtn.TabIndex = 4 Me.ExitBtn.Text = "E&xit" ' 'ConfigForm ' Me.AutoScaleBaseSize = New System.Drawing.Size(7, 19) Me.CancelButton = Me.ExitBtn Me.ClientSize = New System.Drawing.Size(736, 438) Me.Controls.Add(Me.ExitBtn) Me.Controls.Add(Me.CancelBtn) Me.Controls.Add(Me.SaveBtn) Me.Controls.Add(Me.LoadBtn) Me.Controls.Add(Me.Grid) Me.Font = New System.Drawing.Font("Comic Sans MS", 10.0!, System.Drawing.FontStyle.Bold, System.Drawing.GraphicsUnit.Point, CType(0, Byte)) Me.Name = "ConfigForm" Me.Text = "Configuration" CType(Me.ds, System.ComponentModel.ISupportInitialize).EndInit() CType(Me.Grid, System.ComponentModel.ISupportInitialize).EndInit() Me.ResumeLayout(False) End Sub #End Region #Region "Events" Public CodeTemplateFileName As String '= "C:\Program Files\Microsoft Visual Studio .NET 2003\Common7\IDE\CodeTemplates.xml" Private Sub ExitBtn_Click(ByVal sender As Object, ByVal e As System.EventArgs) Handles ExitBtn.Click Close() End Sub Private Sub LoadBtn_Click(ByVal sender As Object, ByVal e As System.EventArgs) Handles LoadBtn.Click LoadDataSet() End Sub Public Sub LoadDataSet() ds = New DataSet ds.ReadXml(CodeTemplateFileName) Grid.DataSource = ds If ds.Tables.Count > 0 Then Grid.DataMember = ds.Tables(0).TableName End Sub Private Sub SaveBtn_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles SaveBtn.Click ds.WriteXml(CodeTemplateFileName, XmlWriteMode.WriteSchema) End Sub Private Sub CancelBtn_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles CancelBtn.Click ds.RejectChanges() LoadDataSet() End Sub #End Region End Class
CodeCompletionVariableEntry.vb
Imports System.Xml Imports System.Windows.Forms Public Class CodeCompletionVariableEntry Inherits System.Windows.Forms.Form #Region "Add variable Controls" Public CodeTemplateVariablesNodes As XmlNodeList Public ReplacementText As String = "for(int ~0~ = 0; ~0~ < ; ~0~++){ }" Public Sub AddVariableControls() Dim i As Integer Dim OffSet As Integer VariablesGroupBox.Controls.Clear() For i = 0 To CodeTemplateVariablesNodes.Count - 1 OffSet = i * 24 'Variable Label Dim variableLabel As New Label variableLabel.Location = New System.Drawing.Point(8, 16 + OffSet) variableLabel.Name = "VariableLabel" + i.ToString() variableLabel.Size = New System.Drawing.Size(128, 23) variableLabel.TabIndex = i + 3 variableLabel.Text = CodeTemplateVariablesNodes(i).Attributes("Name").Value 'Variable Value Dim variableValue As New TextBox variableValue.Location = New System.Drawing.Point(152, 16 + OffSet) variableValue.Name = "VariableValue" + i.ToString() variableValue.TabIndex = i + 2 variableValue.Text = CodeTemplateVariablesNodes(i).Attributes("Value").Value VariablesGroupBox.Controls.Add(variableLabel) VariablesGroupBox.Controls.Add(variableValue) Next If CodeTemplateVariablesNodes.Count > 0 Then Me.ActiveControl = VariablesGroupBox.Controls(1) End Sub #End Region #Region "Windows Form Designer generated code" Public Sub New() MyBase.New() 'This call is required by the Windows Form Designer. InitializeComponent() 'Add any initialization after the InitializeComponent() call End Sub 'Form overrides dispose to clean up the component list. Protected Overloads Overrides Sub Dispose(ByVal disposing As Boolean) If disposing Then If Not (components Is Nothing) Then components.Dispose() End If End If MyBase.Dispose(disposing) End Sub 'Required by the Windows Form Designer Private components As System.ComponentModel.IContainer 'NOTE: The following procedure is required by the Windows Form Designer 'It can be modified using the Windows Form Designer. 'Do not modify it using the code editor. Friend WithEvents OkBtn As System.Windows.Forms.Button Friend WithEvents CancelBtn As System.Windows.Forms.Button Friend WithEvents VariablesGroupBox As System.Windows.Forms.GroupBox Private Sub InitializeComponent() Me.OkBtn = New System.Windows.Forms.Button Me.CancelBtn = New System.Windows.Forms.Button Me.VariablesGroupBox = New System.Windows.Forms.GroupBox Me.SuspendLayout() ' 'OkBtn ' Me.OkBtn.DialogResult = System.Windows.Forms.DialogResult.OK Me.OkBtn.Font = New System.Drawing.Font("Lucida Sans", 9.75!, System.Drawing.FontStyle.Bold) Me.OkBtn.Location = New System.Drawing.Point(16, 8) Me.OkBtn.Name = "OkBtn" Me.OkBtn.Size = New System.Drawing.Size(128, 23) Me.OkBtn.TabIndex = 0 Me.OkBtn.Text = "&Ok" ' 'CancelBtn ' Me.CancelBtn.DialogResult = System.Windows.Forms.DialogResult.Cancel Me.CancelBtn.Font = New System.Drawing.Font("Lucida Sans", 9.75!, System.Drawing.FontStyle.Bold) Me.CancelBtn.Location = New System.Drawing.Point(160, 8) Me.CancelBtn.Name = "CancelBtn" Me.CancelBtn.Size = New System.Drawing.Size(112, 23) Me.CancelBtn.TabIndex = 1 Me.CancelBtn.Text = "&Cancel" ' 'VariablesGroupBox ' Me.VariablesGroupBox.Font = New System.Drawing.Font("Lucida Sans", 9.75!, System.Drawing.FontStyle.Bold) Me.VariablesGroupBox.Location = New System.Drawing.Point(16, 40) Me.VariablesGroupBox.Name = "VariablesGroupBox" Me.VariablesGroupBox.Size = New System.Drawing.Size(264, 216) Me.VariablesGroupBox.TabIndex = 2 Me.VariablesGroupBox.TabStop = False Me.VariablesGroupBox.Text = "Variables" ' 'CodeCompletionVariableEntry ' Me.AcceptButton = Me.OkBtn Me.AccessibleDescription = "" Me.AccessibleName = "" Me.AutoScaleBaseSize = New System.Drawing.Size(5, 13) Me.CancelButton = Me.CancelBtn Me.ClientSize = New System.Drawing.Size(292, 266) Me.Controls.Add(Me.VariablesGroupBox) Me.Controls.Add(Me.CancelBtn) Me.Controls.Add(Me.OkBtn) Me.Name = "CodeCompletionVariableEntry" Me.Text = "Variables Entry" Me.ResumeLayout(False) End Sub #End Region #Region "Event Handlers" Private Sub Cancel(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles CancelBtn.Click Me.Close() End Sub Private Sub SetReplacementText(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles OkBtn.Click Dim i As Integer For i = 0 To CodeTemplateVariablesNodes.Count - 1 ReplacementText = ReplacementText.Replace(String.Format("~{0}~", i), VariablesGroupBox.Controls(i * 2 + 1).Text) Next 'MessageBox.Show(ReplacementText) Me.Close() End Sub #End Region End Class
CodeTemplates.xml
I will post soon, XML doesn't seem to be displayed properly here.