您的位置:首页 > 运维架构

OperationResult

2015-12-13 20:59 225 查看
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)))));
}
}
内容来自用户分享和网络整理,不保证内容的准确性,如有侵权内容,可联系管理员处理 点击这里给我发消息
标签: