예제 #1
0
파일: Ensure.cs 프로젝트: adamralph/Radical
        /// <summary>
        /// Initialize a new instance of the generic Ensure class using the supplied
        /// value as the value to insepct.
        /// </summary>
        /// <typeparam name="T">The type of the inepcted object value.</typeparam>
        /// <param name="obj">The object value to inspect.</param>
        /// <param name="strategy">Determines if the Ensure instance should load the current Stack.</param>
        /// <returns>The Ensure instance for fluent interface usage.</returns>
        public static IConfigurableEnsure <T> That <T>(T obj, SourceInfoLoadStrategy strategy)
        {
            var si = SourceInfo.Empty;

            if (strategy != Validation.SourceInfoLoadStrategy.Skip)
            {
                var lazy = strategy == Validation.SourceInfoLoadStrategy.LazyLoad;
                si = SourceInfo.FromStack(new StackTrace(1), lazy: lazy);
            }

            return(new Ensure <T>(obj, si));
        }