本文整理汇总了C#中CacheItem.ToString方法的典型用法代码示例。如果您正苦于以下问题:C# CacheItem.ToString方法的具体用法?C# CacheItem.ToString怎么用?C# CacheItem.ToString使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类CacheItem
的用法示例。
在下文中一共展示了CacheItem.ToString方法的3个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。
示例1: CacheItemToStringNoException
public void CacheItemToStringNoException()
{
var item = new CacheItem<TestDTO>
{
CacheDuration = TimeSpan.FromSeconds(1),
ItemState = CacheItemState.New,
Method = "GET",
Parameters = new Dictionary<string, object> {{"key", "value"}},
ResponseText = "ResponseText",
RetryCount = 3,
Target = "target",
ThrottleScope = "throttleScope",
UriTemplate = "uriTemplate",
Url = "url",
Request = WebRequest.Create("http://tempuri.org")
};
item.Request.Headers = new WebHeaderCollection() { { "name", "value" } };
var actual = item.ToString();
const string expected = @"ItemState : New
Url : url
Method : GET
Target : target
UriTemplate : uriTemplate
Parameters :
key: ""value""
Request URI : http://tempuri.org/
Request Headers :
name: value
CacheDuration : 00:00:01
RetryCount : 3
ThrottleScope : throttleScope
Expiration : 0001-01-01 00:00:00Z
ResponseText : ResponseText
";
Assert.AreEqual(expected, actual);
}
示例2: DoAdd
private bool DoAdd(CacheItem ci)
{
if (ci == null)
{
LogManager.Warn("CacheManager:Assert Failure", "DoAdd a null item");
return true;
}
//Cache Item
bool added = m_cacheItems.TryAdd(ci.Key, ci);
if (added)
{
//Add the SchedulerKey at the same time
SchedulerKey sk = new SchedulerKey(ci.NextExpirationTime, ci.Key);
if (m_heap.ContainsKey(sk))
{
//This should not happen. If it does, then this is a critial bug!
LogManager.Warn("CacheManager:Assert Failure", string.Format("The SchedulerKey key[{0}] is already exising", sk.ToString()));
}
else
{
m_heap.Add(sk, DUMMY);
}
}
if (added)
{
LogManager.Info("CacheManager:DoAdd", string.Format("The key [{0}] is added, value=[{1}]", ci.Key, ci.ToString()));
}
else
{
LogManager.Info("CacheManager:DoAdd", string.Format("The key [{0}] is already existing", ci.Key));
}
return true;
}
示例3: CacheItemToStringNoExceptionNoRequest
public void CacheItemToStringNoExceptionNoRequest()
{
var item = new CacheItem<TestDTO>
{
CacheDuration = TimeSpan.FromSeconds(1),
ItemState = CacheItemState.New,
Method = "GET",
Parameters = new Dictionary<string, object> {{"key", "value"}},
ResponseText = "ResponseText",
RetryCount = 3,
Target = "target",
ThrottleScope = "throttleScope",
UriTemplate = "uriTemplate",
Url = "url"
};
var actual = item.ToString();
const string expected = @"ItemState : New
Url : url
Method : GET
Target : target
UriTemplate : uriTemplate
Parameters :
key: value
CacheDuration : 00:00:01
RetryCount : 3
ThrottleScope : throttleScope
Expiration : 1/1/0001 12:00:00 AM +00:00
ResponseText : ResponseText
";
Assert.AreEqual(expected, actual);
}