Click here to Skip to main content
15,887,175 members
Articles / Desktop Programming / Windows Forms

Knit - A Visual Studio Add-In

Rate me:
Please Sign up or sign in to vote.
5.00/5 (5 votes)
30 Dec 2007CDDL8 min read 35K   415   21  
Knit is a Visual Studio add-in tool that allows a developer to apply multi-step patterns to solution and assembly meta-data.
using System;
using System.Collections.Generic;
using System.Text;
using System.Web.UI.WebControls.WebParts;
using System.ComponentModel;
using System.Web.UI;

namespace Hitachi.VisualStudio.Knit.SampleProject
{
    [Serializable]
    public class TestWebPart : WebPart
    {
        public const string TITLE = "Knit Test Web Part";
        public const string DESCRIPTION = "A web part used to unit test the Knit Share Point 2007 solution generation logic";
        private string m_preProcessing;

        public TestWebPart()
        {
            base.Title = TITLE;
            base.Title = DESCRIPTION;
        }
        [WebBrowsable(true)]
        [Personalizable(PersonalizationScope.User)]
        [DefaultValue( TestWebPart.TITLE )]
        public override string Title
        {
            get
            {
                return base.Title;
            }
            set
            {
                base.Title = value;
            }
        }
        [WebBrowsable(true)]
        [Personalizable(PersonalizationScope.User)]
        [DefaultValue(TestWebPart.DESCRIPTION)]
        public override string Description
        {
            get
            {
                return base.Description;
            }
            set
            {
                base.Description = value;
            }
        }

        [WebBrowsable(true)]
        [DefaultValue(null)]
        [WebDisplayName("Pre Processing")]
        [WebDescription("Enter any C# code to perform pre processing here")]
        [Personalizable(PersonalizationScope.Shared)]
        public string PreProcessing
        {
            get { return m_preProcessing; }
            set { m_preProcessing = value; }
        }
        private string m_postProcessing;
        [WebBrowsable(true)]
        [DefaultValue(null)]
        [WebDisplayName("Post Processing")]
        [Personalizable(PersonalizationScope.Shared)]
        [WebDescription("Enter any C# code to perform post processing here")]
        public string PostProcessing
        {
            get { return m_postProcessing; }
            set { m_postProcessing = value; }
        }

        public void DoSomeStuff(int a, string b, bool c)
        {
        }
        protected override void OnPreRender(EventArgs e)
        {
            base.OnPreRender(e);
            //Do the processing here...
        }
        protected override void Render(System.Web.UI.HtmlTextWriter writer)
        {
            writer.RenderBeginTag( HtmlTextWriterTag.P);
            writer.WriteEncodedText("Pre-Processing:");
            writer.RenderBeginTag(HtmlTextWriterTag.Br);
            writer.RenderEndTag();
            writer.RenderBeginTag(HtmlTextWriterTag.Pre);
            writer.WriteEncodedText(m_preProcessing);
            writer.RenderEndTag();
            writer.RenderEndTag();
            writer.RenderBeginTag(HtmlTextWriterTag.P);
            writer.WriteEncodedText("Post-Processing:");
            writer.RenderBeginTag(HtmlTextWriterTag.Br);
            writer.RenderEndTag();
            writer.RenderBeginTag(HtmlTextWriterTag.Pre);
            writer.WriteEncodedText(m_postProcessing);
            writer.RenderEndTag();
            writer.RenderEndTag();
        }
    }
}

By viewing downloads associated with this article you agree to the Terms of Service and the article's licence.

If a file you wish to view isn't highlighted, and is a text file (not binary), please let us know and we'll add colourisation support for it.

License

This article, along with any associated source code and files, is licensed under The Common Development and Distribution License (CDDL)


Written By
Architect Hitachi Consulting
United States United States
27 years of experience in information systems project management, architecture, analysis, and implementation.
I specialize in highly technical software architectures and development involving the very latest technologies. With several years experience in object-oriented design and development, I am able to produce workable designs for most object-oriented languages and design environments available today. Have a thorough understanding of software development life cycles and methodologies. Coached development teams on software engineering, including project management, database design and process design. Communicate effectively to, and wins respect from, both board members and hard-core development staff.
Notable projects include: Share Point web parts and other customizations; Colored Petri-net engine; Knowledge management system; .NET based RDF data store; several persistent object stores; Wireless Field Force Automation; Wireless E-commerce work order system; B2B e-commerce purchase order system; survey package; catalog purchasing system; SGML document viewing system; stock and bond trading system; accounting systems; project management applications; Electronic Mail and electronic library systems; EAI engine system architecture.
Other projects were developed as early as 1980, involving the networking of mainframes and personal computers.
Published author, inventor and member of the IEEE Computing Society.

Comments and Discussions