public static void Print <T>(this CLL <T> myList) { for (int i = 1; i <= myList.Count; i++) { Console.WriteLine(myList.Retrieve(i).NodeContent); } }
public static CLL <int> TakeInputList_CLL(bool isRandom = true, int MinContentLegth = 10, int MaxContentLength = 20, int MaxValue = 20) { if (!isRandom) { CLL <int> meList = new CLL <int>(); Console.WriteLine("Enter the number of elements in List"); int numbers = Convert.ToInt32(Console.ReadLine()); Console.WriteLine("Enter elements of List\n "); int i = 1; while (i <= numbers) { meList.Insert(Convert.ToInt32(Console.ReadLine()), false); i++; } return(meList); } else { InputGenerator ioGenerator = new InputGenerator(); ioGenerator.MaxContentLength = MaxContentLength; ioGenerator.MinContentLength = MinContentLegth; var meList = InputStream.ReadFileAsCLL(ioGenerator.GenerateIntegerInputFile(MaxValue)); return(meList); } }
}// null public OfficeFloor(int numberOffice) { for (int i = 0; i < numberOffice; i++) { CLL.Add(new Office()); } }//принемает количество офисов на этаже.
}//принемает количество офисов на этаже. public OfficeFloor(Office[] numberOffice) { for (int i = 0; i < numberOffice.Length; i++) { CLL.Add(numberOffice[i]); } }//принемает массив офисов этажа.
//验证数字 private bool validatedNumber(MB.WinBase.Common.ColumnPropertyInfo colPropertyInfo, object inputValue, ref string errMsg) { double val = MB.Util.MyConvert.Instance.ToDouble(inputValue); //判断最大最小值 if (val < colPropertyInfo.MinValue || val > colPropertyInfo.MaxValue) { errMsg = CLL.Message(MSG_MIN_MAX_VALUE, colPropertyInfo.Description, colPropertyInfo.MinValue.ToString(), colPropertyInfo.MaxValue.ToString()); return(false); } //判断小数点位数 if (colPropertyInfo.MaxDecimalPlaces >= 0) { string sv = val.ToString(); if (sv.IndexOf('.') >= 0) { int position = sv.Length - sv.LastIndexOf('.') - 1; if (position > colPropertyInfo.MaxDecimalPlaces) { errMsg = CLL.Message(MSG_MAX_PLACES, colPropertyInfo.Description, colPropertyInfo.MaxDecimalPlaces.ToString()); return(false); } } } return(true); }
private System.Windows.Forms.MenuItem createMenuByType(XtraContextMenuType menuType) { Type enumType = typeof(XtraContextMenuType); string str = MB.Util.MyCustomAttributeLib.Instance.GetFieldDesc(enumType, menuType.ToString(), false); str = CLL.Convert(str); XtraMenu menu = new XtraMenu(str, new System.EventHandler(menuItemClick), menuType); _GridMenu.MenuItems.Add(menu); if (menuType == XtraContextMenuType.ColumnsAllowSort) { menu.Checked = true; } if (menuType == XtraContextMenuType.Chart) { var templateMenu = new WinDxChart.Chart.ChartTemplateMenu(_XtraGrid); System.Windows.Forms.ContextMenu contextMenu = templateMenu.ChartContextMenu; int count = contextMenu.MenuItems.Count; for (int i = 0; i < count; i++) { menu.MenuItems.Add(contextMenu.MenuItems[0]); } } return(menu); }
//验证字符窜处理相关... private bool validatedString(MB.WinBase.Common.ColumnPropertyInfo colPropertyInfo, object inputValue, ref string errMsg) { bool b = true; if (colPropertyInfo.MaxLength > 0) { b = MB.Util.DataValidated.Instance.ValidatedLength(colPropertyInfo.MaxLength, inputValue.ToString()); if (b == false) { //如果检验不通过输出错误的信息 int leng = colPropertyInfo.MaxLength / 2; errMsg = CLL.Message(MSG_CHECKED_LENGTH, new string[] { colPropertyInfo.Description, colPropertyInfo.MaxLength.ToString(), leng.ToString() }); return(false); } } if (colPropertyInfo.FitLength > 0) { b = MB.Util.DataValidated.Instance.ValidatedFitLength(colPropertyInfo.FitLength, inputValue.ToString()); if (!b) { errMsg = CLL.Message(MSG_CHECKED_FIT, new string[] { colPropertyInfo.Description, colPropertyInfo.FitLength.ToString() }); } } return(b); }
public static CLL <int> ReadFileAsCLL(string filePath) { if (!File.Exists(filePath)) { return(null); } CLL <int> list = new CLL <int>(); using (FileStream inputStream = File.Open(filePath, FileMode.Open, FileAccess.Read)) { byte[] inputArray = new byte[inputStream.Length]; inputStream.Read(inputArray, 0, inputArray.Length); string inputvalues = ASCIIEncoding.ASCII.GetString(inputArray); string[] values = inputvalues.Split(','); foreach (var value in values ?? Enumerable.Empty <string>()) { int number; if (int.TryParse(value, out number)) { list.Insert(number, false); } } } return(list); }
//根据类型创建菜单项 private ToolStripMenuItem createMenuByType(GeneralOperateMenus menuType) { Type enumType = typeof(GeneralOperateMenus); string str = MB.Util.MyCustomAttributeLib.Instance.GetFieldDesc(enumType, menuType.ToString(), false); str = CLL.Convert(str); ToolStripMenuItem menu = new ToolStripMenuItem(str, (Image)null, new System.EventHandler(menuItemClick)); _MenuBinding.Add(menuType, menu); _ContextMenuStrip.Items.Add(menu); return(menu); }
/// <summary> /// 验证日期格式的字段 /// </summary> /// <param name="colPropertyInfo">对该字段列的客户端配置属性</param> /// <param name="inputValue">该列的值</param> /// <param name="errMsg">错误信息,ref参数,在方法中定义错误信息并传出</param> /// <returns>验证字段值是否正确,true表示验证正确,false表示验证错误</returns> private bool validatedDateTime(MB.WinBase.Common.ColumnPropertyInfo colPropertyInfo, object inputValue, ref string errMsg) { DateTime val = Convert.ToDateTime(inputValue); //判断是不是DateTime初始值,如果是初始值,则认为是空 if (!colPropertyInfo.IsNull && val == DateTime.MinValue) { string nameDesc = (colPropertyInfo.Description != null && colPropertyInfo.Description.Length > 0) ? colPropertyInfo.Description : colPropertyInfo.Name; errMsg = CLL.Message(MSG_NOTNULL, nameDesc); return(false); } return(true); }
//根据指定的ColumnPropertyInfo 判断输入的值是否符合要求。 private bool validated(MB.WinBase.Common.ColumnPropertyInfo colPropertyInfo, MB.WinBase.Common.ColumnEditCfgInfo colEditProInfo, object inputValue, ref string errMsg) { bool b; StringBuilder msgStr = new StringBuilder(); //得到要检验的这个列 //如果是字符窜类型需要检验长度 //如果值为空不需要检验数据类型 if (colPropertyInfo.IsNull == true && (inputValue == null || inputValue.ToString().Length == 0)) { return(true); } if (colPropertyInfo.IsNull != true && (inputValue == null || inputValue.ToString().Length == 0)) { string nameDesc = (colPropertyInfo.Description != null && colPropertyInfo.Description.Length > 0) ? colPropertyInfo.Description : colPropertyInfo.Name; msgStr.Append(nameDesc + ":不能为空"); //如果检验不通过输出错误的信息 errMsg = CLL.Message(MSG_NOTNULL, new string[] { nameDesc }); return(false); } Type sType = MB.Util.General.CreateSystemType(colPropertyInfo.DataType, false); if (sType == null) { throw new MB.Util.APPException(string.Format("XML 文件中列{0} 的类型配置信息有误,请检查XML 文件配置", colPropertyInfo.Description)); } b = MB.Util.DataValidated.Instance.ValidatedDataType(sType, inputValue); if (b == true) { if (string.Compare(sType.Name, "String", true) == 0) { b = validatedString(colPropertyInfo, inputValue, ref errMsg); } else if (Array.IndexOf(NUMBER_DATA_TYPE, sType.Name.ToUpper()) >= 0) { b = validatedNumber(colPropertyInfo, inputValue, ref errMsg); } else if (Array.IndexOf(DATETIME_DATA_TYPE, sType.Name.ToUpper()) >= 0) { b = validatedDateTime(colPropertyInfo, inputValue, ref errMsg); } else { //其它类型先不做处理 后期根据实际需要再加上 } } else { errMsg = CLL.Message(MSG_MUST_INPUT, new string[] { colPropertyInfo.Description, MB.Util.DataValidated.Instance.GetTypeValidatedErrMsg(sType) }); return(false); } if (colEditProInfo != null && colEditProInfo.IsValidateInputFromDataSource) { b = validateColValueInLookUpSource(colPropertyInfo, colEditProInfo, inputValue, ref errMsg); } return(b); }
public Queue(int max) { this.max = max; inter = new CLL(); }