public void Read(long parentEndPosition, Encoding encoding, AdsBinaryReader reader) { long position = reader.BaseStream.Position; this.entryLength = reader.ReadUInt32(); long num2 = position + this.entryLength; this.size = reader.ReadUInt32(); this.alignSize = reader.ReadUInt32(); this.dataType = (AdsDatatypeId)reader.ReadUInt32(); this.flags = (MethodParamFlags)reader.ReadUInt32(); this.reserved = reader.ReadUInt32(); this.typeGuid = reader.ReadGuid(); this.lengthIsPara = reader.ReadUInt16(); this.nameLength = reader.ReadUInt16(); this.typeLength = reader.ReadUInt16(); this.commentLength = reader.ReadUInt16(); this.name = reader.ReadPlcString(this.nameLength + 1, encoding); this.type = reader.ReadPlcString(this.typeLength + 1, encoding); this.comment = reader.ReadPlcString(this.commentLength + 1, encoding); if (reader.BaseStream.Position <= num2) { byte[] buffer = reader.ReadBytes((int)(num2 - reader.BaseStream.Position)); } else if (reader.BaseStream.Position > num2) { object[] args = new object[] { this.name }; Module.Trace.TraceError("Reading MethodPara entry for '{0}' failed!", args); reader.BaseStream.Position = num2; } }
public static string ToString(ITcAdsDataType dataType, object value) { AdsDatatypeId dataTypeId = dataType.BaseType.DataTypeId; if (dataTypeId == AdsDatatypeId.ADST_INT16) { return(EnumTypeConverter <short> .ToString(dataType, (short)value)); } if (dataTypeId == AdsDatatypeId.ADST_INT32) { return(EnumTypeConverter <int> .ToString(dataType, (int)value)); } switch (dataTypeId) { case AdsDatatypeId.ADST_INT8: return(EnumTypeConverter <sbyte> .ToString(dataType, (sbyte)value)); case AdsDatatypeId.ADST_UINT8: return(EnumTypeConverter <byte> .ToString(dataType, (byte)value)); case AdsDatatypeId.ADST_UINT16: return(EnumTypeConverter <ushort> .ToString(dataType, (ushort)value)); case AdsDatatypeId.ADST_UINT32: return(EnumTypeConverter <uint> .ToString(dataType, (uint)value)); case AdsDatatypeId.ADST_INT64: return(EnumTypeConverter <long> .ToString(dataType, (long)value)); case AdsDatatypeId.ADST_UINT64: return(EnumTypeConverter <ulong> .ToString(dataType, (ulong)value)); } throw new ArgumentException("Wrong data type!"); }
protected override int OnMarshalParameter(int i, RpcMethodParameterCollection inParameters, IList <IDataType> inParameterTypes, object[] parameterValues, byte[] buffer, int offset) { ITcAdsDataType type = (ITcAdsDataType)inParameterTypes[i]; object val = parameterValues[i]; AdsDatatypeId dataTypeId = type.DataTypeId; int num = 0; if (PrimitiveTypeConverter.CanMarshal(type.Category)) { byte[] data = null; PrimitiveTypeConverter.Marshal(dataTypeId, val, out data); num = copyHelper(buffer, offset, data); } else { if (type.Category != DataTypeCategory.String) { throw new MarshalException($"Cannot marshal complex type '{type.Name}'"); } int length = -1; bool isUnicode = false; DataTypeStringParser.TryParseString(type.Name, out length, out isUnicode); string str = (string)val; byte[] source = null; PlcStringConverter converter = isUnicode ? PlcStringConverter.UnicodeVariableLength : PlcStringConverter.DefaultVariableLength; if (converter.MarshalSize(str) > type.ByteSize) { throw new MarshalException("String size mismatch"); } source = converter.Marshal(str); num = copyHelper(buffer, offset, source); } return(num); }
public AdsDataTypeEntry(Type t) { EntryLength = (uint)new AdsDataTypeEntry().GetSize(); Version = 1; HashValue = 1; TypeHashValue = 10; Size = 1; Offset = 0; BaseTypeId = AdsDatatypeId.ADST_UINT8; Flags = AdsDataTypeFlags.None; ArrayDim = 0; NameLength = 4; TypeLength = 4; CommentLength = 0; SubItems = 0; EntryName = new byte[5]; TypeName = new byte[5]; Comment = new byte[81]; var typeBytes = Encoding.ASCII.GetBytes("BYTE"); Array.Copy(typeBytes, EntryName, typeBytes.Length); Array.Copy(typeBytes, TypeName, typeBytes.Length); }
internal static DataTypeCategory FromId(AdsDatatypeId id, string typeName) { DataTypeCategory pointer = FromId(id); if (!string.IsNullOrEmpty(typeName) && (pointer == DataTypeCategory.Unknown)) { if (DataTypeStringParser.IsPointer(typeName)) { pointer = DataTypeCategory.Pointer; } else if (DataTypeStringParser.IsReference(typeName)) { pointer = DataTypeCategory.Reference; } else if (DataTypeStringParser.IsArray(typeName)) { pointer = DataTypeCategory.Array; } else if (DataTypeStringParser.IsSubRange(typeName)) { pointer = DataTypeCategory.SubRange; } else if (DataTypeStringParser.IsIntrinsicType(typeName)) { pointer = DataTypeCategory.Primitive; } else if (DataTypeStringParser.IsString(typeName)) { pointer = DataTypeCategory.String; } } return(pointer); }
internal int InitializePointerType(Type managedType, AdsDatatypeId dataType, int byteLength, AdsBinaryReader reader, int readerOffset, out object value) { if (reader == null) { throw new ArgumentNullException("reader"); } if ((byteLength != 4) && (byteLength != 8)) { throw new ArgumentOutOfRangeException("byteLength"); } reader.BaseStream.Position = readerOffset; byte[] buffer = reader.ReadBytes(byteLength); object sourceValue = null; if (byteLength == 4) { sourceValue = BitConverter.ToUInt32(buffer, 0); } else if (byteLength == 8) { sourceValue = BitConverter.ToUInt64(buffer, 0); } if ((managedType == null) || (managedType == sourceValue.GetType())) { value = sourceValue; } else { value = PrimitiveTypeConverter.Convert(sourceValue, managedType); } return(0); }
internal TcAdsSymbol(AdsSymbolEntry symbolEntry, TcAdsDataType typeEntry) { if (symbolEntry == null) { throw new ArgumentNullException("symbolEntry"); } if (typeEntry == null) { object[] args = new object[] { symbolEntry.name }; Module.Trace.TraceWarning("No data type found for AdsSymbolEntry '{0}'", args); } this._indexGroup = symbolEntry.indexGroup; this._indexOffset = symbolEntry.indexOffset; this._size = symbolEntry.size; this._typeId = (AdsDatatypeId)symbolEntry.dataType; this._typeEntryFlags = typeEntry.Flags; this._flags = symbolEntry.flags; this._name = symbolEntry.name; this._typeName = symbolEntry.type; this._comment = symbolEntry.comment; this._arrayDimensions = symbolEntry.arrayDim; this._arrayInfos = symbolEntry.array; this._attributeCount = symbolEntry.attributeCount; this._attributes = symbolEntry.attributes; this._dataType = typeEntry; }
internal DataType(DataTypeCategory cat, AdsDataTypeEntry entry) { s_idCounter++; this.id = s_idCounter; this.comment = string.Empty; this.flags = AdsDataTypeFlags.DataType; this.attributes = new TypeAttributeCollection(); this.category = cat; this.comment = entry.comment; this.name = entry.entryName; this.flags = entry.flags; this.size = (int)entry.size; this.dataTypeId = entry.baseTypeId; if ((this.dataTypeId == AdsDatatypeId.ADST_BIGTYPE) && (this.category == DataTypeCategory.Unknown)) { this.category = DataTypeCategory.Interface; } else if (this.category == DataTypeCategory.Unknown) { this.category = DataTypeCategory.Primitive; } this.typeHashValue = entry.typeHashValue; if (entry.HasAttributes) { this.attributes = new TypeAttributeCollection(entry.attributes); } }
public AliasType(string name, DataType baseType) : base(baseType) { base.category = DataTypeCategory.Alias; base.dataTypeId = AdsDatatypeId.ADST_BIGTYPE; base.name = name; this._baseTypeId = baseType.DataTypeId; this._baseType = baseType; this._baseTypeName = baseType.Name; }
private AdsMarshallingInfo(Type adsType, AdsDatatypeId adsTypeCode, string adsTypeName, Delegate readDelegate, Delegate writeDelegate) { _adsType = adsType; _managedType = typeof(TValue); _adsTypeCode = adsTypeCode; _adsTypeName = adsTypeName; _readDelegate = readDelegate; _writeDelegate = writeDelegate; }
internal int InitializeEnum(string typeName, Type managedType, AdsDatatypeId dataType, int size, AdsBinaryReader reader, int readerPosition, out object value) { AdsDatatypeId typeId = dataType; if (typeId == AdsDatatypeId.ADST_BIGTYPE) { PrimitiveTypeConverter.TryGetDataTypeId(managedType, out typeId); } return(this.InitializePrimitiveType(typeName, managedType, typeId, size, reader, readerPosition, out value)); }
public bool TryResolveType(string name, out IDataType ret) { if (string.IsNullOrEmpty(name)) { throw new ArgumentNullException("typeName"); } ITcAdsDataType type = null; if ((this._dataTypes != null) && !this._dataTypes.TryGetDataType(name, out type)) { int length = 0; bool isUnicode = false; AdsDatatypeArrayInfo[] dims = null; if (DataTypeStringParser.TryParseString(name, out length, out isUnicode)) { AdsDatatypeId dataType = isUnicode ? AdsDatatypeId.ADST_WSTRING : AdsDatatypeId.ADST_STRING; type = new TcAdsDataType(name, dataType, isUnicode ? ((uint)((length + 1) * 2)) : ((uint)(length + 1)), AdsDataTypeFlags.DataType, DataTypeCategory.String, typeof(string), this); } else { string str; if (DataTypeStringParser.TryParsePointer(name, out str)) { ITcAdsDataType type2 = (ITcAdsDataType)this.ResolveDataType(str); type = new TcAdsDataType(name, AdsDatatypeId.ADST_BIGTYPE, (uint)this.PlatformPointerSize, AdsDataTypeFlags.DataType, DataTypeCategory.Pointer, null, this); } else if (DataTypeStringParser.TryParseReference(name, out str)) { ITcAdsDataType type3 = (ITcAdsDataType)this.ResolveDataType(str); type = new TcAdsDataType(name, AdsDatatypeId.ADST_BIGTYPE, (uint)this.PlatformPointerSize, AdsDataTypeFlags.DataType, DataTypeCategory.Reference, null, this); } else if (DataTypeStringParser.TryParseArray(name, out dims, out str)) { ITcAdsDataType type4 = (ITcAdsDataType)this.ResolveDataType(str); if (type4 != null) { type = new TcAdsDataType(name, str, (uint)type4.Size, dims, this); } } } if (type == null) { this.OnTypeResolveError(name); } else { this._dataTypes.Add(type); this.OnTypeCreated(type); } } ret = type; return(ret != null); }
public AdsSymbolEntryHeader(Type type) { EntryLength = 0; IndexGroup = 61445; IndexOffset = 0; //to supply Size = type == typeof(string) ? 81 : (uint)Marshal.SizeOf(type); DataType = type.ToAdsDatatypeId(); Flags = AdsSymbolFlags.None; ArrayDim = 0; NameLength = 0; //to supply TypeLength = (ushort)type.ToAdsDatatypeName().Length; CommentLength = 0; }
internal RpcMethodParameter(AdsMethodParaInfo paraInfo) { this._name = paraInfo.name; this._size = (int)paraInfo.size; this._alignSize = (int)paraInfo.alignSize; this._dataTypeId = paraInfo.dataType; this._flags = paraInfo.flags; this._typeGuid = paraInfo.typeGuid; this._lengthParaIndex = paraInfo.lengthIsPara; this._name = paraInfo.name; this._typeName = paraInfo.type; this._comment = paraInfo.comment; }
private int unmarshal(byte[] buffer, int offset, ITcAdsDataType dataType, out object value) { AdsDatatypeId dataTypeId = dataType.DataTypeId; value = null; int size = dataType.Size; if (!PrimitiveTypeConverter.CanMarshal(dataType.Category)) { throw new MarshalException($"Cannot unmarshal complex type '{dataType.Name}'"); } return(PrimitiveTypeConverter.Default.Unmarshal(dataType, buffer, offset, out value)); }
internal Instance(AdsSymbolEntry symbol) { this.comment = symbol.comment; this.instanceName = symbol.name; this.size = (int)symbol.size; this.typeName = AlignTypeName(symbol.type); this.dataTypeId = (AdsDatatypeId)symbol.dataType; this.flags = symbol.flags; if ((symbol.attributeCount > 0) && (symbol.attributes != null)) { this.attributes = new TypeAttributeCollection(symbol.attributes); } }
internal void WritePointerValue(string symbolPath, object value, AdsDatatypeId dataType, int byteSize, AdsBinaryWriter writer, int writerOffset) { if (string.IsNullOrEmpty(symbolPath)) { throw new ArgumentNullException("symbolPath"); } if ((byteSize < 0) || ((byteSize != 4) && (byteSize != 8))) { throw new ArgumentOutOfRangeException("byteSize"); } if (writer == null) { throw new ArgumentNullException("writer"); } if (writerOffset < 0) { throw new ArgumentOutOfRangeException("writerOffset"); } Type targetType = null; if (byteSize == 4) { targetType = typeof(uint); } else if (byteSize == 8) { targetType = typeof(ulong); } if (targetType != value.GetType()) { try { object obj1 = PrimitiveTypeConverter.Convert(value, targetType); value = obj1; } catch (MarshalException exception) { throw new ArgumentException($"Cannot convert value type '{value.GetType()}' to symbol type '{targetType}'!", "value", exception); } } writer.BaseStream.Position = writerOffset; if (byteSize == 4) { writer.Write((uint)value); } else if (byteSize == 8) { writer.Write((ulong)value); } }
internal Instance(AdsFieldEntry subEntry) { this.comment = subEntry.comment; this.instanceName = subEntry.entryName; this.size = (int)subEntry.size; this.typeName = AlignTypeName(subEntry.typeName); this.dataTypeId = subEntry.baseTypeId; this.flags = DataTypeFlagConverter.Convert(subEntry.flags); this.staticAddress = (subEntry.flags & (AdsDataTypeFlags.None | AdsDataTypeFlags.Static)) != AdsDataTypeFlags.None; if (subEntry.HasAttributes && (subEntry.attributes != null)) { this.attributes = new TypeAttributeCollection(subEntry.attributes); } }
internal DataType(string name, AdsDatatypeId typeId, DataTypeCategory cat, int size, Type dotnetType, AdsDataTypeFlags flags) { s_idCounter++; this.id = s_idCounter; this.comment = string.Empty; this.flags = AdsDataTypeFlags.DataType; this.attributes = new TypeAttributeCollection(); this.name = name; this.dataTypeId = typeId; this.category = cat; this.flags = flags | AdsDataTypeFlags.DataType; this.size = size; this.dotnetType = dotnetType; }
internal EnumValueCollection(AdsDatatypeId typeId, AdsEnumInfoEntry[] coll) { this._list = new List <IEnumValue>(); this._nameValueDict = new Dictionary <string, IEnumValue>(StringComparer.OrdinalIgnoreCase); if (coll == null) { throw new ArgumentNullException("coll"); } foreach (AdsEnumInfoEntry entry in coll) { IEnumValue item = EnumValueFactory.Create(typeId, entry); this.Add(item); } }
public StructType(AdsDataTypeEntry entry) : base(DataTypeCategory.Struct, entry) { this._members = new MemberCollection(); this._baseTypeId = entry.baseTypeId; this._baseTypeName = entry.typeName; for (int i = 0; i < entry.subItems; i++) { AdsFieldEntry subEntry = entry.subEntries[i]; Member instance = new Member(this, subEntry); if (!this._members.isUnique(instance)) { ((IInstanceInternal)instance).SetInstanceName(this._members.createUniquepathName(instance)); } this._members.Add(instance); } }
internal TcAdsSymbolInfo(AdsParseSymbols symbolParser, TcAdsSymbolInfo parent, int subIndex, AdsSymbolEntry symbolEntry, TcAdsDataType typeEntry) : this(symbolParser, parent, subIndex) { if (symbolEntry == null) { throw new ArgumentNullException("symbolEntry"); } this.indexGroup = symbolEntry.indexGroup; this.indexOffset = symbolEntry.indexOffset; this.size = symbolEntry.size; this.dataTypeId = (AdsDatatypeId)symbolEntry.dataType; if (typeEntry != null) { this.typeEntryFlags = typeEntry.Flags; } if (this.typeEntryFlags.HasFlag(AdsDataTypeFlags.None | AdsDataTypeFlags.Static)) { this.indexGroup = 0xf019; this.indexOffset = 0; } this.flags = symbolEntry.flags; this.instancePath = symbolEntry.name; this.shortName = symbolEntry.name; this.typeName = symbolEntry.type; this.comment = symbolEntry.comment; this.dataType = typeEntry; if (((symbolEntry.array != null) || (typeEntry == null)) || !typeEntry.IsArray) { this.arrayInfo = symbolEntry.array; } else { this.arrayInfo = typeEntry.Dimensions.ToArray(); if (typeEntry.Size != this.size) { this.size = (uint)typeEntry.Size; } } if (symbolEntry.attributes != null) { this.attributes = new TypeAttributeCollection(symbolEntry.attributes).AsReadOnly(); } else { this.attributes = null; } }
internal TcAdsDataType(string name, AdsDatatypeId dataType, uint size, AdsDataTypeFlags flags, DataTypeCategory cat, string baseTypeName, Type managedType, IDataTypeResolver resolver) : this() { if (string.IsNullOrEmpty(name)) { throw new ArgumentOutOfRangeException("name"); } this._table = resolver; this._typeName = name; this._size = size; this._flags = flags; this._dataTypeId = dataType; this._category = cat; this._managedType = managedType; if ((this._category == DataTypeCategory.Array) && string.IsNullOrEmpty(baseTypeName)) { string message = $"Base type of ARRAY '{name}' not defined!"; Module.Trace.TraceWarning(message); } this._baseTypeName = baseTypeName; }
internal TcAdsSymbolInfo(AdsParseSymbols symbolParser, TcAdsSymbolInfo parent, int subIndex, TcAdsDataType typeEntry) : this(symbolParser, parent, subIndex) { if (typeEntry == null) { throw new ArgumentNullException("typeEntry"); } this.indexGroup = (uint)parent.IndexGroup; this.indexOffset = (uint)parent.IndexOffset; this.size = (uint)typeEntry.Size; this.dataTypeId = typeEntry.DataTypeId; this.typeEntryFlags = typeEntry.Flags; this.flags = DataTypeFlagConverter.Convert(typeEntry.Flags); this.instancePath = parent.Name; this.shortName = parent.ShortName; this.typeName = typeEntry.Name; this.comment = typeEntry.Comment; this.dataType = typeEntry; this.arrayInfo = typeEntry.ArrayInfo; this.attributes = typeEntry.Attributes; }
public EnumType(AdsDataTypeEntry entry) : base(DataTypeCategory.Enum, entry) { int num1; Type type = typeof(T); if (((type == typeof(byte)) || ((type == typeof(sbyte)) || ((type == typeof(short)) || ((type == typeof(ushort)) || ((type == typeof(int)) || (type == typeof(uint))))))) || (type == typeof(long))) { num1 = 1; } else { num1 = (int) (type == typeof(ulong)); } if (num1 == 0) { throw new AdsException($"'{type}' is not a valid base type for an enumeration!"); } base.dotnetType = type; this._baseTypeId = entry.baseTypeId; this._baseTypeName = entry.typeName; this._fields = new EnumValueCollection<T>(entry.enums); }
public ArrayType(AdsDataTypeEntry entry) : base(DataTypeCategory.Array, entry) { string str2; AdsDatatypeArrayInfo[] arrayInfos = entry.arrayInfos; AdsDatatypeArrayInfo[] dims = null; AdsDatatypeArrayInfo[] infoArray3 = null; string baseType = null; if (DataTypeStringParser.TryParseArray(base.name, out dims, out baseType) && DataTypeStringParser.TryParseArray(baseType, out infoArray3, out str2)) { this._dimensions = new DimensionCollection(dims); this.elementTypeName = baseType; this.elementTypeId = entry.baseTypeId; } else { this._dimensions = new DimensionCollection(arrayInfos); this.elementTypeName = entry.typeName; this.elementTypeId = entry.baseTypeId; } this._oversampled = (entry.flags & (AdsDataTypeFlags.None | AdsDataTypeFlags.Oversample)) == (AdsDataTypeFlags.None | AdsDataTypeFlags.Oversample); }
//array //guid //attributeCount //attributes //extended flags //reserve public AdsSymbolEntry(Unit unit) { EntryLength = (uint)new AdsSymbolEntry().GetSize(); IndexGroup = 61445; IndexOffset = 0; Size = 1; DataType = AdsDatatypeId.ADST_UINT8; Flags = AdsSymbolFlags.None; ArrayDim = 0; NameLength = 4; TypeLength = 4; CommentLength = 0; Name = new byte[5]; Type = new byte[5]; Comment = new byte[81]; var nameBytes = Encoding.ASCII.GetBytes("Test"); var typeBytes = Encoding.ASCII.GetBytes("BYTE"); Array.Copy(nameBytes, Name, nameBytes.Length); Array.Copy(typeBytes, Type, typeBytes.Length); }
private Type GetTypeForDataTypeId(AdsDatatypeId id) { switch (id) { case AdsDatatypeId.ADST_INT16: return(typeof(Int16)); case AdsDatatypeId.ADST_INT32: return(typeof(Int32)); case AdsDatatypeId.ADST_REAL32: return(typeof(Single)); case AdsDatatypeId.ADST_REAL64: return(typeof(Double)); case AdsDatatypeId.ADST_INT8: return(typeof(SByte)); case AdsDatatypeId.ADST_UINT8: return(typeof(Byte)); case AdsDatatypeId.ADST_UINT16: return(typeof(UInt16)); case AdsDatatypeId.ADST_UINT32: return(typeof(UInt32)); case AdsDatatypeId.ADST_INT64: return(typeof(Int64)); case AdsDatatypeId.ADST_UINT64: return(typeof(UInt64)); case AdsDatatypeId.ADST_BIT: return(typeof(Byte)); case AdsDatatypeId.ADST_STRING: case AdsDatatypeId.ADST_WSTRING: case AdsDatatypeId.ADST_REAL80: case AdsDatatypeId.ADST_MAXTYPES: case AdsDatatypeId.ADST_BIGTYPE: case AdsDatatypeId.ADST_VOID: default: throw new NotSupportedException(String.Format("AdsDataTypeId={0} not supported", id.ToString())); } }
private object GetObjectForTypeId(AdsDatatypeId id, string value) { switch (id) { case AdsDatatypeId.ADST_INT16: return(Convert.ToInt16(value)); case AdsDatatypeId.ADST_INT32: return(Convert.ToInt32(value)); case AdsDatatypeId.ADST_REAL32: return(Convert.ToSingle(value)); case AdsDatatypeId.ADST_REAL64: return(Convert.ToDouble(value)); case AdsDatatypeId.ADST_INT8: return(Convert.ToSByte(value)); case AdsDatatypeId.ADST_UINT8: return(Convert.ToByte(value)); case AdsDatatypeId.ADST_UINT16: return(Convert.ToUInt16(value)); case AdsDatatypeId.ADST_UINT32: return(Convert.ToUInt32(value)); case AdsDatatypeId.ADST_INT64: return(Convert.ToInt64(value)); case AdsDatatypeId.ADST_UINT64: return(Convert.ToUInt64(value)); case AdsDatatypeId.ADST_BIT: return(Convert.ToByte(value)); case AdsDatatypeId.ADST_STRING: case AdsDatatypeId.ADST_WSTRING: case AdsDatatypeId.ADST_REAL80: case AdsDatatypeId.ADST_MAXTYPES: case AdsDatatypeId.ADST_BIGTYPE: case AdsDatatypeId.ADST_VOID: default: throw new NotSupportedException(String.Format("AdsDataTypeId={0} not supported", id.ToString())); } }
internal static IEnumValue Create(AdsDatatypeId baseTypeId, AdsEnumInfoEntry enumInfo) { if (enumInfo == null) { throw new ArgumentNullException("entry"); } if (baseTypeId == AdsDatatypeId.ADST_INT16) { return(new EnumValue <short>(enumInfo)); } if (baseTypeId == AdsDatatypeId.ADST_INT32) { return(new EnumValue <int>(enumInfo)); } switch (baseTypeId) { case AdsDatatypeId.ADST_INT8: return(new EnumValue <sbyte>(enumInfo)); case AdsDatatypeId.ADST_UINT8: return(new EnumValue <byte>(enumInfo)); case AdsDatatypeId.ADST_UINT16: return(new EnumValue <ushort>(enumInfo)); case AdsDatatypeId.ADST_UINT32: return(new EnumValue <uint>(enumInfo)); case AdsDatatypeId.ADST_INT64: return(new EnumValue <long>(enumInfo)); case AdsDatatypeId.ADST_UINT64: return(new EnumValue <ulong>(enumInfo)); } throw new ArgumentOutOfRangeException("baseTypeId"); }