public void Set <T>(FuzzyValue <T> fuzzyValue) where T : struct, System.IConvertible { FuzzyUtils.IsGenericParameterValid <T>(); EnumKey key = EnumKey.From(fuzzyValue.linguisticVariable); float degree = fuzzyValue.membershipDegree; this._internalDictionary[key] = degree; }
public Type NewEnum(string name, Type baseType, IEnumerable <KeyValuePair <string, object> > literals) { lock (Lock) { var item = new EnumKey(name, baseType, literals); item = (EnumKey)FindInCache(item); return(item.Result ?? (item.Result = Wrapping.NewEnum(name, baseType, item._literals))); } }
public void Set(FuzzyVariable <T> fuzzyVariable) { if (fuzzyVariable == null) { return; } int idx = Array.IndexOf <EnumKey <T> >(this.enumValues, EnumKey <T> .From(fuzzyVariable.LinguisticVariable)); this._variables[idx] = fuzzyVariable; }
private void ClearOutputs() { List <FuzzyValue <T> > duplicateList = null; for (int i = 0; i < this.outputEnumValues.Length; i++) { duplicateList = this.duplicateOutputs[EnumKey.From(this.outputEnumValues[i])]; duplicateList.Clear(); } }
private void Initialize() { FuzzyUtils.IsGenericParameterValid <T>(); this.duplicateOutputs = new Dictionary <EnumKey, List <FuzzyValue <T> > >(); this.outputEnumValues = FuzzyUtils.GetEnumValues <T>(); for (int i = 0; i < this.outputEnumValues.Length; i++) { this.duplicateOutputs.Add(EnumKey.From(this.outputEnumValues[i]), new List <FuzzyValue <T> >(10)); } }
public FuzzyValue <T> Get <T>(T linguisticVariable) where T : struct, System.IConvertible { FuzzyUtils.IsGenericParameterValid <T>(); EnumKey key = EnumKey.From(linguisticVariable); float degree = 0.0f; this._internalDictionary.TryGetValue(key, out degree); FuzzyValue <T> fuzzyValue = new FuzzyValue <T>(linguisticVariable, degree); return(fuzzyValue); }
public FuzzySet() { FuzzyUtils.IsGenericParameterValid <T>(); var enumArr = FuzzyUtils.GetEnumValues <T>(); this.enumValues = new EnumKey <T> [enumArr.Length]; for (int i = 0; i < this.enumValues.Length; i++) { this.enumValues[i] = EnumKey <T> .From(enumArr[i]); } this._variables = new FuzzyVariable <T> [this.enumValues.Length]; }
private void CollapseOutputs(FuzzyValue <T>[] values) { List <FuzzyValue <T> > duplicateList = null; for (int i = 0; i < values.Length; i++) { var outputValue = values[i]; if (outputValue.membershipDegree <= 0.0f) { continue; } duplicateList = this.duplicateOutputs[EnumKey.From(outputValue.linguisticVariable)]; duplicateList.Add(outputValue); } }
/// <summary> /// 初始化系统枚举 /// </summary> public static void InitializeEnum() { //记录日志 LogHelper.WriteBussLogStart(BussID, LoginInfoDAX.UserName, System.Reflection.MethodBase.GetCurrentMethod().ToString(), "", "", null); //定义枚举对象列表 BindingList <MDLSM_Enum> resultList = new BindingList <MDLSM_Enum>(); //创建数据CRUD对象 var bll = new BLLBase(Trans.COM); //查询系统所有枚举数据 bll.QueryForList <MDLSM_Enum>(new MDLSM_Enum(), resultList); //初始化字典 dicEnum = new Dictionary <EnumKey, List <MDLSM_Enum> >(); //将查询结果数据保存到字典中 foreach (MDLSM_Enum enu in resultList.OrderBy(x => x.Enum_ID)) { //将字符串转换成对应的枚举类型 EnumKey eKey = (EnumKey)Enum.Parse(typeof(EnumKey), enu.Enum_Key, true); //枚举Key存在的场合:追加数据到枚举值列表 if (dicEnum.ContainsKey(eKey)) { //创建枚举值对象 List <MDLSM_Enum> valueList = new List <MDLSM_Enum>(); //获取已有枚举值列表 valueList = dicEnum[eKey]; valueList.Add(enu); } //枚举Key不存在的场合:新增枚举值 else { //创建枚举值对象 List <MDLSM_Enum> valueList = new List <MDLSM_Enum>(); valueList.Add(enu); dicEnum.Add(eKey, valueList); } } //记录日志 LogHelper.WriteBussLogEndOK(BussID, LoginInfoDAX.UserName, System.Reflection.MethodBase.GetCurrentMethod().ToString(), "", "", null); }
public static void Enum(string Username, string Password, string Domain, string ComputerName, object Hive, string Subkey, object Access) { try { if (CheckAccess.Check(Username, Password, Domain, ComputerName, Hive, Subkey, Access)) { EnumKey.Get(Username, Password, Domain, ComputerName, Hive, Subkey); } else { Console.WriteLine($"[-] Error: Do not have permissions to enumerate keys for {Subkey}"); Environment.Exit(1); } } catch (Exception e) { Console.WriteLine($"[-] Error: {e.Message}"); } }
/// <summary> /// 根据枚举编码,获取对应【枚举值编码】和【枚举名称】的列表 /// </summary> /// <param name="paramKey"></param> /// <returns></returns> public static List <ComComboBoxDataSourceTC> GetEnumForComboBoxWithCodeText(EnumKey paramKey) { List <MDLSM_Enum> cacheEnums = new List <MDLSM_Enum>(); List <ComComboBoxDataSourceTC> resultList = new List <ComComboBoxDataSourceTC>(); if (!dicEnum.ContainsKey(paramKey)) { return(resultList); } else { cacheEnums = dicEnum[paramKey]; } foreach (MDLSM_Enum enu in cacheEnums.OrderBy(x => x.Enum_ID)) { ComComboBoxDataSourceTC ds = new ComComboBoxDataSourceTC(); ds.Code = enu.Enum_ValueCode; ds.Text = enu.Enum_DisplayName; resultList.Add(ds); } return(resultList); }
public void MergeValues(FuzzyValue <T>[] values, FuzzyValueSet mergedOutputs) { this.CollapseOutputs(values); float maxValue = 0.0f; FuzzyValue <T> value; List <FuzzyValue <T> > duplicateList = null; for (int i = 0; i < this.outputEnumValues.Length; i++) { maxValue = 0.0f; duplicateList = this.duplicateOutputs[EnumKey.From(this.outputEnumValues[i])]; for (int j = 0; j < duplicateList.Count; j++) { value = duplicateList[j]; if (value.membershipDegree > maxValue) //Or-ing outputs { maxValue = value.membershipDegree; } } mergedOutputs.Set(new FuzzyValue <T>(this.outputEnumValues[i], maxValue)); duplicateList.Clear(); } }
/// <summary> /// 根据枚举编码,获取对应【枚举信息】的列表 /// </summary> /// <param name="paramKey"></param> /// <returns></returns> public static List <MDLSM_Enum> GetEnum(EnumKey paramKey) { return(dicEnum[paramKey]); }
public FuzzyVariable <T> Get(T linguisticVar) { int idx = Array.IndexOf <EnumKey <T> >(this.enumValues, EnumKey <T> .From(linguisticVar)); return(this._variables[idx]); }