Click here to Skip to main content
15,897,273 members
Home / Discussions / C#
   

C#

 
QuestionAbout Reflecting and generics Pin
PozzaVecia14-Feb-12 11:06
PozzaVecia14-Feb-12 11:06 
AnswerRe: About Reflecting and generics Pin
Luc Pattyn14-Feb-12 11:19
sitebuilderLuc Pattyn14-Feb-12 11:19 
GeneralRe: About Reflecting and generics Pin
PozzaVecia14-Feb-12 11:42
PozzaVecia14-Feb-12 11:42 
AnswerRe: About Reflecting and generics Pin
Luc Pattyn14-Feb-12 12:08
sitebuilderLuc Pattyn14-Feb-12 12:08 
GeneralRe: About Reflecting and generics Pin
PozzaVecia14-Feb-12 12:29
PozzaVecia14-Feb-12 12:29 
AnswerRe: About Reflecting and generics Pin
Luc Pattyn14-Feb-12 12:41
sitebuilderLuc Pattyn14-Feb-12 12:41 
RantRe: About Reflecting and generics Pin
PozzaVecia14-Feb-12 12:58
PozzaVecia14-Feb-12 12:58 
GeneralRe: About Reflecting and generics Pin
GParkings14-Feb-12 23:44
GParkings14-Feb-12 23:44 
- IMoto interface
- ICar interface exposing a Moto property of type IMoto
- Moto factory returning an implementation of IMoto, the concrete implementation determined by switch statement
- car factory returning an implementation of ICar, the concrete implementation determined by switch statement and setting the Moto property using the Moto factory

e.g.

C#
public class CarFactory
{
    public ICar CreateCar(string carID, string motoID)
    {
       ICar result;

       switch(carID)
       {
            case "jaguar":
                result = new Jaguar();
                break;
            case "porche":
                result = new porche();
                break;
       }

       result.Moto = MotoFactory.Create(MotoID);
       return result;
    }
}

public class MotoFactory
{
    public IMoto Create(string motoID)
    {
       IMoto result;

       switch(motoID)
       {
            case "uber":
                result = new UberMoto();
                break;
            case "pants":
                result = new PantsMoto();
                break;
       }
        
       return result;
    }

}

Pedis ex oris
Quidquid latine dictum sit, altum sonatur

GeneralRe: About Reflecting and generics Pin
PozzaVecia15-Feb-12 0:10
PozzaVecia15-Feb-12 0:10 
GeneralRe: About Reflecting and generics Pin
GParkings15-Feb-12 0:59
GParkings15-Feb-12 0:59 
GeneralRe: About Reflecting and generics Pin
jschell14-Feb-12 13:40
jschell14-Feb-12 13:40 
AnswerRe: About Reflecting and generics Pin
AspDotNetDev14-Feb-12 13:00
protectorAspDotNetDev14-Feb-12 13:00 
GeneralRe: About Reflecting and generics Pin
PozzaVecia14-Feb-12 21:20
PozzaVecia14-Feb-12 21:20 
AnswerRe: About Reflecting and generics Pin
AspDotNetDev14-Feb-12 21:49
protectorAspDotNetDev14-Feb-12 21:49 
GeneralRe: About Reflecting and generics Pin
PozzaVecia14-Feb-12 22:26
PozzaVecia14-Feb-12 22:26 
GeneralRe: About Reflecting and generics Pin
AspDotNetDev15-Feb-12 7:09
protectorAspDotNetDev15-Feb-12 7:09 
GeneralRe: About Reflecting and generics Pin
AspDotNetDev14-Feb-12 21:52
protectorAspDotNetDev14-Feb-12 21:52 
AnswerRe: About Reflecting and generics Pin
BobJanova14-Feb-12 23:20
BobJanova14-Feb-12 23:20 
GeneralRe: About Reflecting and generics Pin
PozzaVecia14-Feb-12 23:29
PozzaVecia14-Feb-12 23:29 
GeneralRe: About Reflecting and generics Pin
BobJanova15-Feb-12 0:50
BobJanova15-Feb-12 0:50 
GeneralRe: About Reflecting and generics Pin
PozzaVecia15-Feb-12 1:24
PozzaVecia15-Feb-12 1:24 
GeneralRe: About Reflecting and generics Pin
BobJanova15-Feb-12 1:59
BobJanova15-Feb-12 1:59 
GeneralRe: About Reflecting and generics Pin
PozzaVecia15-Feb-12 2:30
PozzaVecia15-Feb-12 2:30 
GeneralRe: About Reflecting and generics Pin
BobJanova15-Feb-12 2:37
BobJanova15-Feb-12 2:37 
GeneralRe: About Reflecting and generics Pin
GParkings15-Feb-12 2:52
GParkings15-Feb-12 2:52 

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.