Beispiel #1
0
        public static T GetOrCreateDataItem <T>(this DkmDataContainer container, Func <T> factory)
            where T : DkmDataItem
        {
            var result = container.GetDataItem <T>();

            if (result == null)
            {
                result = factory();
                container.SetDataItem(DkmDataCreationDisposition.CreateNew, result);
            }
            return(result);
        }
Beispiel #2
0
        internal static T GetOrCreateDataItem <T>(DkmDataContainer container) where T : DkmDataItem, new()
        {
            T item = container.GetDataItem <T>();

            if (item != null)
            {
                return(item);
            }

            item = new T();

            container.SetDataItem <T>(DkmDataCreationDisposition.CreateNew, item);

            return(item);
        }