@@ -5,43 +5,34 @@ This Source Code Form is subject to the terms of the
55at http://mozilla.org/MPL/2.0/.
66----------------------------------------------------------*/
77using Microsoft . AspNetCore . Http ;
8- using OneScript . Commons ;
98using OneScript . Contexts ;
10- using OneScript . StandardLibrary ;
119using OneScript . StandardLibrary . Binary ;
12- using OneScript . Web . Server ;
13- using OneScript . StandardLibrary . Http ;
14- using OneScript . StandardLibrary . Processes ;
15- using OneScript . StandardLibrary . Text ;
1610using OneScript . Values ;
1711using ScriptEngine . Machine ;
1812using ScriptEngine . Machine . Contexts ;
19- using System ;
20- using System . Text ;
21- using System . Threading . Tasks ;
2213using OneScript . StandardLibrary . Collections ;
23- using OneScript . Types ;
2414
2515namespace OneScript . Web . Server
2616{
2717 [ ContextClass ( "HTTPСервисЗапрос" , "HTTPServiceRequest" ) ]
2818 public class HttpRequestWrapper : AutoContext < HttpRequestWrapper >
2919 {
3020 private readonly HttpRequest _request ;
21+ private readonly PropertyWrappersCollection _wrappers = new ( ) ;
3122
3223 public HttpRequestWrapper ( HttpRequest request )
3324 {
3425 _request = request ;
3526 }
3627
3728 [ ContextProperty ( "Параметры" , "Parameters" , CanWrite = false ) ]
38- public FixedMapImpl Query => _request . Query . ToFixedMap ( ) ;
29+ public FixedMapImpl Query => _wrappers . Get ( nameof ( Query ) , ( ) => _request . Query . ToFixedMap ( ) ) ;
3930
4031 [ ContextProperty ( "ЕстьФормыВТипеКонтента" , "HasFormContentType" , CanWrite = false ) ]
41- public IValue HasFormContentType => BslBooleanValue . Create ( _request . HasFormContentType ) ;
32+ public bool HasFormContentType => _request . HasFormContentType ;
4233
4334 [ ContextProperty ( "Тело" , "Body" , CanWrite = false ) ]
44- public GenericStream Body => new ( _request . Body ) ;
35+ public GenericStream Body => _wrappers . Get ( nameof ( Body ) , ( ) => new GenericStream ( _request . Body ) ) ;
4536
4637 [ ContextProperty ( "ТипКонтента" , "ContentType" , CanWrite = false ) ]
4738 public IValue ContentType
@@ -68,13 +59,13 @@ public IValue ContentLength
6859 }
6960
7061 [ ContextProperty ( "Куки" , "Cookie" , CanWrite = false ) ]
71- public RequestCookieCollectionWrapper Cookies => new ( _request . Cookies ) ;
62+ public RequestCookieCollectionWrapper Cookies => _wrappers . Get ( nameof ( Cookies ) , ( ) => new RequestCookieCollectionWrapper ( _request . Cookies ) ) ;
7263
7364 [ ContextProperty ( "Заголовки" , "Headers" , CanWrite = false ) ]
74- public HeaderDictionaryWrapper Headers => new ( _request . Headers ) ;
65+ public HeaderDictionaryWrapper Headers => _wrappers . Get ( nameof ( Headers ) , ( ) => new HeaderDictionaryWrapper ( _request . Headers ) ) ;
7566
7667 [ ContextProperty ( "Протокол" , "Protocol" , CanWrite = false ) ]
77- public IValue Protocol => BslStringValue . Create ( _request . Protocol ) ;
68+ public string Protocol => _request . Protocol ;
7869
7970 [ ContextProperty ( "СтрокаПараметров" , "ParametersString" , CanWrite = false ) ]
8071 public IValue QueryString
@@ -125,21 +116,21 @@ public IValue Host
125116 }
126117
127118 [ ContextProperty ( "ЭтоHttps" , "IsHttps" , CanWrite = false ) ]
128- public IValue IsHttps => BslBooleanValue . Create ( _request . IsHttps ) ;
119+ public bool IsHttps => _request . IsHttps ;
129120
130121 [ ContextProperty ( "Схема" , "Scheme" , CanWrite = false ) ]
131- public IValue Scheme => BslStringValue . Create ( _request . Scheme ) ;
122+ public string Scheme => _request . Scheme ;
132123
133124 [ ContextProperty ( "Метод" , "Method" , CanWrite = false ) ]
134- public IValue Method => BslStringValue . Create ( _request . Method ) ;
125+ public string Method => _request . Method ;
135126
136127 [ ContextProperty ( "Форма" , "Form" , CanWrite = false ) ]
137128 public IValue Form
138129 {
139130 get
140131 {
141132 if ( _request . HasFormContentType )
142- return new FormCollectionWrapper ( _request . Form ) ;
133+ return _wrappers . Get ( nameof ( Form ) , ( ) => new FormCollectionWrapper ( _request . Form ) ) ;
143134 else
144135 return BslUndefinedValue . Instance ;
145136 }
0 commit comments