♯ C# EVOCATION DIFFICULTY: Archmage Creational

The Abstract Factory Evocation

Manifest entire suites of coherent magical artifacts through enterprise sigils.

✧ GANG OF FOUR LINEAGE & ARCANUM ✧
GOF DESIGN PATTERN: Abstract Factory
ARCANUM SCHOOL: Conjuration // Enterprise Evocation
SCRIBE / ARCHON: Joshua Edward McLaughlin Cox
CANONICAL REGISTRATION:
// CSHARP PATTERN //
using System;

namespace EnterpriseEvocation
{
    public interface IStaff { void Cast(); }
    public interface IRobe { void Equip(); }

    public class VoidStaff : IStaff { public void Cast() => Console.WriteLine("Casting Void Bolt."); }
    public class VoidRobe : IRobe { public void Equip() => Console.WriteLine("Equipping Void Threads."); }

    public class AetherStaff : IStaff { public void Cast() => Console.WriteLine("Casting Aether Flare."); }
    public class AetherRobe : IRobe { public void Equip() => Console.WriteLine("Equipping Aether Silks."); }

    public interface IArtifactFactory
    {
        IStaff CreateStaff();
        IRobe CreateRobe();
    }

    public class VoidArtifactFactory : IArtifactFactory
    {
        public IStaff CreateStaff() => new VoidStaff();
        public IRobe CreateRobe() => new VoidRobe();
    }

    public class AetherArtifactFactory : IArtifactFactory
    {
        public IStaff CreateStaff() => new AetherStaff();
        public IRobe CreateRobe() => new AetherRobe();
    }

    public class Enchanter
    {
        private readonly IStaff _staff;
        private readonly IRobe _robe;

        public Enchanter(IArtifactFactory factory)
        {
            _staff = factory.CreateStaff();
            _robe = factory.CreateRobe();
        }

        public void PrepareForBattle()
        {
            _robe.Equip();
            _staff.Cast();
        }
    }
}

Enterprise evocation demands strict adherence to coherent suites of artifacts. The Abstract Factory ensures that your Void Robes are never mismatched with an Aether Staff, maintaining the delicate balance of corporate magical monoliths.

Runic Tags: #creational #abstract-factory #enterprise #csharp