OperationResult

public class OperationResult<T> {

private readonly ConcurrentDictionary<string, T> _values =

new ConcurrentDictionary<string, T>();

public OperationResult() { }

public OperationResult(bool success) : this(success, String.Empty) { }

public OperationResult(string message) : this(false, message) { }

public OperationResult(bool success, string message) : this() {
Success = success;
Message = message;
}

public int Count {
get { return _values.Count; }
}

public T this[string key] {
get { return _values[key]; }
set { _values[key] = value; }
}

public string Message { get; set; }

public bool Success { get; set; }

public override string ToString() {
return String.Format("{0}:{1}{2}", Success ? "PASS" : "FAIL", Message,
Count == 0 ? String.Empty :
String.Format("({0})", String.Join(";", _values.OrderBy(o => o.Key)
.Select(s => String.Format("{0}:\"{1}\"", s.Key, s.Value)))));
}
}

 

posted on 2015-12-13 20:59  武胜-阿伟  阅读(830)  评论(0编辑  收藏  举报