// Gets the value, if the key exists public static string GetStr(string key) { string testStr = string.Empty; IGFSerializable cValue = m_region.Get(key); // Is the key found? if (cValue != null) { testStr = cValue.ToString(); // Type of value? if (cValue is CacheableBytes) { System.Text.StringBuilder sb = new System.Text.StringBuilder(); CacheableBytes cBytes = cValue as CacheableBytes; foreach (byte b in cBytes.Value) { sb.Append((char)b); } testStr = sb.ToString(); } else if (cValue is CacheableObjectXml) { object val = ((CacheableObjectXml)cValue).Value; System.Xml.XmlDocument xd = val as System.Xml.XmlDocument; if (xd != null) { testStr = xd.OuterXml; } } Console.WriteLine("Get [{0}] -- key: {1}, value: {2}", cValue.GetType().Name, key, testStr); } else { testStr = "NULL"; Console.WriteLine("No such key in region: " + key); } return(testStr); }
public override object Get(object key) { string cachableKey = GetCachableKey(key); IGFSerializable cacheableValue = region.Get(cachableKey); if (cacheableValue == null) { return(null); } CacheableObject cacheableObject = cacheableValue as CacheableObject; if (cacheableObject != null) { return(cacheableObject.Value); } throw new ArgumentException(String.Format("The value type [{0}] is not CacheableObject", cacheableValue.GetType())); }