Click here to Skip to main content
15,891,248 members
Home / Discussions / .NET (Core and Framework)
   

.NET (Core and Framework)

 
GeneralRe: .NET Framework Class Library Pin
Mark Salsbery25-Mar-08 16:01
Mark Salsbery25-Mar-08 16:01 
GeneralTracing internal method calls in aspect oriented programming Pin
mercurysmiles20-Mar-08 23:59
mercurysmiles20-Mar-08 23:59 
QuestionHow to sign the soap body in WCF Pin
konkola19-Mar-08 22:51
konkola19-Mar-08 22:51 
AnswerRe: How to sign the soap body in WCF Pin
MrMundial21-Apr-10 4:31
MrMundial21-Apr-10 4:31 
GeneralRe: How to sign the soap body in WCF Pin
Rick Piovesan15-Oct-10 3:18
Rick Piovesan15-Oct-10 3:18 
GeneralRe: How to sign the soap body in WCF Pin
MrMundial21-Oct-10 3:20
MrMundial21-Oct-10 3:20 
QuestionObject Consistency Problem Pin
Thanks for all the fish19-Mar-08 22:23
Thanks for all the fish19-Mar-08 22:23 
GeneralRe: Object Consistency Problem Pin
Pete O'Hanlon20-Mar-08 0:54
mvePete O'Hanlon20-Mar-08 0:54 
I would look at using a hierarchy like this:
public interface Weapon
{
}

public interface HumanWeapon : IWeapon
{
}

public interface AlienWeapon : IWeapon
{
}

public interface IHumanArmour : IArmour
{
}

public interface IAlienArmour : IArmour
{
}

public abstract class Warrior : IWeapon, IArmour
{
  private IWeapon _weapon;
  private IArmour _armour;
  private string  _description;
  public Warrior(string description, IWeapon weapon, IArmour armour)
  {
    _weapon = weapon;
    _armour = armour;
    _description = description;
  }
  // Properties...
}

public class HumanWarrior : Warrior
{
  public HumanWarrior(string description, IHumanWeapon weapon, IHumanArmour armour) 
    : base(description, weapon, armour) 
  {} 
}

public class AlienWarrior : Warrior
{
  public HumanWarrior(string description, IAlienWeapon weapon, IAlienArmour armour) 
    : base(description, weapon, armour) 
  {} 
}

public class GenericWarrior<T> : Warrior 
  where T : Warrior
{
  private T _warrior;
  public GenericWarrior(T warrior)
  {
    _warrior = warrior;
  }
}
Finally, you allocate this as:
GenericWarrior<Human> warrior = new GenericWarrior<Human>(new Human("Hello", _myHumanWeapon, _myHumanArmour));
I hope this helps.


Deja View - the feeling that you've seen this post before.

My blog | My articles



GeneralRe: Object Consistency Problem [modified] Pin
PIEBALDconsult20-Mar-08 16:46
mvePIEBALDconsult20-Mar-08 16:46 
GeneralRe: Object Consistency Problem Pin
Pete O'Hanlon21-Mar-08 11:18
mvePete O'Hanlon21-Mar-08 11:18 
GeneralRe: Object Consistency Problem Pin
PIEBALDconsult21-Mar-08 12:55
mvePIEBALDconsult21-Mar-08 12:55 
GeneralRe: Object Consistency Problem Pin
Derek Bartram21-Mar-08 15:29
Derek Bartram21-Mar-08 15:29 
GeneralRe: Object Consistency Problem Pin
Ray Cassick25-Mar-08 11:35
Ray Cassick25-Mar-08 11:35 
QuestionUsing Certificates with c# and ASP.NET Pin
sfog19-Mar-08 11:10
sfog19-Mar-08 11:10 
GeneralCross post - please ignore Pin
pmarfleet19-Mar-08 11:16
pmarfleet19-Mar-08 11:16 
QuestionWhat do you mean you can't find the assembly? Pin
FyreWyrm18-Mar-08 15:13
FyreWyrm18-Mar-08 15:13 
GeneralRe: What do you mean you can't find the assembly? Pin
led mike19-Mar-08 5:32
led mike19-Mar-08 5:32 
GeneralRe: What do you mean you can't find the assembly? Pin
PIEBALDconsult19-Mar-08 11:55
mvePIEBALDconsult19-Mar-08 11:55 
GeneralRe: What do you mean you can't find the assembly? Pin
led mike21-Mar-08 9:41
led mike21-Mar-08 9:41 
GeneralRe: What do you mean you can't find the assembly? Pin
FyreWyrm19-Mar-08 12:18
FyreWyrm19-Mar-08 12:18 
AnswerRe: What do you mean you can't find the assembly? Pin
FyreWyrm19-Mar-08 12:22
FyreWyrm19-Mar-08 12:22 
GeneralRe: What do you mean you can't find the assembly? Pin
leppie20-Mar-08 22:32
leppie20-Mar-08 22:32 
QuestionEmail address encoding upper ascii (umlaut) question. Pin
tdpollard18-Mar-08 8:56
tdpollard18-Mar-08 8:56 
GeneralRe: Email address encoding upper ascii (umlaut) question. Pin
pmarfleet18-Mar-08 11:28
pmarfleet18-Mar-08 11:28 
QuestionHow to sign BinarySecurityToken using WSE 3.0 [modified] Pin
Timo Kokkinen18-Mar-08 7:40
Timo Kokkinen18-Mar-08 7:40 

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.