private Int32 GetLengthValue(CommonType value) { switch (value) { case CommonType.Nothing: case CommonType.InternetPassword1: case CommonType.InternetPassword2: case CommonType.InternetPassword3: case CommonType.PasswordManager1: case CommonType.PasswordManager2: case CommonType.PasswordManager3: case CommonType.WepKey64Bit: case CommonType.WepKey128Bit: case CommonType.WepKey152Bit: case CommonType.WepKey256Bit: case CommonType.WepKeyCustom: case CommonType.WpaKey: // No rules found return(this.GetLengthMinimum(value)); case CommonType.InternetPasswordX: return(16); case CommonType.Wpa2Key: return(20); // Government recommendation default: throw new NotSupportedException($"Password type of \"{value}\" is not yet supported."); } }
private Boolean GetPoolsEnabled(CommonType value) { switch (value) { case CommonType.Nothing: case CommonType.InternetPassword1: case CommonType.InternetPassword2: case CommonType.InternetPassword3: case CommonType.InternetPasswordX: return(false); case CommonType.PasswordManager1: case CommonType.PasswordManager2: case CommonType.PasswordManager3: case CommonType.WepKey64Bit: case CommonType.WepKey128Bit: case CommonType.WepKey152Bit: case CommonType.WepKey256Bit: return(true); case CommonType.WepKeyCustom: case CommonType.WpaKey: // No rules found return(false); case CommonType.Wpa2Key: return(true); default: throw new NotSupportedException($"Password type of \"{value}\" is not yet supported."); } }
//-- ctors public CommonField(string name, CommonType ctype, CommonField[] fields = null) { Name = name; CType = ctype; Fields = fields; Logger.Assert(HasHeading == (Fields != null)); }
private Int32 GetLengthMaximum(CommonType value) { switch (value) { case CommonType.Nothing: case CommonType.InternetPassword1: case CommonType.InternetPassword2: case CommonType.InternetPassword3: case CommonType.PasswordManager1: case CommonType.PasswordManager2: case CommonType.PasswordManager3: case CommonType.WepKey64Bit: case CommonType.WepKey128Bit: case CommonType.WepKey152Bit: case CommonType.WepKey256Bit: case CommonType.WpaKey: // No rules found return(this.GetLengthMinimum(value)); case CommonType.InternetPasswordX: return(50); case CommonType.WepKeyCustom: return(this.GetLengthMinimum(CommonType.WepKey256Bit) / 2); // Exceptionally, it's the character count. case CommonType.Wpa2Key: return(63); default: throw new NotSupportedException($"Password type of \"{value}\" is not yet supported."); } }
public int Insert(CommonType obj) {//Thêm mới //1: thành công; 0: thất bại int res = 0; string queryStr = "INSERT INTO `commontype` ("; queryStr += string.IsNullOrEmpty(obj.CommonTypeId) ? "" : "`CommonTypeId`, "; queryStr += string.IsNullOrEmpty(obj.Description) ? "" : "`Description`, "; queryStr += string.IsNullOrEmpty(obj.Note) ? "" : "`Note`, "; queryStr += "`CreatedBy`, "; queryStr += "`CreatedDate`, "; queryStr += "`CanDelete`"; queryStr += ") VALUES ( "; queryStr += string.IsNullOrEmpty(obj.CommonTypeId) ? "" : string.Format("'{0}', ", obj.CommonTypeId); queryStr += string.IsNullOrEmpty(obj.Description) ? "" : string.Format("'{0}', ", obj.Description); queryStr += string.IsNullOrEmpty(obj.Note) ? "" : string.Format("'{0}', ", obj.Note); queryStr += "'admin', "; queryStr += "NOW(), b'1')"; Program.destopService.DataExecute(Program.Username, Program.Password, queryStr, ref errorString); if (string.IsNullOrEmpty(errorString)) { res = 1; } return(res); }
// lấy dữ liệu theo ID public CommonType GetCommonTypeById(string commontypeid) { CommonType res = new CommonType(); DataSet ds = new DataSet(); string query = @"SELECT * FROM `commontype` WHERE `CommonTypeId` = '" + commontypeid + "'"; Program.destopService.DataQuery(Program.Username, Program.Password, query, ref ds, "X", ref errorString); if (string.IsNullOrEmpty(errorString) && ds.Tables[0].Rows.Count > 0) { res.CommonTypeId = ds.Tables[0].Rows[0]["CommonTypeId"].ToString(); res.Description = ds.Tables[0].Rows[0]["Description"].ToString(); res.Note = ds.Tables[0].Rows[0]["Note"].ToString(); res.CreatedBy = ds.Tables[0].Rows[0]["CreatedBy"].ToString(); res.CreatedDate = ds.Tables[0].Rows[0]["CreatedDate"].ToString(); res.ModifiedBy = ds.Tables[0].Rows[0]["ModifiedBy"].ToString(); res.ModifiedDate = ds.Tables[0].Rows[0]["ModifiedDate"].ToString(); res.CanDelete = ds.Tables[0].Rows[0]["CanDelete"].ToString(); } else { res = null; } return(res); }
private void GenerateSetMethodBody(MonoCecilAssembly monoCecilAssembly, CommonType viewModelBase, MonoCecilProperty property, string propertyName, MonoCecilField backgroundField) { log.Info("Generate method reference on Set method in ViewModelBase..."); var propertySetMethod = property.SetMethod; if (propertySetMethod == null) { const string errorMessage = "Patching property must have set method accessor"; log.Error(errorMessage); throw new PropertyPatchingException(errorMessage, property.FullName); } var setMethodFromViewModelBase = monoCecilFactory.CreateGenericInstanceMethod(GetSetMethodFromViewModelBase(viewModelBase.MonoCecilType)); setMethodFromViewModelBase.AddGenericArgument(property.PropertyType); var setMethodInViewModelBaseWithGenericParameter = monoCecilAssembly.MainModule.Import(setMethodFromViewModelBase); log.Info("Generate set method body..."); var setMethodBodyInstructions = propertySetMethod.Body.Instructions; setMethodBodyInstructions.Clear(); setMethodBodyInstructions.Add(monoCecilFactory.CreateInstruction(OpCodes.Ldarg_0)); setMethodBodyInstructions.Add(monoCecilFactory.CreateInstruction(OpCodes.Ldstr, propertyName)); setMethodBodyInstructions.Add(monoCecilFactory.CreateInstruction(OpCodes.Ldarg_0)); setMethodBodyInstructions.Add(monoCecilFactory.CreateInstruction(OpCodes.Ldflda, backgroundField)); setMethodBodyInstructions.Add(monoCecilFactory.CreateInstruction(OpCodes.Ldarg_1)); setMethodBodyInstructions.Add(monoCecilFactory.CreateInstruction(OpCodes.Ldc_I4_0)); setMethodBodyInstructions.Add(monoCecilFactory.CreateInstruction(OpCodes.Call, setMethodInViewModelBaseWithGenericParameter)); setMethodBodyInstructions.Add(monoCecilFactory.CreateInstruction(OpCodes.Pop)); setMethodBodyInstructions.Add(monoCecilFactory.CreateInstruction(OpCodes.Ret)); propertySetMethod.RemoveAttribute(typeof(CompilerGeneratedAttribute)); log.Info("Set method body was generated"); }
private void PatchProprty(MonoCecilAssembly monoCecilAssembly, CommonType viewModelBase, CommonType viewModel, CommonProperty property) { CheckProperty(property); var propertyName = property.Name; log.Debug($"Property name: {propertyName}"); var backgroundFieldName = $"{char.ToLower(propertyName.First())}{propertyName.Substring(1)}"; log.Debug($"Background field name: {backgroundFieldName}"); var backgroundField = viewModel.Fields.FirstOrDefault(field => field.Name == backgroundFieldName)?.MonoCecilField; if (backgroundField == null) { backgroundField = monoCecilFactory.CreateField(backgroundFieldName, FieldAttributes.Private, property.MonoCecilProperty.PropertyType); viewModel.MonoCecilType.AddField(backgroundField); log.Debug("Background field was created"); } else { log.Debug("Background field was connected"); } GenerateGetMethodBody(property.MonoCecilProperty, backgroundField); GenerateSetMethodBody(monoCecilAssembly, viewModelBase, property.MonoCecilProperty, propertyName, backgroundField); }
public object GetValue(CommonType type) { object value; if ((type & CommonType.axis) != 0) { value = GetAxis(); } else if ((type & CommonType.toggle) != 0) { value = GetToggle(); } else if ((type & CommonType.direction) != 0) { value = GetDirection(); } else if ((type & CommonType.point) != 0) { value = GetPoint(); } else if ((type & CommonType.orientation) != 0) { value = GetOrientation(); } else { throw new System.ArgumentException("Bad type"); } return(value); }
private static Func <object[], object> CreateImpl(Type valueTupleType) { var genericTypeArguments = valueTupleType.GenericTypeArguments; var createVT = CommonType.GetValueTupleCreateMethod(genericTypeArguments); var dynamicMethod = new DynamicMethod("ValueTupleConvert_" + Guid.NewGuid().ToString("N"), CommonType.Object, new[] { CommonType.ObjectArray }); var ilGen = dynamicMethod.GetILGenerator(); for (int i = 0; i < genericTypeArguments.Length; i++) { Type argType = genericTypeArguments[i]; ilGen.LoadArg(0); ilGen.LoadInt32(i); ilGen.LoadElement(CommonType.Object); if (argType.IsValueType) { ilGen.Unbox(argType); ilGen.LoadValueIndirect(argType); } } ilGen.Emit(OpCodes.Call, createVT); ilGen.Box(valueTupleType); ilGen.Return(); return((Func <object[], object>)dynamicMethod.CreateDelegate(typeof(Func <object[], object>))); }
public static DbParameter GetParameter(CommonType dbType) { DbParameter param = null; switch (dbType) { case CommonType.SqlServer: param = new SqlParameter(); break; case CommonType.Oracle: param = new OracleParameter(); break; case CommonType.Sqlite: param = new SqlParameter(); break; case CommonType.OleDb: param = new OleDbParameter(); break; default: break; } return(param); }
public void SaveToXml(XmlElement xml) { this.SavePropertiesCore(xml); if (CommonType != null) { CommonType.SaveToXml(xml.AddChild("Type")); } }
public static object GetDefault(CommonType ctype) { if (ToDefaultDict.ContainsKey(ctype)) { return(ToDefaultDict[ctype]); } return(null); }
public static Type CommontoType(CommonType ctype) { if (ToTypeDict.ContainsKey(ctype)) { return(ToTypeDict[ctype]); } return(null); }
public static double GetValue(CommonType common) { if (commonDatas.ContainsKey(common) == false) { return(0.0); } return(commonDatas[common]); }
public static Offset <CommonType> CreateCommonType(FlatBufferBuilder builder, int type = 0, int id = 0) { builder.StartTable(2); CommonType.AddId(builder, id); CommonType.AddType(builder, type); return(CommonType.EndCommonType(builder)); }
public void Patch(MonoCecilAssembly monoCecilAssembly, CommonType viewModelBase, CommonType viewModel, ViewModelPatchingType viewModelPatchingType) { log.Info($"Patching {viewModel.FullName} commands..."); var commandMethods = GetCommonCommandMethods(viewModel, viewModelPatchingType); var commandProperties = GetCommonCommandProperties(viewModel, viewModelPatchingType); var commandsMembers = JoinMembers(commandMethods, commandProperties); }
public string Present(CommonAttribute displayAttribute, CommonType declaringType, CommonAttribute subjectAttribute) { var dictionary = Tuple.Create("type", (object)declaringType) .Concat(subjectAttribute.PositionalArguments.Select(x => Tuple.Create(x.Position.ToString(), x.Value))) .Concat(subjectAttribute.NamedArguments.Select(x => Tuple.Create(x.Name, x.Value))) .ToDictionary(x => x.Item1, x => x.Item2); return(Present(GetDisplayFormat(displayAttribute), dictionary)); }
// extract value from row in common type object GetDatarowValue(DataRow row, string fieldname, CommonType ctype) { try { var value = row[fieldname]; return((value == null || value == DBNull.Value) ? CommonConverter.GetDefault(ctype) : value); } catch (Exception) { throw Error.Fatal($"bad field {fieldname}"); } }
public QueryResultColumnInfo Clone() { var res = (QueryResultColumnInfo)MemberwiseClone(); if (CommonType != null) { res.CommonType = CommonType.Clone(); } return(res); }
public static string CreateText(CommonType concernType, [CanBeNull] CommonType subjectType, [CanBeNull] string subjectText) { var subject = subjectType == null ? subjectText : subjectText == null ? subjectType.Name : $"{subjectType.Name} {subjectText}"; return($"{subject}, {concernType.Name.Replace(oldChar: '_', newChar: ' ')}"); }
private void FillCommonItems(string name) { using (Entities1 db = new Entities1()) { CommonType ty = db.CommonTypes.Where(x => x.Name == name).FirstOrDefault(); drplvl3.DataSource = db.usp_CommonItemsSelectByType(ty.ID).ToList(); drplvl3.ValueField = "ID"; drplvl3.TextField = "Name"; DataBind(); } }
private void dgvResult_CellClick(object sender, DataGridViewCellEventArgs e) { if (e.RowIndex >= 0) { string commonTypeId = dgvResult.Rows[e.RowIndex].Cells[1].Value.ToString(); CommonType ctId = new CommonType(); ctId = objBLL.GetCommonTypeById(commonTypeId); if (ctId != null) { tbxCommonTypeId.Text = string.IsNullOrEmpty(ctId.CommonTypeId) ? "" : ctId.CommonTypeId; rtbDescrition.Text = string.IsNullOrEmpty(ctId.Description) ? "" : ctId.Description; tbxNote.Text = string.IsNullOrEmpty(ctId.Note) ? "" : ctId.Note; } if (e.ColumnIndex == 5) { if (ctId.CanDelete == "1") { if (CustomMessageBox.MessageBox.ShowCustomMessageBox(Common.clsLanguages.GetResource("Delete01"), Common.clsLanguages.GetResource("Information"), Common.Config.CUSTOM_MESSAGEBOX_ICON.Information, Common.Config.CUSTOM_MESSAGEBOX_BUTTON.YESNO) == DialogResult.Yes) { int Xoa = objBLL.Detele(commonTypeId); // xóa thành côg if (Xoa == 1) { dgvResult.Rows.RemoveAt(e.RowIndex); CustomMessageBox.MessageBox.ShowCustomMessageBox(Common.clsLanguages.GetResource("DeleteSuccess"), Common.clsLanguages.GetResource("Information"), Common.Config.CUSTOM_MESSAGEBOX_ICON.Information, Common.Config.CUSTOM_MESSAGEBOX_BUTTON.OK); lblTB.Text = "..."; lblTB1.Text = "..."; //đánh lại stt int RecPerPage = int.Parse(ConfigurationManager.AppSettings["MaxRecordDesk"]); for (int i = 0; i < dgvResult.Rows.Count; i++) { dgvResult.Rows[i].Cells[0].Value = ((CurPage - 1) * RecPerPage + (i + 1)).ToString(); } } } } else { CustomMessageBox.MessageBox.ShowCustomMessageBox(clsLanguages.GetResource("NoDelete"), Common.clsLanguages.GetResource("Information"), Common.Config.CUSTOM_MESSAGEBOX_ICON.Information, Common.Config.CUSTOM_MESSAGEBOX_BUTTON.OK); } } } }
private Int32 GetLengthMinimum(CommonType value) { switch (value) { case CommonType.Nothing: return(0); case CommonType.InternetPassword1: return(8); case CommonType.InternetPassword2: return(10); case CommonType.InternetPassword3: return(14); case CommonType.InternetPasswordX: return(8); case CommonType.PasswordManager1: return(16); case CommonType.PasswordManager2: return(32); case CommonType.PasswordManager3: return(64); case CommonType.WepKey64Bit: return(10); case CommonType.WepKey128Bit: return(26); case CommonType.WepKey152Bit: return(32); case CommonType.WepKey256Bit: return(58); case CommonType.WepKeyCustom: return(0); case CommonType.WpaKey: // No rules found return(0); case CommonType.Wpa2Key: return(8); default: throw new NotSupportedException($"Password type of \"{value}\" is not yet supported."); } }
private void frmCommonType_Load(object sender, EventArgs e) { objBLL = new CommonTypeBLL(); objSea = new CommonType(); objSea.CommonTypeId = tbxCommonTypeId.Text; objSea.Description = rtbDescrition.Text; objSea.Note = tbxNote.Text; //objSea.CreatedBy = tbxCreatedBy.Text; //objSea.CreatedDate = cbxCreatedDate.Checked ? dtpCreatedDate.Value.ToString("yyyy-MM-dd HH:mm:ss") : ""; //objSea.ModifiedBy = tbxModifiedBy.Text; //objSea.ModifiedDate = cbxModifiedDate.Checked ? dtpCreatedDate.Value.ToString("yyyy-MM-dd HH:mm:ss") : ""; }
// extract reader value in common type object GetReaderValue(DbDataReader rdr, string fieldname, CommonType ctype) { var field = rdr.GetOrdinal(fieldname); if (rdr.IsDBNull(field)) { return(CommonConverter.GetDefault(ctype)); } else { return(rdr.GetValue(field)); } }
public RgbLed( IDigitalOutputPort redPort, IDigitalOutputPort greenPort, IDigitalOutputPort bluePort, CommonType commonType = CommonType.CommonCathode) { RedPort = redPort; GreenPort = greenPort; BluePort = bluePort; Common = commonType; _cancellationTokenSource = new CancellationTokenSource(); }
public RgbLed( IIODevice device, IPin redPin, IPin greenPin, IPin bluePin, CommonType commonType = CommonType.CommonCathode) : this( device.CreateDigitalOutputPort(redPin), device.CreateDigitalOutputPort(greenPin), device.CreateDigitalOutputPort(bluePin), commonType) { }
public IDataReaderDeserializer Get(Type resultType) { if (CommonType.IsValueTuple(resultType)) { return(_valueTupleDeser); } if (resultType.IsValueType || resultType == CommonType.String) { return(_valueTypeDeser); } return(resultType == CommonType.Object ? _dynamicDeser : _defaultDeser); }
public static void Load() { commonDatas = new Dictionary <CommonType, double>(); string json = File.ReadAllText(Path.Combine("..", "..", "..", "..", "Datasheet", "Common.json")); CommonData data = JsonConvert.DeserializeObject <CommonData>(json); foreach (CommonDataDetail common in data.Common) { CommonType type = (CommonType)Enum.Parse(typeof(CommonType), common.Category); commonDatas.Add(type, common.Value); } }