public string PerformSomeFunction(ThingTypes valueThatDeterminesTypeOfThing)
    {
        var thingINeed = _factory.Create(valueThatDeterminesTypeOfThing);

        try
        {
            return(thingINeed.GetType().Name);
        }
        finally
        {
            _factory.Release(thingINeed);
        }
    }
Пример #2
0
    public string PerformSomeFunction(ThingTypes valueThatDeterminesTypeOfThing)
    {
        var thingINeed = _factory.Create(valueThatDeterminesTypeOfThing);

        try
        {
            //This is just for demonstration purposes. The method
            //returns the name of the type created by the factory
            //so you can tell that the factory worked.
            return(thingINeed.GetType().Name);
        }
        finally
        {
            _factory.Release(thingINeed);
        }
    }