Apistry.WebApiDocumentationProvider.CreateInstanceOfType C# (CSharp) Method

CreateInstanceOfType() private method

private CreateInstanceOfType ( Type type ) : Object
type System.Type
return Object
        private Object CreateInstanceOfType(Type type)
        {
            try
            {
                var fixture = new Fixture().Customize(new CompositeCustomization(new ObjectHydratorCustomization()));
                fixture.Behaviors.Remove(new ThrowingRecursionBehavior());
                fixture.Behaviors.Add(new OmitOnRecursionBehavior());

                return fixture.Create(type, new SpecimenContext(fixture));

                // We encounter race conditions with AutoFixture when using a field below.

                // var fixture = _Fixture.Value;
                // return fixture.Create(type, new SpecimenContext(fixture));
            }
            catch
            {
                return null;
            }
        }