Esempio n. 1
0
        private bool TryGetSubSymbol(IArrayInstance root, int[] indices, out T found)
        {
            IArrayType dataType = (IArrayType)root.DataType;
            ISymbol    symbol   = null;
            T          local    = default(T);

            if (!root.TryGetElement(indices, out symbol))
            {
                found = default(T);
                return(false);
            }
            local = (T)symbol;
            found = local;
            return(true);
        }
Esempio n. 2
0
        public bool TryGetElement(IList <int[]> jaggedIndices, out ISymbol symbol)
        {
            if (jaggedIndices == null)
            {
                throw new ArgumentNullException("jaggedIndices");
            }
            if (((IArrayType)base.DataType).JaggedLevel < jaggedIndices.Count)
            {
                throw new ArgumentOutOfRangeException("jaggedIndices");
            }
            bool           flag     = true;
            IArrayInstance instance = this;
            ISymbol        symbol2  = null;

            symbol = null;
            int num = 0;

            while (true)
            {
                if (num < jaggedIndices.Count)
                {
                    flag &= instance.TryGetElement(jaggedIndices[num], out symbol2);
                    if (flag)
                    {
                        instance = symbol2 as IArrayInstance;
                        num++;
                        continue;
                    }
                }
                if (flag)
                {
                    symbol = symbol2;
                }
                return(flag);
            }
        }
Esempio n. 3
0
        internal static bool TryGetSubItem(IInstanceCollection <T> coll, string[] pathSplit, int splitIndex, out T symbol)
        {
            SymbolParser.ArrayIndexType type;
            T local = default(T);

            symbol = default(T);
            string        nameWithIndices = pathSplit[splitIndex];
            string        instanceName    = null;
            IList <int[]> jaggedIndices   = null;
            string        indicesStr      = null;
            bool          flag            = SymbolParser.TryParseArrayElement(nameWithIndices, out instanceName, out indicesStr, out jaggedIndices, out type);

            if (flag)
            {
                nameWithIndices = instanceName;
            }
            bool flag2 = nameWithIndices[nameWithIndices.Length - 1] == '^';

            if (flag2)
            {
                nameWithIndices = nameWithIndices.Substring(0, nameWithIndices.Length - 1);
            }
            IList <T> list2 = null;

            if (coll.TryGetInstanceByName(nameWithIndices, out list2))
            {
                local = list2[0];
                if (flag)
                {
                    ISymbol                  symbol2  = null;
                    IArrayInstance           instance = local as IArrayInstance;
                    IReferenceInstanceAccess access   = local as IReferenceInstanceAccess;
                    if (instance != null)
                    {
                        instance.TryGetElement(jaggedIndices, out symbol2);
                    }
                    else if (access != null)
                    {
                        access.TryGetElement(jaggedIndices, out symbol2);
                    }
                    local = (T)symbol2;
                }
                if ((local == null) || (splitIndex >= (pathSplit.Length - 1)))
                {
                    symbol = !((splitIndex == (pathSplit.Length - 1)) & flag2) ? local : ((ISymbolInternal)local).SubSymbolsInternal[0];
                }
                else
                {
                    ISymbol symbol3 = local as ISymbol;
                    if (symbol3.IsContainerType)
                    {
                        ISymbolCollection subSymbolsInternal = ((ISymbolInternal)symbol3).SubSymbolsInternal;
                        if (flag2)
                        {
                            subSymbolsInternal = ((ISymbolInternal)subSymbolsInternal[0]).SubSymbolsInternal;
                        }
                        if ((subSymbolsInternal != null) && (subSymbolsInternal.Count > 0))
                        {
                            T local2 = default(T);
                            splitIndex++;
                            if (InstanceCollection <T> .TryGetSubItem((IInstanceCollection <T>)subSymbolsInternal, pathSplit, splitIndex, out local2))
                            {
                                symbol = local2;
                            }
                            else
                            {
                                symbol = default(T);
                            }
                        }
                    }
                }
            }
            return(((T)symbol) != null);
        }