コード例 #1
0
ファイル: ArrayInstance.cs プロジェクト: Pravin044/TwinCat
        public bool TryGetElement(int[] indices, out ISymbol symbol)
        {
            if (indices == null)
            {
                throw new ArgumentNullException("indices");
            }
            ArrayType dataType = (ArrayType)base.DataType;

            if (!ArrayType.AreIndicesValid(indices, dataType, false))
            {
                symbol = null;
                return(false);
            }
            int elementPosition = dataType.GetElementPosition(indices);

            symbol = base.SubSymbols[elementPosition];
            return(true);
        }
コード例 #2
0
        bool IReferenceInstanceAccess.TryGetElement(int[] indices, out ISymbol symbol)
        {
            if (indices == null)
            {
                throw new ArgumentNullException("indices");
            }
            if (this.ResolvedCategory != DataTypeCategory.Array)
            {
                throw new SymbolException($"Cannot dereference indices. The reference symbol '{this.InstancePath}' is not referencing an array type!", this);
            }
            ArrayType type = (ArrayType)base.ResolveType(DataTypeResolveStrategy.AliasReference);

            if (!ArrayType.AreIndicesValid(indices, type, false))
            {
                symbol = null;
                return(false);
            }
            int elementPosition = type.GetElementPosition(indices);

            symbol = base.SubSymbols[elementPosition];
            return(true);
        }