private IEditHandler DoRegister(object uiElement) { if (handlers.ContainsKey(uiElement)) { return(handlers[uiElement]); } IAdapterFactory <IEditHandler> factroy = factoryCatalog.GetFactory(uiElement); if (factroy == null) { return(null); } IEditHandler handler = factroy.GetAdapter(uiElement); handlers.Add(uiElement, handler); Register(handler); return(handler); }
public async Task <Result[]> ExecuteAdapterTasks(List <string> services, string address) { var tasks = new List <Task <Result> >(); foreach (string s in services) { tasks.Add(Task <Result> .Factory.StartNew(() => _adapterFactory.GetAdapter(s).GetResults(address))); } await Task.WhenAll(tasks); var results = new Result[tasks.Count]; for (int i = 0; i < tasks.Count; i++) { results[i] = tasks[i].Result; } return(results); }
public void Run() { foreach (var file in _helper.GetInventoryFilePaths(".")) { var extension = Path.GetExtension(file); var adapter = _factory.GetAdapter(extension); var items = adapter.GetInventoryItems(_helper.GetFileContents(file)); _output.WriteMessage(string.Format("Source file: {0}", file)); if (items == null) { _output.WriteMessage("No items."); continue; } foreach (var item in items) { _output.WriteMessage(string.Format("Item: {0}, Quantity: {1}", item.Name, item.Quantity)); } } _output.WriteMessage("Done!"); }
public MyCStreamingService(IAdapterFactory <int, MyCStreamingData> adapterFactory) { var adapter = adapterFactory.GetAdapter(); _streamingManager = new StreamingManager <int, MyCStreamingData>(data => data.Key, adapter); }
protected TAdapter CreateCore(object adaptee) { return((TAdapter)implementation.GetAdapter(adaptee, this.role)); }