230
231
get { return "<% %>"; }
235
public static class AspNetDomExtensions
237
static XName scriptName = new XName ("script");
238
static XName runatName = new XName ("runat");
239
static XName idName = new XName ("id");
241
public static bool IsRunatServer (this XElement el)
243
var val = el.Attributes.GetValue (runatName, true);
244
return string.Equals (val, "server", StringComparison.OrdinalIgnoreCase);
247
public static string GetId (this IAttributedXObject el)
249
return el.Attributes.GetValue (idName, true);
252
public static bool IsServerScriptTag (this XElement el)
254
return XName.Equals (el.Name, scriptName, true) && IsRunatServer (el);
257
public static IEnumerable<T> WithName<T> (this IEnumerable<XNode> nodes, XName name, bool ignoreCase) where T : XNode, INamedXObject
259
return nodes.OfType<T> ().Where (el => XName.Equals (el.Name, name, true));
262
public static IEnumerable<string> GetAllPlaceholderIds (this XDocument doc)
264
return doc.AllDescendentNodes
265
.WithName<XElement> (new XName ("asp", "ContentPlaceHolder"), true)
266
.Where (x => x.IsRunatServer ())
267
.Select (x => x.GetId ())
268
.Where (id => !string.IsNullOrEmpty (id));