protected override Array DecodeImproper(byte[] bytes) { string s = TransferSyntax.ToString(bytes); string[] multiValue = ToImproperMultiValue(s); Age[] age = new Age[multiValue.Length]; for (int i = 0; i < age.Length; i++) { string item = multiValue[i]; try { if (item == null || item.Equals("")) { item = "000D"; } age[i] = new Age(item); } catch (Exception e) { throw new EncodingException("Age string format is invalid.", Name + "/item", item); } } return(age); }
protected override Array DecodeImproper(byte[] bytes) { string unlimitedText = TransferSyntax.ToString(bytes); unlimitedText = unlimitedText.TrimEnd(null); return(new string[] { unlimitedText }); }
protected override Array DecodeImproper(byte[] bytes) { string s = TransferSyntax.ToString(bytes); string[] multiValue = ToImproperMultiValue(s); Uid[] uidValue = new Uid[multiValue.Length]; for (int i = 0; i < uidValue.Length; i++) { string item = multiValue[i]; // trailing zero padding if (item.Length > 0) { byte b = (byte)item[item.Length - 1]; if (b == 0) { item = item.Remove(item.Length - 1, 1); } item = item.Replace(" ", null); } if (item == null || item.Equals("")) { item = "0"; } uidValue[i] = new Uid(item); } return(uidValue); }
protected override Array DecodeProper(byte[] bytes) { string shortText = TransferSyntax.ToString(bytes); ValueMultiplicity vm = Tag.GetDictionaryEntry().VM; if (vm.Equals(1) || vm.IsUndefined) { if (shortText.Length <= 1024) { shortText = shortText.TrimEnd(null); } else { throw new EncodingException( "A value of max. 1024 characters is only allowed.", Tag, Name + "/shortText", shortText); } } else { throw new EncodingException( "Multiple values are not allowed within this field.", Tag, Name + "/VM, " + Name + "/shortText", vm.ToString() + ", " + shortText); } return(new string[] { shortText }); }
protected override Array DecodeImproper(byte[] bytes) { string s = TransferSyntax.ToString(bytes); string[] multiValue = ToImproperMultiValue(s); decimal[] decimalValue = new decimal[multiValue.Length]; for (int i = 0; i < decimalValue.Length; i++) { string item = multiValue[i]; item = item.Trim(); try { if (item.Length > 0) { decimalValue[i] = decimal.Parse(item, NumberStyles.Float, NumberFormatInfo.InvariantInfo); } } catch (Exception e) { throw new EncodingException( "Decimal string format is invalid.", Tag, Name + "/item", item); } } return(decimalValue); }
protected override Array DecodeImproper(byte[] bytes) { string shortText = TransferSyntax.ToString(bytes); shortText = shortText.TrimEnd(null); return(new string[] { shortText }); }
protected override Array DecodeProper(byte[] bytes) { string s = TransferSyntax.ToString(bytes); string[] multiValue = ToProperMultiValue(s); long[] intValue = new long[multiValue.Length]; for (int i = 0; i < intValue.Length; i++) { string item = multiValue[i]; if (item.Length <= 12) { item = item.Trim(); try { if (item.Length > 0) { intValue[i] = long.Parse(item); } } catch (Exception e) { throw new EncodingException( "Integer string format is invalid.", Tag, Name + "/item", item); } } else { throw new EncodingException( "A value of max. 12 bytes is only allowed.", Tag, Name + "/item", item); } } return(intValue); }
protected override Array DecodeImproper(byte[] bytes) { string s = TransferSyntax.ToString(bytes); string[] multiValue = ToImproperMultiValue(s); System.DateTime[] date = new System.DateTime[multiValue.Length]; for (int i = 0; i < date.Length; i++) { string item = multiValue[i]; if (Regex.IsMatch(item, "^[0-9]{4}\\.?[0-9]{2}\\.?[0-9]{2}$")) { item = item.Replace(".", null); string year = item.Substring(0, 4); string month = item.Substring(4, 2); string day = item.Substring(6, 2); try { date[i] = new System.DateTime(int.Parse(year), int.Parse(month), int.Parse(day)); } catch (Exception e) { throw new EncodingException("Date format is invalid.", Tag, Name + "/item", item); } } } return(date); }
protected override Array DecodeProper(byte[] bytes) { string s = TransferSyntax.ToString(bytes); string[] applicationName = ToProperMultiValue(s); for (int i = 0; i < applicationName.Length; i++) { string item = applicationName[0]; if (item.Length > 16) { throw new EncodingException( "A value of max. 16 bytes is only allowed.", Tag, Name + "/item", item); } else if (Regex.IsMatch(item, "^[\\s]{16}$")) { throw new EncodingException( "No application name specified.", Tag, Name + "/item", item); } else if (item.Length > 0) { applicationName[i] = item.Trim(); } } return(applicationName); }
protected override Array DecodeProper(byte[] bytes) { string s = TransferSyntax.ToString(bytes); string[] multiValue = ToProperMultiValue(s); Uid[] uidValue = new Uid[multiValue.Length]; for (int i = 0; i < uidValue.Length; i++) { string item = multiValue[i]; if (item.Length > 64) { throw new EncodingException( "A value of max. 64 characters is only allowed.", Tag, Name + "/item", item); } else if (item.Length > 0) { // trailing zero padding byte b = (byte)item[item.Length - 1]; if (b == 0) { item = item.Remove(item.Length - 1, 1); } item = item.Replace(" ", null); } if (item == null || item.Equals("")) { throw new EncodingException("Uid is empty.", Tag, Name + "/item", item); } uidValue[i] = new Uid(item); } return(uidValue); }
protected override Array DecodeProper(byte[] bytes) { string unlimitedText = TransferSyntax.ToString(bytes); ValueMultiplicity vm = Tag.GetDictionaryEntry().VM; if (vm.Equals(1) || vm.IsUndefined) { // 0xFFFFFFFF is reserved! if (unlimitedText.Length <= 0xFFFFFFFE) { unlimitedText = unlimitedText.TrimEnd(null); } else { throw new EncodingException( "A value of max. 2^32 - 2 characters is only allowed.", Tag, Name + "/unlimitedText", unlimitedText); } } else { throw new EncodingException( "Multiple values are not allowed within this field.", Tag, Name + "/unlimitedText", unlimitedText); } return(new string[] { unlimitedText }); }
protected override Array DecodeImproper(byte[] bytes) { string s = TransferSyntax.ToString(bytes); string[] multiValue = ToImproperMultiValue(s); TimeSpan[] time = new TimeSpan[multiValue.Length]; for (int i = 0; i < time.Length; i++) { string item = multiValue[i]; if (item.Length > 0) { item = item.TrimEnd(null); if (Regex.IsMatch(item, "^[0-9]{2}(:?[0-9]{2}(:?[0-9]{2}(\\.[0-9]{1,6})?)?)?$")) { item = item.Replace(":", null).Replace(".", null); string hour = item.Substring(0, 2); string minute = "0"; if (item.Length > 2) { minute = item.Substring(2, 2); } string second = "0"; if (item.Length > 4) { second = item.Substring(4, 2); } string millisecond = "0"; if (item.Length > 6) { millisecond = item.Substring(6, item.Length - 6); } try { time[i] = new TimeSpan(0, int.Parse(hour), int.Parse(minute), int.Parse(second), int.Parse(millisecond)); } catch (Exception e) { throw new EncodingException( "Time format is invalid.", Tag, Name + "/item", item); } } else { throw new EncodingException("Time format is invalid.", Tag, Name + "/item", item); } } } return(time); }
protected override Array DecodeImproper(byte[] bytes) { string s = TransferSyntax.ToString(bytes); string[] multiValue = ToImproperMultiValue(s); TimeSpan[] time = new TimeSpan[multiValue.Length]; for (int i = 0; i < time.Length; i++) { string item = multiValue[i]; if (item.Length > 0) { item = item.TrimEnd(null); if (Regex.IsMatch(item, "^[0-9]{2}(:?[0-9]{2}(:?[0-9]{2}(\\.[0-9]{1,6})?)?)?$")) { item = item.Replace(":", null).Replace(".", null); string hour = item.Substring(0, 2); string minute = "0"; if (item.Length > 2) { minute = item.Substring(2, 2); } string second = "0"; if (item.Length > 4) { second = item.Substring(4, 2); } string millisecond = "0"; if (item.Length > 6) { millisecond = item.Substring(6, item.Length - 6); } try { time[i] = new TimeSpan(0, int.Parse(hour), int.Parse(minute), int.Parse(second), int.Parse(millisecond)); } catch (Exception e) { UnityEngine.Debug.LogWarning($"Date time format is invalid. tag: {Tag}, name: {Name}, item: {item}"); time[i] = TimeSpan.Zero; } } else { UnityEngine.Debug.LogWarning($"Time format is invalid. tag: {Tag}, name: {Name}, item: {item}"); time[i] = TimeSpan.Zero; } } } return(time); }
protected override Array DecodeImproper(byte[] bytes) { string s = TransferSyntax.ToString(bytes); string[] applicationName = ToImproperMultiValue(s); for (int i = 0; i < applicationName.Length; i++) { string item = applicationName[0]; applicationName[i] = item.Trim(); } return(applicationName); }
protected override Array DecodeImproper(byte[] bytes) { string s = TransferSyntax.ToString(bytes); string[] shortName = ToImproperMultiValue(s); for (int i = 0; i < shortName.Length; i++) { string item = shortName[i]; shortName[i] = item.Trim(); } return(shortName); }
protected override Array DecodeImproper(byte[] bytes) { string s = TransferSyntax.ToString(bytes); string[] longString = ToImproperMultiValue(s); for (int i = 0; i < longString.Length; i++) { string item = longString[i]; longString[i] = item.Trim(); } return(longString); }
protected override Array DecodeImproper(byte[] bytes) { string s = TransferSyntax.ToString(bytes); s = s.TrimEnd(null); string[] multiValue = ToImproperMultiValue(s); Type.PersonName[] personName = new Type.PersonName[multiValue.Length]; for (int i = 0; i < personName.Length; i++) { string item = multiValue[i]; personName[i] = new Type.PersonName(item); } return(personName); }
protected override Array DecodeProper(byte[] bytes) { string s = TransferSyntax.ToString(bytes); string[] longString = ToProperMultiValue(s); for (int i = 0; i < longString.Length; i++) { string item = longString[i]; if (item.Length <= 64) { longString[i] = item.Trim(); } else { throw new EncodingException( "A value of max. 64 characters is only allowed.", Tag, Name + "/item", item); } } return(longString); }
protected override Array DecodeProper(byte[] bytes) { string s = TransferSyntax.ToString(bytes); string[] shortName = ToProperMultiValue(s); for (int i = 0; i < shortName.Length; i++) { string item = shortName[i]; if (item.Length <= 16) { shortName[i] = item.Trim(); } else { throw new EncodingException( "A value of max. 16 characters is only allowed.", Tag, Name + "/item", item); } } return(shortName); }
protected override Array DecodeProper(byte[] bytes) { string s = TransferSyntax.ToString(bytes); string[] code = ToProperMultiValue(s); for (int i = 0; i < code.Length; i++) { string item = code[i]; if (item.Length > 16) { throw new EncodingException( "A value of max. 16 bytes is only allowed.", Tag, Name + "/item", item); } else if (item.Length > 0) { code[i] = item.Trim(); } } return(code); }
protected override Array DecodeProper(byte[] bytes) { string s = TransferSyntax.ToString(bytes); if (s.Length < 64 * 5) { s = s.TrimEnd(null); string[] multiValue = ToProperMultiValue(s); Type.PersonName[] personName = new Type.PersonName[multiValue.Length]; for (int i = 0; i < personName.Length; i++) { string item = multiValue[i]; personName[i] = new Type.PersonName(item); } return(personName); } else { throw new EncodingException( "A value of max. 64 * 5 characters is only allowed.", Tag, Name + "/s", s); } }
protected override Array DecodeImproper(byte[] bytes) { string s = TransferSyntax.ToString(bytes); string[] multiValue = ToImproperMultiValue(s); System.DateTime[] dateTime = new System.DateTime[multiValue.Length]; for (int i = 0; i < dateTime.Length; i++) { string item = multiValue[i]; if (item.Length > 0) { if (Regex.IsMatch(item, "^ [0-9]{10}" + "([0-9]{2} ([0-9]{2} (\\.[0-9]{6}" + "([\\+\\-][0-9]{4})? )? )? )? $", RegexOptions.IgnorePatternWhitespace)) { item = item.Replace(".", null); string year = item.Substring(0, 4); string month = item.Substring(4, 2); string day = item.Substring(6, 2); string hour = "0"; if (item.Length > 8) { hour = item.Substring(8, 2); } string minute = "0"; if (item.Length > 10) { minute = item.Substring(10, 2); } string second = "0"; if (item.Length > 12) { second = item.Substring(12, 2); } string millisecond = "0"; if (item.Length > 14) { millisecond = item.Substring(14, 6); } string timeZone = "+0"; if (item.Length > 20) { timeZone = item.Substring(20, 5); } // TODO: What to do with the time zone? try { dateTime[i] = new System.DateTime(int.Parse(year), int.Parse(month), int.Parse(day), int.Parse(hour), int.Parse(minute), int.Parse(second), int.Parse(millisecond)); } catch (Exception e) { UnityEngine.Debug.LogWarning($"Date time format is invalid. tag: {Tag}, name: {Name}"); dateTime[i] = System.DateTime.Now; } } else { UnityEngine.Debug.LogWarning($"Date time format is invalid. tag: {Tag}, name: {Name}"); dateTime[i] = System.DateTime.Now; } } } return(dateTime); }