コード例 #1
0
        public virtual bool IsValidPartialVariableName(String value)
        {
            if (value.Length == 0)
            {
                return(false);
            }

            if (value[0] != '$' && value[0] != '?')
            {
                return(false);
            }

            if (value.Length == 1)
            {
                return(true);
            }

            char[] cs = value.ToCharArray(1, value.Length - 1);

            //First Character must be from PN_CHARS_U or a digit
            char first = cs[0];

            if (Char.IsDigit(first) || SparqlSpecsHelper.IsPNCharU(first))
            {
                if (cs.Length > 1)
                {
                    for (int i = 1; i < cs.Length; i++)
                    {
                        //Middle Chars must be from PN_CHARS or a '.'
                        if (!(cs[i] == '.' || SparqlSpecsHelper.IsPNChar(cs[i])))
                        {
                            return(false);
                        }
                        //Can't do the last character specific test because this is only a partial test
                    }

                    return(true);
                }
                else
                {
                    return(true);
                }
            }
            else
            {
                return(false);
            }
        }