Dev2.Diagnostics.DebugItem.TryCache C# (CSharp) Method

TryCache() public method

public TryCache ( IDebugItemResult item ) : void
item IDebugItemResult
return void
        public void TryCache(IDebugItemResult item)
        {
            if(item == null)
            {
                throw new ArgumentNullException("item");
            }

            if(!string.IsNullOrEmpty(item.Value) && item.Value.Length > MaxCharDispatchCount)
            {
                item.MoreLink = SaveFile(item.Value, string.Format("{0}-{1}.txt", DateTime.Now.ToString("s"), Guid.NewGuid()));
                item.Value = item.Value.Substring(0, ActCharDispatchCount);
            }
        }

Usage Example

        // ReSharper disable InconsistentNaming - Unit Test
        public void TryCache_With_ValueGreaterThanMaxCharDispatchCount_Expected_TruncatesValueToActCharDispatchCount()
        // ReSharper restore InconsistentNaming
        {
            var item = CreateDebugItemWithLongValue();

            var debugState = new DebugItem();
            debugState.TryCache(item);

            Assert.AreEqual(DebugItem.ActCharDispatchCount, item.Value.Length);
        }
All Usage Examples Of Dev2.Diagnostics.DebugItem::TryCache