コード例 #1
0
 public override List <BaseImporter> HandleWildcard()
 {
     if (Collection.Contains("*"))
     {
         //this is a wildcard importer.
         List <BaseImporter> expanded = new List <BaseImporter>();
         var collection = Collection;
         var regex      = collection
                          .Replace(".", "\\.")
                          .Replace("*", "(?<wildcards>.*)");
         var db          = GetDatabase();
         var collections = db.GetCollectionNames();
         foreach (var collectionName in collections)
         {
             var match = Regex.Match(collectionName, regex);
             if (match.Success)
             {
                 var           wildcardValue = match.Groups["wildcards"].Value;
                 MongoImporter importer      = new MongoImporter()
                 {
                     Connection = this.Connection,
                     Collection = collectionName,
                     EsIndex    = this.EsIndex.Replace("*", wildcardValue),
                     EsServer   = this.EsServer,
                 };
                 expanded.Add(importer);
             }
         }
         return(expanded);
     }
     else
     {
         return(null);
     }
 }
コード例 #2
0
        public override object ReadJson(JsonReader reader,
                                        Type objectType,
                                        object existingValue,
                                        JsonSerializer serializer)
        {
            JObject      jObject = JObject.Load(reader);
            BaseImporter retValue;

            switch (jObject["Type"].Value <String>())
            {
            case "mongo":
                retValue = new MongoImporter();
                break;

            default:
                throw new ConfigurationErrorsException("Unknown type " + jObject["Type"]);
            }

            foreach (var property in jObject.Properties().Where(p => p.Name != "Type"))
            {
                retValue.SetPropertyValue(property.Name, property.Value.Value <String>());
            }

            return(retValue);
        }