Beispiel #1
0
 internal void SetResolver(IDataTypeResolver resolver)
 {
     this._table = resolver;
     if ((this.Size != 0) && this.IsPointer)
     {
         this.SetPointerSize(resolver.PlatformPointerSize);
     }
 }
Beispiel #2
0
        internal static ReadOnlyTcAdsDataTypeCollection GetDefaultTypes(IDataTypeResolver resolver)
        {
            TcAdsDataTypeCollection types = new TcAdsDataTypeCollection(_defaultTypes);

            foreach (TcAdsDataType type in types)
            {
                type.SetResolver(resolver);
            }
            return(types.AsReadOnly());
        }
Beispiel #3
0
        internal static ISubRangeType Create(string name, IDataTypeResolver resolver)
        {
            string baseType = null;

            if (DataTypeStringParser.TryParseSubRange(name, out baseType))
            {
                IDataType type = null;
                if (resolver.TryResolveType(baseType, out type))
                {
                    Create(name, type);
                }
            }
            return(null);
        }
Beispiel #4
0
        internal static ISubRangeType Create(AdsDataTypeEntry entry, IDataTypeResolver resolver)
        {
            ISubRangeType type     = null;
            string        baseType = null;

            if (DataTypeStringParser.TryParseSubRange(entry.entryName, out baseType))
            {
                IDataType type2 = null;
                if (resolver.TryResolveType(baseType, out type2))
                {
                    type = Create(entry.entryName, type2);
                }
            }
            return(type);
        }
Beispiel #5
0
 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;
 }
Beispiel #6
0
 public TcAdsSubItem(AdsFieldEntry adsFieldEntry, IDataTypeResolver typeResolver) : base(adsFieldEntry, typeResolver)
 {
     this._subItemName = string.Empty;
     base._typeName    = adsFieldEntry.Name;
     this._subItemName = adsFieldEntry.SubItemName;
 }
Beispiel #7
0
 public RpcMarshaller(IDataTypeResolver dataTypeResolver)
 {
     this._resolver = dataTypeResolver;
 }
Beispiel #8
0
 public SymbolAdsMarshaller(IDataTypeResolver resolver) : base(resolver)
 {
 }
Beispiel #9
0
 internal TcAdsDataType(AdsDataTypeEntry entry, IDataTypeResolver table) : this()
 {
     if (entry == null)
     {
         throw new ArgumentNullException("entry");
     }
     if (table == null)
     {
         throw new ArgumentNullException("table");
     }
     this._table         = table;
     this._size          = entry.size;
     this._typeName      = entry.entryName;
     this._typeHashValue = entry.typeHashValue;
     this._comment       = entry.Comment;
     this._flags         = entry.flags;
     this._offset        = entry.offset;
     this._dataTypeId    = entry.baseTypeId;
     if (entry.nameLength > 0)
     {
         bool   isUnicode            = false;
         int    length               = 0;
         string referencedType       = null;
         AdsDatatypeArrayInfo[] dims = null;
         string baseType             = null;
         if (entry.IsArray)
         {
             if (DataTypeStringParser.TryParseArray(this._typeName, out dims, out baseType))
             {
                 this._category     = DataTypeCategory.Array;
                 this._arrayInfo    = dims;
                 this._baseTypeName = baseType;
             }
             else
             {
                 this._arrayInfo    = entry.arrayInfos;
                 this._category     = DataTypeCategory.Array;
                 this._baseTypeName = entry.Name;
             }
         }
         else if (DataTypeStringParser.TryParseString(this._typeName, out length, out isUnicode))
         {
             this._category = DataTypeCategory.String;
         }
         else if (DataTypeStringParser.TryParseReference(this._typeName, out referencedType))
         {
             this._baseTypeName = referencedType;
             this._category     = DataTypeCategory.Reference;
         }
         else if (DataTypeStringParser.TryParsePointer(this._typeName, out referencedType))
         {
             this._baseTypeName = referencedType;
             this._category     = DataTypeCategory.Pointer;
         }
         else if (DataTypeStringParser.TryParseSubRange(this._typeName, out referencedType))
         {
             this._baseTypeName = entry.Name;
             this._category     = DataTypeCategory.SubRange;
         }
         else if (!string.IsNullOrEmpty(entry.Name))
         {
             this._baseTypeName = entry.Name;
             this._category     = DataTypeCategory.Alias;
         }
     }
     if (entry.subItems <= 0)
     {
         if (entry.IsEnum)
         {
             this._enumInfos = entry.enums;
             this._category  = DataTypeCategory.Enum;
             bool flag3 = PrimitiveTypeConverter.TryGetManagedType(this._dataTypeId, out this._managedType);
         }
     }
     else
     {
         this._subItems = new TcAdsSubItem[entry.subItems];
         bool flag2 = false;
         int  num2  = 0;
         int  index = 0;
         while (true)
         {
             int num1;
             if (index < entry.subItems)
             {
                 if (entry.subEntries[index] != null)
                 {
                     this._subItems[index] = new TcAdsSubItem(entry.subEntries[index], table);
                     if (!this._subItems[index].IsStatic && !this._subItems[index].IsProperty)
                     {
                         int num4 = 0;
                         num4   = !this._subItems[index].IsBitType ? (this._subItems[index].Offset * 8) : this._subItems[index].Offset;
                         flag2 |= num4 < num2;
                         num2  += this._subItems[index].BitSize;
                     }
                     index++;
                     continue;
                 }
                 object[] args = new object[] { index, entry.Name };
                 Module.Trace.TraceError("SubEntry '{0}' missing in TcAdsDataType '{1}'", args);
             }
             if ((entry.subItems <= 1) || (entry.BitSize >= num2))
             {
                 num1 = 0;
             }
             else
             {
                 num1 = (int)!entry.IsBitType;
             }
             this._category = ((num1 & flag2) == 0) ? DataTypeCategory.Struct : DataTypeCategory.Union;
             break;
         }
     }
     if (entry.HasAttributes)
     {
         this._attributes = entry.attributes;
     }
     if (entry.HasRpcMethods)
     {
         this._rpcMethodInfos = entry.methods;
     }
     if (this._category == DataTypeCategory.Unknown)
     {
         this._category = (entry.DataTypeId != AdsDatatypeId.ADST_BIGTYPE) ? DataTypeCategory.Primitive : DataTypeCategory.Interface;
     }
     if ((this._category == DataTypeCategory.Array) && string.IsNullOrEmpty(this._baseTypeName))
     {
         string message = $"Base type of ARRAY '{this._typeName}' not defined!";
         Module.Trace.TraceWarning(message);
     }
 }
Beispiel #10
0
 internal TcAdsDataType(string name, AdsDatatypeId dataType, uint size, AdsDataTypeFlags flags, DataTypeCategory cat, Type managedType, IDataTypeResolver resolver) : this(name, dataType, size, flags, cat, string.Empty, managedType, resolver)
 {
 }
Beispiel #11
0
 internal TcAdsDataType(string name, string elementType, uint elementSize, AdsDatatypeArrayInfo[] dims, IDataTypeResolver resolver) : this(name, AdsDatatypeId.ADST_BIGTYPE, 0, AdsDataTypeFlags.DataType, DataTypeCategory.Array, elementType, null, resolver)
 {
     if (dims == null)
     {
         throw new ArgumentNullException("dims");
     }
     this._arrayInfo    = dims;
     this._size         = (uint)(AdsArrayDimensionsInfo.GetArrayElementCount(dims) * elementSize);
     this._baseTypeName = elementType;
     if (string.IsNullOrEmpty(this._baseTypeName))
     {
         string message = $"Base type of ARRAY '{name}' not defined!";
         Module.Trace.TraceWarning(message);
     }
 }