Beispiel #1
0
        public override ODataSerializer GetODataPayloadSerializer(Type type, HttpRequestMessage request)
        {
            if (typeof(IEdmModel).IsAssignableFrom(type))
            {
                IServiceProvider oldProvider = request.Properties[RequestContainerKey] as IServiceProvider;

                IContainerBuilder builder = new DefaultContainerBuilder();
                builder.AddDefaultODataServices();
                builder.AddService <IEdmModel>(ServiceLifetime.Singleton, sp => CreateEdmModel());

                builder.AddService <IODataPathHandler, DefaultODataPathHandler>(ServiceLifetime.Singleton);

                builder.AddServicePrototype(new ODataMessageWriterSettings
                {
                    EnableMessageStreamDisposal = false,
                    MessageQuotas = new ODataMessageQuotas {
                        MaxReceivedMessageSize = Int64.MaxValue
                    },
                });

                IServiceProvider serviceProvider = builder.BuildContainer();

                request.Properties[RequestContainerKey] = serviceProvider;

                return(new MyMetadataSerializer(oldProvider));
            }

            return(base.GetODataPayloadSerializer(type, request));
        }