public void Normalizing() { PathList list = new PathList(); list.Add("libs"); list.Add("/libs2"); list.Add("~/libs3"); CollectionAssert.AreEqual(new string[] { "~/libs/", "~/libs2/", "~/libs3/" }, list.ToList()); }
public void Normalizing() { PathList list = new PathList(); list.Add("libs"); list.Add("/libs2"); list.Add("~/libs3"); CollectionAssert.AreEqual(new string[] { "~/libs/", "~/libs2/", "~/libs3/"}, list.ToList()); }
public void OptionParsing() { PathList list = new PathList(); list.Add("~/libs"); list.Add("~/libs2"); var coll = new ScriptCollection(list, TestUtil.MapPath); coll.AddPath("~/scripts/test-script-3.js"); Assert.AreEqual(coll.Count, 1); }
public void OptionParsing() { PathList list = new PathList(); list.Add("~/libs"); list.Add("~/libs2"); var coll = new ScriptCollection(list, TestUtil.MapPath); coll.AddPath("~/scripts/test-script-3.js"); Assert.AreEqual(coll.Count, 1); }
protected virtual object commandSaveExecute(object parameter) { if (PathList != null) { //Clear item with empty information for (int i = PathList.Count - 1; i >= 0; i--) { PathItem item = PathList[i]; if (String.IsNullOrWhiteSpace(item.Name) || String.IsNullOrWhiteSpace(item.Path)) { PathList.RemoveAt(i); continue; } item.Path = item.Path.TrimEnd('\\'); } //Order list to save IList <PathItem> orderList = (from p in PathList orderby p.Name select p).ToList <PathItem>(); PathList.Clear(); foreach (var item in orderList) { PathList.Add(item); } //Save XML File if (GlobalHelper.SaveFolderFile(orderList, GlobalHelper.FOLDERS_FILE_PATH)) { MessageBox.Show(Resources.AddFolderPathVM_commandSaveExecute_SuccessMessage, Resources.AddFolderPathVM_commandSaveExecute_SuccessTitle, MessageBoxButton.OK, MessageBoxImage.Information); ListChanged = true; } } return(null); }
public void WildcardNoDirectory() { var pathColl = new PathList(); pathColl.Add(@"NoDirectory\*.txt"); Assert.AreEqual(4, pathColl.Count); }
public void WildcardWithExtensionNoMatch() { var pathColl = new PathList(); pathColl.Add("*.noMatch"); Assert.AreEqual(0, pathColl.Count); }
public void createStringBasedPath(string path) //dodaje sciezke do listy scieżek na podstawie stringa z ciągiem wierzchołków { Path createdPath = null; try { if (!String.IsNullOrEmpty(path)) { int b = 0; string[] nbsVertices = path.Split(' '); createdPath = new Path(Int32.Parse(nbsVertices[0]) + 1, Int32.Parse(nbsVertices[nbsVertices.GetLength(0) - 1]) + 1); PathList.Add(createdPath); for (int a = 0; a < nbsVertices.GetLength(0) - 1; a++) { b = a + 1; PathList[PathList.Count - 1].edgesInPath.Add(getEdge(Int32.Parse(nbsVertices[a]) + 1, Int32.Parse(nbsVertices[b]) + 1, EdgeList)); } } } catch (System.FormatException e) { LogClass.WhiteLog("[RC] Can't find path with this capacity"); PathList.Remove(createdPath); } }
public void ApplyPathTransformation() { var fileList = new PathList <UoeFileToCompile>(); for (int i = 0; i < 1000; i++) { fileList.Add(new UoeFileToCompile(i.ToString())); } Assert.AreEqual(1000, fileList.Count); Assert.IsTrue(fileList.ToList().Exists(f => f.Path.Equals("0"))); fileList.ApplyPathTransformation(k => { k.Path = $"fu{k.Path}"; return(k); }); Assert.AreEqual(1000, fileList.Count, "wrong count"); Assert.IsTrue(fileList.ToList().Exists(f => f.Path.Equals("fu0")), "can't find fu0"); fileList.ApplyPathTransformation(k => { k.Path = "no"; return(k); }); Assert.AreEqual(1, fileList.Count, "should find only 1 because they all have the same key"); Assert.IsTrue(fileList.ToList().Exists(f => f.Path.Equals("no")), "can't find no"); }
public override object InformationToProperty(IInformation information, Type propertyType) { var value = information as IInformationValue; if (value == null) { throw new OptionReaderException(information.Lines.First().Number, information.Lines.Last().Number, $"'{information.Name}' must be a value type."); } try { var xElements = new List <XElement>(); // The path could contain wildcards, so use a PathList. var pathList = new PathList() { PathStorage = PathStorageMode.Relative }; pathList.Add(value.Value.Trim()); foreach (var path in pathList) { var xElement = new XElement("UserPage"); xElement.Add(new XElement("Path", PathUtils.ChangeExtension(path, ".html"))); xElement.Add(XmlUtils.WrapAndParse("Content", new Markdown().Transform(OtherUtils.ReadAllText(path)))); xElements.Add(xElement); } return(xElements); } catch (Exception e) { throw new OptionReaderException(information.Lines.First().Number, information.Lines.Last().Number, e.Message); } }
public ScriptCollectionTest() { var html = Support.GetFile("CsQuery.Mvc.Tests/Views/Test/Index6.cshtml"); Dom = CQ.Create(html); pathList = new PathList(); pathList.Add("~/scripts"); }
public King(bool isWhite, bool hasTextures = true) : base(isWhite) { if (hasTextures) { Texture = isWhite ? Resources.WhiteKing.ToBitmapSource() : Resources.BlackKing.ToBitmapSource(); } PathList.Add(PathFactory.AddToPath(Movement.Direction.Top).SetIsRecursive(false).Create()); PathList.Add(PathFactory.AddToPath(Movement.Direction.TopLeft).SetIsRecursive(false).Create()); PathList.Add(PathFactory.AddToPath(Movement.Direction.Left).SetIsRecursive(false).Create()); PathList.Add(PathFactory.AddToPath(Movement.Direction.BottomLeft).SetIsRecursive(false).Create()); PathList.Add(PathFactory.AddToPath(Movement.Direction.Bottom).SetIsRecursive(false).Create()); PathList.Add(PathFactory.AddToPath(Movement.Direction.BottomRight).SetIsRecursive(false).Create()); PathList.Add(PathFactory.AddToPath(Movement.Direction.Right).SetIsRecursive(false).Create()); PathList.Add(PathFactory.AddToPath(Movement.Direction.TopRight).SetIsRecursive(false).Create()); }
public void GetName() { PathList list = new PathList(); list.Add("libs"); list.Add("/libs2"); list.Add("~/libs3"); Assert.AreEqual("test.js", list.GetName("test")); Assert.AreEqual("test.js", list.GetName("test.js")); Assert.AreEqual("test.js", list.GetName("~/test.js")); Assert.AreEqual("test.js", list.GetName("~/libs/test.js")); Assert.AreEqual("test.js", list.GetName("/libs/test.js")); Assert.AreEqual("test.js", list.GetName("~/libs3/test.js")); Assert.AreEqual("something/test.js", list.GetName("something/test.js")); Assert.AreEqual("something/test.js", list.GetName("~/libs2/something/test")); }
public void OptionParsing() { PathList list = new PathList(); list.Add("~/scripts/libs"); list.Add("~/scripts/libs2"); var coll = new ScriptCollection(new ScriptEnvironment { RelativePathRoot = "/", LibraryPath = list, MapPath = TestUtil.MapPath }); coll.AddPath("~/scripts/test-script-3.js"); Assert.AreEqual(coll.Count, 1); }
public void GetName() { PathList list = new PathList(); list.Add("libs"); list.Add("/libs2"); list.Add("~/libs3"); Assert.AreEqual("test.js", list.GetName("test")); Assert.AreEqual("test.js", list.GetName("test.js")); Assert.AreEqual("test.js", list.GetName("~/test.js")); Assert.AreEqual("test.js", list.GetName("~/libs/test.js")); Assert.AreEqual("test.js", list.GetName("/libs/test.js")); Assert.AreEqual("test.js", list.GetName("~/libs3/test.js")); Assert.AreEqual("something/test.js", list.GetName("something/test.js")); Assert.AreEqual("something/test.js", list.GetName("~/libs2/something/test")); }
public ScriptCollectionTest() { var html = Support.GetFile("CsQuery.Mvc.Tests/Views/Test/unresolvedscripts.cshtml"); Dom = CQ.Create(html); pathList = new PathList(); pathList.Add("~/scripts"); }
public void OptionParsing() { PathList list = new PathList(); list.Add("~/scripts/libs"); list.Add("~/scripts/libs2"); var coll = new ScriptCollection(new ScriptEnvironment { RelativePathRoot= "/", LibraryPath= list, MapPath = TestUtil.MapPath }); coll.AddPath("~/scripts/test-script-3.js"); Assert.AreEqual(coll.Count, 1); }
protected virtual object commandAddExecute(object parameter) { var newItem = new PathItem(); if (PathList != null) { PathList.Add(newItem); } return(null); }
public void Start() { streams = new ObjectStream <Streams>(template, spawnRate, 16, () => { var path = new PathList(); path.Add(new LinearPath { origin = this.gameObject, target = target }); path.Add(new FadeOutPath { offset = 0.5f }); return(new SpawnData <Streams> { stream = Streams.STREAM_0, manager = AnimationManager.Default, path = path, origin = new NTransform(target), curve = new Linear(lifeTime) }); }); }
public void PathListRefresh() { // 갯수만 동일하고 내용물이 다를 경우가 있어 버그를 유발하였음... //if (PathList.Count == TLKs.Count) return; PathList.Clear(); foreach (var item in TLKs) { PathList.Add(item.FilePath); } }
public void Start() { streams = new ObjectStream <Streams>(template, spawnRate, 16, () => { var path = new PathList(); path.Add(new LinearFixedPath { origin = this.gameObject, target = target, speed = speed }); path.Add(new FadeOutDistance { offset = fadeOutAt, target = target }); path.Add(new FadeInDistance { distance = fadeInOver }); return(new SpawnData <Streams> { stream = Streams.STREAM_1, manager = AnimationManager.Default, path = path, origin = new NTransform(gameObject), curve = new Linear(lifeTime) }); }); }
public Pawn(bool isWhite, bool hasTextures = true) : base(isWhite) { if (hasTextures) { Texture = isWhite ? Resources.WhitePawn.ToBitmapSource() : Resources.BlackPawn.ToBitmapSource(); } if (IsBlack()) { PathList.Add( PathFactory.AddToPath (Movement.Direction.Bottom).AddToPath (Movement.Direction.Bottom).SetIsRecursive(false).Create()); PathList.Add( PathFactory.AddToPath (Movement.Direction.Bottom).SetIsRecursive(false).Create()); EatList.Add( PathFactory.AddToPath (Movement.Direction.BottomLeft).SetIsRecursive(false).Create()); EatList.Add( PathFactory.AddToPath (Movement.Direction.BottomRight).SetIsRecursive(false).Create()); } else { PathList.Add( PathFactory.AddToPath (Movement.Direction.Top).AddToPath (Movement.Direction.Top).SetIsRecursive(false).Create()); PathList.Add( PathFactory.AddToPath (Movement.Direction.Top).SetIsRecursive(false).Create()); EatList.Add( PathFactory.AddToPath (Movement.Direction.TopLeft).SetIsRecursive(false).Create()); EatList.Add( PathFactory.AddToPath (Movement.Direction.TopRight).SetIsRecursive(false).Create()); } }
public void GenerateMap() { _dataList = _data.LoadDataFromFile(); int lineNumber = 0; foreach (string data in _dataList) { string[] text = new string[6]; text = data.Split(' '); if (lineNumber == 0) { _mapLengthX = Int32.Parse(text[2]); _mapLengthY = Int32.Parse(text[1]); AddGrids(_mapLengthY, _mapLengthX); } else if (lineNumber == 1) { _robotX = Int32.Parse(text[1]); _robotY = Int32.Parse(text[2]); foreach (Grid grid in _gridList) { if (_robotX == grid.X && _robotY == grid.Y) { grid.GridName = "ROBOT"; } } } else if (lineNumber == 2) { AddGoal(Int32.Parse(text[1]), Int32.Parse(text[2])); } else if ((lineNumber >= 3)) { AddWalls(Int32.Parse(text[1]), Int32.Parse(text[2]), Int32.Parse(text[3]), Int32.Parse(text[4])); } lineNumber++; } foreach (Grid grid in GridList) { if (grid.GridName != "WALL") { Path path = new Path(grid); PathList.Add(path); } } }
protected virtual object commandSaveExecute(object parameter) { if (PathList != null) { //Clear item with empty information for (int i = PathList.Count - 1; i >= 0; i--) { PathItem item = PathList[i]; if (String.IsNullOrWhiteSpace(item.Name) || String.IsNullOrWhiteSpace(item.Path)) { PathList.RemoveAt(i); continue; } item.Path = item.Path.TrimEnd('\\'); } //Order list to save IList <PathItem> orderList = (from p in PathList orderby p.Name select p).ToList <PathItem>(); PathList.Clear(); foreach (var item in orderList) { PathList.Add(item); } //Save XML File string path = Constants.FOLDERS_FILE_PATH; try { DataService.SaveFolderFile(orderList, path); MessageBox.Show(Resources.AddFolderPathVM_commandSaveExecute_SuccessMessage, Resources.AddFolderPathVM_commandSaveExecute_SuccessTitle, MessageBoxButton.OK, MessageBoxImage.Information); ListChanged = true; } catch (Exception ex) { string message = String.Format((string)Resources.GlobalHelper_SaveFolderFile_Error_Text, path, ex.Message); MessageBox.Show(message, Resources.GlobalHelper_SaveFolderFile_Error_Title, MessageBoxButton.OK, MessageBoxImage.Exclamation); } } return(null); }
//Adds a point into the pathlist and standardizes the path to make it continous public void AddPoint(double[] newPt) { if (PathList.Count == 0) { if (firstPoint == null) { firstPoint = newPt; } else { PathList.Add(new Segment(firstPoint, newPt)); SetTotalDistance(); } return; } Segment newSegment = new Segment(PathList[PathList.Count - 1].ControlptFour, newPt); PathList.Add(newSegment); StandardizePath(PathList.Count - 2); SetTotalDistance(); }
public Bishop(bool isWhite, bool hasTextures = true) : base(isWhite) { if (hasTextures) { Texture = isWhite ? Resources.WhiteBishop.ToBitmapSource() : Resources.BlackBishop.ToBitmapSource(); } var path = PathFactory.AddToPath(Movement.Direction.TopLeft).SetIsRecursive(true).Create(); PathList.Add(path); path = PathFactory.AddToPath(Movement.Direction.TopRight).SetIsRecursive(true).Create(); PathList.Add(path); path = PathFactory.AddToPath(Movement.Direction.BottomLeft).SetIsRecursive(true).Create(); PathList.Add(path); path = PathFactory.AddToPath(Movement.Direction.BottomRight).SetIsRecursive(true).Create(); PathList.Add(path); }
public bool TryAddImage(string path) { var img = CozyPixelHelper.ReadBitmapFromFile(path); if (img.Width > 128 || img.Height > 128) { return(false); } int i = PathList.Count; PathList.Add(path); ImgList.Images.Add(img); var filename = Path.GetFileNameWithoutExtension(path); Items.Add(filename.Substring(0, (filename.Length < MaxNameLength ? filename.Length : MaxNameLength)), i); Items[i].ImageIndex = i; Items[i].ToolTipText = filename; return(true); }
/// <summary> /// Default constructor. /// </summary> public CsQueryViewEngine() { LibraryPath = new PathList(); LibraryPath.Add("~/scripts/lib"); }
internal void AddPath(GremlinMatchPath path) { PathList.Add(path); }
void HandleDragDataGet(object sender, DragDataGetArgs args) { Logger.Debug ("ImagesFileView.HandleDragDataGet. Sender {0}, args {1}", sender, args.Info); string file; TreeIter iter; TreePath[] items = SelectedItems; PathList list = new PathList (); for (int i = 0; i < items.Length; i++) { store.GetIter (out iter, items [i]); file = (string) store.GetValue (iter, 0); Logger.Debug ("ImagesFileView.HandleDragDataGet. Dropped {0}", file); list.Add (file); } switch (args.Info) { case 2: { Byte [] data = Encoding.UTF8.GetBytes (list.ToString ()); Atom [] targets = args.Context.Targets; args.SelectionData.Set (targets[0], 2, data); Logger.Debug ("ImagesFileView.HandleDragDataGet. Data.Length {0}", data.Length); return; } default: Logger.Debug ("ImagesFileView.HandleDragDataGet. Drop cancelled"); break; } args.RetVal = true; }
public void Full_test() { var fileList = new PathList <UoeFileToCompile>(); for (int i = 0; i < 1000; i++) { fileList.Add(new UoeFileToCompile(i.ToString())); } var j = 0; foreach (var compile in fileList) { Assert.AreEqual(j.ToString(), compile.Path); j++; } Assert.AreEqual(1000, fileList.Count); for (int i = 0; i < 1000; i++) { Assert.AreEqual(i.ToString(), fileList[i.ToString()].Path); } j = 0; foreach (var compile in fileList) { Assert.AreEqual(j.ToString(), fileList[compile].Path); j++; } for (int i = 0; i < 1000; i++) { Assert.AreEqual(true, fileList.Contains(i.ToString())); } j = 0; foreach (var compile in fileList) { Assert.AreEqual(true, fileList.Contains(compile)); j++; } for (int i = 0; i < 1000; i++) { Assert.AreEqual(false, fileList.TryAdd(new UoeFileToCompile(i.ToString()))); } for (int i = 0; i < 1000; i++) { Assert.AreEqual(true, fileList.Remove(new UoeFileToCompile(i.ToString()))); } for (int i = 0; i < 1000; i++) { Assert.AreEqual(true, fileList.TryAdd(new UoeFileToCompile(i.ToString()))); } fileList.Clear(); Assert.AreEqual(0, fileList.Count); var tempList = new List <UoeFileToCompile>(); for (int i = 0; i < 1000; i++) { tempList.Add(new UoeFileToCompile(i.ToString())); } fileList.AddRange(tempList); Assert.AreEqual(1000, fileList.Count); }
public void Test_performances() { List <string> files = new List <string>(); for (int i = 0; i < 1000; i++) { files.Add(Path.Combine("C:\\folder\\subfolder\\again\\even\\more\\subfolder\\to\\makeit\\super\\long\\and\\realistic", $"file{i}.ext")); } for (int i = 0; i < 1000; i++) { files.Add(Path.Combine("D:\\folder\\subfolder\\again\\even\\more\\subfolder\\to\\makeit\\super\\long\\and\\realistic", $"file{i}.ext")); } for (int i = 0; i < 1000; i++) { files.Add(Path.Combine("C:\\folder\\subfolder\\again\\even\\THIS FOLDER CHANGES\\subfolder\\to\\makeit\\super\\long\\and\\realistic", $"file{i}.ext")); } var fileList = new PathList <UoeFileToCompile>(); foreach (var file in files) { fileList.Add(new UoeFileToCompile(file)); } Console.WriteLine("PathEquals done in {0} ms", TestHelper.Time(() => { foreach (var file1 in files) { foreach (var file2 in files) { Assert.IsNotNull(file1.PathEquals(file2)); } } }).Milliseconds.ToString()); Console.WriteLine("Equals done in {0} ms", TestHelper.Time(() => { foreach (var file1 in files) { foreach (var file2 in files) { Assert.IsNotNull(file1.EqualsCi(file2)); } } }).Milliseconds.ToString()); var dic = new Dictionary <string, UoeFileToCompile>(StringComparer.OrdinalIgnoreCase); foreach (var file in files) { dic.Add(file, new UoeFileToCompile(file)); } Console.WriteLine("HashSet done in {0} ms", TestHelper.Time(() => { foreach (var file in files) { string found = null; if (dic.ContainsKey(file)) { found = dic[file].Path; } Assert.AreEqual(file, found); } }).Milliseconds.ToString()); //Console.WriteLine("Compare done in {0} ms", TestHelper.Time(() => { // foreach (var file in files) { // string found = null; // foreach (var file1 in files) { // if (file1.EqualsCi(file)) { // found = file1; // break; // } // } // Assert.AreEqual(file, found); // } //}).Milliseconds.ToString()); }
/// <summary> /// Default constructor. /// </summary> public CsQueryViewEngine() { LibraryPath = new PathList(); LibraryPath.Add("~/scripts/lib"); }
public void FileNotFoundAtNormalPath() { var pathColl = new PathList(); pathColl.Add("NotExistingFile"); }
// Insert logic for processing found files here. private void ProcessFile(string path) { PathList.Add(path); log.Info($"Processed file '{path}'."); }
/// <summary> /// 添加历史轨迹路线 /// </summary> public void AddHistoryPath(LocationHistoryPath path) { PathList.Add(path); }