private static HelpApiModel GenerateApiModel(ApiDescription apiDescription, HelpSampleGenerator sampleGenerator) { HelpApiModel apiModel = new HelpApiModel(); apiModel.ApiDescription = apiDescription; //try //{ foreach (var item in sampleGenerator.GetSampleRequests(apiDescription)) { apiModel.SampleRequests.Add(item.Key, item.Value); LogInvalidSampleAsError(apiModel, item.Value); } foreach (var item in sampleGenerator.GetSampleResponses(apiDescription)) { apiModel.SampleResponses.Add(item.Key, item.Value); LogInvalidSampleAsError(apiModel, item.Value); } //} //catch (Exception e) //{ // apiModel.ErrorMessages.Add(String.Format(CultureInfo.CurrentCulture, "An exception has occurred while generating the sample. Exception Message: {0}", e.Message)); //} return apiModel; }
/// <summary> /// Sets the help page sample generator. /// </summary> /// <param name="config">The <see cref="HttpConfiguration"/>.</param> /// <param name="sampleGenerator">The help page sample generator.</param> public static void SetHelpSampleGenerator(this HttpConfiguration config, HelpSampleGenerator sampleGenerator) { config.Properties.AddOrUpdate( typeof(HelpSampleGenerator), k => sampleGenerator, (k, o) => sampleGenerator); }