Click here to Skip to main content
15,893,486 members
Articles / Desktop Programming / Windows Forms

Project Metadata Generation using T4

Rate me:
Please Sign up or sign in to vote.
4.97/5 (45 votes)
7 Nov 2009BSD16 min read 168.6K   1.5K   152  
Generate project metadata with T4 and unburden yourself from string literals in XAML binding expressions and INotifyPropertyChanged event arguments.

// ReSharper disable PossibleNullReferenceException
/*
This code was automatically generated by Daniel Vaughan's metadata generator.
Changes to this file may be lost if regeneration occurs.
http://danielvaughan.orpius.com
*/
using System.Windows;
using System;
using System.Linq;
using System.Linq.Expressions;


    /// <summary>Metadata for class <see cref="SimpleClass"/></summary>
    internal static class SimpleClassMetadata
    {
        public static class MemberNames
        {
            /// <summary>Refers to property <see cref="SimpleClass.Property0"/></summary>
            public const string Property0 = "Property0";

            /// <summary>Refers to property <see cref="SimpleClass.Property1"/></summary>
            public const string Property1 = "Property1";

            /// <summary>Refers to property <see cref="SimpleClass.Property2"/></summary>
            public const string Property2 = "Property2";

        }

        /// <summary>Refers to property <see cref="SimpleClass.Property0"/></summary>
        public static PropertyPath Property0Path { get { return new PropertyPath("Property0"); } }

        /// <summary>Refers to property <see cref="SimpleClass.Property1"/></summary>
        public static PropertyPath Property1Path { get { return new PropertyPath("Property1"); } }

        /// <summary>Refers to property <see cref="SimpleClass.Property2"/></summary>
        public static PropertyPath Property2Path { get { return new PropertyPath("Property2"); } }

    }


namespace DanielVaughan.MetaGen.Demo.Metadata
{
    /// <summary>Metadata for class <see cref="DanielVaughan.MetaGen.Demo.App"/></summary>
    internal static class AppMetadata
    {
        public static class MemberNames
        {
        }

    }

    /// <summary>Metadata for interface <see cref="DanielVaughan.MetaGen.Demo.IPerson"/></summary>
    internal static class IPersonMetadata
    {
        public static class MemberNames
        {
            /// <summary>Refers to property <see cref="DanielVaughan.MetaGen.Demo.IPerson.Name"/></summary>
            public const string Name = "Name";

            /// <summary>Refers to property <see cref="DanielVaughan.MetaGen.Demo.IPerson.Address"/></summary>
            public const string Address = "Address";

            /// <summary>Refers to property <see cref="DanielVaughan.MetaGen.Demo.IPerson.Age"/></summary>
            public const string Age = "Age";

        }

        /// <summary>Refers to property <see cref="DanielVaughan.MetaGen.Demo.IPerson.Name"/></summary>
        public static PropertyPath NamePath { get { return new PropertyPath("Name"); } }

        /// <summary>Refers to property <see cref="DanielVaughan.MetaGen.Demo.IPerson.Address"/></summary>
        public static PropertyPath AddressPath { get { return new PropertyPath("Address"); } }

        /// <summary>Refers to property <see cref="DanielVaughan.MetaGen.Demo.IPerson.Age"/></summary>
        public static PropertyPath AgePath { get { return new PropertyPath("Age"); } }

    }

    /// <summary>Metadata for class <see cref="DanielVaughan.MetaGen.Demo.Person"/></summary>
    internal static class PersonMetadata
    {
        public static class MemberNames
        {
            /// <summary>Refers to field <see cref="DanielVaughan.MetaGen.Demo.Person.name"/></summary>
            public const string name = "name";

            /// <summary>Refers to property <see cref="DanielVaughan.MetaGen.Demo.Person.Name"/></summary>
            public const string Name = "Name";

            /// <summary>Refers to field <see cref="DanielVaughan.MetaGen.Demo.Person.address"/></summary>
            public const string address = "address";

            /// <summary>Refers to property <see cref="DanielVaughan.MetaGen.Demo.Person.Address"/></summary>
            public const string Address = "Address";

            /// <summary>Refers to field <see cref="DanielVaughan.MetaGen.Demo.Person.age"/></summary>
            public const string age = "age";

            /// <summary>Refers to property <see cref="DanielVaughan.MetaGen.Demo.Person.Age"/></summary>
            public const string Age = "Age";

            /// <summary>Refers to method <see cref="DanielVaughan.MetaGen.Demo.Person.ObfuscationTest"/></summary>
            public const string ObfuscationTest = "ObfuscationTest";

            /// <summary>Refers to method <see cref="DanielVaughan.MetaGen.Demo.Person.OnPropertyChanged"/></summary>
            public const string OnPropertyChanged = "OnPropertyChanged";

        }

        /// <summary>Refers to property <see cref="DanielVaughan.MetaGen.Demo.Person.Name"/></summary>
        public static PropertyPath NamePath { get { return new PropertyPath("Name"); } }

        /// <summary>Refers to property <see cref="DanielVaughan.MetaGen.Demo.Person.Address"/></summary>
        public static PropertyPath AddressPath { get { return new PropertyPath("Address"); } }

        /// <summary>Refers to property <see cref="DanielVaughan.MetaGen.Demo.Person.Age"/></summary>
        public static PropertyPath AgePath { get { return new PropertyPath("Age"); } }

    }

    /// <summary>Metadata for class <see cref="DanielVaughan.MetaGen.Demo.Window1"/></summary>
    internal static class Window1Metadata
    {
        public static class MemberNames
        {
            /// <summary>Refers to field <see cref="DanielVaughan.MetaGen.Demo.Window1.stateToggled"/></summary>
            public const string stateToggled = "stateToggled";

            /// <summary>Refers to method <see cref="DanielVaughan.MetaGen.Demo.Window1.Button_ChangeClick"/></summary>
            public const string Button_ChangeClick = "Button_ChangeClick";

        }

    }

}

namespace DanielVaughan.MetaGen.Demo.Folder1.Metadata
{
    /// <summary>Metadata for interface <see cref="DanielVaughan.MetaGen.Demo.Folder1.Folder1Interface"/></summary>
    internal static class Folder1InterfaceMetadata
    {
        public static class MemberNames
        {
            /// <summary>Refers to property <see cref="DanielVaughan.MetaGen.Demo.Folder1.Folder1Interface.Foo"/></summary>
            public const string Foo = "Foo";

        }

        /// <summary>Refers to property <see cref="DanielVaughan.MetaGen.Demo.Folder1.Folder1Interface.Foo"/></summary>
        public static PropertyPath FooPath { get { return new PropertyPath("Foo"); } }

    }

    /// <summary>Metadata for class <see cref="DanielVaughan.MetaGen.Demo.Folder1.Folder1StaticClass"/></summary>
    internal static class Folder1StaticClassMetadata
    {
        public static class MemberNames
        {
            /// <summary>Refers to field <see cref="DanielVaughan.MetaGen.Demo.Folder1.Folder1StaticClass.StringConstant"/></summary>
            public const string StringConstant = "StringConstant";

            /// <summary>Refers to property <see cref="DanielVaughan.MetaGen.Demo.Folder1.Folder1StaticClass.StringStaticProperty"/></summary>
            public const string StringStaticProperty = "StringStaticProperty";

        }

        /// <summary>Refers to property <see cref="DanielVaughan.MetaGen.Demo.Folder1.Folder1StaticClass.StringStaticProperty"/></summary>
        public static PropertyPath StringStaticPropertyPath { get { return new PropertyPath("StringStaticProperty"); } }

    }

}

namespace DanielVaughan.MetaGen.Demo.Folder1.Folder2.Metadata
{
    /// <summary>Metadata for class <see cref="DanielVaughan.MetaGen.Demo.Folder1.Folder2.Folder2Class"/></summary>
    internal static class Folder2ClassMetadata
    {
        public static class MemberNames
        {
            /// <summary>Refers to property <see cref="DanielVaughan.MetaGen.Demo.Folder1.Folder2.Folder2Class.Foo"/></summary>
            public const string Foo = "Foo";

            /// <summary>Metadata for class <see cref="DanielVaughan.MetaGen.Demo.Folder1.Folder2.Folder2Class.Folder2InnerClass"/></summary>
            internal static class Folder2InnerClassMetadata
            {
                public static class MemberNames
                {
                    /// <summary>Refers to property <see cref="DanielVaughan.MetaGen.Demo.Folder1.Folder2.Folder2Class.Folder2InnerClass.Foo2"/></summary>
                    public const string Foo2 = "Foo2";

                }

                /// <summary>Refers to property <see cref="DanielVaughan.MetaGen.Demo.Folder1.Folder2.Folder2Class.Folder2InnerClass.Foo2"/></summary>
                public static PropertyPath Foo2Path { get { return new PropertyPath("Foo2"); } }

            }

        }

        /// <summary>Refers to property <see cref="DanielVaughan.MetaGen.Demo.Folder1.Folder2.Folder2Class.Foo"/></summary>
        public static PropertyPath FooPath { get { return new PropertyPath("Foo"); } }

    }

}

namespace DanielVaughan.MetaGen.Demo.Properties.Metadata
{
    /// <summary>Metadata for class <see cref="DanielVaughan.MetaGen.Demo.Properties.Resources"/></summary>
    internal static class ResourcesMetadata
    {
        public static class MemberNames
        {
            /// <summary>Refers to field <see cref="DanielVaughan.MetaGen.Demo.Properties.Resources.resourceMan"/></summary>
            public const string resourceMan = "resourceMan";

            /// <summary>Refers to field <see cref="DanielVaughan.MetaGen.Demo.Properties.Resources.resourceCulture"/></summary>
            public const string resourceCulture = "resourceCulture";

            /// <summary>Refers to property <see cref="DanielVaughan.MetaGen.Demo.Properties.Resources.ResourceManager"/></summary>
            public const string ResourceManager = "ResourceManager";

            /// <summary>Refers to property <see cref="DanielVaughan.MetaGen.Demo.Properties.Resources.Culture"/></summary>
            public const string Culture = "Culture";

        }

        /// <summary>Refers to property <see cref="DanielVaughan.MetaGen.Demo.Properties.Resources.ResourceManager"/></summary>
        public static PropertyPath ResourceManagerPath { get { return new PropertyPath("ResourceManager"); } }

        /// <summary>Refers to property <see cref="DanielVaughan.MetaGen.Demo.Properties.Resources.Culture"/></summary>
        public static PropertyPath CulturePath { get { return new PropertyPath("Culture"); } }

    }

    /// <summary>Metadata for class <see cref="DanielVaughan.MetaGen.Demo.Properties.Settings"/></summary>
    internal static class SettingsMetadata
    {
        public static class MemberNames
        {
            /// <summary>Refers to field <see cref="DanielVaughan.MetaGen.Demo.Properties.Settings.defaultInstance"/></summary>
            public const string defaultInstance = "defaultInstance";

            /// <summary>Refers to property <see cref="DanielVaughan.MetaGen.Demo.Properties.Settings.Default"/></summary>
            public const string Default = "Default";

        }

        /// <summary>Refers to property <see cref="DanielVaughan.MetaGen.Demo.Properties.Settings.Default"/></summary>
        public static PropertyPath DefaultPath { get { return new PropertyPath("Default"); } }

    }

}

// ReSharper restore PossibleNullReferenceException

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 BSD License


Written By
Engineer
Switzerland Switzerland
Daniel is a former senior engineer in Technology and Research at the Office of the CTO at Microsoft, working on next generation systems.

Previously Daniel was a nine-time Microsoft MVP and co-founder of Outcoder, a Swiss software and consulting company.

Daniel is the author of Windows Phone 8 Unleashed and Windows Phone 7.5 Unleashed, both published by SAMS.

Daniel is the developer behind several acclaimed mobile apps including Surfy Browser for Android and Windows Phone. Daniel is the creator of a number of popular open-source projects, most notably Codon.

Would you like Daniel to bring value to your organisation? Please contact

Blog | Twitter


Xamarin Experts
Windows 10 Experts

Comments and Discussions