public DataType Create(string name, string description, System.TypeCode systemType) { Contract.Requires(!string.IsNullOrWhiteSpace(name)); Contract.Ensures(Contract.Result <DataType>() != null && Contract.Result <DataType>().Id >= 0); DataType u = new DataType() { Name = name, Description = description, SystemType = systemType.ToString(), }; using (IUnitOfWork uow = this.GetUnitOfWork()) { IRepository <DataType> repo = uow.GetRepository <DataType>(); repo.Put(u); uow.Commit(); } return(u); }
public override object EditValue(ITypeDescriptorContext context, IServiceProvider provider, object value) { IWindowsFormsEditorService editorService = null; if (context != null && context.Instance != null && provider != null) { editorService = (IWindowsFormsEditorService)provider.GetService(typeof(IWindowsFormsEditorService)); if (editorService != null) { IDataControl control = (IDataControl)context.Instance; //PropertySelectorForm dlg = new PropertySelectorForm(control); if (!string.IsNullOrEmpty(control.LinkObject)) { System.TypeCode code = control.SysTypeCode; if (code != TypeCode.Empty) { MessageBox.Show("请先选择SysTypeCode 属性并设置为" + code.ToString()); } else { MessageBox.Show("请先选择SysTypeCode 属性并设置合适的值"); } control.SysTypeCode = TypeCode.Empty; return(control.LinkObject.Trim()); } else { MessageBox.Show("请先选择LinkProperty 属性设置值并设置合适的SysTypeCode"); control.SysTypeCode = TypeCode.Empty; return(""); } } } return(value); }
void TestParse() { System.TypeCode tc1 = TypeCode.Byte; System.TypeCode tc2; tc1.ToString().TryParse <System.TypeCode>(out tc2); Logger.LogG("Testing TryParse", $"{tc1} and {tc2}\n"); var a = tc1.HasFlag(TypeCode.Int32); Logger.LogG("Testing HasFlag TypeCode.Byte = TypeCode.Int32", $"HasFlag = {a}\n"); a = tc1.HasFlag(TypeCode.Byte); Logger.LogG("Testing HasFlag TypeCode.Byte = TypeCode.Byte", $"HasFlag = {a}\n"); // var r = tc1. // Logger.LogG("Testing TryParse(Enum.Name, out...)",$""); Console.Write("Press a Key to continue\n"); Console.ReadKey(); return; }