Ejemplo n.º 1
0
        internal TcAdsSymbolInfo GetSubSymbol(TcAdsSymbolInfo parent, int subIndex, bool dereference)
        {
            if (parent == null)
            {
                throw new ArgumentNullException("parent");
            }
            TcAdsSymbolInfo info = null;

            try
            {
                ITcAdsDataType dataType = parent.DataType;
                ITcAdsDataType type2    = null;
                if (dataType != null)
                {
                    type2 = (ITcAdsDataType)dataType.ResolveType(DataTypeResolveStrategy.AliasReference);
                }
                if (type2 != null)
                {
                    int count = parent.SubSymbols.Count;
                    if (((type2 != null) && (type2.SubItems.Count > 0)) && (subIndex < type2.SubItems.Count))
                    {
                        info = this._subSymbolFactory.CreateSubSymbol(parent, subIndex);
                    }
                    else if ((type2 != null) && ((type2.Dimensions.Count > 0) || DataTypeStringParser.IsArray(type2.Name)))
                    {
                        info = this._subSymbolFactory.CreateArrayElement(parent, (TcAdsDataType)type2, subIndex);
                    }
                    else if ((type2 != null) && type2.IsReference)
                    {
                        this.SetPlatformPointerSize(type2.Size);
                    }
                    else if ((subIndex == 0) && type2.IsPointer)
                    {
                        this.SetPlatformPointerSize(type2.Size);
                        if (dereference)
                        {
                            string str;
                            DataTypeStringParser.TryParsePointer(type2.Name, out str);
                            TcAdsDataType referencedType = (TcAdsDataType)this.ResolveDataType(str);
                            if ((referencedType != null) & dereference)
                            {
                                bool flag = (referencedType.Flags & AdsDataTypeFlags.AnySizeArray) == AdsDataTypeFlags.AnySizeArray;
                                if ((referencedType.Size > 0) | flag)
                                {
                                    info = this._subSymbolFactory.CreatePointerSymbol(parent, referencedType);
                                }
                            }
                        }
                    }
                }
            }
            catch (Exception exception)
            {
                Module.Trace.TraceError($"ParentSymbol: {parent.Name}", exception);
                throw;
            }
            return(info);
        }
Ejemplo n.º 2
0
        internal ITcAdsDataType ResolveType(DataTypeResolveStrategy type)
        {
            ITcAdsDataType dataType = this.DataType;

            return((dataType == null) ? null : ((ITcAdsDataType)dataType.ResolveType(type)));
        }