コード例 #1
0
 public static T OrDefault <T>(this ICompositeKeyComponentAccessor <T> accessor,
                               Func <T> getDefault = null)
 {
     return(accessor.TryGet(out T value) ? value : getDefault != null?getDefault() : default(T));
 }
コード例 #2
0
        //public static string Mandatory(this ICompositeKeyComponentAccessor accessor)
        //{
        //    return accessor.TryGet(out string value) ? value : throw new KeyNotFoundException();
        //}

        //public static string OrDefault(this ICompositeKeyComponentAccessor accessor,
        //    Func<string> getDefault = null)
        //{
        //    return accessor.TryGet(out string value) ? value : getDefault?.Invoke();
        //}

        public static T Mandatory <T>(this ICompositeKeyComponentAccessor <T> accessor)
        {
            return(accessor.TryGet(out T value) ? value : throw new KeyNotFoundException());
        }