static StackObject *ReadAsync_4(ILIntepreter __intp, StackObject *__esp, IList <object> __mStack, CLRMethod __method, bool isNewObj) { ILRuntime.Runtime.Enviorment.AppDomain __domain = __intp.AppDomain; StackObject *ptr_of_this_method; StackObject *__ret = ILIntepreter.Minus(__esp, 1); ptr_of_this_method = ILIntepreter.Minus(__esp, 1); System.Xml.XmlReader instance_of_this_method = (System.Xml.XmlReader) typeof(System.Xml.XmlReader).CheckCLRTypes(StackObject.ToObject(ptr_of_this_method, __domain, __mStack), (CLR.Utils.Extensions.TypeFlags) 0); __intp.Free(ptr_of_this_method); var result_of_this_method = instance_of_this_method.ReadAsync(); object obj_result_of_this_method = result_of_this_method; if (obj_result_of_this_method is CrossBindingAdaptorType) { return(ILIntepreter.PushObject(__ret, __mStack, ((CrossBindingAdaptorType)obj_result_of_this_method).ILInstance)); } return(ILIntepreter.PushObject(__ret, __mStack, result_of_this_method)); }
public async System.Threading.Tasks.Task ReadXmlAsync(Action <int> percentProgress) { string xmlPath = xmlFile; // Счетчик элементов int i = 0; // Инициализация XMLReader System.IO.FileStream sr = new System.IO.FileStream(xmlPath, System.IO.FileMode.Open, System.IO.FileAccess.Read); System.Xml.XmlReaderSettings _settings = new System.Xml.XmlReaderSettings() { Async = true }; System.Xml.XmlReader rdr = System.Xml.XmlReader.Create(sr, _settings); long lastPosition = 0; while (await rdr.ReadAsync()) { rdr.MoveToContent(); // Новая строка BulkData _pair = new BulkData(tableDefinition, typesList); // Чтение элемента while (rdr.MoveToNextAttribute()) { if (rdr.NodeType == System.Xml.XmlNodeType.Attribute) { _pair.InsertCell(rdr.Name.ToLower(), rdr.Value); } } i += 1; percentage = (int)Math.Round((double)(sr.Position / sr.Length), 2) * 100; if (lastPosition != sr.Position) { lastPosition = sr.Position; percentage = (int)(100.0 * lastPosition / sr.Length); percentProgress(percentage); } // Вставка CancellationTokenSource source = new CancellationTokenSource(); CancellationToken token = source.Token; await _wrt.WriteRowAsync(token, _pair.GetRow()); //Проверяем достигнут ли максимальный размер списка if (i == bulkSize) { await _wrt.CompleteAsync(); await _wrt.CloseAsync(); i = 0; _wrt = _conn.BeginBinaryImport(string.Format("COPY {0} ({1}) FROM STDIN (FORMAT BINARY)", _dbTableName, _dbColumns)); if (percentProgress != null) { percentProgress(percentage); } } } await _wrt.CompleteAsync(); if (percentProgress != null) { percentProgress(percentage); } await _wrt.CloseAsync(); await _conn.CloseAsync(); }