public override bool Parse(AsfParser parser) { ErrorCorrectionDataLength = (byte)(_errorCorrectionFlags & 0x0F); Attributes.Add(new FormattedAttribute <LAttribute, byte>(LAttribute.ErrorCorrectionDataLength, ErrorCorrectionDataLength)); bool opaqueDataPresent = ((_errorCorrectionFlags >>= 4) & 1) != 0; Attributes.Add(new FormattedAttribute <LAttribute, bool>(LAttribute.OpaqueDataPresent, opaqueDataPresent)); if (opaqueDataPresent) { Valid = false; } LengthType errorCorrectionLengthType = (LengthType)((_errorCorrectionFlags >>= 1) & 3); Attributes.Add(new FormattedAttribute <LAttribute, string>(LAttribute.ErrorCorrectionLengthType, errorCorrectionLengthType.PrettyPrint())); if (errorCorrectionLengthType != 0) { Valid = false; } bool errorCorrectionPresent = ((_errorCorrectionFlags >> 2) & 1) != 0; Attributes.Add(new FormattedAttribute <LAttribute, bool>(LAttribute.ErrorCorrectionPresent, errorCorrectionPresent)); return(Valid); }
public override bool Parse(AsfParser parser) { TypedValue = _lengthTypeFlags.ToString(); MultiplePayloadsPresent = (_lengthTypeFlags & 1) != 0; Attributes.Add(new FormattedAttribute <LAttribute, bool>(LAttribute.MultiplePayloadsPresent, MultiplePayloadsPresent)); SequenceType = (LengthType)((_lengthTypeFlags >>= 1) & 3); if (SequenceType != LengthType.ValueNotPresent) { Valid = false; } Attributes.Add(new FormattedAttribute <LAttribute, string>(LAttribute.SequenceType, SequenceType.PrettyPrint())); PaddingLengthType = (LengthType)((_lengthTypeFlags >>= 2) & 3); Attributes.Add(new FormattedAttribute <LAttribute, string>(LAttribute.PaddingLengthType, PaddingLengthType.PrettyPrint())); PacketLengthType = (LengthType)((_lengthTypeFlags >>= 2) & 3); Attributes.Add(new FormattedAttribute <LAttribute, string>(LAttribute.PacketLengthType, PacketLengthType.PrettyPrint())); bool errorCorrectionPresent = ((_lengthTypeFlags >>= 2) & 1) != 0; Attributes.Add(new FormattedAttribute <LAttribute, bool>(LAttribute.ErrorCorrectionPresent, errorCorrectionPresent)); return(Valid); }
/// <summary> /// Default constructor /// </summary> public PhysicalUnitTypeAttribute() { angleUnit = AngleType.Radian; lengthUnit = LengthType.Meter; timeUnit = TimeType.Second; massUnit = MassType.Kilogram; }
/// <summary> /// 写入一个字符串 /// </summary> /// <param name="content">待写入的字符串</param> /// <param name="lenType">写入的字符串长度类型</param> public void WriteUTF8String(string content, LengthType lenType) { byte[] bytes = System.Text.Encoding.UTF8.GetBytes(content); int max; if (lenType == LengthType.BYTE) { WriteByte(bytes.Length); max = byte.MaxValue; } else if (lenType == LengthType.SHORT) { WriteShort((short)bytes.Length); max = short.MaxValue; } else { WriteInt(bytes.Length); max = int.MaxValue; } if (bytes.Length > max) { WriteBytes(bytes, 0, max); } else { WriteBytes(bytes, 0, bytes.Length); } }
private uint GetLengthTypeValue(Stream inStream, long offsetToValue, LengthType valueSize, ref uint bytesRead) { uint lengthTypeValue = 0; switch (valueSize) { case LengthType.Byte: lengthTypeValue = (uint)(ParseFile.ParseSimpleOffset(inStream, offsetToValue, 1)[0]); bytesRead = 1; break; case LengthType.Word: lengthTypeValue = (uint)BitConverter.ToUInt16(ParseFile.ParseSimpleOffset(inStream, offsetToValue, 2), 0); bytesRead = 2; break; case LengthType.Dword: lengthTypeValue = BitConverter.ToUInt32(ParseFile.ParseSimpleOffset(inStream, offsetToValue, 4), 0); bytesRead = 4; break; } ; return(lengthTypeValue); }
public static string GetMatchTypeDisplayName(MatchType mt, LengthType len = LengthType.Long) { string dn = ""; string specialSuffix = ""; switch (len) { case LengthType.Short: specialSuffix = "*"; break; case LengthType.Long: specialSuffix = " (Special Consideration)"; break; } switch (mt.IsSpecialConsideration) { case true: dn = mt.MatchTypeName + specialSuffix; break; case false: dn = mt.MatchTypeName; break; } return(dn); }
protected void WriteLengh(int length, LengthType lengthType = LengthType.Int32) { switch (lengthType) { case LengthType.Byte: if (length > byte.MaxValue) { Debug.LogError("长度[" + length + "]大于" + byte.MaxValue); } Write((byte)length); break; case LengthType.Int16: if (length > Int16.MaxValue) { Debug.LogError("长度[" + length + "]大于" + Int16.MaxValue); } Write((Int16)length); break; case LengthType.Int32: if (length > Int32.MaxValue) { Debug.LogError("长度[" + length + "]大于" + Int32.MaxValue); } Write((Int32)length); break; default: break; } }
internal LengthValueBox(LayoutMeasure measure, LengthType type, Vector p1, Vector p2) : base(measure) { Type = type; P1 = p1; P2 = p2; TargetPosition = (p1 + p2) / 2; }
public static bool MaxLengthIsValid(LengthType lengthType, int maxlength) { bool isValid; switch (lengthType) { case LengthType.FIXED: isValid = maxlength <= _FIXEDMAXLENGTH; break; case LengthType.LLVAR: isValid = maxlength <= _LLVARMAXLENGTH; break; case LengthType.LLLVAR: isValid = maxlength <= _LLLVARMAXLENGTH; break; default: isValid = maxlength <= _FIXEDMAXLENGTH; break; } return isValid; }
public string ReadString(LengthType lengthType = LengthType.Int32) { var length = ReadLength(lengthType); var value = bytes.GetString(index, length); index += length; return(value); }
//Length public NetCommand(LengthType lengthtype, int length, int session) { Type = CommandType.LENGTH; Length = lengthtype; Session = session; Timestamp = Helper.Now; LengthValue = length; }
public BinaryWriter Write(byte[] bytes, LengthType lengthType = LengthType.Int32) { var length = bytes.Length; WriteLengh(length, lengthType); byteList.AddRange(bytes); return(this); }
public static LengthModel GetModel(LengthType type) { if (lengths.Count == 0) { Create(); } return(lengths[(int)type]); }
public Atrribute(AttributeFormat[] attributeFormat, LengthType lengthType, AttributeMask[] attributeMask, short maxLength, short length) { AttributeFormat = attributeFormat; AttributeMask = attributeMask; LengthType = lengthType; MaxLength = maxLength; Length = lengthType != LengthType.FIXED ? length : maxLength; }
public Atrribute(AttributeFormat[] characterFormat, LengthType lengthType, AttributeMask[] attributeMask, short maxLength) { AttributeFormat = characterFormat; LengthType = lengthType; AttributeMask = attributeMask; MaxLength = maxLength; Length = MaxLength; }
public BinaryWriter Write(string value, LengthType lengthType = LengthType.Int32) { var bytes = value.GetBytes(); var length = bytes.Length; WriteLengh(length, lengthType); byteList.AddRange(bytes); return(this); }
public Length(LengthType type, int value) { if (value > 100 || value < -100) { throw new ArgumentException($"Percentage length must be between -100 and 100%"); } Type = type; Value = value; }
public Length(string value, double defaultValue, LengthType defaultType) { Value = value; if (data == 0 && type == LengthType.None) { data = defaultValue; type = defaultType; } }
public static LengthModel_Ctrl CreateCtrl(LengthType type) { if (type.GetText() == "") { return(null); } return((LengthModel_Ctrl) Assembly.Load(AssemblyName).CreateInstance(type.GetText())); }
/// <summary> /// Constructor /// </summary> /// <param name="angleType">Type of angle</param> /// <param name="lengthType">Type of length</param> /// <param name="timeType">Type of time</param> /// <param name="massType">Type of mass</param> public PhysicalUnitTypeAttribute(AngleType angleType = AngleType.Radian, LengthType lengthType = LengthType.Meter, TimeType timeType = TimeType.Second, MassType massType = MassType.Kilogram) { this.angleUnit = angleType; this.lengthUnit = lengthType; this.timeUnit = timeType; this.massUnit = massType; }
public void TestCreateSingleItem(Enums.ResourceType resourceType, LengthType lengthType, Enums.TextType textType) { Phase phase = PhaseHelper.CreatePhaseInstance(creatingRequestRecords, resourceType); phase.Memo = Util.GetRandomText(textType, stringLength[lengthType]); string result = PhaseHelper.WriteResource(phase); Assert.That(result, Is.Not.Null.And.Not.Empty, string.Format("Cannot create phase for {0}", resourceType)); }
/// <summary> /// Common Constructor of Iso Field /// </summary> /// <param name="position">position of Field</param> /// <param name="maxLen">max Len of Field value</param> /// <param name="lengthType">length Type</param> /// <param name="contentType">content type</param> /// <param name="dataType">data type</param> /// <param name="lenDataType">length data type</param> /// <param name="encoding">Encoding type in case that the bytes are not in Common ASCII char set</param> public IsoFieldAttribute(IsoFields position, int maxLen, LengthType lengthType, ContentType contentType, DataType dataType = DataType.ASCII, DataType lenDataType = DataType.ASCII, EncodingType encoding = EncodingType.None) { Position = position; MaxLen = maxLen; LengthType = lengthType; ContentType = contentType; DataType = dataType; LenDataType = lenDataType; Encoding = encoding; }
/// <summary> /// /// </summary> /// <param name="lengthType"></param> /// <returns></returns> public Length ConvertTo(LengthType destType) { if (this._lengthType == destType) { return(this); } else { double r = _value * GetFactor(this._lengthType) / GetFactor(destType); return(new Length(r, destType)); } }
public void TestUpdateSingleItem(Enums.ResourceType resourceType, LengthType lengthType, Enums.TextType textType) { var phase = new Phase { Id = phaseReader.Data[$"{resourceType.ToPrivateEnum()}{0}"].FirstOrDefault().Id, Memo = Util.GetRandomText(textType, stringLength[lengthType]), }; string result = PhaseHelper.WriteResource(phase); Assert.That(result, Is.Not.Null.And.Not.Empty, string.Format("Cannot update phase memo for {0}", resourceType)); }
public byte[] ReadBytes(LengthType lengthType = LengthType.Int32) { var length = ReadLength(lengthType); var bytes = new byte[length]; for (int i = 0; i < length; i++) { bytes[i] = ReadByte(); } return(bytes); }
public void TestCreateListItem(Enums.ResourceType resourceType, LengthType lengthType, Enums.TextType textType) { var resourceList = new[] { 0, 1 }.Select(depKey => { Phase phase = PhaseHelper.CreatePhaseInstance(creatingRequestRecords, resourceType, depKey); phase.Memo = Util.GetRandomText(textType, stringLength[lengthType]); return(phase); }).ToList(); List <WriteResultItem> result = PhaseHelper.WritePhases(resourceList); Assert.That(result, MustBe.SuccessfullyWritten(2), string.Format("Cannot create phase for {0}", resourceType)); }
/// <summary> /// 读取一个值,值类型根据type决定,int或short或byte /// </summary> /// <param name="type">值类型</param> /// <returns>int数据</returns> public int ReadValue(LengthType type) { switch (type) { case LengthType.BYTE: return(ReadByteToInt()); case LengthType.SHORT: return((int)ReadShort()); default: return(ReadInt()); } }
public Vector() { d_alpha = new List <double>(); d_cosAlpha = new List <double>(); d_sinAlpha = new List <double>(); d_length = new List <double>(); d_lengthNorm = new List <double>(); d_equalLength = 10; d_pixelLength = 0; d_lengthType = LengthType.Axis; d_drawArrowHead = true; d_arrowHeadSize = -1; LineStyle = LineStyle.None; }
private static Color GetMeasureTypeColor(LengthType type) { switch (type) { default: case LengthType.Length: return(Color.Black); case LengthType.Width: return(Color.Blue); case LengthType.Height: return(Color.Red); } }
public void TestUpdateListItem(Enums.ResourceType resourceType, LengthType lengthType, Enums.TextType textType) { var resourceList = new[] { 0, 1 }.Select(depKey => { var phase = new Phase { Id = phaseReader.Data[$"{resourceType.ToPrivateEnum()}{depKey}"].FirstOrDefault().Id, Memo = Util.GetRandomText(textType, stringLength[lengthType]), }; return(phase); }); List <WriteResultItem> result = PhaseHelper.WritePhases(resourceList); Assert.That(result, MustBe.SuccessfullyWritten(2), string.Format("Cannot update phase memo for {0}", resourceType)); }
public void WriteString(string value, Encoding encoding, LengthType lengthType = LengthType.UInt32) { var bytes = encoding.GetBytes(value); switch (lengthType) { case LengthType.UInt16: this.WriteUInt16((ushort)bytes.Length); break; default: case LengthType.UInt32: this.WriteUInt32((uint)bytes.Length); break; } this.WriteBytes(bytes); }
/// <summary> /// 写入一个数据 /// </summary> /// <param name="value">待写入的数据</param> /// <param name="type">待写入的数据类型</param> public void WriteValue(int value, LengthType type) { switch (type) { case LengthType.BYTE: this.WriteByte(value); break; case LengthType.SHORT: this.WriteShort((short)value); break; default: this.WriteInt(value); break; } }
protected int ReadLength(LengthType lengthType) { switch (lengthType) { case LengthType.Byte: return(ReadByte()); case LengthType.Int16: return(ReadInt16()); case LengthType.Int32: return(ReadInt32()); default: return(0); } }
/// <summary> /// Set LengthType field</summary> /// <param name="lengthType_">Nullable field value to be set</param> public void SetLengthType(LengthType? lengthType_) { SetFieldValue(12, 0, lengthType_, Fit.SubfieldIndexMainField); }
/// <summary> /// /// </summary> /// <param name="lengthType"></param> /// <returns></returns> private double GetFactor(LengthType lengthType) { return _factors[lengthType]; }
/// <summary> /// construct a new Length object. The value is set to 0 /// </summary> /// <param name="u"></param> public Length(LengthType u) { Type = u; Value = 0; }
/// <summary> /// construct a new Length object /// </summary> /// <param name="u">the type of the Length</param> /// <param name="v">the value of the Length</param> public Length(LengthType u, float v) { Type = u; Value = v; }
/// <summary> /// /// </summary> /// <param name="lengthType"></param> /// <returns></returns> public Length ConvertTo(LengthType destType) { if (this._lengthType == destType) { return this; } else { double r = _value * GetFactor(this._lengthType) / GetFactor(destType); return new Length(r, destType); } }
public isoFieldDefinition(int fn, FieldType ft, EncodingType fe, LengthType lt, EncodingType le, int fl) { fieldType = ft; // the data type of the field data lengthType = lt; // the length type FIXED,LVAR, LLVAR or LLLVAR if (lengthType == LengthType.LLVAR) { lenLength = 1; // check the encoding to decide how many bytes needed. if BCD then 1 byte is enough lengthEncoding = le; // the length indicator encoding type fixedLength = 0; } else if (lengthType == LengthType.LLLVAR) { lenLength = 2; // check the encoding to decide how many bytes needed. if BCD then 2 bytes are enough lengthEncoding = le; // the length indicator encoding type fixedLength = 0; } else if (lengthType == LengthType.FIXED) { lenLength = 0; // length indicator is 0 since is FIXED length field lengthEncoding = EncodingType.NULL; // encoding method is NULL since we have no length indicator to encode fixedLength = fl; } fieldEncoding = fe; // the field data encoding type number = fn; // field number }
/// <summary> /// /// </summary> /// <param name="value"></param> /// <param name="lengthType"></param> public Length(double value, LengthType lengthType) { _value = value; _lengthType = lengthType; }