示例#1
0
        public int indexOf(IObjectWithChildSelector child)
        {
            if (items == null)
            {
                return(-1);
            }

            return(items.IndexOf(child as IContentToken));
        }
示例#2
0
        public virtual int indexOf(IObjectWithChildSelector child)
        {
            IMetaContentNested __child = child as IMetaContentNested;

            if (__child == null)
            {
                return(-1);
            }
            return(items.IndexOf(__child));
        }
        /// <summary>
        /// Index of supplied child - in his collection
        /// </summary>
        /// <param name="child"></param>
        /// <returns></returns>
        public int indexOf(IObjectWithChildSelector child)
        {
            if (!items.ContainsValue(child as selectRangeAreaNamed))
            {
                return(-1);
            }

            Int32 c = 0;

            foreach (selectRangeAreaNamed item in items.Values)
            {
                if (item == child)
                {
                    return(c);
                }
                c++;
            }
            return(-1);
        }
 int IObjectWithChildSelector.indexOf(IObjectWithChildSelector child) => indexOf(child);
 /// <summary>
 /// Index of supplied child - in his collection
 /// </summary>
 /// <param name="child"></param>
 /// <returns>
 /// -1 if not found
 /// </returns>
 public int indexOf(IObjectWithChildSelector child)
 {
     return(items.imbGetIndexOf(child, true));  //((IObjectWithChildSelector)parent).indexOf(child);
 }
 int IObjectWithChildSelector.indexOf(IObjectWithChildSelector child) => this.Values.imbGetIndexOf(child);
示例#7
0
        //public static IObjectWithPathAndChildSelector getMemberByPath(this IObjectWithPathAndChildSelector shead, )

        /// <summary>
        /// Get member by resolving relative or absolute <c>path</c> over <c>shead</c> starting object.
        /// </summary>
        /// <remarks>
        /// Path supports: absolute (starts with <c>PATHSPLITER</c>, go to parent <c>..</c>, ordinal selectors <c>[1]</c> and sequential child <c>name</c> selection
        /// </remarks>
        /// <param name="shead">Start head - object to start from</param>
        /// <param name="path">The path: accepts go to parent syntax.</param>
        /// <returns></returns>
        /// <exception cref="System.Exception">getChild() STACK OVERFLOW [".o(c).a("] metaContentBase")</exception>
        public static IObjectWithChildSelector getChildByPath(this IObjectWithChildSelector shead, string path)
        {
            if (path.StartsWith(PATHSPLITER))
            {
                if (shead is IObjectWithRoot)
                {
                    IObjectWithRoot sroot = shead as IObjectWithRoot;
                    shead = sroot.root as IObjectWithChildSelector;
                }
                path = imbSciStringExtensions.removeStartsWith(path, PATHSPLITER);
            }

            List <string>            prts = path.SplitSmart(PATHSPLITER); //.getPathParts();
            IObjectWithChildSelector head = shead;

            Int32 c = 0;

            foreach (String pt in prts)
            {
                IObjectWithChildSelector nhead;
                Int32 ord = getOrdinalPathPart(pt);

                if (ord > -1)
                {
                    if (ord >= head.Count())
                    {
                        ord = head.Count() - 1;
                    }

                    nhead = head[ord] as IObjectWithChildSelector;
                }
                else if (pt.StartsWith(PATHGO_PARENT))
                {
                    IObjectWithParent phead = head as IObjectWithParent;
                    if (phead != null)
                    {
                        nhead = phead.parent as IObjectWithPathAndChildSelector;
                    }
                    else
                    {
                        throw new ArgumentException("Go to parent path syntax found but head is not IObjectWithParent!!"); //  [".o(c).a("] metaContentBase"));
                    }
                }
                else
                {
                    nhead = head[pt] as IObjectWithChildSelector;
                }

                if (nhead == head)
                {
                    // logSystem.log("tmp");
                    //break;
                }
                else
                {
                    head = nhead;
                }
                c++;
                if (c > 100)
                {
                    throw new ArgumentException("getChild() would lead to STACK OVERFLOW - the limit was breached"); // aceGeneralException("getChild() STACK OVERFLOW [".o(c).a("] metaContentBase"));
                }
            }

            return(head);
        }
 int IObjectWithChildSelector.indexOf(IObjectWithChildSelector child)
 {
     throw new NotImplementedException();
 }