private static ReflectionResult GetLookUpDictionary(string property, object source) { try { var sourceAsList = (IDictionary <string, object>)source; return(new ReflectionResult { Result = sourceAsList[property] }); } catch (KeyNotFoundException e) { return(new ReflectionResult { ReflectionException = ReflectionException.KeyNotFound(property) }); } }
private static ReflectionResult GetNameValueCollection(string property, object source) { try { var sourceAsList = (NameValueCollection)source; return(new ReflectionResult { Result = sourceAsList[property] }); } catch (KeyNotFoundException e) { return(new ReflectionResult { ReflectionException = ReflectionException.KeyNotFound(property) }); } }
private static ReflectionResult GetJObject(string property, object source) { try { var json = (JObject)source; return(new ReflectionResult { Result = json[property] }); } catch (KeyNotFoundException e) { return(new ReflectionResult { ReflectionException = ReflectionException.KeyNotFound(property) }); } }
private static ReflectionResult GetDictionary(string property, object source) { try { var sourceAsList = (IDictionary)source; var result = new ReflectionResult { Result = sourceAsList[property] }; if (result.Result == null) { result.Full = sourceAsList.Contains(property); } return(result); } catch (KeyNotFoundException e) { return(new ReflectionResult { ReflectionException = ReflectionException.KeyNotFound(property) }); } }
private static ReflectionResult GetIndexer(string property, object source) { var result = GetSimple(property, source); if (result.ReflectionException == null) { return(result); } try { var sourceAsList = (IHaveIndexer)source; return(new ReflectionResult { Result = sourceAsList[property] }); } catch (KeyNotFoundException e) { return(new ReflectionResult { ReflectionException = ReflectionException.KeyNotFound(property) }); } }