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); } }
private static bool TryParseSubRange(IDataType baseType, TypeAttributeCollection attributes, IBinder binder, out ISubRangeType subRange) { string str; string str2; if (((attributes != null) && ((attributes.Count >= 2) && (baseType.Category == DataTypeCategory.Primitive))) && (attributes.TryGetValue("LowerBorder", out str2) & attributes.TryGetValue("UpperBorder", out str))) { object obj2; object obj3; IManagedMappableType type = (IManagedMappableType)baseType; System.Type managedType = type.ManagedType; System.Type type3 = type.ManagedType; if (managedType == typeof(byte)) { type3 = typeof(sbyte); } else if (managedType == typeof(ushort)) { type3 = typeof(short); } else if (managedType == typeof(uint)) { type3 = typeof(int); } else if (managedType == typeof(ulong)) { type3 = typeof(long); } if (DataTypeStringParser.TryParse(str, type3, out obj3) & DataTypeStringParser.TryParse(str2, type3, out obj2)) { object obj4; object obj5; if (managedType == type3) { obj4 = obj2; obj5 = obj3; } else { PrimitiveTypeConverter converter = PrimitiveTypeConverter.Default; byte[] data = converter.Marshal(obj2); byte[] buffer2 = converter.Marshal(obj3); converter.UnmarshalPrimitive(managedType, data, 0, data.Length, out obj4); converter.UnmarshalPrimitive(managedType, buffer2, 0, buffer2.Length, out obj5); } string name = $"{baseType.Name} ({obj4}..{obj5})"; IDataType type4 = null; if (binder.TryResolveType(name, out type4)) { subRange = (ISubRangeType)type4; return(true); } } } subRange = null; return(false); }
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 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; }