Esempio n. 1
0
 internal RemoteEntities(IRequestInternal request, RESTarStream stream, ulong entityCount) : base(request)
 {
     RequestInternal     = request;
     Body                = stream;
     EntityType          = typeof(JObject);
     EntityCount         = entityCount;
     IsSerialized        = true;
     ContentTypeProvider = ContentTypeController.ResolveOutputContentTypeProvider(RequestInternal);
 }
Esempio n. 2
0
        public override ISerializedResult Serialize(ContentType?contentType = null)
        {
            if (IsSerialized)
            {
                return(this);
            }
            if (!HasResource)
            {
                return(base.Serialize(contentType));
            }
            var stopwatch   = Stopwatch.StartNew();
            var optionsBody = new OptionsBody(Resource.Name, Resource.ResourceKind, Resource.AvailableMethods);
            var provider    = ContentTypeController.ResolveOutputContentTypeProvider(null, contentType);

            Body = new MemoryStream();
            provider.SerializeCollection(new[] { optionsBody }, Body);
            this.Finalize(provider);
            IsSerialized = true;
            stopwatch.Stop();
            TimeElapsed     = TimeElapsed + stopwatch.Elapsed;
            Headers.Elapsed = TimeElapsed.TotalMilliseconds.ToString(CultureInfo.InvariantCulture);
            return(this);
        }