コード例 #1
0
        public Try(Func <TResult> function) : base()
        {
            Results = new TryResult <object> [1];

            TResult resultObject;

            Success    = TryUtility.Try(function, out resultObject);
            Results[0] = new TryResult <object>(resultObject, Success);
        }
コード例 #2
0
ファイル: TryResultT.cs プロジェクト: welrocken/xamn
        public bool Equals(TryResult <TResult> tryResult)
        {
            if ((object)tryResult == null)
            {
                return(false);
            }

            return(Success == tryResult.Success && Object.Equals(tryResult.Object));
        }
コード例 #3
0
        public Try With(Action action)
        {
            var results = new TryResult[Results.Length + 1];

            Results.CopyTo(results, 0);

            results[results.Length - 1] = new Try(action).Results[0];

            return(new Try(results));
        }
コード例 #4
0
        public Try <TResultNew> With <TResultNew>(Func <TResultNew> function)
        {
            var results = new TryResult <object> [Results.Length + 1];

            Results.CopyTo(results, 0);

            var result = new Try <TResultNew>(function);

            results[results.Length - 1] = new TryResult <object>(result.Result.Object, result.Result.Success);

            return(new Try <TResultNew>(results));
        }
コード例 #5
0
 public Try()
 {
     Results    = new TryResult[1];
     Results[0] = new TryResult(false);
 }
コード例 #6
0
 public Try(Action action)
 {
     Results    = new TryResult[1];
     Results[0] = new TryResult(TryUtility.Try(action));
 }
コード例 #7
0
 protected Try(TryResult[] results)
 {
     Results = new TryResult[results.Length];
     results.CopyTo(Results, 0);
 }
コード例 #8
0
 public Try() : base()
 {
     Results = new TryResult <object> [1];
     Results[Results.Length - 1] = new TryResult <object>(default(TResult), false);
 }
コード例 #9
0
 protected Try(TryResult <object>[] results) : base(results)
 {
     Results = new TryResult <object> [results.Length];
     results.CopyTo(Results, 0);
 }