sep24images.Areas.HelpPage.HelpPageSampleGenerator.GetActionSample C# (CSharp) Method

GetActionSample() public method

Search for samples that are provided directly through ActionSamples.
public GetActionSample ( string controllerName, string actionName, IEnumerable parameterNames, Type type, System.Net.Http.Formatting.MediaTypeFormatter formatter, MediaTypeHeaderValue mediaType, SampleDirection sampleDirection ) : object
controllerName string Name of the controller.
actionName string Name of the action.
parameterNames IEnumerable The parameter names.
type System.Type The CLR type.
formatter System.Net.Http.Formatting.MediaTypeFormatter The formatter.
mediaType System.Net.Http.Headers.MediaTypeHeaderValue The media type.
sampleDirection SampleDirection The value indicating whether the sample is for a request or for a response.
return object
        public virtual object GetActionSample(string controllerName, string actionName, IEnumerable<string> parameterNames, Type type, MediaTypeFormatter formatter, MediaTypeHeaderValue mediaType, SampleDirection sampleDirection)
        {
            object sample;

            // First, try get sample provided for a specific mediaType, controllerName, actionName and parameterNames.
            // If not found, try get the sample provided for a specific mediaType, controllerName and actionName regardless of the parameterNames
            // If still not found, try get the sample provided for a specific type and mediaType
            if (ActionSamples.TryGetValue(new HelpPageSampleKey(mediaType, sampleDirection, controllerName, actionName, parameterNames), out sample) ||
                ActionSamples.TryGetValue(new HelpPageSampleKey(mediaType, sampleDirection, controllerName, actionName, new[] { "*" }), out sample) ||
                ActionSamples.TryGetValue(new HelpPageSampleKey(mediaType, type), out sample))
            {
                return sample;
            }

            return null;
        }