private void SelfParse() { string comment = ""; for (int index = 0; index < TextData.Count; index++) { var line = TextData[index]; if (line.TrimStart().StartsWith("///")) { comment += line; continue; } var match = RegexHelpers.ClassHeaderRegex.Match(line); if (match.Success) { var lst = new List <string>(); int brackets = line.Count(x => x == '{') - line.Count(x => x == '}'); int j = index + 1; do { line = TextData[j]; brackets += line.Count(x => x == '{'); brackets -= line.Count(x => x == '}'); lst.Add(TextData[j]); j++; } while (j < TextData.Count && brackets > 0); index = j; var data = new ClassData(Name, match.Value, lst, comment); ClassList.Add(data); comment = ""; } } TextData = null; }
private void RefreshClassData() { ClassList.Clear(); foreach (var item in Classes) { ClassList.Add(new ClassInfoViewModel(item)); } }
/// <summary> /// Ajoute une classe à la liste. /// </summary> /// <param name="classe">La classe à ajouter.</param> /// <exception cref="System.ArgumentNullException">Si la classe fournie en paramètre est null.</exception> public void AddClass(ModelClass classe) { if (classe == null) { throw new ArgumentNullException("classe"); } ClassList.Add(classe); }
public override void AddStudent(Student stu) { if (stu is BusinessStudent) { ClassList.Add(stu); } else { new Exception("" + stu.Name + " is not in the Business College"); } }
public NetClassRepInstance(string className, uint groupMask, NetClassType classType, int classVersion) { ClassName = className; ClassType = classType; ClassGroupMask = groupMask; ClassVersion = classVersion; for (var i = 0; i < ClassId.Length; ++i) { ClassId[i] = 0U; } ClassList.Add(this); }
public void SetClassTrue(string classStr, bool value) { if (value == GetClassTrue(classStr)) { return; } if (value) { ClassList.Add(classStr); } else { ClassList.Remove(classStr); } }
internal void SetContextual(string type, string value) { int length = ClassList.Length; for (int i = 0; i < length; i++) { if (ClassList[i].StartsWith(type)) { ClassList.Remove(ClassList[i]); break; } } if (!string.IsNullOrWhiteSpace(value) && value.StartsWith(type)) { ClassList.Add(value); } }
/// <summary> /// Add the Class 's' into the SQL Database if it does not yet exist /// </summary> /// <param name="s">The class to add</param> public void AddClassList(String s) { if (s == "") { return; } //Look if we can find the class in the database. If found, exit foreach (String cl in ClassList) { if (cl == s) { return; } } ClassList.Add(s); OnPropertyChanged("ClassList"); }
/// <summary> /// Generates a list of key-value pairs of classes that derive from this one /// </summary> /// <typeparam name="ClassType"></typeparam> /// <returns></returns> public static ClassList GenerateClassList <ClassType>(bool includeAbstract = true) { ClassList list = new ClassList(); Type[] classes = StratusReflection.GetSubclass <ClassType>(); foreach (Type e in classes) { string name = e.FullName.Replace('+', '.'); Type type = e.ReflectedType; if (!includeAbstract && type.IsAbstract) { continue; } list.Add(new KeyValuePair <string, Type>(name, type)); } return(list); }
private void _F_AddClassInfo() { var cInstatnce = ServiceLocator.Current.GetInstance <ClassModifyViewModel>(); cInstatnce.OriginalClass = new ClassInfo(); cInstatnce.SelectModel = false; cInstatnce.GradeEditable = true; cInstatnce.Title = "添加班级信息"; ClassInfoWindow ciw = new ClassInfoWindow(); ciw.ShowDialog(); if (ciw.DialogResult == true) { var c = cInstatnce.OriginalClass; _ClassInfoDal.Insert(c); _ClassInfoDal.Save(); ClassList.Add(new ClassInfoViewModel(c)); //ClassList.OrderBy(a => a.Grade).ThenBy(b=>b.Name); } }
/// <summary> /// List alle Klassen für die angemeldete Person aus der Datenbank heraus /// </summary> /// <param name="IdPerson">ID der angemeldeten Person</param> /// <returns>Eine Liste aller Klassen auf welche die angemeldete Person Zugriff hat</returns> public List <SchoolClass> ReadClasses(int IdPerson) { try { // Instanziierung DatabaseConnector Connect = new DatabaseConnector(); Connect.OpenConnection(); MySqlCommand command = Connect.Connection.CreateCommand(); // query liest nur bestimmte Klassen einer Person Aus! command.CommandText = "SELECT * FROM Class WHERE idclass IN(SELECT Class_idClass FROM Class_has_Person WHERE Person_idPerson LIKE " + IdPerson + ");"; MySqlDataReader reader = command.ExecuteReader(); while (reader.Read()) { ClassList.Add(new SchoolClass((int)reader.GetValue(0), reader.GetValue(1).ToString())); } foreach (SchoolClass schoolClass in ClassList) { ReadAppointments(schoolClass); } reader.Close(); //Connection schliessen Connect.CloseConnection(); return(ClassList); } catch (Exception) { throw; } }
/// <summary> /// /// </summary> /// <param name="fil"></param> public FiliereClassCard(Filiere fil) { FiliereName = fil.Name.ToUpper(); using (var db = new SchoolContext()) { //Parallel.ForEach(db.Classe.Where(c => c.FiliereGuid == fil.FiliereGuid), cl => //{ // ClassList.Add(new ClassCard(cl)); //}); foreach (var cl in db.Classes.Where(c => c.FiliereGuid == fil.FiliereGuid).OrderBy(c => c.ClassGrade)) { ClassList.Add(new ClassCard(cl)); } if (!ClassList.Any()) { return; } ClassList = ClassList.OrderBy(c => c.Level).ToList(); } }
public string Load() { if (string.IsNullOrWhiteSpace(AssemblyPath)) { return("操作失败,未能找到编译后的文件,请重新生成。"); } FileInfo assemFile = new FileInfo(AssemblyPath); if (!assemFile.Exists) { return("操作失败,未能找到编译后的文件,请重新生成。"); } LastModifyTime = assemFile.LastWriteTime; FileInfo pdbFile = new FileInfo(PdbPath); if (!assemFile.Exists) { return("操作失败,未能找到.pdb文件,打开debug-full模式。"); } // 加载pdb PdbFile Pdb = new PdbFile(PdbPath); try { Assembly asm = Assembly.LoadFrom(AssemblyPath); foreach (var typ in asm.DefinedTypes) { var cls = new ClassInfo(); cls.Name = typ.Name; cls.FullName = typ.FullName; cls.NameSpace = typ.Namespace; foreach (var item in typ.CustomAttributes) { var attr = new AttributeInfo(); attr.TypeFullName = item.AttributeType.FullName; foreach (var arg in item.ConstructorArguments) { attr.ArgumentList.Add(arg.Value.ToString()); } cls.AttributeList.Add(attr); } foreach (var item in typ.ImplementedInterfaces) { cls.Interfaces.Add(item.FullName); } foreach (var item in typ.DeclaredMethods) { var method = new MethodInfo(); method.Name = item.Name; method.ReturnType = item.ReturnType.FullName; var parameters = item.GetParameters(); foreach (var attre in item.CustomAttributes) { var attr = new AttributeInfo(); attr.TypeFullName = attre.AttributeType.FullName; foreach (var arg in attre.ConstructorArguments) { attr.ArgumentList.Add(arg.Value.ToString()); } method.AttributeList.Add(attr); } cls.MethodList.Add(method); } foreach (var prop in typ.DeclaredProperties) { var property = new PropertyInfo(); property.Name = prop.Name; property.Type = prop.PropertyType.FullName; foreach (var item in prop.CustomAttributes) { var attr = new AttributeInfo(); attr.TypeFullName = item.AttributeType.FullName; foreach (var arg in item.ConstructorArguments) { attr.ArgumentList.Add(arg.Value.ToString()); } property.AttributeList.Add(attr); } cls.PropertyList.Add(property); } // 从pdb文件中取出代码路径和位置 foreach (var module in Pdb.DbiStream.Modules) { if (module.ModuleName.String == cls.FullName) { cls.FilePath = module.Files.ToList(); if (cls.FilePath.Count > 1) { continue; } var pdbFunctions = GetManagedProcedures(module.LocalSymbolStream); // 确定函数的行号 var classMembers = module.DebugSubsectionStream[DebugSubsectionKind.Lines].OfType <LinesSubsection>().ToArray(); foreach (var mem in classMembers) { // 找对应的pdbFunction ManagedProcedureSymbol pdbFunction = null; foreach (var pdbf in pdbFunctions) { if (pdbf.CodeOffset == mem.CodeOffset) { pdbFunction = pdbf; break; } } if (pdbFunction == null) { continue; } // 找对应的FunctionInfo var method = cls.MethodList.FirstOrDefault(f => f.Name == pdbFunction.Name.String); if (method == null) { continue; } // 统计行号 uint min = 999999; uint max = 0; var mlins = mem.Files[0].Lines; foreach (var elin in mlins) { if (elin.LineStart < 10000 && elin.LineEnd < 10000) { min = Math.Min(min, elin.LineStart); max = Math.Max(max, elin.LineEnd); } } if (min < max) { method.MinLine = (int)min; method.MaxLine = (int)max; } } } } ClassList.Add(cls); } return(""); } catch (Exception e) { return(e.Message + Environment.NewLine + e.StackTrace); } finally { Pdb.Dispose(); } }
//This method is upon changing a class private void OnClassChange(object sender, EventArgs e) { //If the option selected is the first index, a new category is created. if (comboBoxClass.SelectedIndex == 0) { //Deselect text comboBoxClass.SelectedIndex = -1; //Open up category selection form FormEnterClass formEnterClass = new FormEnterClass(); if (formEnterClass.ShowDialog() == DialogResult.OK) { //Create the class SchoolClass schoolClass = new SchoolClass(formEnterClass.name); //Add it to the classList ClassList.Add(schoolClass); //Add it to the comboBoxClass comboBoxClass.Items.Add(schoolClass.Name); //Set the currentClassIndex to the last index CurrentClassIndex = ClassList.Count - 1; //Enable the comboBoxCategory if not enabled if (comboBoxCategory.Enabled == false) { comboBoxCategory.Enabled = true; } //Set the combobox text to the newly created class comboBoxClass.Text = CurrentClass.Name; //Update the groupboxgrade's text to the current class's name groupBoxGrade.Text = CurrentClass.Name + " Grade"; if (ClassList.Count != 1) { //Clear the rows dataGridView.Rows.Clear(); //Reset the text groupBoxTotals.Text = "Category Totals (%)"; labelLetterGrade.Text = ""; labelGrade.Text = ""; labelPtsPoss.Text = ""; labelScore.Text = ""; labelPercent.Text = ""; //Update the category list UpdateCategoryList(); //Disable the datagriview dataGridView.Enabled = false; saveToolStripMenuItem.Enabled = true; saveAsToolStripMenuItem.Enabled = true; } else { editClassToolStripMenuItem.Enabled = true; deleteClassToolStripMenuItem.Enabled = true; addCategoryToolStripMenu.Enabled = true; } } else if (ClassList.Count != 0) { comboBoxClass.Text = CurrentClass.Name; } } //Else, set the currentClassIndex to the index of the selected option minus one else { //Update the currentclassindex current index - 1 CurrentClassIndex = comboBoxClass.SelectedIndex - 1; //Update the groupboxgrade's text to the current class's name groupBoxGrade.Text = CurrentClass.Name + " Grade"; if (CurrentClass.CategoryList.Count != 0) { comboBoxCategory.Items.Clear(); comboBoxCategory.Items.Add("Create new category"); foreach (Category c in CurrentClass.CategoryList) { comboBoxCategory.Items.Add(c.Name); } //Update the combobox text to the current category's text comboBoxCategory.SelectedIndex = CurrentClass.CurrentCategoryIndex + 1; //Load the data LoadData(); //Store the data StoreData(); //Update the totals UpdateTotals(); //Update the grade UpdateGrade(); //Update the category list UpdateCategoryList(); dataGridView.Enabled = true; } else { comboBoxCategory.SelectedIndex = -1; comboBoxCategory.Items.Clear(); comboBoxCategory.Items.Add("Create new category"); labelLetterGrade.Text = ""; labelGrade.Text = ""; labelPtsPoss.Text = ""; labelScore.Text = ""; labelPercent.Text = ""; groupBoxTotals.Text = "Category Totals (%)"; dataGridView.Rows.Clear(); dataGridView.Enabled = false; } } }
public void AddStudentToClass(Student student) { ClassList.Add(student); }