bool ProcessIfMarkedAsClassless(string rawCode)
{
int beginPos = -1;
int endPos = -1;
if (-1 != (beginPos = rawCode.IndexOf("//css_classless", beginPos + 1)))
{
endPos = rawCode.IndexOf(";", beginPos);
if (endPos != 1)
{
string className = rawCode.Substring(beginPos, endPos - beginPos)
.Substring("//css_classless".Length)
.Trim()
.Replace("\n", "")
.Replace("\r", "");
if (className.Contains(" "))
throw new ApplicationException("Directive //css_classless contains illegal class name.\nIt is possible that the directive is not closed with ';').");
var tokens = className.Split('.');
classNameToInject = tokens[tokens.Length - 1];
if (tokens.Length > 1)
namespaceToInject = className.Substring(0, className.Length - classNameToInject.Length - 1);
else
namespaceToInject = "";
}
}
beginPos = -1;
endPos = -1;
while (-1 != (beginPos = rawCode.IndexOf("//css_begin;", beginPos + 1)))
{
if (beginPos != 0)
if (rawCode[beginPos - 1] != '\n' && rawCode[beginPos - 1] != '\r')
continue;
if ((beginPos + "//css_begin;".Length) < rawCode.Length)
if (rawCode[beginPos + "//css_begin;".Length + 1] != '\n' && rawCode[beginPos + "//css_begin;".Length + 1] != '\r')
continue;
break;
}
endPos = -1;
while (-1 != (endPos = rawCode.IndexOf("//css_end;", endPos + 1)))
{
if (endPos != 0)
if (rawCode[endPos - 1] != '\n' && rawCode[endPos - 1] != '\r')
continue;
if ((endPos + "//css_end;".Length) < rawCode.Length)
if (rawCode[endPos + "//css_end;".Length + 1] != '\n' && rawCode[endPos + "//css_end;".Length + 1] != '\r')
continue;
break;
}
if (beginPos == -1 && endPos == -1)
return false;
if (endPos == -1)
endPos = rawCode.Length - 1;
if (beginPos == -1)
beginPos = 0;
header.Append(rawCode.Substring(0, beginPos));
body.Append(rawCode.Substring(beginPos, endPos - beginPos));
footer.Append(rawCode.Substring(endPos, rawCode.Length - endPos));
return true;
}