public ICapturePlugin SetCapturePlugin(Type pluginType) { ICapturePlugin plugin = Activator.CreateInstance(pluginType, new object[] { Table.Database.AddTable(), Logger, Runtime }) as ICapturePlugin; this.CapturePlugin = plugin; SaveToStorage(() => this.CapturePlugin, this.CapturePlugin); return(plugin); }
/// <summary> /// Trys to get a configured Capture Setup Plugin (no specific ordering), /// failing that it will attempt to create a new Capture Plugin from the available types (trys CopyScreenCapture first then, no specific ordering) /// </summary> /// <returns>A list with one Capture Plugin</returns> /// <exception cref="ArgumentNullException"></exception> public SerializableInterfaceList<ICapturePlugin> DefaultCapturePlugins() { SerializableInterfaceList<ICapturePlugin> capturePlugins = new SerializableInterfaceList<ICapturePlugin>(); Type type = AvailableCapturePlugins.Where(a => a.Name == "CopyScreenCapture").FirstOrDefault(); if (type == null) { type = AvailableCapturePlugins.FirstOrDefault(); } if (type == null) { AfterglowRuntime.Logger.Fatal("No ICapturePlugin's have been loaded, please check the install and try again"); } else { ICapturePlugin plugin = Activator.CreateInstance(type) as ICapturePlugin; plugin.Id = this.GetNewId<ICapturePlugin>(); capturePlugins.Add(plugin); } return capturePlugins; }
private IList <ICapturePlugin> GetLookupValues() { PropertyInfo prop = _profile.GetType().GetProperties().Where(p => p.Name == "CapturePlugin").FirstOrDefault(); ConfigTableAttribute configAttribute = Attribute.GetCustomAttribute(prop, typeof(ConfigTableAttribute)) as ConfigTableAttribute; Type pluginType = _profile.GetType(); Type propertyType = prop.PropertyType; IEnumerable <Type> availableValues = null; if (configAttribute.RetrieveValuesFrom != null) { var member = pluginType.GetMember(configAttribute.RetrieveValuesFrom); if (member.Length > 0) { if (member[0].MemberType == MemberTypes.Method) { MethodInfo mi = pluginType.GetMethod(configAttribute.RetrieveValuesFrom); var propertyValue = mi.Invoke(_profile, null); availableValues = propertyValue as IEnumerable <Type>; } } } List <ICapturePlugin> result = new List <ICapturePlugin>(); foreach (Type item in availableValues) { ICapturePlugin plugin = Activator.CreateInstance(item) as ICapturePlugin; result.Add(plugin); } return(result); }