Пример #1
0
        public void ReplenishInventory(enmInvParts InventoryPart)
        {
            PartsFactory    factory = new PartsFactory();
            IPartsInventory IP      = factory.ReturnPartInventory(InventoryPart);

            IP.Restock();
        }
Пример #2
0
        public IPartsInventory ReturnPartInventory(enmInvParts vInvPart)
        {
            IPartsInventory InvPart = null;
            object          Obj;

            Type[]                 IntrfaceImpl;
            Attribute              Attr;
            enmInvParts            enmInventoryPart;
            InventoryPartAttribute InvPartAttr;
            int ImplementorCount;

            //Retrieve the attribute ImplAttr attached to the IPartsInventory
            //interface
            Attr = Attribute.GetCustomAttribute(typeof(IPartsInventory),
                                                typeof(ImplAttr));

            //Retrieve the Type array containing the types that implement
            //the IPartsInventory interface
            IntrfaceImpl = ((ImplAttr)Attr).ImplementorList;

            //Determine the number of classes that
            //implement IPartsInventory
            ImplementorCount = IntrfaceImpl.GetLength(0);

            for (int i = 0; i < ImplementorCount; i++)
            {
                Attr = Attribute.GetCustomAttribute(IntrfaceImpl[i],
                                                    typeof(InventoryPartAttribute));

                InvPartAttr = (InventoryPartAttribute)Attr;

                //Determine what inventory part this class supports
                enmInventoryPart = InvPartAttr.InventoryPartSupported;

                if ((int)enmInventoryPart == (int)vInvPart)
                {
                    Obj     = Activator.CreateInstance(IntrfaceImpl[i]);
                    InvPart = (IPartsInventory)Obj;
                    break;
                }
            }
            return(InvPart);
        }
Пример #3
0
 public InventoryPartAttribute(enmInvParts vInvPart)
 {
     mInventoryPart = vInvPart;
 }