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 string verificarLLaves(List<string> text) { entrada.Clear(); salida.Clear(); //buscamos en el texto las { y } y guardamos sus posiciones for (int i = 0; i < text.Count; i++) { if (text[i].Contains("{")) { addEntada(i); } if (text[i].Contains("}")) { addSalida(i); } } if (ControlLLaves() == -1) // si el numero de { y } son iguales { return controlParentesis(text);//llamamos a control de ( ) } else { return "se esperaba } de la linea: " + ControlLLaves().ToString(); } }
public async Task get_artists() { // arrange var asyncWebClient = Substitute.For<IAsyncWebClient>(); var artists = new List<Artist>(); var cancellationTokenSource = new CancellationTokenSource(); var artist = new Artist { name = "Jake", image = new[]{new Image{ size = "small", text = "http://localhost/image.png"}} }; asyncWebClient .GetStringAsync(Arg.Any<Uri>(), cancellationTokenSource.Token) .Returns(Task.FromResult(JsonConvert.SerializeObject(new Wrapper { Artists = new Artists { artist = new[]{artist }} }))); asyncWebClient .GetDataAsync(Arg.Any<Uri>()) .Returns(Task.FromResult(new byte[0])); // act await MainWindow.GetArtistsAsync(asyncWebClient, cancellationTokenSource.Token, new TestProgress<Artist>(artists.Add), bytes => null); // assert Assert.Equal(1, artists.Count); Assert.Equal("Jake", artists[0].name); }
public List<String> getLastProjects() { 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"]); list.Add(reader["address"].ToString()); } } con.Close(); } } return list; }
public void TestCutByLine_Common1() { var lstC = new List<VertexBase> { new Vertex(4, 8), new Vertex(12, 9), new Vertex(14, 1), new Vertex(2, 3), new Vertex(4, 8) }; //S1S5切割多边形 var polyC = new LinkedList<VertexBase>(lstC); var inters = CutByLine(new Vertex(2, 12), new Vertex(10, 1), polyC); Assert.True(inters.Count == 2 && polyC.Count == 7); //S2S1切割多边形 polyC = new LinkedList<VertexBase>(lstC); inters = CutByLine(new Vertex(6, -2), new Vertex(2, 12), polyC); Assert.True(inters.Count == 2 && polyC.Count == 7); // S5S4切割多边形 // 测试虚交点 polyC = new LinkedList<VertexBase>(lstC); inters = CutByLine(new Vertex(10, 1), new Vertex(12, 5), polyC); Assert.True(inters.Count == 1 && polyC.Count == 6); }
public void TestCutByLineForCrossDi_Common1() { //S1S5切割多边形 //普通情况 var polyC = new List<VertexBase> { new Vertex(4, 8), new Vertex(12, 9), new Vertex(14, 1), new Vertex(2, 3), new Vertex(4, 8) }; var inters = CutByLineForCrossDi(new Vertex(2, 12), new Vertex(10, 1), polyC, false); Assert.True(inters.Item1 == CrossInOut.In && inters.Item2 == 0 && inters.Item3); inters = CutByLineForCrossDi(new Vertex(10, 1), new Vertex(2, 12), polyC, false); Assert.True(inters.Item1 == CrossInOut.In && inters.Item2 == 2 && inters.Item3); var polyS = new List<VertexBase> { new Vertex(2, 12), new Vertex(10, 1), new Vertex(12, 5), new Vertex(13, 0), new Vertex(6, -2), new Vertex(2, 12) }; var inters2 = CutByLineForCrossDi(new Vertex(14, 1), new Vertex(2, 3), polyS, true, 0); Assert.True(inters2.Item1 == CrossInOut.In && inters2.Item2 == 0 && inters2.Item3); }
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 dynamicDetection(String s) { this.recog = new recognizer(s); //this.file = new System.IO.StreamWriter("C:\\Users\\workshop\\Desktop\\11122.csv"); this.iter = 0; this.frame = 0; this.feature = new _feature(0.0); //this.featureSet = new double[20]; this.wDist = new double[4]; this.wDistLeg = new double[4]; this.prevAccel = new double[4]; this.prevAccelLeg = new double[4]; this.prevSpeed = new double[4]; this.prevSpeedLeg = new double[4]; this.totJI = new double[4]; this.wprevLeg = new _qbit[4]; this.wprev = new _qbit[4]; this.featureList = new List<double[]>(); refreshVars(); }
/// <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; }
private void selectedCellsChangedHandler(object param = null) { IEnumerable<object> selected = param as IEnumerable<object>; var selectedDataItems = selected.Cast<DataItemViewModel>().ToList(); // Clone the SelectedEntries List<DataItemViewModel> clonedSelectedEntries = new List<DataItemViewModel>(selectedDataItems); // keep the previous entry that is part of the selection DataItemViewModel previousSelectedItem = null; // Keep the previous entry that is in the list DataItemViewModel previousItem = null; // build list backwards so that diffs happen in order going up int viewCount = Data.Count; for (int i = viewCount - 1; i >= 0; i--) { // Get current item in the list var currentItem = Data[i] as DataItemViewModel; // If the item is part of the selection we will want some kind of diff if (clonedSelectedEntries.Contains(currentItem)) { // If the previous selected item is null // this means that it is the bottom most item in the selection // and compare it to the previous non selected string if (previousSelectedItem != null) { currentItem.PrevName = previousSelectedItem.Name; currentItem.IsVisualDiffVisible = true; } else if (previousItem != null) // if there is a previous selected item compare the item with that one { currentItem.PrevName = previousItem.Name; currentItem.IsVisualDiffVisible = true; } else //the selected item is the bottom item with nothing else to compare, so just show differences from an empty string { currentItem.PrevName = String.Empty; currentItem.IsVisualDiffVisible = true; } // Set the previously selected item to the current item to keep for comparison with the next selected item on the way up previousSelectedItem = currentItem; // clean up clonedSelectedEntries.Remove(currentItem); } else // if item is not part of the selection we will want the original text { currentItem.PrevName = String.Empty; currentItem.IsVisualDiffVisible = false; } // regardless of whether item is in selection or not we keep it as the previous item when we move up to the next one previousItem = currentItem; } }
static void Main(string[] args) { ControlStructuresAnalizer csa = new ControlStructuresAnalizer(); List<string> forloop = new List<string>(); forloop = csa.ForStatementAnalizer("for(int i = 0; i < n; i++)"); Console.WriteLine(forloop[0].ToString()); Console.ReadKey(); }
public static void SaveTimerValue(List<TimeSpan> items) { if( items.Count == 0 ) { return; } File.WriteAllLines(outputValueFileName, items.Select(c => c.ToString(@"hh\:mm\:ss"))); }
/// <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 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 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" }); }
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; }
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 Queue(int type, double size, double pages = 0) { _StatusReport = new List<Stats>(); _Type = (QueueType) type; _MaxSize = size; _PageSizes = new Collection<double>(); _PageSizes.Add(pages); _ProcessList = new Collection<Process>(); _Log = new Collection<string>(); _MemoryList = new Collection<Memory>(); }
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 Level(Canvas canvas) { this.canvas = canvas; commands = new List<Command>(); primitives = new List<Primitive>(); levelRect = new Rectangle(); levelRect.Fill = Brushes.White; this.canvas.Children.Add(levelRect); Canvas.SetLeft(levelRect, levelOffsetX); Canvas.SetTop(levelRect, levelOffsetY); LevelWidth = 4000; LevelHeight = 1000; }
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 List<string> GetDatabases(SqlConnectionString connectionString) { var databases = new List<string>(); using (var conn = new SqlConnection(connectionString.WithDatabase("master"))) { conn.Open(); var serverConnection = new ServerConnection(conn); var server = new Server(serverConnection); databases.AddRange(from Database database in server.Databases select database.Name); } return databases; }
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 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> 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 MainViewModel() { easyTimer = new EasyTimer(); try { _timerValueList = TimerFileIo.ReadTimerValue().ToList(); } catch (Exception e) { MessageBox.Show(e.ToString()); // File絡みのエラー(Fileなし、Parse出来ない等)の場合は3分タイマー1個にしておく _timerValueList = new List<TimeSpan> { new TimeSpan(0, 3, 0) }; } SelectedTimeSpanListId = 0; }
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> 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 Memory(double size, bool replace, int replaceMethod = 0) { _SecondChanceList = new List<string>(); _InternalFragReport = new List<string>(); if (size != .5 || size != 1 || size != 4) { _BlockSize = 1; } else { _BlockSize = size; } _Start = _End = _UsedSpace = _Entries = _PageCount = 0; _Replace = replace; _ReplaceMethod = replaceMethod; _Points = new List<int>(); }
public Memory(double size, double start, double end, int pages, int entries, bool replace, int replaceMethod = 0) { _SecondChanceList = new List<string>(); _InternalFragReport = new List<string>(); if (size != .5 || size != 2 || size != 1 || size != 4) { _BlockSize = 1; } else { _BlockSize = size; } _Start = start; _End = end; _UsedSpace = end - start; // error checking // if we're not a full size break for pages... if ((_End - _Start) % (1024 * size) != 0) { // bump end up to page size _End += ((1024 * size) - (_End % (1024 * size))); } _Entries = entries; _PageCount = pages; _Table = new bool[_PageCount]; _Age = new int[_PageCount]; // initialize the pages to empty; for (int i = 0; i < _PageCount; i += 1) { _Table[i] = false; } // check if replacement is happening or if this is simple _Replace = replace; _ReplaceMethod = replaceMethod; _Points = new List<int>(); }