public static T SnapshotPagingScrollId <T>(this T options, IHaveData target) where T : ICommandOptions { options.Values.Set(SnapshotPagingKey, true); options.Values.Set(SnapshotPagingScrollIdKey, target.GetScrollId()); return(options); }
public static object GetInstance(this IServiceProvider container, IHaveData target, string key, ILogger logger) { string typeName = target.Data[key].ToString(); if (String.IsNullOrWhiteSpace(typeName)) { return(null); } try { var configuratorType = Type.GetType(typeName); if (configuratorType == null) { return(null); } return(container.GetRequiredService(configuratorType)); } catch (Exception exception) { logger.LogError(exception, "Error creating instance of type: {TypeName} with key: {Key}", typeName, key); return(null); } }
public static IEnumerable <object> GetInstances(this IServiceProvider container, IHaveData target, string key, ILogger logger) { var types = target.Data[key] as string[]; var instances = new List <object>(); if (types == null || types.Length == 0) { return(Enumerable.Empty <object>()); } foreach (string typeName in types) { try { var configuratorType = Type.GetType(typeName); if (configuratorType == null) { continue; } object instance = container.GetRequiredService(configuratorType); instances.Add(instance); } catch (Exception exception) { logger.LogError(exception, "Error creating instance of type: {TypeName} with key: {Key}", typeName, key); } } return(instances); }
public static void Register(IHaveData instance) { collection.Add(instance); }
public static string GetScrollId(this IHaveData results) { return(results.Data.GetString(ElasticDataKeys.ScrollId)); }