Click here to Skip to main content
15,888,521 members
Home / Discussions / C#
   

C#

 
GeneralRe: Determine Is App Is Running Remote Pin
dandy7215-Feb-16 9:41
dandy7215-Feb-16 9:41 
QuestionI have downloaded the source code of Open Source Extensible Enterprise n-tier Application Framework with Multilayered Architecture Pin
Malikdanish13-Feb-16 19:37
professionalMalikdanish13-Feb-16 19:37 
AnswerRe: I have downloaded the source code of Open Source Extensible Enterprise n-tier Application Framework with Multilayered Architecture Pin
Richard MacCutchan13-Feb-16 21:17
mveRichard MacCutchan13-Feb-16 21:17 
GeneralRe: I have downloaded the source code of Open Source Extensible Enterprise n-tier Application Framework with Multilayered Architecture Pin
Malikdanish13-Feb-16 21:58
professionalMalikdanish13-Feb-16 21:58 
QuestionShow only whole numbers on axis in chart Pin
CJ201013-Feb-16 6:21
CJ201013-Feb-16 6:21 
AnswerRe: Show only whole numbers on axis in chart Pin
Gerry Schmitz13-Feb-16 10:00
mveGerry Schmitz13-Feb-16 10:00 
Questionpartial or completely match rows in c# in a datagridview Pin
anyi2612-Feb-16 8:19
anyi2612-Feb-16 8:19 
AnswerRe: partial or completely match rows in c# in a datagridview Pin
Sascha Lefèvre12-Feb-16 10:00
professionalSascha Lefèvre12-Feb-16 10:00 
AnswerRe: partial or completely match rows in c# in a datagridview Pin
anyi2613-Feb-16 1:03
anyi2613-Feb-16 1:03 
GeneralRe: partial or completely match rows in c# in a datagridview Pin
Sascha Lefèvre13-Feb-16 1:35
professionalSascha Lefèvre13-Feb-16 1:35 
QuestionSemantic Types for Name-Strings Pin
Sascha Lefèvre11-Feb-16 3:07
professionalSascha Lefèvre11-Feb-16 3:07 
AnswerRe: Semantic Types for Name-Strings Pin
Richard Deeming11-Feb-16 3:37
mveRichard Deeming11-Feb-16 3:37 
GeneralRe: Semantic Types for Name-Strings Pin
Sascha Lefèvre11-Feb-16 4:49
professionalSascha Lefèvre11-Feb-16 4:49 
AnswerRe: Semantic Types for Name-Strings Pin
RugbyLeague11-Feb-16 3:37
RugbyLeague11-Feb-16 3:37 
GeneralRe: Semantic Types for Name-Strings Pin
Sascha Lefèvre11-Feb-16 4:50
professionalSascha Lefèvre11-Feb-16 4:50 
GeneralRe: Semantic Types for Name-Strings Pin
RugbyLeague11-Feb-16 4:53
RugbyLeague11-Feb-16 4:53 
AnswerRe: Semantic Types for Name-Strings Pin
Pete O'Hanlon11-Feb-16 4:10
mvePete O'Hanlon11-Feb-16 4:10 
GeneralRe: Semantic Types for Name-Strings Pin
Sascha Lefèvre11-Feb-16 5:00
professionalSascha Lefèvre11-Feb-16 5:00 
AnswerRe: Semantic Types for Name-Strings Pin
Gerry Schmitz11-Feb-16 4:52
mveGerry Schmitz11-Feb-16 4:52 
GeneralRe: Semantic Types for Name-Strings Pin
Sascha Lefèvre11-Feb-16 5:07
professionalSascha Lefèvre11-Feb-16 5:07 
GeneralRe: Semantic Types for Name-Strings Pin
Gerry Schmitz11-Feb-16 7:29
mveGerry Schmitz11-Feb-16 7:29 
AnswerRe: Semantic Types for Name-Strings Pin
Midi_Mick11-Feb-16 11:02
professionalMidi_Mick11-Feb-16 11:02 
AnswerRe: Semantic Types for Name-Strings Pin
BillWoodruff15-Feb-16 4:59
professionalBillWoodruff15-Feb-16 4:59 
GeneralRe: Semantic Types for Name-Strings Pin
Sascha Lefèvre15-Feb-16 5:16
professionalSascha Lefèvre15-Feb-16 5:16 
GeneralRe: Semantic Types for Name-Strings Pin
BillWoodruff15-Feb-16 8:36
professionalBillWoodruff15-Feb-16 8:36 
Hi Sascha, I'm in the process of studying T4 in depth (steep learning curve ... for me). But, I can see the power available by using it. fyi: here's an experimental design-time .tt file that will produce a new .cs file with a series of "nested" Classes built from iterating a List of Strings. Each Class except the first in the List will inherit from the previous Class in the List, and each Class will define a Property to hold a List of the Class that inherits from it ... except for the last Class in the List which has no sub-Class. An interesting experiment, but don't me ask me what it might be good for Smile | :)

The design-time .tt file:
C#
<#@ template  debug="true" hostSpecific="true"#>
<#@ output extension=".cs"#>
<#@ Assembly Name="System.Core"#>
<#@ Assembly Name="System.Windows.Forms"#>
<#@ import namespace="System"#>
<#@ import namespace="System.IO"#>
<#@ import namespace="System.Diagnostics"#>
<#@ import namespace="System.Linq"#>
<#@ import namespace="System.Collections"#>
<#@ import namespace="System.Collections.Generic"#>
<#
List<string> categories = new List<string>{"Life","Domain", "Kingdom", "Phylum", "Class", "Order", "Family", "Genus", "Species"}; 
#>
using System;
using System.Collections.Generic;
using System.Linq;
/* 
	Bill Woodruff
	T4 Experiement #2 
*/
namespace TestNameSpace
{
	public class Life
	{
		public string Name { set; get; }
		public List<Domain> Domains{ set; get; }

		public Life(string name = "Life", params string[] args)
		{
			Name = name;

			Domains = new List<Domain>();

			foreach(string str in args) Domains.Add(new Domain(str));
		}

		<#
		for (int i = 1; i < categories.Count; i++)
		{
			#>public class <#=categories[i]#>: <#=categories[i - 1]#>
			{

			<#if(i < categories.Count - 1)
			{	
			#>
			public List< <#=categories[i + 1]#>> <#=categories[i + 1]#>s = new List< <#=categories[i + 1]#>>();  
			<#}#>

			public <#=categories[i]#>(string name = "", params string[] args)
			{
				Name = name;
				<#if(i < categories.Count - 1)
				{
				#>	
				foreach(string str in args)
				{
					<#=categories[i +1]#>s.Add(new <#=categories[i + 1]#>(str));
				}
	<#}#>
		}
		}

	<#}
#>
}
}
When processed by the compiler's TextTemplatingTool, this generates the following "live" class structure:
C#
using System;
using System.Collections.Generic;
using System.Linq;
/* 
	Bill Woodruff
	T4 Experiement #2 
*/

namespace TestNameSpace
{
    public class Life
    {
        public Life(string name = "Life", params string[] args)
        {
            Name = name;

            Domains = new List<Domain>();

            foreach (string str in args) Domains.Add(new Domain(str));
        }

        public string Name { set; get; }
        public List<Domain> Domains { set; get; }

        public class Domain : Life
        {
            public List<Kingdom> Kingdoms = new List<Kingdom>();

            public Domain(string name = "", params string[] args)
            {
                Name = name;

                foreach (string str in args)
                {
                    Kingdoms.Add(new Kingdom(str));
                }
            }
        }

        public class Kingdom : Domain
        {
            public List<Phylum> Phylums = new List<Phylum>();

            public Kingdom(string name = "", params string[] args)
            {
                Name = name;

                foreach (string str in args)
                {
                    Phylums.Add(new Phylum(str));
                }
            }
        }

        public class Phylum : Kingdom
        {
            public List<Class> Classs = new List<Class>();

            public Phylum(string name = "", params string[] args)
            {
                Name = name;

                foreach (string str in args)
                {
                    Classs.Add(new Class(str));
                }
            }
        }

        public class Class : Phylum
        {
            public List<Order> Orders = new List<Order>();

            public Class(string name = "", params string[] args)
            {
                Name = name;

                foreach (string str in args)
                {
                    Orders.Add(new Order(str));
                }
            }
        }

        public class Order : Class
        {
            public List<Family> Familys = new List<Family>();

            public Order(string name = "", params string[] args)
            {
                Name = name;

                foreach (string str in args)
                {
                    Familys.Add(new Family(str));
                }
            }
        }

        public class Family : Order
        {
            public List<Genus> Genuss = new List<Genus>();

            public Family(string name = "", params string[] args)
            {
                Name = name;

                foreach (string str in args)
                {
                    Genuss.Add(new Genus(str));
                }
            }
        }

        public class Genus : Family
        {
            public List<Species> Speciess = new List<Species>();

            public Genus(string name = "", params string[] args)
            {
                Name = name;

                foreach (string str in args)
                {
                    Speciess.Add(new Species(str));
                }
            }
        }

        public class Species : Genus
        {
            public Species(string name = "", params string[] args)
            {
                Name = name;
            }
        }
    }
}

«In art as in science there is no delight without the detail ... Let me repeat that unless these are thoroughly understood and remembered, all “general ideas” (so easily acquired, so profitably resold) must necessarily remain but worn passports allowing their bearers short cuts from one area of ignorance to another.» Vladimir Nabokov, commentary on translation of “Eugene Onegin.”


modified 15-Feb-16 14:43pm.

General General    News News    Suggestion Suggestion    Question Question    Bug Bug    Answer Answer    Joke Joke    Praise Praise    Rant Rant    Admin Admin   

Use Ctrl+Left/Right to switch messages, Ctrl+Up/Down to switch threads, Ctrl+Shift+Left/Right to switch pages.