private void BulkUpdate(IEnumerable <ObjectDescriptor> updates) { var spliter = new EntityDescriptorSpliter { MaxCount = _WebView.GetMaxAcceptableArguments() - 1 }; var packer = new ObjectChildrenDescriptionPacker(); foreach (var entityDescriptor in spliter.SplitParameters(updates)) { var arguments = GetUpdateParameters(entityDescriptor, packer); BulkObjectsUpdater.ExecuteFunctionNoResult(_WebView, null, arguments); } }
public static IEnumerable <IJavascriptObject[]> Slice(this IWebView webView, IEnumerable <IJavascriptObject> elements) { var slicer = new Slicer <IJavascriptObject>(elements, webView.GetMaxAcceptableArguments()); return(slicer.Slice()); }
private CfrV8Value FactoryCreator() { var builderScript = @"(function(){ const maxCount = {{MaxFunctionArgumentsNumber}} function pushResult(fn, array){ const count = array.length if (count < maxCount) { fn.apply(null, array) return; } for(var index = 0; index< count;) { var length = Math.min(count - index, maxCount) var subArray = [] while (length--) { subArray.push(array[index++]); } fn.apply(null, subArray) } } function objectWithId(id, readOnly){ Object.defineProperty(this, '{{NeutroniumConstants.ObjectId}}', {value: id}); Object.defineProperty(this, '{{NeutroniumConstants.ReadOnlyFlag}}', {value: readOnly}); } function createObject(id, readOnly){ return new objectWithId(id, readOnly) } function createArray(id){ const res = [] Object.defineProperty(res, '{{NeutroniumConstants.ObjectId}}', {value: id}); return res } function pushObjects(array, id, number, readOnly){ while (number--) { array.push(new objectWithId(id++, readOnly)) } return id; } function createBulkObject(id, noneNumber, readWriteNumber, observableNumber, observableReadOnlyNumber, fn){ const numbers = [noneNumber, readWriteNumber, observableNumber, observableReadOnlyNumber] const array = [] numbers.forEach((number, index) => { id = pushObjects(array, id, number, index) }) pushResult(fn, array) } function createBulkBasic(values, fn){ const array = eval(values) pushResult(fn, array) } function createBulkArray(id, size, fn){ const array = [] while (size --) { array.push(createArray(id++)) } pushResult(fn, array) } function createBulkObjectWithConstructor(id, number, constructor, fn){ const array = [] const allArgs = Array.from(arguments) const args = allArgs.slice(4) while (number --) { array.push(new constructor(id++, ...args)) } pushResult(fn, array) } return { createObject, createBulkObject, createBulkArray, createBulkBasic, createBulkObjectWithConstructor }; }())"; var finalString = builderScript.Replace("{{MaxFunctionArgumentsNumber}}", $"{_WebView.GetMaxAcceptableArguments()}") .Replace(NeutroniumConstants.ObjectIdTemplate, NeutroniumConstants.ObjectId) .Replace(NeutroniumConstants.ReadOnlyFlagTemplate, NeutroniumConstants.ReadOnlyFlag); return(Eval(finalString)); }