public Foo(Thing tmpThing, string name)
    {
        if (tmpThing == null && name == null)
        {
            throw new System.ArgumentException("Either tmpThing or name must be non-null");
        }

        doSomeStuff();
        if (tmpThing != null)
        {
            myThing = tmpThing;
        }
        else
        {
            if (ThingCache.ContainsKey(name))
            {
                myThing = ThingCache[name];
            }
            else
            {
                myThing = ExternalStaticFactory.GetThing(name);
                ThingCache.Add(name, myThing);
            }
        }
        doSomeOtherStuff();
    }
Пример #2
0
 public Foo(string name)
 {
     if (ThingCache.ContainsKey(name))
     {
         Init(ThingCache[name]);
     }
     else
     {
         Init(ExternalStaticFactory.GetThing(name));
         ThingCache.Add(name, myThing);
     }
 }