Пример #1
0
        /// <summary>
        /// Gets the node adress from binding expression splitted with '/' starting at a given node
        /// </summary>
        public static NodeAddress getNodeAdressFromBindingExp(NodeAddress sourceAddr, string[] bindingExp)
        {
            int ptr = sourceAddr.Count - 1;

            //if exp start with '/' => Graphic tree parsing start at source
            if (string.IsNullOrEmpty (bindingExp [0])) {
                //TODO:
            } else if (bindingExp [0] == ".") { //search template root
                ptr--;
                while (ptr >= 0) {
                    if (typeof(TemplatedControl).IsAssignableFrom (sourceAddr [ptr].CrowType))
                        break;
                    ptr--;
                }
            } else if (bindingExp [0] == "..") { //search starting at current node
                int levelUp = bindingExp.Length - 1;
                if (levelUp > ptr + 1)
                    throw new Exception ("Binding error: try to bind outside IML source");
                ptr -= levelUp;
            }
            //TODO:change Template special address identified with Nodecount = 0 to something not using array count to 0,
            //here linq is working without limits checking in compile option
            //but defining a 0 capacity array with limits cheking enabled, cause 'out of memory' error
            return new NodeAddress (sourceAddr.Take(ptr+1).ToArray());//[ptr+1];
            //Array.Copy (sourceAddr.ToArray (), targetNode, ptr + 1);
            //return new NodeAddress (targetNode);
        }