public WebApiRuntimeServiceModelReflector(ServiceModelReflectionOptions options, HttpConfiguration configuration, Assembly referencingAssembly, string hostname)
 {
     this.referencingAssembly = referencingAssembly;
     this.hostname = hostname;
     this.options = options;
     this.configuration = configuration;
 }
示例#2
0
        public HttpResponseMessage Fickle()
        {
            var options = new ServiceModelReflectionOptions
            {
                ControllersTypesToIgnore = new[] { this.GetType() }
            };

            var reflector = new WebApiRuntimeServiceModelReflector(options, this.Configuration, this.GetType().Assembly, Request.RequestUri.Host);
            var serviceModel = reflector.Reflect();

            var content = new PushStreamContent(
                (stream, httpContent, transportContext) =>
                {
                    using (var streamWriter = new StreamWriter(stream))
                    {
                        var writer = new FicklefileWriter(streamWriter);
                        writer.Write(serviceModel);
                    }
                },
                new MediaTypeHeaderValue("text/fickle"));

            var response = new HttpResponseMessage
            {
                Content = content
            };

            return response;
        }
示例#3
0
        private static Model.ServiceModel ReflectServiceModel()
        {
            var options = new ServiceModelReflectionOptions();

            var configuration = new HttpConfiguration();

            configuration.Routes.MapHttpRoute
                (
                    name: "DefaultApi",
                    routeTemplate: "api/{controller}/{action}"
                );

            configuration.EnsureInitialized();

            var assembly = Assembly.Load("Fickle.WebApi.Tests.ServiceModel");

            var reflector = new WebApiRuntimeServiceModelReflector(options, configuration, assembly, "localhost");
            return reflector.Reflect();
        }