コード例 #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);
 }
コード例 #2
0
ファイル: Options.cs プロジェクト: Opportunity-Holding/RESTar
        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);
        }