public async Task Register(ModificationContext modificationContext, IJSEngine engine) { string jsonContent = string.Empty; using (StreamReader reader = new StreamReader(modificationContext.ContentStream, GetEncoding(modificationContext.ContentType))) { jsonContent = await reader.ReadToEndAsync(); } _content = new StringBuilder(jsonContent); engine.InitializeJsonApi(_content); }
public async Task Register(ModificationContext modificationContext, IJSEngine engine) { string html = string.Empty; using (StreamReader reader = new StreamReader(modificationContext.ContentStream, GetEncoding(modificationContext.ContentType))) { html = await reader.ReadToEndAsync(); } if (!string.IsNullOrEmpty(html)) { _htmlDocument = new HtmlDocument(); _htmlDocument.LoadHtml(html); } engine.InitializeHtmlDocumentApi(_htmlDocument); }
public async Task Register(ModificationContext modificationContext, IJSEngine engine) { string content = string.Empty; var encoding = GetEncoding(modificationContext.ContentType); if (encoding == null) { return; } using (StreamReader reader = new StreamReader(modificationContext.ContentStream, encoding)) { content = await reader.ReadToEndAsync(); } _content = new StringBuilder(content); engine.InitializeContentApi(_content); }
public PrettyPrint(IJSEngine engine) { _engine = engine; }
public TimerCallsHelper(IJSEngine engine) { _engine = engine; }
public Command(BaseOption option) { _baseOption = option; _scope = IoCContainerBuilder.Build(option); _engine = _scope.Resolve <IJSEngine>(); }
public static string[] GetObjectPropertyNames(this IJSEngine engine, JavaScriptValue obj) { return(engine.GlobalObject.CallFunction <JavaScriptValue, string>("_getOwnPropertyNames", obj) .Split(",")); }
public static void AssignToUnderscore(this IJSEngine engine, JavaScriptValue self) { engine.GlobalObject.CallMethod("_assignToUnderscore", self); }
public static int GetArraySize(this IJSEngine engine, JavaScriptValue array) { Debug.Assert(array.ValueType == JavaScriptValueType.Array); return(engine.GlobalObject.CallFunction <JavaScriptValue, string, int>("_getOwnProperty", array, "length")); }
public static string GetFunctionToString(this IJSEngine engine, JavaScriptValue func) { Debug.Assert(func.ValueType == JavaScriptValueType.Function); return(new JSValue(engine.ServiceNode, func).CallFunction <string>("toString")); }
public static JavaScriptValue GetObjectProperty(this IJSEngine engine, JavaScriptValue obj, string propertyName) { return(engine.GlobalObject .CallFunction <JavaScriptValue, string, JavaScriptValue>("_getOwnProperty", obj, propertyName)); }
public async Task Register(ModificationContext modificationContext, IJSEngine engine) { FormCollection formFields = null; MediaTypeHeaderValue contentType; MediaTypeHeaderValue.TryParse(modificationContext.ContentType, out contentType); _originalEncoding = contentType?.Encoding ?? Encoding.UTF8; if (HasApplicationFormContentType(contentType)) { var encoding = FilterEncoding(contentType.Encoding); using (var formReader = new FormReader(modificationContext.ContentStream, encoding) { ValueCountLimit = _options.Value.FormOptions.ValueCountLimit, KeyLengthLimit = _options.Value.FormOptions.KeyLengthLimit, ValueLengthLimit = _options.Value.FormOptions.ValueLengthLimit, }) { formFields = new FormCollection(await formReader.ReadFormAsync()); } } else if (HasMultipartFormContentType(contentType)) { _isMultiPart = true; _originalBoundary = GetBoundary(contentType, _options.Value.FormOptions.MultipartBoundaryLengthLimit); formFields = await GetMultipartFormCollection(modificationContext); } _internalForm = formFields ?? FormCollection.Empty; if (modificationContext.ContentStream.CanSeek) { modificationContext.ContentStream.Seek(0, SeekOrigin.Begin); } _formFieldContainer = new Dictionary <string, List <string> >(); foreach (var field in _internalForm) { foreach (var value in field.Value) { if (_formFieldContainer.ContainsKey(field.Key)) { _formFieldContainer[field.Key].Add(value); } else { _formFieldContainer.Add(field.Key, new List <string> { value }); } } } engine.InitializeFormApi(_formFieldContainer, _formFiles); }
public CompleteHandler(IJSEngine engine) { _engine = engine; }