private void PluginInit() { var types = TypeLocator.FindTypes("*plugin*.dll", typeof(PanelBase)); foreach (Type type in types) { PluginInfo info = new PluginInfo(); PanelMetadataAttribute atty = type.GetAttribute <PanelMetadataAttribute>(); info.PluginType = type; if (atty != null && !string.IsNullOrWhiteSpace(atty.DisplayName)) { info.Name = atty.DisplayName; } else { info.Name = PascalCaseSplitter.Split(type.Name); } if (atty != null && !string.IsNullOrWhiteSpace(atty.IconPath)) { info.Icon = WPFHelpers.GetImage(atty.IconPath, info.PluginType.Assembly); } if (info.Icon == null) { info.Icon = WPFHelpers.GetImage("images/puzzle-piece.png"); } this.Invoke(() => Plugins.Add(info)); } this.BeginInvoke(() => { if (SelectedPanel == null) { SelectedPanel = Plugins[0]; } }); }
private Dictionary <Type, ServiceHostInfo> FindAllHosts() { var hosts = new Dictionary <Type, ServiceHostInfo>(); foreach (Type type in TypeLocator.FindTypes(_dllSearchPattern, typeof(IServiceHost))) { ServiceHostInfo info = new ServiceHostInfo(); Type interfaceType = (Type)type.GetMethod("GetInterfaceType", BindingFlags.Public | BindingFlags.Static | BindingFlags.FlattenHierarchy).Invoke(null, null); info.InterfaceType = interfaceType; info.Logger = _logger; info.Host = new ServiceHost(type); info.Host.Description.Behaviors.Add(new HostErrorHandlerBehavior(info)); info.Host.Authorization.ServiceAuthorizationManager = new RoleBasedAuthorizationManager(); ContractDescription contract = ContractDescription.GetContract(interfaceType); EndpointAddress endpoint = EndpointInformation.BuildEndpoint(new EndpointInformation(), ServerConnectionInformation.Instance, interfaceType); Binding binding = BindingInformation.BuildBinding(new BindingInformation(), ServerConnectionInformation.Instance); ServiceEndpoint service = new ServiceEndpoint(contract, binding, endpoint); info.Host.AddServiceEndpoint(service); hosts.Add(interfaceType, info); } return(hosts); }
private IEnumerable <Type> EnumerateWithCompositeSelector() { TypeIncludes includes = new TypeIncludes(); if (IsSet(Mode, UiControlTypeSelectorMode.ConcreteTypes)) { includes = TypeIncludes.ConcreteTypes; } if (IsSet(Mode, UiControlTypeSelectorMode.InterfaceTypes)) { includes = includes | TypeIncludes.InterfaceTypes; } if (IsSet(Mode, UiControlTypeSelectorMode.PrimitiveTypes)) { includes = includes | TypeIncludes.PrimitiveTypes; } return(TypeLocator.FindTypes(includes, this.AssignableTo)); }
public static void Register(ComponentType types = ComponentType.All) { var components = TypeLocator.FindTypes("*Component*.dll", typeof(IComponent)); foreach (var component in components) { if (!component.IsAbstract) //skip abstract classes { var atty = component.GetAttribute <ComponentRegistrationAttribute>(); if (atty != null) { if ((types & atty.Type) == types && !atty.DoNotRegister) { var lifeCycle = typeof(SingletonBase).IsAssignableFrom(component) ? LifeCycle.Singleton : LifeCycle.Transient; IoCContainer.Instance.Register(atty.InterfaceType, component, lifeCycle); } } } } }
private static void BuildJobActionTypeMap() { var type = typeof(JobBase <>); var jobBases = TypeLocator.FindTypes("*.dll", typeof(JobBase <>)).ToList(); var jobConfigs = TypeLocator.FindTypes("*.dll", typeof(JobConfiguration)).ToList(); //types.AddRange(Assembly.GetExecutingAssembly().GetTypes().Where(t => t != type && type.IsAssignableFrom(t))); foreach (var realtype in jobBases) { foreach (ConstructorInfo con in realtype.GetConstructors()) { foreach (ParameterInfo parm in con.GetParameters()) { if (jobConfigs.Contains(parm.ParameterType)) { _jobTypeMap.Add(parm.ParameterType, realtype); } } } } }
public void Load() { lock (Instances) { RegistryKey key = Registry.CurrentUser.OpenSubKey("Software", true); key = key.CreateSubKey(_keyname); List <KeyValuePair <string, object> > values = new List <KeyValuePair <string, object> >(); foreach (string name in key.GetValueNames()) { values.Add(new KeyValuePair <string, object>(name, key.GetValue(name))); } List <Type> types = new List <Type>(); types.AddRange(TypeLocator.FindTypes("*client*dll", typeof(ClientSettingsBase))); types.AddRange(TypeLocator.FindTypes("*plugin*dll", typeof(ClientSettingsBase))); foreach (Type t in types.Distinct()) { ClientSettingsBase instance = (ClientSettingsBase)Activator.CreateInstance(t); instance.Unserialize(values); Instances.Add(instance); } } }