Example #1
0
        /// <summary>
        /// Puts view model result to the bundle.
        /// </summary>
        /// <typeparam name="TResult">The type of the view model result.</typeparam>
        /// <param name="bundle">The bundle to put view model result.</param>
        /// <param name="result">The view model result. Can be <c>null</c>.</param>
        /// <exception cref="ArgumentNullException"><paramref name="bundle"/> is <c>null</c>.</exception>
        public static void PutResult <TResult>(this Bundle bundle, TResult?result)
            where TResult : Result
        {
            if (bundle == null)
            {
                throw new ArgumentNullException(nameof(bundle));
            }

            var resultNativeBundleOwner = (INativeBundleOwner?)result?.ExportBundle();
            var resultNativeBundle      = resultNativeBundleOwner?.ExportNativeBundle();

            if (resultNativeBundle != null)
            {
                bundle.PutBundle(ResultKey, resultNativeBundle);
            }
        }