MVCSendGripJenkinsProDev.Areas.HelpPage.HelpPageSampleGenerator.GetSampleObject C# (CSharp) Method

GetSampleObject() public method

Gets the sample object that will be serialized by the formatters. First, it will look at the SampleObjects. If no sample object is found, it will try to create one using ObjectGenerator.
public GetSampleObject ( Type type ) : object
type System.Type The type.
return object
        public virtual object GetSampleObject(Type type)
        {
            object sampleObject;

            if (!SampleObjects.TryGetValue(type, out sampleObject))
            {
                // Try create a default sample object
                ObjectGenerator objectGenerator = new ObjectGenerator();
                sampleObject = objectGenerator.GenerateObject(type);
            }

            return sampleObject;
        }