public TestModel() { BlotterCommandList = new List<BlotterCommand>(); BlotterCommandList.Add(new BlotterCommand() { CommandType = BlotterCommandType.Create, CommandHandler = () => MessageBox.Show("Create button!"), LayOut = BlotterCommandLayOut.Botton }); BlotterCommandList.Add(new BlotterCommand() { CommandType = BlotterCommandType.Delete, CommandHandler = () => MessageBox.Show("Delete button!"), LayOut = BlotterCommandLayOut.Botton }); Elements = new List<object>(); Elements.Add(new Car() { Name = "Benz" }); Elements.Add(new Desk() { Name = "HighDesk" }); }
/// <summary> /// Get the child processes for a given process /// </summary> /// <param name="process"></param> /// <returns></returns> public static List<Process> GetChildProcesses(this Process process) { var results = new List<Process>(); // query the management system objects for any process that has the current // process listed as it's parentprocessid string queryText = string.Format("select processid from win32_process where parentprocessid = {0}", process.Id); using (var searcher = new ManagementObjectSearcher(queryText)) { foreach (var obj in searcher.Get()) { object data = obj.Properties["processid"].Value; if (data != null) { // retrieve the process var childId = Convert.ToInt32(data); var childProcess = Process.GetProcessById(childId); // ensure the current process is still live if (childProcess != null) results.Add(childProcess); } } } return results; }
public static System.Collections.ObjectModel.ObservableCollection<string> GeneratePassPhrases() { if (!System.IO.File.Exists("words.txt")) DownloadWordList(); if (!System.IO.File.Exists("words.txt")) throw new Exception("Could not download word list"); string[] words = System.IO.File.ReadAllLines("words.txt"); List<string> phrases = new List<string>(); for (int j = 0; j < 1000; j++) { StringBuilder sb = new StringBuilder(); for (int i = 0; i < 4; i++) { if (i > 0) sb.Append(" "); int d = Randomness.GetValue(0, words.Length - 1); string word = words[d]; if (i == 0 && word.Length > 1) word = word.Capitalize(); sb.Append(word); } sb.Append("....."); phrases.Add(sb.ToString()); } return new System.Collections.ObjectModel.ObservableCollection<string>(phrases); }
public List<String> checkProjects() { List<String> list = new List<String>(); using (System.Data.SQLite.SQLiteConnection con = new System.Data.SQLite.SQLiteConnection("data source=databaseFile.db3")) { using (System.Data.SQLite.SQLiteCommand com = new System.Data.SQLite.SQLiteCommand(con)) { con.Open(); com.CommandText = "Select * FROM LASTPROJECTS"; using (System.Data.SQLite.SQLiteDataReader reader = com.ExecuteReader()) { while (reader.Read()) { Console.WriteLine(reader["address"]); if (!File.Exists(reader["address"].ToString())) list.Add(reader["address"].ToString()); } } con.Close(); } } if(list.Count > 0) removeProject(list); return getLastProjects(); }
public List<string> separadorEspacios(string cadena) { List<string> tokenizer = new List<string>(); string [] n = cadena.Split(' '); foreach (string item in n) { tokenizer.Add(item); } return tokenizer; }
public List<string> separadorLineas(string cadena) { List<string> tokenizer = new List<string>(); string[] n = cadena.Split(new string[] { Environment.NewLine}, StringSplitOptions.None ); foreach (string item in n) { tokenizer.Add(item); } return tokenizer; }
/// <summary> /// Gets the list of available WIA devices. /// </summary> /// <returns></returns> public static List<string> GetDevices() { List<string> devices = new List<string>(); WIA.DeviceManager manager = new WIA.DeviceManager(); foreach (WIA.DeviceInfo info in manager.DeviceInfos) { devices.Add(info.DeviceID); } return devices; }
public MainViewModel() { CurrentColor = GetPaletteColor(); Model = new Model3DGroup(); Voxels = new List<Voxel>(); Highlighted = new List<Model3D>(); ModelToVoxel = new Dictionary<Model3D, Voxel>(); OriginalMaterial = new Dictionary<Model3D, Material>(); Voxels.Add(new Voxel(new Point3D(0, 0, 0), CurrentColor)); UpdateModel(); }
public List<Person> CreatePersons() { List<Person> personlist = new List<Person>(); Person person1 = new Person(); Person person2 = new Person(); personlist.Add(person1); personlist.Add(person2); person1.Username = "******"; person1.Password = "******"; person1.Gender = "Male"; person1.Weight = 110; person2.Username = "******"; person2.Password = "******"; person2.Gender = "Female"; person2.Weight = 50; return personlist; }
static void Main(string[] args) { Matrix mat = new Matrix(2, 2); mat.Initialize(20); int a = 33; Serializer x = new Serializer(); List<int> l = new List<int>(); l.Add(5); x.WriteObject(mat,@"C:\qwer.xml"); var b = x.ReadObject(@"C:\qwer.xml"); }
public List<string> GetUsersList() { List<string> userlist = new List<string>(); Usersname.CommandText = "SELECT name FROM message"; SQLiteDataReader r = Usersname.ExecuteReader(); while (r.Read()) { userlist.Add(Convert.ToString(r["name"])); } return userlist; }
public MainWindow() { InitializeComponent(); List<Location> locations = new List<Location>(); locations.Add(new Location() { ContinentCode = "EU", CountryID = 2 }); ((GridViewComboBoxColumn)this.radGridView.Columns[0]).ItemsSource = Locations.Continents; this.radGridView.ItemsSource = locations; //We need to sense when the combo selection is changed and submit the value immediately //otherwise the value will be submited on leaving the cell which is too late for our needs. this.AddHandler(RadComboBox.SelectionChangedEvent, new System.Windows.Controls.SelectionChangedEventHandler(comboSelectionChanged)); }
public List<string> LoadMusic() { List<string> data = new List<string>(); try { string line; System.IO.StreamReader file = new System.IO.StreamReader("radio.txt"); while ((line = file.ReadLine()) != null) { data.Add(line); } } catch (Exception) { } return data; }
public void evaluateConfidence(double[] data) { output = this.confiRecog.recognizeEmotion(data); List<KeyValuePair<double, int>> lst = new List<KeyValuePair<double,int>>(); //checking for multiple emo category: for (int i = 0; i < this.emoCategory; i++) { if (output[i] > this.emoThreshold) { lst.Add(new KeyValuePair<double, int>(output[i], i)); } } getConfidence(lst); }
public List<string> ForStatementAnalizer(string forStatement) { string aux = statementFilter(forStatement, "for"); var forValues = new List<string>(); if (!aux.Contains("Error")) { var iteratRestrict = aux.Split(';'); foreach (string rest in iteratRestrict) { forValues.Add(rest); } if (forValues.Count != 3) { /////verificar asignacion de variable como primera entrada(int i = 0), condicion(i<n) y expresion final(i++)//////////// } } return forValues; }
public override List<string> getAllColumns(String database, String table) { List<string> data = new List<string>(); try { var connectionString = string.Format("Data Source=.\\SQLExpress;Integrated Security=SSPI;" + "Database=" + database + ";"); sqlConnection = new SqlConnection(connectionString); sqlConnection.Open(); try { using (sqlConnection) { //Select * From DBNAME.INFORMATION_SCHEMA.COLUMNS SqlCommand command = sqlConnection.CreateCommand(); command.CommandText = String.Format("SELECT COLUMN_NAME FROM " + "INFORMATION_SCHEMA.COLUMNS WHERE TABLE_NAME = '{0}' ", table); //======================================================== SqlDataReader Reader; Reader = command.ExecuteReader(); while (Reader.Read()) { data.Add(Reader.GetValue(0).ToString()); } sqlConnection.Close(); } } catch (SqlException ex) { System.Windows.MessageBox.Show(ex.ToString()); } } catch (InvalidOperationException ex) { System.Windows.MessageBox.Show(ex.ToString()); } return data; }
public List<string> GetMessage(string names) { List<string> tmpmessage = new List<string>(); Int64 integer; integer = Int64.Parse(Usersname.CommandText = "SELECT id FROM users WHERE name=names"); string mes; mes = Usersname.CommandText = "SELECT messages FROM message WHERE us_id=integer".ToString(); SQLiteDataReader m = Usersname.ExecuteReader(); while (m.Read()) { tmpmessage.Add(Convert.ToString(m["messages"])); } Usersmess.ExecuteNonQuery(); // chgitem es piti lini te che return tmpmessage; }
protected void AddPropError(string propertyName, string errorMsg) { if (string.IsNullOrEmpty(propertyName)) { return; } if (_validationErrors.ContainsKey(propertyName)) { List<string> errors; if (_validationErrors.TryGetValue(propertyName, out errors)) { errors.Add(errorMsg); } } else { List<string> errors = new List<string>(); errors.Add(errorMsg); _validationErrors.Add(propertyName, errors); } }
public MainWindow() { InitializeComponent(); RadGridView1.GroupRenderMode = Telerik.Windows.Controls.GridView.GroupRenderMode.Nested; List<TestClass> items = new List<TestClass>(); for (int i = 0; i < 100; i++) { for (int j = 0; j < 2; j++) { for (int k = 0; k < 2; k++) { items.Add(new TestClass() { MyProperty1 = string.Format("Prop1_{0}", i), MyProperty2 = string.Format("Prop2_{0}", j), MyProperty3 = string.Format("Prop3_{0}", k), }); } } } DataContext = items; }
public int play(string foo) { try { StreamReader sr = new StreamReader(foo, Encoding.Default); String line; List<int> wave = new List<int>(); while ((line = sr.ReadLine()) != null) { wave.Add(int.Parse(line)); } if (wave.Count % 2 != 0) return -2; Thread t = new Thread(new ParameterizedThreadStart(cplay)); t.Start(wave); } catch { Console.WriteLine("音频不存在"); return -1; } return 0; }
public override List<string> getAllDataBases() { connect(); MySqlCommand command = connection.CreateCommand(); command.CommandText = "SHOW DATABASES;"; //======================================================== MySqlDataReader Reader; List<string> data = new List<string>(); try { Reader = command.ExecuteReader(); while (Reader.Read()) { //добавление баз данных всех data.Add(Reader.GetValue(0).ToString()); } disconnect(); } catch (MySqlException ex) { System.Windows.MessageBox.Show(ex.ToString()); } data.Remove("information_schema"); data.Remove("performance_schema"); data.Remove("mysql"); return data; }
public override List<string> getAllTables(String database) { List<string> data = new List<string>(); DataTable table = null; try { var connectionString = string.Format("Data Source=.\\SQLExpress;Integrated Security=SSPI;" + "Database=" + database + ";"); sqlConnection = new SqlConnection(connectionString); try { using (sqlConnection) { sqlConnection.Open(); table = sqlConnection.GetSchema("Tables"); sqlConnection.Close(); } } catch (SqlException ex) { System.Windows.MessageBox.Show(ex.ToString()); } if (table != null) { foreach (DataRow row in table.Rows) { //2 элемент это база данных data.Add(row.ItemArray[2].ToString()); } } return data; } catch (InvalidOperationException ex) { System.Windows.MessageBox.Show(ex.ToString()); } return data; }
public override List<List<string>> getDataOfTable(String database, String table) { List<List<string>> data = new List<List<string>>(); try { var connectionString = string.Format("Data Source=.\\SQLExpress;Integrated Security=SSPI;" + "Database=" + database + ";"); sqlConnection = new SqlConnection(connectionString); sqlConnection.Open(); try { using (sqlConnection) { //Select * From DBNAME.INFORMATION_SCHEMA.COLUMNS SqlCommand command = sqlConnection.CreateCommand(); command.CommandText = String.Format("SELECT * FROM {0} ", table); //======================================================== SqlDataReader Reader; Reader = command.ExecuteReader(); while (Reader.Read()) { List<string> row = new List<string>(); for (int i = 0; i < Reader.FieldCount; i++) { row.Add(Reader.GetValue(i).ToString()); } data.Add(row); } sqlConnection.Close(); } } catch (SqlException ex) { System.Windows.MessageBox.Show(ex.ToString()); } } catch (InvalidOperationException ex) { System.Windows.MessageBox.Show(ex.ToString()); } return data; }
public override List<string> getAllColumns(String database, String table) { connect(); MySqlCommand command = connection.CreateCommand(); command.CommandText = String.Format("SHOW COLUMNS FROM {0} FROM {1}", table, database); //======================================================== MySqlDataReader Reader; List<string> data = new List<string>(); try { Reader = command.ExecuteReader(); while (Reader.Read()) { data.Add(Reader.GetValue(0).ToString()); } disconnect(); } catch (MySqlException ex) { System.Windows.MessageBox.Show(ex.ToString()); } return data; }
// Omnipresence goes here (knowledge of what files will be done) public void Establish_List(FileInfo[] files) { var temp = new List<FileInfo>(); Random rand = new Random(); for (int i = 0; i < 1000 ; i +=1) { FileInfo fi = files[rand.Next(files.Length)]; temp.Add(fi); } // make new _AllFiles = new List<FileInfo>(temp).ToArray(); }
public override List<string> getAllTables(String database) { connect(); MySqlCommand command = connection.CreateCommand(); command.CommandText = "show tables from " + database + ";"; //======================================================== MySqlDataReader Reader; List<string> data = new List<string>(); try { Reader = command.ExecuteReader(); while (Reader.Read()) { data.Add(Reader.GetValue(0).ToString()); } disconnect(); } catch (MySqlException ex) { System.Windows.MessageBox.Show(ex.ToString()); } return data; }
static Dictionary<string, FunctionStat> ProcessingCallStack(string rawTextLog) { string[] perRecord = rawTextLog.Split(new string[] { recordSep }, StringSplitOptions.None); List<string> PrevCallStackString = null; List<string> CurCallStackString = new List<string>(); string curRunningFn = null; string prevRunningFn = null; Dictionary<string, FunctionStat> histogram = new Dictionary<string, FunctionStat>(); foreach (string l in perRecord) { Regex regex = new Regex(@"tsc: ([\w]+ [\w]+) ([\d]+.[\d]+) \(([\d]+.[\d]+)\) rip:([\w]+)"); Match match = regex.Match(l); //bool bFound = false; double curTimestamp = 0; double previousTimestamp = 0; // Read current callstack if (match.Success) { curTimestamp = double.Parse(match.Groups[2].Value); string temp = l.Trim(); CurCallStackString.Clear(); foreach (string l2 in temp.Split('\n')) { Regex regex2 = new Regex(@"Pc:([\w]+) AddrReturn:([\w]+) \(([\w\+]+)\) Frame:([\w]+)"); Match match2 = regex2.Match(l2); if (match2.Success) { CurCallStackString.Add(l2); } } } // Compare cur/prev callstack to figure out running fn if (PrevCallStackString != null && PrevCallStackString.Count != 0 && CurCallStackString.Count != 0) { for (int i = 0; i != CurCallStackString.Count - 1; i++) { for (int j = 0; j != PrevCallStackString.Count - 1; j++) { //Console.WriteLine("i {0} j {1}", i, j); if (CurCallStackString[i] == PrevCallStackString[j] && CurCallStackString[i + 1] == PrevCallStackString[j + 1] && IsInFilter(getNameOnlyFunction(CurCallStackString[i])) == false) { // bFound = true; curRunningFn = CurCallStackString[i]; goto _break; } } } _break: ; //Console.WriteLine("--- curRunningFn: {0} prevRunningFn: {1}", curRunningFn, prevRunningFn); } // update the current fn if (curRunningFn != null && curRunningFn == prevRunningFn) { string fnName = getNameOnlyFunction(curRunningFn); //Console.WriteLine("Fn: {0}", fnName); UpdateTimeHistogram(ref histogram, fnName, curTimestamp - previousTimestamp); } prevRunningFn = curRunningFn; previousTimestamp = curTimestamp; // update prev callstack PrevCallStackString = null; PrevCallStackString = CurCallStackString.ToList(); } return histogram; }
public static bool Read(string filePath) { try { var reader = new StreamReader(File.OpenRead(@filePath)); fileNames = new List<string>(); utterances = new List<string>(); count = 0; while (!reader.EndOfStream) { var line = reader.ReadLine(); var values = line.Split('\t'); fileNames.Add(values[0]); utterances.Add(values[1]); count += 1; } curIndex = 0; Console.WriteLine(fileNames.ToString()); return true; } catch (Exception e) { return false; } }
public override List<string> getAllDataBases() { connect(); DataTable databases = null; try { using (sqlConnection) { sqlConnection.Open(); databases = sqlConnection.GetSchema("Databases"); sqlConnection.Close(); } } catch (SqlException ex) { System.Windows.MessageBox.Show(ex.ToString()); } List<string> data = new List<string>(); if (databases != null) { foreach (DataRow row in databases.Rows) { data.Add(row.ItemArray[0].ToString()); } } data.Remove("master"); data.Remove("model"); data.Remove("msdb"); data.Remove("tempdb"); return data; }
public override List<List<string>> getDataOfTable(String database, String table) { connect(); MySqlCommand command = connection.CreateCommand(); command.CommandText = String.Format("USE {0}; SELECT * FROM {1};", database, table); //======================================================== MySqlDataReader Reader; List<List<string>> data = new List<List<string>>(); try { Reader = command.ExecuteReader(); while (Reader.Read()) { List<string> row = new List<string>(); for (int i = 0; i < Reader.FieldCount; i++) { row.Add(Reader.GetValue(i).ToString()); } data.Add(row); } disconnect(); } catch (MySqlException ex) { System.Windows.MessageBox.Show(ex.ToString()); } return data; }