public void AddRegisterDirective(RegisterDirective directive) { this.AddRegisterDirective(directive, true); }
private void AddRegisterDirective(RegisterDirective directive, bool raiseEvent) { string tagPrefix = directive.TagPrefix; if (directive.IsUserControl) { tagPrefix = tagPrefix + ":" + directive.TagName; } bool flag = this._registerDirectiveTable.Contains(tagPrefix.ToLower()); this._registerDirectiveTable[tagPrefix.ToLower()] = directive; this._registerDirectivesText = null; if ((!flag && raiseEvent) && (this.DirectiveAdded != null)) { this.DirectiveAdded(this, new DirectiveEventArgs(directive)); } }
public bool PerformMapping(IServiceProvider serviceProvider, IDataObject originalDataObject, DataObject mappedDataObject) { if (!this.IsValidDataObject(serviceProvider, originalDataObject)) { return false; } IDocumentDesignerHost service = (IDocumentDesignerHost) serviceProvider.GetService(typeof(IDocumentDesignerHost)); DocumentProjectItem data = (DocumentProjectItem) originalDataObject.GetData(typeof(ProjectItem).Name); bool flag = false; if (service == null) { return flag; } bool flag2 = false; string fileNameWithoutExtension = Path.GetFileNameWithoutExtension(data.Path); string fullPath = Path.GetFullPath(data.Path); string tagPrefix = string.Empty; WebFormsDocument document = service.Document as WebFormsDocument; string str4 = Path.GetFullPath(document.DocumentPath); if (document == null) { return flag; } int num = 0; foreach (RegisterDirective directive in document.RegisterDirectives) { if (!directive.IsUserControl) { string str5 = directive.TagPrefix; if (str5.StartsWith("UC") && !str5.Equals("UC")) { try { int num2 = int.Parse(str5.Substring(2)); if (num2 >= num) { num = num2 + 1; } } catch { } } continue; } if (Path.Combine(str4, directive.SourceFile) == fullPath) { flag2 = true; tagPrefix = directive.TagPrefix; fileNameWithoutExtension = directive.TagName; break; } } if (!flag2) { tagPrefix = "uc" + num; Uri uri = new Uri(str4); Uri toUri = new Uri(fullPath); RegisterDirective directive2 = new RegisterDirective(tagPrefix, fileNameWithoutExtension, uri.MakeRelative(toUri), true); document.RegisterDirectives.AddRegisterDirective(directive2); WebFormsDesignView view = serviceProvider.GetService(typeof(IDesignView)) as WebFormsDesignView; if (view != null) { view.RegisterNamespace(tagPrefix); } } StringBuilder builder = new StringBuilder(); builder.Append('<'); builder.Append(tagPrefix); builder.Append(':'); builder.Append(fileNameWithoutExtension); builder.Append(" runat=\"server\" />"); string str6 = builder.ToString(); mappedDataObject.SetData(DataFormats.Html, str6); mappedDataObject.SetData(DataFormats.Text, str6); return true; }
internal void AddParsedRegisterDirective(RegisterDirective directive) { this.AddRegisterDirective(directive, false); }
private string DirectiveMatchEvaluator(Match match) { GroupCollection groups = match.Groups; CaptureCollection captures = match.Groups["attrname"].Captures; if (captures.Count > 0) { CaptureCollection captures2 = match.Groups["attrval"].Captures; CaptureCollection captures3 = match.Groups["equal"].Captures; Directive directive = null; int num = 0; string name = this._defaultDirectiveName; if ((captures2[0].ToString().Length == 0) && (captures3[0].ToString().Length == 0)) { name = captures[0].ToString().ToLower(); num = 1; } if (name.Equals("page")) { directive = new PageDirective(); } else if (name.Equals("control")) { directive = new ControlDirective(); } else if (name.Equals("register")) { directive = new RegisterDirective(); } else if (name.Equals("webservice")) { directive = new WebServiceDirective(); } else if (name.Equals("webhandler")) { directive = new WebHandlerDirective(); } else { directive = new UnknownDirective(name); } for (int i = num; i < captures.Count; i++) { directive.AddAttribute(captures[i].ToString(), captures2[i].ToString()); } this._directives.Add(directive); } return match.ToString(); }