Esempio n. 1
0
            protected override void ScanSpan(ref int i)
            {
                if (!spanStack.Any(s => s is CodeDeclarationSpan || s is CodeExpressionSpan) && i + 3 < doc.Length && doc.GetTextAt(i, 2) == "<%" && doc.GetCharAt(i + 2) != '@')
                {
                    var span = new CodeExpressionSpan(GetDefaultMime());
                    spanStack.Push(span);
                    ruleStack.Push(GetRule(span));
                    OnFoundSpanBegin(span, i, doc.GetCharAt(i + 2) == '=' ? 3 : 2);
                    return;
                }

                if (i > 0 && doc.GetCharAt(i - 1) == '>')
                {
                    int k = i - 1;
                    while (k > 0 && doc.GetCharAt(k) != '<')
                    {
                        k--;
                    }
                    if (k + 7 < doc.Length && doc.GetTextAt(k, 7) == "<script")
                    {
                        int    j    = k + 7;
                        string mime = "application/javascript";
                        while (j < doc.Length && doc.GetCharAt(j) != '>')
                        {
                            if (j + 8 < doc.Length && doc.GetTextAt(j, 8) == "language")
                            {
                                j   += 8;
                                mime = GetMimeForLanguage(GetAttributeValue(ref j));
                                break;
                            }
                            if (j + 5 < doc.Length && doc.GetTextAt(j, 5) == "runat")
                            {
                                j += 5;
                                GetAttributeValue(ref j);
                                mime = GetDefaultMime();
                                break;
                            }
                            if (j + 4 < doc.Length && doc.GetTextAt(j, 4) == "type")
                            {
                                j   += 4;
                                mime = GetAttributeValue(ref j);
                                break;
                            }

                            j++;
                        }

                        if (mime != null)
                        {
                            CodeDeclarationSpan span = new CodeDeclarationSpan(mime);
                            spanStack.Push(span);
                            ruleStack.Push(GetRule(span));
                            OnFoundSpanBegin(span, i, 0);
                            return;
                        }
                    }
                }

                base.ScanSpan(ref i);
            }
Esempio n. 2
0
            protected override bool ScanSpan(ref int i)
            {
                if (!spanStack.Any(s => s is CodeDeclarationSpan || s is CodeExpressionSpan) && i + 4 < doc.TextLength && doc.GetTextAt(i, 2) == "<%" && doc.GetTextAt(i, 4) != "<%--" && doc.GetCharAt(i + 2) != '@')
                {
                    var span = new CodeExpressionSpan(GetDefaultMime());
                    FoundSpanBegin(span, i, 2);
                    return(true);
                }

                if (i > 0 && doc.GetCharAt(i) == '>')
                {
                    int k = i;
                    while (k > 0 && doc.GetCharAt(k) != '<')
                    {
                        k--;
                    }
                    if (k + 7 < doc.TextLength && doc.GetTextAt(k, 7) == "<script")
                    {
                        int    j    = k + "<script".Length;
                        string mime = "application/javascript";
                        while (j < doc.TextLength && doc.GetCharAt(j) != '>')
                        {
                            if (j + 8 < doc.TextLength && doc.GetTextAt(j, 8) == "language")
                            {
                                j   += 8;
                                mime = GetMimeForLanguage(GetAttributeValue(ref j));
                                break;
                            }
                            if (j + 5 < doc.TextLength && doc.GetTextAt(j, 5) == "runat")
                            {
                                j += 5;
                                GetAttributeValue(ref j);
                                mime = GetDefaultMime();
                                break;
                            }
                            if (j + 4 < doc.TextLength && doc.GetTextAt(j, 4) == "type")
                            {
                                j   += 4;
                                mime = GetAttributeValue(ref j);
                                break;
                            }

                            j++;
                        }

                        if (mime != null)
                        {
                            CodeDeclarationSpan span = new CodeDeclarationSpan(mime);
                            try {
                                FoundSpanBegin(span, i, 0);
                                return(true);
                            } catch (Exception ex) {
                                LoggingService.LogInternalError(ex);
                            }
                        }
                    }
                }

                return(base.ScanSpan(ref i));
            }
			protected override void ScanSpan (ref int i)
			{
				if (i + 3 < doc.Length && doc.GetTextAt (i, 2) == "<%" && doc.GetCharAt (i + 2) != '@') {
					var span = new CodeExpressionSpan (GetDefaultMime ());
					spanStack.Push (span);
					ruleStack.Push (GetRule (span));
					OnFoundSpanBegin (span, i, 0);
					return;
				}
				
				base.ScanSpan (ref i);
			}
Esempio n. 4
0
			protected override void ScanSpan (ref int i)
			{
				if (!spanStack.Any (s => s is CodeDeclarationSpan || s is CodeExpressionSpan) &&  i + 3 < doc.Length && doc.GetTextAt (i, 2) == "<%" && doc.GetCharAt (i + 2) != '@') {
					var span = new CodeExpressionSpan (GetDefaultMime ());
					spanStack.Push (span);
					ruleStack.Push (GetRule (span));
					OnFoundSpanBegin (span, i, doc.GetCharAt (i + 2) == '=' ? 3 : 2);
					return;
				}
				
				if (i > 0 && doc.GetCharAt (i - 1) == '>') {
					int k = i - 1;
					while (k > 0 && doc.GetCharAt (k) != '<') {
						k--;
					}
					if (k + 7 < doc.Length && doc.GetTextAt (k, 7) == "<script") {
						int j = k + 7;
						string mime = "application/javascript";
						while (j < doc.Length && doc.GetCharAt (j) != '>') {
							if (j + 8 < doc.Length && doc.GetTextAt (j, 8) == "language") {
								j += 8;
								mime = GetMimeForLanguage (GetAttributeValue (ref j));
								break;
							}
							if (j + 5 < doc.Length && doc.GetTextAt (j, 5) == "runat") {
								j += 5;
								GetAttributeValue (ref j);
								mime = GetDefaultMime ();
								break;
							}
							if (j + 4 < doc.Length && doc.GetTextAt (j, 4) == "type") {
								j += 4;
								mime = GetAttributeValue (ref j);
								break;
							}
							
							j++;
						}
						
						if (mime != null) {
							CodeDeclarationSpan span = new CodeDeclarationSpan (mime);
							spanStack.Push (span);
							ruleStack.Push (GetRule (span));
							OnFoundSpanBegin (span, i, 0);
							return;
						}
					}
				}
				
				base.ScanSpan (ref i);
			}
			protected override bool ScanSpan (ref int i)
			{
				if (!spanStack.Any (s => s is CodeDeclarationSpan || s is CodeExpressionSpan) && i + 4 < doc.TextLength && doc.GetTextAt (i, 2) == "<%" && doc.GetTextAt (i, 4) != "<%--" && doc.GetCharAt (i + 2) != '@') {
					var span = new CodeExpressionSpan (GetDefaultMime ());
					FoundSpanBegin (span, i, 2);
					return true;
				}
				
				if (i > 0 && doc.GetCharAt (i) == '>') {
					int k = i;
					while (k > 0 && doc.GetCharAt (k) != '<') {
						k--;
					}
					if (k + 7 < doc.TextLength && doc.GetTextAt (k, 7) == "<script") {
						int j = k + "<script".Length;
						string mime = "application/javascript";
						while (j < doc.TextLength && doc.GetCharAt (j) != '>') {
							if (j + 8 < doc.TextLength && doc.GetTextAt (j, 8) == "language") {
								j += 8;
								mime = GetMimeForLanguage (GetAttributeValue (ref j));
								break;
							}
							if (j + 5 < doc.TextLength && doc.GetTextAt (j, 5) == "runat") {
								j += 5;
								GetAttributeValue (ref j);
								mime = GetDefaultMime ();
								break;
							}
							if (j + 4 < doc.TextLength && doc.GetTextAt (j, 4) == "type") {
								j += 4;
								mime = GetAttributeValue (ref j);
								break;
							}
							
							j++;
						}
						
						if (mime != null) {
							CodeDeclarationSpan span = new CodeDeclarationSpan (mime);
							try {
								FoundSpanBegin (span, i, 0);
								return true;
							} catch (Exception ex) {
								LoggingService.LogInternalError (ex);
							}
						}
					}
				}
				
				return base.ScanSpan (ref i);
			}