/// <summary> /// Sets value to the buffer /// </summary> /// <param name="Buffer"></param> public void SetBuffer(byte[] Buffer) { NumberUnion nu = new NumberUnion(); switch (Type) { case LDF_Constant.Int16: BufferConverter.SetBytesInt16_BE(Buffer, nu, Convert.ToInt16(Value), Location); break; case LDF_Constant.UInt16: BufferConverter.SetBytesUInt16_BE(Buffer, nu, Convert.ToUInt16(Value), Location); break; case LDF_Constant.Int32: BufferConverter.SetBytesInt32_BE(Buffer, nu, Convert.ToInt32(Value), Location); break; case LDF_Constant.Float32: BufferConverter.SetBytesFloat_BE(Buffer, nu, Convert.ToSingle(Value) / ConversionFactor, Location); break; case LDF_Constant.String: string v = (Value.Length > Length) ? Value.Substring(0, Length) : Value; BufferConverter.SetBytesString(Buffer, nu, v, Length + 1, Location); break; default: break; } }
/// <summary> /// Sets value to the buffer /// </summary> /// <param name="Buffer"></param> public void GetBuffer(byte[] Buffer) { NumberUnion nu = new NumberUnion(); switch (Type) { case LDF_Constant.Int16: this.Value = BufferConverter.GetBytesInt16_BE(Buffer, nu, Location).ToString(); break; case LDF_Constant.UInt16: this.Value = BufferConverter.GetBytesUInt16_BE(Buffer, nu, Location).ToString(); break; case LDF_Constant.Int32: this.Value = BufferConverter.GetBytesInt32_BE(Buffer, nu, Location).ToString(); break; case LDF_Constant.Float32: this.Value = BufferConverter.GetBytesFloat_BE(Buffer, nu, Location).ToString(); break; case LDF_Constant.String: this.Value = BufferConverter.GetBytesString(Buffer, nu, Length, Location); break; default: break; } }
public void Bind() { if (this.Target != null && this.Read(out object value)) { MetadataIdentity metadata = this.Target.Identity.Metadata; ColumnMetadata column = this.Column?.Metadata; BufferConverter converter = CommandCache.GetConverter(metadata, column); this.Target.Update(converter(value)); this.Target.Commit(); } }
/// <summary> /// Creates the constant from the string input /// </summary> /// <param name="input">string as in SEG-Y EBCDIC Header file</param> public SEGY_Constant(int line, byte[] input) { int offset = line * 80; NumberUnion nu = new NumberUnion(); string s = BufferConverter.GetEBCDICBytesString(input, nu, 3, offset); if (s.Length < 3) { line++; s = "C" + line.ToString().PadLeft(2); } Name = s; Value = BufferConverter.GetEBCDICBytesString(input, nu, 77, offset); Unit = ""; Description = "Comment line " + s + "."; }
public override void PerformLayout() { base.PerformLayout(); Action <object, string, string> fileOpenAction = (jsBlob, textContent, dataUrl) => { var eventArgs = new FileUploadEventArgs(jsBlob, textContent, dataUrl); FileOpened?.Invoke(this, eventArgs); Command?.Execute(new ICommandParameter(eventArgs)); }; Action <object> changeAction = evt => { var input = Verbatim.Expression("evt.target"); var file = Verbatim.Expression("$0.files[0]", input); FileName = (string)Verbatim.Expression("$0.name", file); var reader = Verbatim.Expression("new FileReader()"); Action onLoadAction = () => { var jsBlob = Verbatim.Expression("$0.result", reader); //string fileMimeType = (string)Verbatim.Expression("$0.type", file); string textContent = null; string dataUrl = null; switch (UploadType) { case FileUploadType.TextFile: switch (FileEncoding) { case FileReaderEncoding.ASCII: textContent = jsBlob as string; break; case FileReaderEncoding.UTF8: textContent = BufferConverter.ArrayBufferToStringUTF8(jsBlob); break; case FileReaderEncoding.UTF16: textContent = BufferConverter.ArrayBufferToStringUTF16(jsBlob); break; } break; case FileUploadType.ImageFile: dataUrl = jsBlob as string; break; } fileOpenAction(jsBlob, textContent, dataUrl); }; Verbatim.Expression("$0.onload = $1", reader, onLoadAction); switch (UploadType) { case FileUploadType.TextFile: case FileUploadType.BinaryFile: if (FileEncoding == FileReaderEncoding.ASCII) { Verbatim.Expression("$0.readAsText($1);", reader, file); } else { Verbatim.Expression("$0.readAsArrayBuffer($1);", reader, file); } break; case FileUploadType.ImageFile: Verbatim.Expression("$0.readAsDataURL($1);", reader, file); break; } }; InternalJQElement.BindEventListener("change", changeAction); }