Exemple #1
0
        public bool IsDataBound(string att)
        {
            if (att == null || !got_hashed)
            {
                return(false);
            }

            return(StrUtils.StartsWith(att, "<%#") && StrUtils.EndsWith(att, "%>"));
        }
Exemple #2
0
        bool GetInclude(string str, out string pathType, out string filename)
        {
            pathType = null;
            filename = null;
            str      = str.Substring(2).Trim();
            int len       = str.Length;
            int lastQuote = str.LastIndexOf('"');

            if (len < 10 || lastQuote != len - 1)
            {
                return(false);
            }

            if (!StrUtils.StartsWith(str, "#include ", true))
            {
                return(false);
            }

            str = str.Substring(9).Trim();
            bool isfile = (StrUtils.StartsWith(str, "file", true));

            if (!isfile && !StrUtils.StartsWith(str, "virtual", true))
            {
                return(false);
            }

            pathType = (isfile) ? "file" : "virtual";
            if (str.Length < pathType.Length + 3)
            {
                return(false);
            }

            str = str.Substring(pathType.Length).Trim();
            if (str.Length < 3 || str [0] != '=')
            {
                return(false);
            }

            int index = 1;

            for (; index < str.Length; index++)
            {
                if (Char.IsWhiteSpace(str [index]))
                {
                    index++;
                }
                else if (str [index] == '"')
                {
                    break;
                }
            }

            if (index == str.Length || index == lastQuote)
            {
                return(false);
            }

            str = str.Substring(index);
            if (str.Length == 2)               // only quotes
            {
                OnError("Empty file name.");
                return(false);
            }

            filename = str.Trim().Substring(index, str.Length - 2);
            if (filename.LastIndexOf('"') != -1)
            {
                return(false);                // file=""" -> no error
            }
            return(true);
        }