public virtual void CollectResources(IList <ResourcePtr> ResourceCollector) { foreach (IHasResources AC in AllComponents.Where(x => x is IHasResources)) { AC.CollectResources(ResourceCollector); } }
public void AddToCart(Components components) { var componentToCart = ShoppingCart.ToList().Find(c => c.ComponentId == components.ComponentId); if (componentToCart == null) { Components newComponent = new Components(); newComponent.ComponentId = components.ComponentId; newComponent.ReceptId = components.ReceptId; newComponent.ComponentName = components.ComponentName; newComponent.ComponentAmount = 1; ShoppingCart.Add(newComponent); } else { componentToCart.ComponentAmount++; } components.ComponentAmount--; if (components.ComponentAmount == 0) { AllComponents.Remove(components); } OnPropertyChanged("AllComponents"); }
public void Update() { while (AddComponents.Count > 0) { AllComponents.Add(AddComponents[0]); AddComponents.RemoveAt(0); } foreach (var item in AllComponents) { if (item.IsDisposed) { RemoveComponents.Add(item); continue; } item.Update(); } if (RemoveComponents.Count > 0) { foreach (var item in RemoveComponents) { AllComponents.Remove(item); } RemoveComponents.Clear(); } }
public ICollection <WizardBaseController> GetComponentsForAssignmentType(AssignmentTypes type) { return(AllComponents .Cast <WizardBaseController>() .Where(a => a.ValidAssignmentTypes.Contains(type)) .ToList()); }
public void DeleteSelectedComponents() { foreach (DrawableComponent dc in SelectedComponents) { foreach (CircuitInput ci in dc.Inputs) { if (ci.Signal != null) { DrawableWire dw = (DrawableWire)ci.Signal; dw.From.RemoveOutputWire(dw.FromIndex, dw); RemoveWire((DrawableWire)ci.Signal); } } foreach (CircuitOutput co in dc.Outputs) { co.Signals.ForEach(x => { DrawableWire dw = (DrawableWire)x; dw.To.RemoveInputWire(dw.ToIndex); RemoveWire((DrawableWire)x); }); } AllComponents.Remove(dc); } SelectedComponents.Clear(); }
public static Entity Player(this AllEntities entities, AllComponents components) { var entity = entities.Create(); components.Set(entity, new Entia.Components.Debug { Name = "Player" }); components.Set(entity, new Components.Position()); components.Set(entity, new Components.Velocity()); components.Set(entity, new Components.Rotation()); components.Set(entity, new Components.Scale { X = 2.0, Y = 2.5 }); components.Set(entity, new Components.Motion { MoveSpeed = 0.0, RotateSpeed = 2.0 }); components.Set(entity, new Components.Sprite { Path = "Shapes/Triangle", Color = Color.Cyan }); components.Set(entity, new Components.Collider { Radius = 0.25 }); components.Set(entity, new Components.Controller()); components.Set(entity, new Components.Damageable { By = DamageTypes.Body }); components.Set(entity, new Components.Health { Current = 1.0, Maximum = 1.0 }); return(entity); }
public void FillList() { using (SqlConnection conn = new SqlConnection(ConfigurationManager.ConnectionStrings["con"].ToString())) { SqlCommand query = new SqlCommand(@"exec Get_AllComponents", conn); conn.Open(); SqlDataAdapter sqlDataAdapter = new SqlDataAdapter(query); DataTable dataTable = new DataTable(); sqlDataAdapter.Fill(dataTable); if (AllComponents == null) { AllComponents = new ObservableCollection <Components>(); } foreach (DataRow row in dataTable.Rows) { Components r = new Components { ComponentId = int.Parse(row[0].ToString()), ReceptId = int.Parse(row[1].ToString()), ComponentName = row[2].ToString(), ComponentAmount = int.Parse(row[3].ToString()), }; AllComponents.Add(r); } } }
private void CreateCurrentComponent() { if (Current == null) { return; } AllComponents.Add(new List <T>()); }
public static WicEncoder FromMimeType(string mimeType) { if (mimeType == null) { return(null); } return(AllComponents.OfType <WicEncoder>().FirstOrDefault(c => c.SupportsMimeType(mimeType))); }
private IEnumerable <LauncherUpdaterItem> GetUpdaterItems(IEnumerable <IComponent> components) { if (components is null) { throw new ArgumentNullException(nameof(components)); } var pendingComponents = components.ToList(); foreach (var pendingComponent in pendingComponents) { var item = new LauncherUpdaterItem(); var componentFilePath = pendingComponent.GetFilePath(); switch (pendingComponent.RequiredAction) { case ComponentAction.Keep: continue; case ComponentAction.Delete: item.File = componentFilePath; item.Destination = null; break; case ComponentAction.Update: ComponentDownloadPathStorage.Instance.TryGetValue(pendingComponent, out var file); item.File = file; item.Destination = componentFilePath; break; } item.BackupDestination = componentFilePath; BackupManager.Instance.TryGetValue(pendingComponent, out var backup); item.Backup = backup; yield return(item); } var completedComponents = AllComponents.Except(pendingComponents).ToList(); foreach (var completedComponent in completedComponents) { if (completedComponent.RequiredAction == ComponentAction.Keep) { continue; } var item = new LauncherUpdaterItem { BackupDestination = completedComponent.GetFilePath() }; BackupManager.Instance.TryGetValue(completedComponent, out var backup); if (!string.IsNullOrEmpty(backup)) { item.Backup = backup; } yield return(item); } }
/// <summary> /// Report an update in tech level and any new components that have became /// available. /// </summary> private void TechLevelUp(TechLevel.ResearchField area, EmpireData empire) { TechLevel oldResearchLevel = empire.ResearchLevels.Clone(); empire.ResearchLevels[area]++; TechLevel newResearchLevel = empire.ResearchLevels; Message techAdvanceMessage = new Message( empire.Id, "Your race has advanced to Tech Level " + empire.ResearchLevels[area] + " in the " + area.ToString() + " field", "TechAdvance", null); serverState.AllMessages.Add(techAdvanceMessage); AllComponents allComponents = new AllComponents(); foreach (Component component in allComponents.GetAll.Values) { if (oldResearchLevel < component.RequiredTech && newResearchLevel >= component.RequiredTech) { empire.AvailableComponents.Add(component); Message newComponentMessage = null; if (component.Properties.ContainsKey("Scanner") && component.Type == ItemType.PlanetaryInstallations) { newComponentMessage = new Message( empire.Id, "All existing planetary scanners has been replaced by " + component.Name + " " + component.Type, "NewComponentMessage", null); foreach (Star star in empire.OwnedStars.Values) { if (star.Owner == empire.Id && star.ScannerType != string.Empty) { star.ScannerType = component.Name; } } } else { newComponentMessage = new Message( empire.Id, "You now have available the " + component.Name + " " + component.Type + " component", "NewComponentMessage", // TODO (priority 4) - Is this used? Is it documented somewhere? Why a string and not an enum? null); } serverState.AllMessages.Add(newComponentMessage); } } }
private static HashSet <string> GetDecoderExtensions() { var dic = new HashSet <string>(StringComparer.OrdinalIgnoreCase); foreach (var dec in AllComponents.OfType <WicDecoder>()) { foreach (var ext in dec.FileExtensionsList) { dic.Add(ext); } } return(dic); }
public Player(Point position, int fovRadius = 10) : base(position, 1, false) { // Set FOV radius we will use for calculating FOV FOVRadius = fovRadius; // Set hook so that FOV is recalculated when the player moves Moved += OnMoved; // Add component for controlling player movement via keyboard var motionControl = new PlayerControlsComponent(); AllComponents.Add(motionControl); }
public static WicEncoder FromFileExtension(string ext) { if (ext == null) { return(null); } if (!ext.StartsWith(".", StringComparison.Ordinal)) { ext = Path.GetExtension(ext); } return(AllComponents.OfType <WicEncoder>().FirstOrDefault(e => e.SupportsFileExtension(ext))); }
/// <summary> /// Converts a delimited string into a list of <see cref="IWizardBaseController"/> objects. /// </summary> /// <param name="itemString"></param> /// <param name="delimiter">The token used to delimit each entry</param> /// <returns></returns> private List <IWizardBaseController> ComponentsFromString(string itemString, string delimiter) { List <IWizardBaseController> components = new List <IWizardBaseController>(); string[] items = itemString.Split(delimiter.ToCharArray()); foreach (string item in items) { IWizardBaseController component = AllComponents.Find(c => c.ControllerName == item); if (component != null) { components.Add(component); } } return(components); }
public static WicEncoder FromName(string name) { if (name == null) { return(null); } var item = AllComponents.OfType <WicEncoder>().FirstOrDefault(c => c.FriendlyName.EqualsIgnoreCase(name)); if (item != null) { return(item); } return(AllComponents.OfType <WicEncoder>().FirstOrDefault(f => f.FriendlyName.ToLowerInvariant().Replace("encoder", "").Trim().EqualsIgnoreCase(name))); }
public static T FromName <T>(string name) where T : WicImagingComponent { if (name == null) { return(null); } var item = AllComponents.OfType <T>().FirstOrDefault(f => f.FriendlyName.EqualsIgnoreCase(name)); if (item != null) { return(item); } return(AllComponents.OfType <T>().FirstOrDefault(f => f.FriendlyName.Replace(" ", "").EqualsIgnoreCase(name))); }
private void CheckForMissingFilesInHomeBuilderDirectory() { var missingComponents = new List <string>(); var homeBuilderFiles = Directory.EnumerateFiles(SourceHomeBuilderPath, "*.*", SearchOption.AllDirectories); homeBuilderFiles = homeBuilderFiles.Where(x => !x.Contains(@"\Logs\")); foreach (var file in homeBuilderFiles) { if (!AllComponents.Contains(file) && !IgnoredHomeBuilderFiles.Contains(file)) { missingComponents.Add(file); } } LogAndThrow("There are additional files in the Home Builder directory that are not specified in this artifact's component set:", missingComponents); }
/// <Summary> /// A new area has been selected for research. Make a note of where the research /// resources are now going to be spent. /// </Summary> /// <param name="sender">The source of the event.</param> /// <param name="e">A <see cref="EventArgs"/> that contains the event data.</param> private void CheckChanged(object sender, EventArgs e) { if (dialoginitialized == false) { return; } RadioButton button = sender as RadioButton; if (button != null && button.Checked == true) { try { clientState.EmpireState.ResearchTopics[targetArea] = 0; targetArea = (TechLevel.ResearchField)Enum.Parse(typeof(TechLevel.ResearchField), button.Text, true); clientState.EmpireState.ResearchTopics[targetArea] = 1; } catch (System.ArgumentException) { Report.Error("ResearchDialog.cs : CheckChanged() - unrecognised field of research."); } } // Populate the expected research benefits list AllComponents allComponents = new AllComponents(); TechLevel oldResearchLevel = currentLevel; TechLevel newResearchLevel = new TechLevel(oldResearchLevel); newResearchLevel[targetArea] = oldResearchLevel[targetArea] + 1; researchBenefits.Items.Clear(); foreach (Nova.Common.Components.Component component in allComponents.GetAll.Values) { if (!oldResearchLevel.Meets(component.RequiredTech) && newResearchLevel.Meets(component.RequiredTech)) { string available = component.Name + " " + component.Type; researchBenefits.Items.Add(available); } } ParameterChanged(null, null); }
public void Update() { if (AllComponents.Count == 0) { return; } for (int i = AllComponents.Count - 1; i >= 0; i--) { var item = AllComponents[i]; if (item.IsDisposed) { AllComponents.RemoveAt(i); continue; } if (item.Disable) { continue; } item.Update(); } }
public static Entity Enemy(this AllEntities entities, AllComponents components, in Components.Position position, in Components.Rotation rotation, double lifetime, double speed, double health)
public bool TryGetComponentByID(string id, [NotNullWhen(true)] out Component?comp) { comp = AllComponents.FirstOrDefault(x => x.UniqueID == id, null); return(comp != null); }
public void RemoveComponent(DrawableComponent dc) { AllComponents.Remove(dc); }
public void AddComponent(DrawableComponent dc) { AllComponents.Add(dc); }
public IEnumerable <WicPixelFormatConverter> GetPixelFormatConvertersTo(Guid targetFormat) => AllComponents.OfType <WicPixelFormatConverter>().Where(pf => pf.CanConvert(Guid, targetFormat));
/// <summary> /// Initialize the data needed for the GUI to run. /// </summary> /// <param name="argArray">The command line arguments.</param> public void Initialize(string[] argArray) { // Restore the component definitions. Must be done first so that components used // in designs can be linked to when loading the .intel file. try { AllComponents allComponents = new AllComponents(); } catch { Report.FatalError("Could not restore component definition file."); } // Need to identify the RaceName so we can load the correct race's intel. // We also want to identify the ClientState data store, if any, so we // can load it and use any historical information in there. // Last resort we will ask the user what to open. // There are a number of starting scenarios: // 1. the Nova GUI was started directly (e.g. in the debugger). // There will be zero options/arguments in the argArray. // We will continue an existing game, if any. // - get GameFolder from the config file // - look for races and ask the user to pick one. If none need to // ask the user to open a game (.intel), then treat as per option 2. // - Build the stateFileName from the GameFolder and Race name and // load it, if it exists. If not don't care. // 2. the Nova GUI was started from Nova Launcher's "open a game option". // or by double clicking a race in the Nova Console // There will be a .intel file listed in the argArray. // Evenything we need should be found in there. // 3. the Nova GUI was started from the launcher to continue a game. // There will be a StateFileName in the argArray. // Directly load the state file. If it is missing - FatalError. // (The race name and game folder will be loaded from the state file) StatePathName = null; string intelFileName = null; // process the arguments CommandArguments commandArguments = new CommandArguments(argArray); if (commandArguments.Contains(CommandArguments.Option.RaceName)) { EmpireState.Race.Name = commandArguments[CommandArguments.Option.RaceName]; } if (commandArguments.Contains(CommandArguments.Option.StateFileName)) { StatePathName = commandArguments[CommandArguments.Option.StateFileName]; } if (commandArguments.Contains(CommandArguments.Option.IntelFileName)) { intelFileName = commandArguments[CommandArguments.Option.IntelFileName]; } // Get the name of the folder where all the game files will be stored. // Normally this would be placed in the config file by the NewGame wizard. // We also cache a copy in the ClientState.Data.GameFolder GameFolder = FileSearcher.GetFolder(Global.ServerFolderKey, Global.ServerFolderName); if (GameFolder == null) { Report.FatalError("ClientState.cs Initialize() - An expected config file entry is missing\n" + "Have you ran the Race Designer and \n" + "Nova Console?"); } // Sort out what we need to initialize the ClientState bool isLoaded = false; // 1. the Nova GUI was started directly (e.g. in the debugger). // There will be zero options/arguments in the argArray. // We will continue an existing game, if any. if (argArray.Length == 0) { // - get GameFolder from the conf file - already done. // - look for races and ask the user to pick one. EmpireState.Race.Name = SelectRace(GameFolder); if (!string.IsNullOrEmpty(EmpireState.Race.Name)) { isLoaded = true; } else { // If none need to ask the user to open a game (.intel), // then treat as per option 2. try { OpenFileDialog fd = new OpenFileDialog(); fd.Title = "Open Game"; fd.FileName = "*." + Global.IntelExtension; DialogResult result = fd.ShowDialog(); if (result != DialogResult.OK) { Report.FatalError("ClientState.cs Initialize() - Open Game dialog canceled. Exiting. Try running the NovaLauncher."); } intelFileName = fd.FileName; } catch { Report.FatalError("ClientState.cs Initialize() - Unable to open a game. Try running the NovaLauncher."); } } } // 2. the Nova GUI was started from the launcher open a game option. // There will be a .intel file listed in the argArray. if (!isLoaded && intelFileName != null) { if (File.Exists(intelFileName)) { // Evenything we need should be found in there. IntelReader intelReader = new IntelReader(this); intelReader.ReadIntel(intelFileName); isLoaded = true; } else { Report.FatalError("ClientState.cs Initialize() - Could not locate .intel file \"" + intelFileName + "\"."); } } // 3. the Nova GUI was started from the launcher to continue a game. // There will be a StateFileName in the argArray. // NB: we already copied it to ClientState.Data.StateFileName, but other // code sets that too, so check the arguments to see if it was there. if (!isLoaded && commandArguments.Contains(CommandArguments.Option.StateFileName)) { // The state file is not sufficient to load a turn. We need the .intel // for this race. What race? The state file can tell us. // (i.e. The race name and game folder will be loaded from the state file) // If it is missing - FatalError. if (File.Exists(StatePathName)) { Restore(); IntelReader intelReader = new IntelReader(this); intelReader.ReadIntel(intelFileName); isLoaded = true; } else { Report.FatalError("ClientState.cs Initialize() - File not found. Could not continue game \"" + StatePathName + "\"."); } } if (!isLoaded) { Report.FatalError("ClientState.cs initialize() - Failed to find any .intel when initializing turn"); } FirstTurn = false; }
/// <summary> /// When state is loaded from file, objects may contain references to other objects. /// As these may be loaded in any order (or be cross linked) it is necessary to tidy /// up these references once the state is fully loaded and all objects exist. /// In most cases a placeholder object has been created with the Key set from the file, /// and we need to find the actual reference using this Key. /// Objects can't do this themselves as they don't have access to the state data, /// so we do it here. /// </summary> private void LinkReferences() { AllComponents allComponents = new AllComponents(); // HullModule reference to a component foreach (ShipDesign design in Designs.Values) { foreach (HullModule module in design.Hull.Modules) { if (module.AllocatedComponent != null && module.AllocatedComponent.Name != null) { module.AllocatedComponent = allComponents.Fetch(module.AllocatedComponent.Name); } } design.Update(); if (design.Id >= designCounter) { designCounter = design.Id + 1; } } // Link enemy designs too foreach (EmpireIntel enemy in EmpireReports.Values) { foreach (ShipDesign design in enemy.Designs.Values) { foreach (HullModule module in design.Hull.Modules) { if (module.AllocatedComponent != null && module.AllocatedComponent.Name != null) { module.AllocatedComponent = allComponents.Fetch(module.AllocatedComponent.Name); } } design.Update(); } } // Fleet reference to Star foreach (Fleet fleet in OwnedFleets.Values) { if (fleet.InOrbit != null) { if (StarReports[fleet.InOrbit.Name].Owner == fleet.Owner) { fleet.InOrbit = OwnedStars[fleet.InOrbit.Name]; } else { fleet.InOrbit = StarReports[fleet.InOrbit.Name]; } } // Ship reference to Design foreach (ShipToken token in fleet.Composition.Values) { token.Design = Designs[token.Design.Key]; } } // Set designs in any Battle Reports foreach (BattleReport battle in BattleReports) { foreach (Stack stack in battle.Stacks.Values) { if (stack.Owner == empireId) { stack.Token.Design = Designs[stack.Token.Key]; } else { stack.Token.Design = EmpireReports[stack.Owner].Designs[stack.Token.Key]; } } } // Link reports to Designs to get accurate data. foreach (FleetIntel report in FleetReports.Values) { foreach (ShipToken token in report.Composition.Values) { if (report.Owner == Id) { token.Design = Designs[token.Design.Key]; } else { token.Design = EmpireReports[report.Owner].Designs[token.Design.Key]; } } } // Link Star Races and Starbases foreach (Star star in OwnedStars.Values) { if (star.Owner == Id) { star.ThisRace = Race; } else { star.ThisRace = null; } if (star.Starbase != null) { star.Starbase = OwnedFleets[star.Starbase.Key]; } } }
/// <summary> /// Initialize some starting designs. /// </summary> /// <param name="race">The <see cref="Race"/> of the player being initialized.</param> /// <param name="player">The player being initialized.</param> private void PrepareDesigns(EmpireData empire, string player) { // Read components data and create some basic stuff AllComponents components = new AllComponents(); Component colonyShipHull = null, scoutHull = null; Component colonizer = null; Component scaner = components.Fetch("Bat Scanner"); Component armor = components.Fetch("Tritanium"); Component shield = components.Fetch("Mole-skin Shield"); Component laser = components.Fetch("Laser"); Component torpedo = components.Fetch("Alpha Torpedo"); Component starbaseHull = components.Fetch("Space Station"); Component engine = components.Fetch("Quick Jump 5"); Component colonyShipEngine = null; if (empire.Race.Traits.Primary.Code != "HE") { colonyShipHull = components.Fetch("Colony Ship"); } else { colonyShipEngine = components.Fetch("Settler's Delight"); colonyShipHull = components.Fetch("Mini-Colony Ship"); } scoutHull = components.Fetch("Scout"); if (empire.Race.HasTrait("AR") == true) { colonizer = components.Fetch("Orbital Construction Module"); } else { colonizer = components.Fetch("Colonization Module"); } if (colonyShipEngine == null) { colonyShipEngine = engine; } ShipDesign cs = new ShipDesign(empire.GetNextDesignKey()); cs.Blueprint = colonyShipHull; foreach (HullModule module in cs.Hull.Modules) { if (module.ComponentType == "Engine") { module.AllocatedComponent = colonyShipEngine; module.ComponentCount = 1; } else if (module.ComponentType == "Mechanical") { module.AllocatedComponent = colonizer; module.ComponentCount = 1; } } cs.Icon = new ShipIcon(colonyShipHull.ImageFile, (Bitmap)colonyShipHull.ComponentImage); cs.Type = ItemType.Ship; cs.Name = "Santa Maria"; cs.Update(); ShipDesign scout = new ShipDesign(empire.GetNextDesignKey()); scout.Blueprint = scoutHull; foreach (HullModule module in scout.Hull.Modules) { if (module.ComponentType == "Engine") { module.AllocatedComponent = engine; module.ComponentCount = 1; } else if (module.ComponentType == "Scanner") { module.AllocatedComponent = scaner; module.ComponentCount = 1; } } scout.Icon = new ShipIcon(scoutHull.ImageFile, (Bitmap)scoutHull.ComponentImage); scout.Type = ItemType.Ship; scout.Name = "Scout"; scout.Update(); ShipDesign starbase = new ShipDesign(empire.GetNextDesignKey()); starbase.Name = "Starbase"; starbase.Blueprint = starbaseHull; starbase.Type = ItemType.Starbase; starbase.Icon = new ShipIcon(starbaseHull.ImageFile, (Bitmap)starbaseHull.ComponentImage); bool weaponSwitcher = false; // start with laser bool armorSwitcher = false; // start with armor foreach (HullModule module in starbase.Hull.Modules) { if (module.ComponentType == "Weapon") { if (weaponSwitcher == false) { module.AllocatedComponent = laser; } else { module.AllocatedComponent = torpedo; } weaponSwitcher = !weaponSwitcher; module.ComponentCount = 8; } if (module.ComponentType == "Shield") { module.AllocatedComponent = shield; module.ComponentCount = 8; } if (module.ComponentType == "Shield or Armor") { if (armorSwitcher == false) { module.AllocatedComponent = armor; } else { module.AllocatedComponent = shield; } module.ComponentCount = 8; armorSwitcher = !armorSwitcher; } } starbase.Update(); empire.Designs[starbase.Key] = starbase; empire.Designs[cs.Key] = cs; empire.Designs[scout.Key] = scout; /* * switch (race.Traits.Primary.Code) * { * case "HE": * // Start with one armed scout + 3 mini-colony ships * case "SS": * // Start with one scout + one colony ship. * case "WM": * // Start with one armed scout + one colony ship. * break; * * case "CA": * // Start with an orbital terraforming ship * break; * * case "IS": * // Start with one scout and one colony ship * break; * * case "SD": * // Start with one scout, one colony ship, Two mine layers (one standard, one speed trap) * break; * * case "PP": * empireData.ResearchLevel[TechLevel.ResearchField.Energy] = 4; * // Two shielded scouts, one colony ship, two starting planets in a non-tiny universe * break; * * case "IT": * empireData.ResearchLevel[TechLevel.ResearchField.Propulsion] = 5; * empireData.ResearchLevel[TechLevel.ResearchField.Construction] = 5; * // one scout, one colony ship, one destroyer, one privateer, 2 planets with 100/250 stargates (in non-tiny universe) * break; * * case "AR": * empireData.ResearchLevel[TechLevel.ResearchField.Energy] = 1; * * // starts with one scout, one orbital construction colony ship * break; * * case "JOAT": * // two scouts, one colony ship, one medium freighter, one mini miner, one destroyer * break; */ }
public static T FromContainerFormatGuid <T>(Guid guid) where T : WicCodec => AllComponents.OfType <T>().FirstOrDefault(c => c.ContainerFormat == guid);
/// <summary> /// Registers all components with the component manager /// </summary> private void RegisterComponents() { //use reflection to find all available components string componentNamespace = WizardComponentNamespace; List <Type> componentObjects = (from type in Assembly.GetExecutingAssembly().GetTypes() where type.GetInterfaces().Contains(typeof(IWizardBaseController)) && !type.IsAbstract && type.Namespace.CompareTo(componentNamespace) == 0 select type).ToList(); foreach (Type component in componentObjects) { IWizardBaseController controller = Activator.CreateInstance(component) as IWizardBaseController; AllComponents.Add(controller); } //pull from the cache if possible FileCache cache = FileCacheHelper.GetGlobalCacheInstance(); bool loadedFromCache = false; string[] sorted = (string[])cache.Get(componentsCacheString, CacheRegion); if (sorted != null) { //set loaded to true for now loadedFromCache = true; //make sure that the sizes match up if (sorted.Length != AllComponents.Count) { loadedFromCache = false; } //make sure all components are represented in the cache foreach (IWizardBaseController component in AllComponents) { if (!sorted.Contains(component.ControllerName)) { loadedFromCache = false; break; } } //if we're still clear to load from the cache, then do so if (loadedFromCache) { IWizardBaseController[] tempComponentList = new IWizardBaseController[sorted.Length]; for (int i = 0; i < sorted.Length; i++) { IWizardBaseController component = AllComponents.Find(c => c.ControllerName == sorted[i]); if (component != null) { tempComponentList[i] = component; } } //reassign the sorted list AllComponents = tempComponentList.ToList(); } } //if caching failed, do it the long way if (!loadedFromCache) { List <IWizardBaseController> components = SortComponents(AllComponents); AllComponents = components; //save sorted component information to cache string[] sortedComponents = new string[AllComponents.Count]; for (int i = 0; i < sortedComponents.Length; i++) { sortedComponents[i] = AllComponents[i].ControllerName; } cache.Add(componentsCacheString, sortedComponents, cache.DefaultPolicy, CacheRegion); } //attach event listeners to selection change //and apply a sort order for faster sorting in the future int counter = 1; foreach (IWizardBaseController component in AllComponents) { component.SortOrder = counter; component.PropertyChanged += new System.ComponentModel.PropertyChangedEventHandler(ComponentPropertyChanged); counter++; } }