async Task <IEnumerable <AssetEnvironment> > GetMergedEnvironmentsAsync() { // Get provided resources var provided = await _assetManager.GetAssets(); var providedEnvironments = provided.ToList(); // Get default resources var defaults = DefaultAssets.GetDefaultResources(); var defaultEnvironments = defaults.ToList(); // Merge provided resources into default groups var output = defaultEnvironments.ToDictionary(p => p.TargetEnvironment); foreach (var defaultEnvironment in defaultEnvironments) { // Get provided resources matching our current environment var matchingEnvironments = providedEnvironments .Where(g => g.TargetEnvironment == defaultEnvironment.TargetEnvironment) .ToList(); // Iterate through each matching provided environment adding // resources from that environment into our default environments foreach (var group in matchingEnvironments) { foreach (var resource in group.Resources) { output[defaultEnvironment.TargetEnvironment].Resources.Add(resource); } } } return(output.Values.ToList()); }
IEnumerable <AssetEnvironment> GetMergedEnvironments() { // Get provided assets var provided = _assetManager.GetAssets(); var providedEnvironments = provided.ToList(); // Get default assets var defaults = DefaultAssets.GetDefaultAssets(); var defaultEnvironments = defaults.ToList(); // Merge provided assets into default assets var output = defaultEnvironments.ToDictionary(p => p.TargetEnvironment); foreach (var defaultEnvironment in defaultEnvironments) { // Iterate through each matching provided environment adding // assets from that environment into our default environments foreach (var environment in providedEnvironments .Where(g => g.TargetEnvironment == defaultEnvironment.TargetEnvironment || g.TargetEnvironment == TargetEnvironment.All) .ToList()) { foreach (var asset in environment.Assets) { output[defaultEnvironment.TargetEnvironment].Assets.Add(asset); } } } return(output.Values.ToList()); }
public MainForm(IAssetManager assetManager) { this.assetManager = assetManager; Login(); InitializeComponent(); BuildAssetGridDataSource(assetManager.GetAssets()); dataGridViewAssets.DataSource = assetGridDataSource; toolStripButtonNew.Enabled = assetGridDataSource.Count > 0; if (user != null) { Text = $"{Text} - [{user.Username}]"; } }