public void LoadBindings() { var contexts = new string[1]; contexts[0] = "ksp"; _bindings.Clear(); _vars.Clear(); _flightControl = null; foreach (Type t in Assembly.GetExecutingAssembly().GetTypes()) { kOSBinding attr = (kOSBinding)t.GetCustomAttributes(typeof(kOSBinding), true).FirstOrDefault(); if (attr != null) { if (attr.Contexts.Count() == 0 || attr.Contexts.Intersect(contexts).Any()) { Binding b = (Binding)Activator.CreateInstance(t); b.AddTo(_shared); _bindings.Add(b); if (b is BindingFlightControls) { _flightControl = (BindingFlightControls)b; } } } } }
public BindingManager(CPU cpu, String context) { this.cpu = cpu; var contexts = new string[1]; contexts[0] = context; foreach (Type t in Assembly.GetExecutingAssembly().GetTypes()) { kOSBinding attr = (kOSBinding)t.GetCustomAttributes(typeof(kOSBinding), true).FirstOrDefault(); if (attr != null) { if (attr.Contexts.Count() == 0 || attr.Contexts.Intersect(contexts).Any()) { Binding b = (Binding)Activator.CreateInstance(t); b.AddTo(this); Bindings.Add(b); } } } }