当前位置: 首页>>代码示例>>C#>>正文


C# CacheItem.ToString方法代码示例

本文整理汇总了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);


        }
开发者ID:psrodriguez,项目名称:CIAPI.CS,代码行数:44,代码来源:CacheItemFixture.cs

示例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;
        }
开发者ID:killbug2004,项目名称:cosps,代码行数:36,代码来源:CacheManager.cs

示例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);


        }
开发者ID:zeeshandad,项目名称:CIAPI.CS,代码行数:36,代码来源:CacheItemFixture.cs


注:本文中的CacheItem.ToString方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。