static JsonValue CreateValue(String type, String value) { if (type.Is(InputTypeNames.Checkbox)) return new JsonValue(value.Is(Keywords.On)); else if (type.Is(InputTypeNames.Number)) return new JsonValue(value.ToDouble()); return new JsonValue(value); }
internal IAttr RemoveNamedItemOrDefault(String name, Boolean suppressMutationObservers) { for (var i = 0; i < _items.Count; i++) { if (name.Is(_items[i].Name)) { var attr = _items[i]; _items.RemoveAt(i); attr.Container = null; if (!suppressMutationObservers) { RaiseChangedEvent(attr, null, attr.Value); } return attr; } } return null; }
/// <summary>Checks if the data protocol is given.</summary> /// <param name="protocol">The protocol to check for data.</param> /// <returns>True if data is matched, otherwise false..</returns> public Boolean SupportsProtocol(String protocol) { return protocol.Is(KnownProtocols.Data); }
public IAttr GetNamedItem(String namespaceUri, String localName) { for (var i = 0; i < _items.Count; i++) { if (localName.Is(_items[i].LocalName) && namespaceUri.Is(_items[i].NamespaceUri)) { return _items[i]; } } return null; }
public IAttr GetNamedItem(String name) { for (var i = 0; i < _items.Count; i++) { if (name.Is(_items[i].Name)) { return _items[i]; } } return null; }
private DocumentRequest SubmitForm(HttpMethod method, String scheme, Url action, IHtmlElement submitter) { if (scheme.IsOneOf(ProtocolNames.Http, ProtocolNames.Https)) { if (method == HttpMethod.Get) { return MutateActionUrl(action, submitter); } else if (method == HttpMethod.Post) { return SubmitAsEntityBody(action, submitter); } } else if (scheme.Is(ProtocolNames.Data)) { if (method == HttpMethod.Get) { return GetActionUrl(action); } else if (method == HttpMethod.Post) { return PostToData(action, submitter); } } else if (scheme.Is(ProtocolNames.Mailto)) { if (method == HttpMethod.Get) { return MailWithHeaders(action, submitter); } else if (method == HttpMethod.Post) { return MailAsBody(action, submitter); } } else if (scheme.IsOneOf(ProtocolNames.Ftp, ProtocolNames.JavaScript)) { return GetActionUrl(action); } return MutateActionUrl(action, submitter); }
/// <summary> /// Dirty dirty workaround since the webrequester itself is already /// quite stupid, but the one here (for the PCL) is really not the /// way things should be programmed ... /// </summary> /// <param name="key">The key to add or change.</param> /// <param name="value">The value to be set.</param> private void AddHeader(String key, String value) { if (key.Is(HeaderNames.Accept)) { _http.Accept = value; } else if (key.Is(HeaderNames.ContentType)) { _http.ContentType = value; } else if (key.Is(HeaderNames.Expect)) { SetProperty(HeaderNames.Expect, value); } else if (key.Is(HeaderNames.Date)) { SetProperty(HeaderNames.Date, DateTime.Parse(value)); } else if (key.Is(HeaderNames.Host)) { SetProperty(HeaderNames.Host, value); } else if (key.Is(HeaderNames.IfModifiedSince)) { SetProperty("IfModifiedSince", DateTime.Parse(value)); } else if (key.Is(HeaderNames.Referer)) { SetProperty(HeaderNames.Referer, value); } else if (key.Is(HeaderNames.UserAgent)) { SetProperty("UserAgent", value); } else if (!key.Is(HeaderNames.Connection) && !key.Is(HeaderNames.Range) && !key.Is(HeaderNames.ContentLength) && !key.Is(HeaderNames.TransferEncoding)) { _http.Headers[key] = value; } }
public HtmlQuoteElement(Document owner, String name = null, String prefix = null) : base(owner, name ?? TagNames.Quote, prefix, name.Is(TagNames.BlockQuote) ? NodeFlags.Special : NodeFlags.None) { }
internal IAttr RemoveNamedItemOrDefault(String namespaceUri, String localName) { for (int i = 0; i < _items.Count; i++) { if (localName.Is(_items[i].LocalName) && namespaceUri.Is(_items[i].NamespaceUri)) { var attr = _items[i]; _items.RemoveAt(i); attr.Container = null; RaiseChangedEvent(attr, null, attr.Value); return attr; } } return null; }
Boolean IsInvalid(RenderDevice device, String keyword, RenderDevice.Kind kind) { return keyword.Is(Type) && (device.DeviceType == kind) == IsInverse; }
public CssValue ExtractFor(String name) { if (name.Is(_labels[0])) { return _top.Original; } else if (name.Is(_labels[1])) { return _right.Original; } else if (name.Is(_labels[2])) { return _bottom.Original; } else if (name.Is(_labels[3])) { return _left.Original; } return null; }
static String Bundle(String prefix, String match) { return prefix.Is("*") ? match : String.Concat(prefix, ":", match); }
/// <summary> /// Creates a new element with the given tag name and namespace URI. /// </summary> /// <param name="namespaceUri"> /// Specifies the namespace URI to associate with the element. /// </param> /// <param name="qualifiedName"> /// A string that specifies the type of element to be created. /// </param> /// <returns>The created element.</returns> public IElement CreateElement(String namespaceUri, String qualifiedName) { var localName = default(String); var prefix = default(String); GetPrefixAndLocalName(qualifiedName, ref namespaceUri, out prefix, out localName); if (namespaceUri.Is(NamespaceNames.HtmlUri)) { var element = Factory.HtmlElements.Create(this, localName, prefix); element.SetupElement(); return element; } else if (namespaceUri.Is(NamespaceNames.SvgUri)) { var element = Factory.SvgElements.Create(this, localName, prefix); element.SetupElement(); return element; } else if (namespaceUri.Is(NamespaceNames.MathMlUri)) { var element = Factory.MathElements.Create(this, localName, prefix); element.SetupElement(); return element; } else { var element = new Element(this, localName, prefix, namespaceUri); element.SetupElement(); return element; } }
/// <summary> /// Checks if the element with the provided prefix matches the CSS /// namespace. /// </summary> /// <param name="el">The element to examine.</param> /// <param name="prefix">The namespace in question.</param> /// <returns>True if the namespace is matched, else false.</returns> public static Boolean MatchesCssNamespace(this IElement el, String prefix) { if (prefix.Is(Keywords.Asterisk)) { return true; } var nsUri = el.GetAttribute(NamespaceNames.XmlNsPrefix) ?? el.NamespaceUri; if (prefix.Is(String.Empty)) { return nsUri.Is(String.Empty); } return nsUri.Is(GetCssNamespace(el, prefix)); }
static Boolean IsXmlNamespaceAttribute(String name) { return name.Length > 4 && (name.Is(NamespaceNames.XmlNsPrefix) || name.Is("xmlns:xlink")); }
/// <summary>Checks if the data protocol is given.</summary> /// <param name="protocol">The protocol to check for data.</param> /// <returns>True if data is matched, otherwise false..</returns> public Boolean SupportsProtocol(String protocol) { return protocol.Is(ProtocolNames.Data); }
static String FormMatch(String prefix, String match) { return prefix.Is(Keywords.Asterisk) ? match : String.Concat(prefix, PseudoClassNames.Separator, match); }