Example #1
0
        public DataSchemaNodePath GetNodePathFromPath(string path)
        {
            if (string.IsNullOrEmpty(path))
            {
                return(this.CreateNodePath());
            }
            DataSchemaNode      endNode = this.root;
            IList <ClrPathPart> list    = ClrPropertyPathHelper.SplitPath(path);

            if (list == null)
            {
                return((DataSchemaNodePath)null);
            }
            for (int index = 0; index < list.Count && endNode != null; ++index)
            {
                ClrPathPart clrPathPart = list[index];
                string      pathName    = clrPathPart.Category == ClrPathPartCategory.PropertyName ? clrPathPart.Path : DataSchemaNode.IndexNodePath;
                endNode = endNode.FindChildByPathName(pathName);
            }
            if (endNode != null)
            {
                return(new DataSchemaNodePath((ISchema)this, endNode));
            }
            return((DataSchemaNodePath)null);
        }
Example #2
0
        private DataSchemaNode GetNodeFromPath(string path)
        {
            if (this.root == null)
            {
                return((DataSchemaNode)null);
            }
            bool flag = !string.IsNullOrEmpty(path) && (int)path[0] == 47;

            if (this.invalidRootXPath && !flag)
            {
                return((DataSchemaNode)null);
            }
            if (string.IsNullOrEmpty(path))
            {
                return(this.root);
            }
            DataSchemaNode dataSchemaNode1 = flag ? this.AbsoluteRoot : this.root;

            string[] strArray = path.Split('/');
            int      num      = 0;

            if (flag)
            {
                if (string.IsNullOrEmpty(strArray[1]) && strArray.Length == 2)
                {
                    return(dataSchemaNode1);
                }
                if (dataSchemaNode1.PathName != strArray[1])
                {
                    return((DataSchemaNode)null);
                }
                num = 2;
            }
            DataSchemaNode dataSchemaNode2 = dataSchemaNode1;

            for (int index = num; index < strArray.Length && dataSchemaNode2 != null; ++index)
            {
                string pathName = strArray[index];
                if (pathName == "..")
                {
                    dataSchemaNode2 = dataSchemaNode2.Parent;
                }
                else if (pathName != ".")
                {
                    dataSchemaNode2 = dataSchemaNode2.FindChildByPathName(pathName);
                }
            }
            return(dataSchemaNode2);
        }