public static IEnumerable <MarkdownMetaCompletionData> FromMetaModel(MetaDataModel model)
 {
     foreach (var entry in model.Entries)
     {
         yield return(new MarkdownMetaCompletionData(entry));
     }
 }
Exemplo n.º 2
0
        public static MetaDataModel Load(JObject json)
        {
            var meta = new MetaDataModel();

            if (json == null)
            {
                return(meta);
            }

            foreach (KeyValuePair <string, JToken> child in json)
            {
                var entry = new Entry
                {
                    Name = child.Key
                };

                var token = child.Value;
                entry.IssueMessage = token.SelectToken("message")?.Value <string>();
                entry.IsOptional   = token.SelectToken("optional")?.Value <bool>() ?? false;
                entry.Type         = Parse <MetaDataType>(token.SelectToken("type"));
                entry.IssueType    = Parse <IssueType>(token.SelectToken("issue"));
                entry.IsArray      = token.SelectToken("array")?.Value <bool>() ?? false;
                var regex = token.SelectToken("regex")?.Value <string>();
                if (regex != null)
                {
                    try
                    {
                        entry.Regex = new Regex(regex);
                    }
                    catch
                    {
                        // Regex was not valid
                    }
                }

                meta.Entries.Add(entry);
            }

            return(meta);
        }