Click here to Skip to main content
15,881,812 members
Articles / Programming Languages / C#

Automated Registration of Visual Studio Custom Tools

Rate me:
Please Sign up or sign in to vote.
2.83/5 (3 votes)
2 Jun 20043 min read 60.2K   400   22  
Describes a utility to simplify the registration of a VS.NET custom tool.
//------------------------------------------------------------------------------
// <autogenerated>
//     This code was generated by a tool.
//     Runtime Version: 1.1.4322.573
//
//     Changes to this file may cause incorrect behavior and will be lost if 
//     the code is regenerated.
// </autogenerated>
//------------------------------------------------------------------------------

using System;
using System.Data;
using System.Xml;
using System.Runtime.Serialization;


[Serializable()]
[System.ComponentModel.DesignerCategoryAttribute("code")]
[System.Diagnostics.DebuggerStepThrough()]
[System.ComponentModel.ToolboxItem(true)]
public class RegistrationConfig : DataSet {
    
    private dotNetRegistrationDataTable tabledotNetRegistration;
    
    public RegistrationConfig() {
        this.InitClass();
        System.ComponentModel.CollectionChangeEventHandler schemaChangedHandler = new System.ComponentModel.CollectionChangeEventHandler(this.SchemaChanged);
        this.Tables.CollectionChanged += schemaChangedHandler;
        this.Relations.CollectionChanged += schemaChangedHandler;
    }
    
    protected RegistrationConfig(SerializationInfo info, StreamingContext context) {
        string strSchema = ((string)(info.GetValue("XmlSchema", typeof(string))));
        if ((strSchema != null)) {
            DataSet ds = new DataSet();
            ds.ReadXmlSchema(new XmlTextReader(new System.IO.StringReader(strSchema)));
            if ((ds.Tables["dotNetRegistration"] != null)) {
                this.Tables.Add(new dotNetRegistrationDataTable(ds.Tables["dotNetRegistration"]));
            }
            this.DataSetName = ds.DataSetName;
            this.Prefix = ds.Prefix;
            this.Namespace = ds.Namespace;
            this.Locale = ds.Locale;
            this.CaseSensitive = ds.CaseSensitive;
            this.EnforceConstraints = ds.EnforceConstraints;
            this.Merge(ds, false, System.Data.MissingSchemaAction.Add);
            this.InitVars();
        }
        else {
            this.InitClass();
        }
        this.GetSerializationData(info, context);
        System.ComponentModel.CollectionChangeEventHandler schemaChangedHandler = new System.ComponentModel.CollectionChangeEventHandler(this.SchemaChanged);
        this.Tables.CollectionChanged += schemaChangedHandler;
        this.Relations.CollectionChanged += schemaChangedHandler;
    }
    
    [System.ComponentModel.Browsable(false)]
    [System.ComponentModel.DesignerSerializationVisibilityAttribute(System.ComponentModel.DesignerSerializationVisibility.Content)]
    public dotNetRegistrationDataTable dotNetRegistration {
        get {
            return this.tabledotNetRegistration;
        }
    }
    
    public override DataSet Clone() {
        RegistrationConfig cln = ((RegistrationConfig)(base.Clone()));
        cln.InitVars();
        return cln;
    }
    
    protected override bool ShouldSerializeTables() {
        return false;
    }
    
    protected override bool ShouldSerializeRelations() {
        return false;
    }
    
    protected override void ReadXmlSerializable(XmlReader reader) {
        this.Reset();
        DataSet ds = new DataSet();
        ds.ReadXml(reader);
        if ((ds.Tables["dotNetRegistration"] != null)) {
            this.Tables.Add(new dotNetRegistrationDataTable(ds.Tables["dotNetRegistration"]));
        }
        this.DataSetName = ds.DataSetName;
        this.Prefix = ds.Prefix;
        this.Namespace = ds.Namespace;
        this.Locale = ds.Locale;
        this.CaseSensitive = ds.CaseSensitive;
        this.EnforceConstraints = ds.EnforceConstraints;
        this.Merge(ds, false, System.Data.MissingSchemaAction.Add);
        this.InitVars();
    }
    
    protected override System.Xml.Schema.XmlSchema GetSchemaSerializable() {
        System.IO.MemoryStream stream = new System.IO.MemoryStream();
        this.WriteXmlSchema(new XmlTextWriter(stream, null));
        stream.Position = 0;
        return System.Xml.Schema.XmlSchema.Read(new XmlTextReader(stream), null);
    }
    
    internal void InitVars() {
        this.tabledotNetRegistration = ((dotNetRegistrationDataTable)(this.Tables["dotNetRegistration"]));
        if ((this.tabledotNetRegistration != null)) {
            this.tabledotNetRegistration.InitVars();
        }
    }
    
    private void InitClass() {
        this.DataSetName = "RegistrationConfig";
        this.Prefix = "";
        this.Namespace = "http://schemas.mckechney.com/DotNetRegistrationConfig.xsd";
        this.Locale = new System.Globalization.CultureInfo("en-US");
        this.CaseSensitive = false;
        this.EnforceConstraints = false;
        this.tabledotNetRegistration = new dotNetRegistrationDataTable();
        this.Tables.Add(this.tabledotNetRegistration);
    }
    
    private bool ShouldSerializedotNetRegistration() {
        return false;
    }
    
    private void SchemaChanged(object sender, System.ComponentModel.CollectionChangeEventArgs e) {
        if ((e.Action == System.ComponentModel.CollectionChangeAction.Remove)) {
            this.InitVars();
        }
    }
    
    public delegate void dotNetRegistrationRowChangeEventHandler(object sender, dotNetRegistrationRowChangeEvent e);
    
    [System.Diagnostics.DebuggerStepThrough()]
    public class dotNetRegistrationDataTable : DataTable, System.Collections.IEnumerable {
        
        private DataColumn columndllName;
        
        private DataColumn columncustomToolName;
        
        private DataColumn columnguid;
        
        private DataColumn columnprodDesc;
        
        internal dotNetRegistrationDataTable() : 
                base("dotNetRegistration") {
            this.InitClass();
        }
        
        internal dotNetRegistrationDataTable(DataTable table) : 
                base(table.TableName) {
            if ((table.CaseSensitive != table.DataSet.CaseSensitive)) {
                this.CaseSensitive = table.CaseSensitive;
            }
            if ((table.Locale.ToString() != table.DataSet.Locale.ToString())) {
                this.Locale = table.Locale;
            }
            if ((table.Namespace != table.DataSet.Namespace)) {
                this.Namespace = table.Namespace;
            }
            this.Prefix = table.Prefix;
            this.MinimumCapacity = table.MinimumCapacity;
            this.DisplayExpression = table.DisplayExpression;
        }
        
        [System.ComponentModel.Browsable(false)]
        public int Count {
            get {
                return this.Rows.Count;
            }
        }
        
        internal DataColumn dllNameColumn {
            get {
                return this.columndllName;
            }
        }
        
        internal DataColumn customToolNameColumn {
            get {
                return this.columncustomToolName;
            }
        }
        
        internal DataColumn guidColumn {
            get {
                return this.columnguid;
            }
        }
        
        internal DataColumn prodDescColumn {
            get {
                return this.columnprodDesc;
            }
        }
        
        public dotNetRegistrationRow this[int index] {
            get {
                return ((dotNetRegistrationRow)(this.Rows[index]));
            }
        }
        
        public event dotNetRegistrationRowChangeEventHandler dotNetRegistrationRowChanged;
        
        public event dotNetRegistrationRowChangeEventHandler dotNetRegistrationRowChanging;
        
        public event dotNetRegistrationRowChangeEventHandler dotNetRegistrationRowDeleted;
        
        public event dotNetRegistrationRowChangeEventHandler dotNetRegistrationRowDeleting;
        
        public void AdddotNetRegistrationRow(dotNetRegistrationRow row) {
            this.Rows.Add(row);
        }
        
        public dotNetRegistrationRow AdddotNetRegistrationRow(string dllName, string customToolName, string guid, string prodDesc) {
            dotNetRegistrationRow rowdotNetRegistrationRow = ((dotNetRegistrationRow)(this.NewRow()));
            rowdotNetRegistrationRow.ItemArray = new object[] {
                    dllName,
                    customToolName,
                    guid,
                    prodDesc};
            this.Rows.Add(rowdotNetRegistrationRow);
            return rowdotNetRegistrationRow;
        }
        
        public System.Collections.IEnumerator GetEnumerator() {
            return this.Rows.GetEnumerator();
        }
        
        public override DataTable Clone() {
            dotNetRegistrationDataTable cln = ((dotNetRegistrationDataTable)(base.Clone()));
            cln.InitVars();
            return cln;
        }
        
        protected override DataTable CreateInstance() {
            return new dotNetRegistrationDataTable();
        }
        
        internal void InitVars() {
            this.columndllName = this.Columns["dllName"];
            this.columncustomToolName = this.Columns["customToolName"];
            this.columnguid = this.Columns["guid"];
            this.columnprodDesc = this.Columns["prodDesc"];
        }
        
        private void InitClass() {
            this.columndllName = new DataColumn("dllName", typeof(string), null, System.Data.MappingType.Element);
            this.Columns.Add(this.columndllName);
            this.columncustomToolName = new DataColumn("customToolName", typeof(string), null, System.Data.MappingType.Element);
            this.Columns.Add(this.columncustomToolName);
            this.columnguid = new DataColumn("guid", typeof(string), null, System.Data.MappingType.Element);
            this.Columns.Add(this.columnguid);
            this.columnprodDesc = new DataColumn("prodDesc", typeof(string), null, System.Data.MappingType.Element);
            this.Columns.Add(this.columnprodDesc);
        }
        
        public dotNetRegistrationRow NewdotNetRegistrationRow() {
            return ((dotNetRegistrationRow)(this.NewRow()));
        }
        
        protected override DataRow NewRowFromBuilder(DataRowBuilder builder) {
            return new dotNetRegistrationRow(builder);
        }
        
        protected override System.Type GetRowType() {
            return typeof(dotNetRegistrationRow);
        }
        
        protected override void OnRowChanged(DataRowChangeEventArgs e) {
            base.OnRowChanged(e);
            if ((this.dotNetRegistrationRowChanged != null)) {
                this.dotNetRegistrationRowChanged(this, new dotNetRegistrationRowChangeEvent(((dotNetRegistrationRow)(e.Row)), e.Action));
            }
        }
        
        protected override void OnRowChanging(DataRowChangeEventArgs e) {
            base.OnRowChanging(e);
            if ((this.dotNetRegistrationRowChanging != null)) {
                this.dotNetRegistrationRowChanging(this, new dotNetRegistrationRowChangeEvent(((dotNetRegistrationRow)(e.Row)), e.Action));
            }
        }
        
        protected override void OnRowDeleted(DataRowChangeEventArgs e) {
            base.OnRowDeleted(e);
            if ((this.dotNetRegistrationRowDeleted != null)) {
                this.dotNetRegistrationRowDeleted(this, new dotNetRegistrationRowChangeEvent(((dotNetRegistrationRow)(e.Row)), e.Action));
            }
        }
        
        protected override void OnRowDeleting(DataRowChangeEventArgs e) {
            base.OnRowDeleting(e);
            if ((this.dotNetRegistrationRowDeleting != null)) {
                this.dotNetRegistrationRowDeleting(this, new dotNetRegistrationRowChangeEvent(((dotNetRegistrationRow)(e.Row)), e.Action));
            }
        }
        
        public void RemovedotNetRegistrationRow(dotNetRegistrationRow row) {
            this.Rows.Remove(row);
        }
    }
    
    [System.Diagnostics.DebuggerStepThrough()]
    public class dotNetRegistrationRow : DataRow {
        
        private dotNetRegistrationDataTable tabledotNetRegistration;
        
        internal dotNetRegistrationRow(DataRowBuilder rb) : 
                base(rb) {
            this.tabledotNetRegistration = ((dotNetRegistrationDataTable)(this.Table));
        }
        
        public string dllName {
            get {
                try {
                    return ((string)(this[this.tabledotNetRegistration.dllNameColumn]));
                }
                catch (InvalidCastException e) {
                    throw new StrongTypingException("Cannot get value because it is DBNull.", e);
                }
            }
            set {
                this[this.tabledotNetRegistration.dllNameColumn] = value;
            }
        }
        
        public string customToolName {
            get {
                try {
                    return ((string)(this[this.tabledotNetRegistration.customToolNameColumn]));
                }
                catch (InvalidCastException e) {
                    throw new StrongTypingException("Cannot get value because it is DBNull.", e);
                }
            }
            set {
                this[this.tabledotNetRegistration.customToolNameColumn] = value;
            }
        }
        
        public string guid {
            get {
                try {
                    return ((string)(this[this.tabledotNetRegistration.guidColumn]));
                }
                catch (InvalidCastException e) {
                    throw new StrongTypingException("Cannot get value because it is DBNull.", e);
                }
            }
            set {
                this[this.tabledotNetRegistration.guidColumn] = value;
            }
        }
        
        public string prodDesc {
            get {
                try {
                    return ((string)(this[this.tabledotNetRegistration.prodDescColumn]));
                }
                catch (InvalidCastException e) {
                    throw new StrongTypingException("Cannot get value because it is DBNull.", e);
                }
            }
            set {
                this[this.tabledotNetRegistration.prodDescColumn] = value;
            }
        }
        
        public bool IsdllNameNull() {
            return this.IsNull(this.tabledotNetRegistration.dllNameColumn);
        }
        
        public void SetdllNameNull() {
            this[this.tabledotNetRegistration.dllNameColumn] = System.Convert.DBNull;
        }
        
        public bool IscustomToolNameNull() {
            return this.IsNull(this.tabledotNetRegistration.customToolNameColumn);
        }
        
        public void SetcustomToolNameNull() {
            this[this.tabledotNetRegistration.customToolNameColumn] = System.Convert.DBNull;
        }
        
        public bool IsguidNull() {
            return this.IsNull(this.tabledotNetRegistration.guidColumn);
        }
        
        public void SetguidNull() {
            this[this.tabledotNetRegistration.guidColumn] = System.Convert.DBNull;
        }
        
        public bool IsprodDescNull() {
            return this.IsNull(this.tabledotNetRegistration.prodDescColumn);
        }
        
        public void SetprodDescNull() {
            this[this.tabledotNetRegistration.prodDescColumn] = System.Convert.DBNull;
        }
    }
    
    [System.Diagnostics.DebuggerStepThrough()]
    public class dotNetRegistrationRowChangeEvent : EventArgs {
        
        private dotNetRegistrationRow eventRow;
        
        private DataRowAction eventAction;
        
        public dotNetRegistrationRowChangeEvent(dotNetRegistrationRow row, DataRowAction action) {
            this.eventRow = row;
            this.eventAction = action;
        }
        
        public dotNetRegistrationRow Row {
            get {
                return this.eventRow;
            }
        }
        
        public DataRowAction Action {
            get {
                return this.eventAction;
            }
        }
    }
}

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 has no explicit license attached to it but may contain usage terms in the article text or the download files themselves. If in doubt please contact the author via the discussion board below.

A list of licenses authors might use can be found here


Written By
Web Developer
United States United States
This member has not yet provided a Biography. Assume it's interesting and varied, and probably something to do with programming.

Comments and Discussions