public LiaraRequestParameters(ILiaraContext context) { this.context = context; if (context.Route.RequestModel != null) { isRequestContentAvailable = isRequestContentAvailabilitySet = true; internalContentType = ContentDeterminationType.Property; } else { internalContentType = ContentDeterminationType.Unknown; } }
public object GetFromContent(string key) { switch (internalContentType) { case ContentDeterminationType.Unknown: { if (IsRequestContentAvailable) { goto case ContentDeterminationType.Dictionary; } internalContentType = ContentDeterminationType.None; return(null); } case ContentDeterminationType.Dictionary: { try { var result = context.Request.Content[key]; internalContentType = ContentDeterminationType.Dictionary; return(result); } catch { goto case ContentDeterminationType.Property; } } case ContentDeterminationType.Property: { try { var prop = TypeCache.GetProperty(key); var result = prop.GetValue(context.Request.Content); internalContentType = ContentDeterminationType.Property; return(result); } catch { internalContentType = ContentDeterminationType.Dictionary; } break; } default: { return(null); } } return(null); }