Esempio n. 1
0
 private void ReadSelector(ContextItem item, JObject itemObj) {
     var selectorToken = itemObj.SelectToken("selector");
     if (selectorToken != null) {
         if (selectorToken.Type == JTokenType.String) {
             item.Selector = selectorToken.Value<string>();
         } else {
             WrongJsonType("selector", JTokenType.String, selectorToken.Type);
         }
     }
 }
Esempio n. 2
0
        private JToken ReadDescription(ContextItem item, JObject itemObj) {
            var descriptionToken = itemObj.SelectToken("description");
            if (descriptionToken != null) {
                if (descriptionToken.Type == JTokenType.String) {
                    item.Description = descriptionToken.Value<string>();
                } else {
                    WrongJsonType("description", JTokenType.String, descriptionToken.Type);
                }
            }

            return descriptionToken;
        }
Esempio n. 3
0
        private JToken ReadUrl(ContextItem item, JObject itemObj) {
            var urlToken = itemObj.SelectToken("url");
            if (urlToken != null) {
                if (urlToken.Type == JTokenType.String) {
                    var val = urlToken.Value<string>();
                    Uri uri;
                    if (Uri.TryCreate(val, UriKind.Absolute, out uri)) {
                        if (uri.Scheme == Uri.UriSchemeHttp || uri.Scheme == Uri.UriSchemeHttps) {
                            item.Url = val;
                        } else {
                            InvalidUrl(val);
                        }
                    } else {
                        InvalidUrl(val);
                    }
                } else {
                    WrongJsonType("url", JTokenType.String, urlToken.Type);
                }
            }

            return urlToken;
        }
Esempio n. 4
0
        private JToken ReadLabel(ContextItem item, JObject itemObj) {
            var labelToken = itemObj.SelectToken("label");
            if (labelToken != null) {
                if (labelToken.Type == JTokenType.String) {
                    item.Label = labelToken.Value<string>();
                } else {
                    WrongJsonType("label", JTokenType.String, labelToken.Type);
                }
            }

            return labelToken;
        }