Example #1
0
        private static T EnsureContextObject <T>(this BuildContext context, Func <T> createDefaultObject) where T : IContextObject
        {
            if (!context.ContainsContextObject <T>())
            {
                var obj = createDefaultObject.Invoke();
                context.SetContextObject(obj);
                return(obj);
            }

            return(context.GetContextObject <T>());
        }