internal static void AddCustom(object target, ICustom cc) { var identifier = Identifier(target); var ccs = Shared.GetOrCreateCustomsList(identifier); ccs.Add(cc); }
public void AddICustom() { if (!Directory.Exists(PluginPath)) { return; } string[] dllFiles = Directory.GetFiles(PluginPath, "*.dll"); foreach (string str in dllFiles) { FileInfo f = new FileInfo(str); string t = f.Name.Split(".".ToCharArray())[0]; string pluginName = t + "." + t; ObjectHandle oh = Activator.CreateComInstanceFrom(str, pluginName); ICustom pluginClass = oh.Unwrap() as ICustom; if (pluginClass != null) { if (!_lstICustom.Contains(pluginClass)) { string xmlString = PluginPath + t + ".xml"; pluginClass.ListStructInfo = GetStructInfo(xmlString, pluginName); _lstICustom.Add(pluginClass); _lstStructInfo.AddRange(pluginClass.ListStructInfo); } } } }
static Column() { Type type = typeof(valueType); if (type.IsEnum || !type.IsValueType) { AutoCSer.LogHelper.Error(type.fullName() + " 非值类型,不能用作数据列", LogLevel.Error | LogLevel.AutoCSer); return; } attribute = TypeAttribute.GetAttribute <ColumnAttribute>(type, true) ?? ColumnAttribute.Default; foreach (MethodInfo method in type.GetMethods(System.Reflection.BindingFlags.Static | System.Reflection.BindingFlags.Public | System.Reflection.BindingFlags.NonPublic)) { #if NOJIT if (typeof(ICustom).IsAssignableFrom(method.ReturnType) #else if (typeof(ICustom <valueType>).IsAssignableFrom(method.ReturnType) #endif && method.GetParameters().Length == 0 && method.IsDefined(typeof(ColumnAttribute), false)) { object customValue = method.Invoke(null, null); if (customValue != null) { #if NOJIT custom = (ICustom)customValue; #else custom = (ICustom <valueType>)customValue; #endif return; } } } Fields = Field.Get(MemberIndexGroup <valueType> .GetFields(attribute.MemberFilters), true).ToArray(); dataColumns = new AutoCSer.Threading.LockDictionary <HashString, KeyValue <string, Type>[]>(); AutoCSer.Memory.Common.AddClearCache(dataColumns.Clear, typeof(Column <valueType>), 60 * 60); }
private void run_Click(object sender, EventArgs e) { MakeLoadScreen(); foreach (ListViewItem v in BloatList.CheckedItems) { (v.Tag as WSBloatware).Uninstall(); } foreach (ListViewItem v in MiscList.CheckedItems) { Console.WriteLine(v.Tag.GetType()); foreach (Type iface in v.Tag.GetType().GetInterfaces()) { if (iface == typeof(ICustom)) { ICustom custom = (v.Tag as ICustom); if (custom.CanRun()) { custom.Run(); } } else if (iface == typeof(IRegEdit)) { foreach (RegEdit reg in (v.Tag as IRegEdit).GetRegEdits()) { if (reg.CanRun()) { reg.Run(); } } } break; } } ExitLoadScreen(); DialogResult res = MessageBox.Show("You need to restart for the changes to take affect. Would you like to restart now?", "Restart?", MessageBoxButtons.YesNo); if (res == DialogResult.Yes) { Process.Start(new ProcessStartInfo("shutdown.exe", "-r -t 2")); } else { Application.Exit(); } }
public CustomController(ICustom custom) { this._customServer = custom; }
private bool SetCustomInternal(string key, ICustom cc, bool replace) { Control.LogDebug(DType.CCLoading, $"SetCustomInternal key={key} cc={cc}"); if (!customs.TryGetValue(key, out var ccs)) { ccs = new List <ICustom>(); customs[key] = ccs; } var attribute = Registry.GetAttributeByType(cc.GetType()); for (int i = 0; i < ccs.Count; i++) { var custom = ccs[i]; var attribute2 = Registry.GetAttributeByType(custom.GetType()); bool same_type = string.IsNullOrEmpty(attribute.Group) ? attribute.Name == attribute2.Name : attribute.Group == attribute2.Group; if (!same_type) { continue; } if (attribute.AllowArray) { if (!(cc is IReplaceIdentifier cci1)) { break; } if (custom is IReplaceIdentifier cci2 && cci1.ReplaceID == cci2.ReplaceID) { Control.LogDebug(DType.CCLoading, $"--find replace: add:{attribute.Name} fnd:{attribute2.Name} grp:{attribute.Group} rid:{cci1.ReplaceID} Replace: {replace}"); Control.LogDebug(DType.CCLoading, $"--replace: from:{custom} to:{cc}"); if (replace) { ccs[i] = cc; return(true); } return(false); } } else { Control.LogDebug(DType.CCLoading, $"--find replace: add:{attribute.Name} fnd:{attribute2.Name} grp:{attribute.Group} Replace: {replace}"); Control.LogDebug(DType.CCLoading, $"--replace: from:{custom} to:{cc}"); if (replace) { ccs[i] = cc; return(true); } return(false); } } Control.LogDebug(DType.CCLoading, $"--added"); ccs.Add(cc); return(true); }
internal static bool SetCustomWithIdentifier(string identifier, ICustom cc, bool replace) { return(Shared.SetCustomInternal(identifier, cc, replace)); }
public BasicController(ILogger <BasicController> logger, ICustom customService) { _logger = logger; _customService = customService; }
/// <summary> /// Customs the asynchronous. /// </summary> /// <param name="registration">The registration.</param> /// <param name="custom">The custom.</param> /// <param name="param">The parameter.</param> /// <param name="tag">The tag.</param> /// <param name="cancellationToken">The cancellation token.</param> /// <returns></returns> /// <exception cref="NotSupportedException"></exception> public virtual async Task <object> CustomAsync(Type registration, ICustom custom, object param = null, object tag = null, CancellationToken?cancellationToken = null) => await custom.ExecuteAsync(_client, param, tag, cancellationToken);