/// <summary> /// Возвращает форму запроса. /// </summary> protected TDocument ReadRequestForm <TDocument>(IHttpRequest request, string documentFormKey) { if (request.Headers.ContentType.StartsWith(HttpConstants.MultipartFormDataContentType, StringComparison.OrdinalIgnoreCase) || request.Headers.ContentType.StartsWith(HttpConstants.FormUrlencodedContentType, StringComparison.OrdinalIgnoreCase)) { if (request.Form != null) { var documentString = (string)request.Form[documentFormKey]; if (!string.IsNullOrWhiteSpace(documentString)) { return(_objectSerializer.Deserialize <TDocument>(documentString)); } } } else if (request.Headers.ContentType.StartsWith(HttpConstants.JsonContentType, StringComparison.OrdinalIgnoreCase)) { if (request.Form != null) { return(_objectSerializer.ConvertFromDynamic <TDocument>((object)request.Form)); } } else if (request.Content != null) { return(_objectSerializer.Deserialize <TDocument>(request.Content)); } return(default(TDocument)); }
public override void OnBeforeStart() { _log.Info("Creating the document storage started."); var documentTypes = _metadataApi.GetMetadataItemNames("Documents"); foreach (var documentType in documentTypes) { var documentMetadata = new DocumentMetadata { Type = documentType }; var documentIndexes = _metadataApi.GetDocumentIndexes(documentType); if (documentIndexes != null) { documentMetadata.Indexes = documentIndexes.Select(i => _jsonObjectSerializer.ConvertFromDynamic <DocumentIndex>(i)).ToArray(); } // Специально для Mono пришлось выполнять создание коллекций в последовательном режиме AsyncHelper.RunSync(() => CreateStorageAsync(documentMetadata)); } _log.Info("Creating the document storage successfully completed."); }
public static T ConvertFromDynamic <T>(this IJsonObjectSerializer target, object value) { return((T)target.ConvertFromDynamic(value, typeof(T))); }