static void Main(string[] args) { var messageSerializer = new MessageSerializer(); var messageBodySerializer = new MessageBodySerializer(); var messageFactory = new MessageFactory(); var pathFactory = new PathFactory(); var broker = new Broker(1337, messageSerializer, messageBodySerializer, messageFactory, pathFactory); var messageObserver = new MessageObserver<Foo>(broker.ID, messageBodySerializer) { InterceptRemoteMessagesOnly = false, InterceptOnNext = foo => { // TODO what to do next ... } }; broker.Subscribe(messageObserver); broker.Start(); broker.Publish(new Foo { Bar = "hello" // Not L10N }); Console.ReadLine(); }
private IFolderItemViewModel InitializeView(IPathModel newPath) { string pathroot = string.Empty; IFolderItemViewModel selectedItem = null; string[] dirs; if (newPath == null) { if (string.IsNullOrEmpty(CurrentFolder) == false) { return(null); // No parameter available at this time ... } else { try { newPath = PathFactory.Create(CurrentFolder); } catch { } } } pathroot = newPath.PathRoot; dirs = PathFactory.GetDirectories(newPath.Path); // add drives foreach (string s in Directory.GetLogicalDrives()) { IFolderItemViewModel info = FolderControlsLib.Factory.CreateLogicalDrive(s); CurrentItemsAdd(info); // add items under current folder if we currently create the root folder of the current path if (string.Compare(pathroot, s, true) == 0) { for (int i = 1; i < dirs.Length; i++) { try { string curdir = PathFactory.Join(dirs, 0, i + 1); var curPath = PathFactory.Create(curdir); var info2 = new FolderItemViewModel(curPath, dirs[i]); CurrentItemsAdd(info2); } catch // Non-existing/unknown items will throw an exception here... { } } selectedItem = _CurrentItems.Last(); } } return(selectedItem); }
private void RefreshPaths() { // HACK: ask the factory twice as the individual views alter the path instances differently if (SelectedSubject != null) { Preset.Adapter.SetParts(PathFactory.GetFields(SelectedSubject)); Standard.Adapter.SetPaths(PathFactory.GetFields(SelectedSubject)); } }
public void WhenCreatingANameForACompetingSubscriptionWithAGlobalPrefix_ThePathShouldNotStartWithThePrefix() { var pathFactory = new PathFactory(new GlobalPrefixSetting { Value = "testprefix" }); var subscriptionName = pathFactory.SubscriptionNameFor("My Application", typeof(SimpleEvent)); subscriptionName.ShouldBe("my.application.simpleevent"); }
public void WhenCreatingAnInputQueuePathWithAGlobalPrefix_ThePathShouldStartWithThePrefix() { var pathFactory = new PathFactory(new GlobalPrefixSetting { Value = "testprefix" }); var path = pathFactory.InputQueuePathFor("My Application", "My Instance"); path.ShouldBe("testprefix.inputqueue.my.application.my.instance"); }
public void WhenCreatingATopicPathWithAGlobalPrefix_ThePathShouldStartWithThePrefix() { var pathFactory = new PathFactory(new GlobalPrefixSetting { Value = "testprefix" }); var path = pathFactory.TopicPathFor(typeof(SimpleEvent)); path.ShouldBe("testprefix.t.nimbus.tests.unit.infrastructuretests.messagecontracts.simpleevent"); }
public void FindPath() { Guid requestID = Guid.NewGuid(); PathRequest request = new PathRequest(requestID, mUnitTransform.position, Target.position, OnPathProcessed); PathFactory.RequestPath(request); currentRequestID = requestID; }
/// <summary> /// class constructor /// </summary> /// <param name="curdir"></param> /// <param name="itemType"></param> /// <param name="itemName"></param> /// <param name="indentation"></param> public LVItemViewModel(string curdir, FSItemType itemType, string itemName, int indentation = 0) : this() { this._PathObject = PathFactory.Create(curdir, itemType); this.ItemName = itemName; }
public void WhenCreatingAQueue_WeShouldConvertToLowerCase() { var pathName = PathFactory.TopicPathFor(typeof(MyEscapingTestMessages.EscapingTestMessage)); var expectedName = "t." + typeof(MyEscapingTestMessages.EscapingTestMessage).FullName.Replace("+", ".").ToLower(); pathName.ShouldBe(expectedName); }
public void TestDrivePathNormalization() { var ret = PathFactory.NormalizePath("C:"); var ret1 = PathFactory.NormalizePath(@"C:\"); Assert.AreEqual(ret, ret1); Assert.AreEqual(ret1, @"C:\"); }
public override async Task Execute(params object[] args) { var builder = new StringBuilder(); builder.AppendLine("Diagnostics.Execute()"); builder.AppendLine(new string('-', 80)); var processes = Process.GetProcessesByName("ONENOTE"); var module = processes.Length > 0 ? processes[0].MainModule.FileName : "unknown"; builder.AppendLine($"ONENOTE...: {module}"); builder.AppendLine($"Addin path: {Assembly.GetExecutingAssembly().Location}"); builder.AppendLine($"Data path.: {PathFactory.GetAppDataPath()}"); builder.AppendLine($"Log path..: {logger.LogPath}"); builder.AppendLine(); using (var one = new OneNote()) { var(backupFolder, defaultFolder, unfiledFolder) = one.GetFolders(); builder.AppendLine($"Default path: {defaultFolder}"); builder.AppendLine($"Backup path: {backupFolder}"); builder.AppendLine($"Unfiled path: {unfiledFolder}"); builder.AppendLine(); var(Name, Path, Link) = one.GetPageInfo(); builder.AppendLine($"Page name: {Name}"); builder.AppendLine($"Page path: {Path}"); builder.AppendLine($"Page link: {Link}"); builder.AppendLine(); one.ReportWindowDiagnostics(builder); builder.AppendLine(); var page = one.GetPage(); var pageColor = page.GetPageColor(out _, out _); var pageBrightness = pageColor.GetBrightness(); builder.AppendLine($"Page background: {pageColor.ToRGBHtml()}"); builder.AppendLine($"Page brightness: {pageBrightness}"); builder.AppendLine($"Page is dark...: {pageBrightness < 0.5}"); (float dpiX, float dpiY) = UIHelper.GetDpiValues(); builder.AppendLine($"Screen DPI.....: horizontal/X:{dpiX} vertical/Y:{dpiY}"); (float scalingX, float scalingY) = UIHelper.GetScalingFactors(); builder.AppendLine($"Scaling factors: horizontal/X:{scalingX} vertical/Y:{scalingY}"); builder.AppendLine(new string('-', 80)); logger.WriteLine(builder.ToString()); UIHelper.ShowInfo($"Diagnostics written to {logger.LogPath}"); } await Task.Yield(); }
/// <summary> /// Add a recent folder location into the collection of recent folders. /// This collection can then be used in the folder combobox drop down /// list to store user specific customized folder short-cuts. /// </summary> /// <param name="folderPath"></param> public void AddRecentFolder(string folderPath) { if ((folderPath = PathFactory.ExtractDirectoryRoot(folderPath)) == null) { return; } this.mRecentFolders.Add(folderPath); }
public void WhenCreatingAQueuePathWithAGlobalPrefix_ThePathShouldStartWithThePrefix() { var pathFactory = new PathFactory(new GlobalPrefixSetting { Value = "testprefix" }); var path = pathFactory.QueuePathFor(typeof(SimpleCommand)); path.ShouldBe("testprefix.q.nimbus.unittests.infrastructuretests.messagecontracts.simplecommand"); }
// Use this for initialization void Awake() { setAllowedOperations(); if (Statics.levelType.Equals("all") || (Statics.levelType.Equals("sphere") || Statics.levelType.Equals("torus"))) { if (GameObject.Find("Lines") != null) { GameObject.Find("Lines").SetActive(false); GameObject.Find("Dots").SetActive(false); GameObject.Find("Homotopies").SetActive(false); } GameObject.Find("Circle").SetActive(false); GameObject.Find("Rectangle").SetActive(false); GameObject.Find("DeleteObstacle").SetActive(false); GameObject.Find("DeleteAll").SetActive(false); GameObject.Find("Exit2").SetActive(false); } else { GameObject.Find("Lines").SetActive(false); GameObject.Find("Dots").SetActive(false); GameObject.Find("Homotopies").SetActive(false); GameObject.Find("Exit1").SetActive(false); GameObject.Find("Circle").SetActive(false); GameObject.Find("Rectangle").SetActive(false); GameObject.Find("DeleteObstacle").SetActive(false); GameObject.Find("DeleteAll").SetActive(false); GameObject.Find("Save").SetActive(false); GameObject.Find("Draw").SetActive(false); GameObject.Find("Delete").SetActive(false); } if (Statics.levelType.Equals("dots")) { GameObject.Find("Windung").SetActive(false); } levelNumber = Statics.nextSceneNumber; pathFactory = new PathFactory(pathMat); homotopyFactory = new HomotopyFactory(pathMat, homotopyMat); setColors(); if (Statics.showingAlgebra) { homTextObj = Instantiate(textPrefab); homTextObj.transform.SetParent(canvas.transform); var position = new Vector3(Screen.width / 2, Screen.height - 50); homTextObj.transform.position = position; } LoadObjects(Statics.nextSceneNumber); trailMat.SetColor("_Color", GetNextColor(MType.Path)); }
/// <summary> /// Sets the current folder to a new folder (with or without adjustments of History). /// </summary> /// <param name="path"></param> /// <param name="bSetHistory"></param> public void SetCurrentFolder(string path, bool bSetHistory) { try { this.CurrentFolder = PathFactory.Create(path); } catch { } }
public CreateFileAction(BrowserController controller, Path workdir, string filename, bool edit) : base(controller) { _workdir = workdir; _filename = filename; _edit = edit; _file = PathFactory.createPath(getSession(), _workdir.getAbsolute(), _filename, Path.FILE_TYPE); }
public static void Initialize(TestContext context) { var path = Path.Combine(PathFactory.GetAppDataPath(), Resx.CustomStylesFilename); if (File.Exists(path)) { // might fail; don't catch File.Delete(path); } }
public void TryCreate_WithValidPath_ReturnsTrue() { const string path = "C:\\tmp"; var factory = new PathFactory(); IPath tmp; var actual = factory.TryCreate(path, out tmp); Assert.IsTrue(actual); }
/// <summary> /// Public construction method to create a <see cref="IFolderItemViewModel"/> /// object that represents a logical drive (eg 'C:\') /// </summary> /// <param name="curdir"></param> /// <returns></returns> public static IFolderItemViewModel CreateLogicalDrive(string curdir) { var model = PathFactory.Create(curdir, FSItemType.LogicalDrive); var item = new FolderItemViewModel(model, model.Name); item.SetDisplayName(item.ItemDisplayString); return(item); }
public void TryCreate_WithInvalidPath_ReturnsFalse() { const string path = ":::"; var factory = new PathFactory(); IPath tmp; var actual = factory.TryCreate(path, out tmp); Assert.IsFalse(actual); }
public IEnumerable <IFieldPath> Add(Node n) { // if node is SubjectNode, add all fields (and defaults for IRelationFields) // if node is FieldNode with an IRelationField, add all fields for the related subject (and defaults for IRelationFields) // if node is FieldNode with an IField, create a path tracing back to the parent if (n is SubjectNode) { var fields = PathFactory.GetFields(((SubjectNode)n).Subject); foreach (var f in fields) { f.Description = null; // this is bad behaviour from the FieldPathFactory if (!Fields.Contains(f)) { Fields.Add(f); } } return(fields); } else if (n is FieldNode && ((FieldNode)n).Field is IRelationField) { var fields = PathFactory.GetFields((IRelationField)((FieldNode)n).Field); foreach (var f in fields) { // ensure hierarchy is maintained var parent = n; while (parent != null && parent is FieldNode) { f.Insert(0, ((FieldNode)parent).Field); parent = parent.Parent; } f.Description = null; if (!Fields.Contains(f)) { Fields.Add(f); } } return(fields); } else { var path = new FieldPath(); var parent = n; while (parent != null && parent is FieldNode) { path.Insert(0, ((FieldNode)parent).Field); parent = parent.Parent; } if (!Fields.Contains(path)) { Fields.Add(path); } return(new IFieldPath[] { path }); } }
/// <summary> /// /// </summary> /// <param name="graph">an implementation of the interface GraphGenerics</param> /// <param name="pathFactory">an implementation of the interface PathFactory, if null then a default instance will be created</param> protected PathFinderBase( GraphGenerics <E, V, W> graph, PathFactory <P, E, V, W> pathFactory ) { this.graph = graph; this.pathFactory = pathFactory != null ? pathFactory : CreateStandardInstanceOfPathFactory(); // Precondition to method below is that validation is performed i.e. // the method below will NOT try to validate, edgeMapper = EdgeMapper <E, V, W> .CreateEdgeMapper <E, V, W>(graph.Edges); }
public static PathParser <P, E, V, W> CreatePathParser <P, E, V, W>( PathFactory <P, E, V, W> pathFactory, IList <E> edgesUsedForFindingTheWeightsBetweenVerticesInPath ) where P : PathGenerics <E, V, W> where E : EdgeGenerics <V, W> where V : Vertex where W : Weight { return(new PathParser <P, E, V, W>(pathFactory, edgesUsedForFindingTheWeightsBetweenVerticesInPath)); }
public void TestSplitPathNormalization() { var ret = PathFactory.GetDirectories(@"c:temp\test\"); Assert.AreNotEqual(ret, null); Assert.AreEqual(ret.Length, 3); Assert.AreEqual(ret[0], "c:\\"); Assert.AreEqual(ret[1], "temp"); Assert.AreEqual(ret[2], "test"); }
internal ConstraintSelector(ComposedGraph graph, NodeReference targetNode, IEnumerable <NodeReference> selectedNodes) { _factory = new PathFactory(targetNode, graph, false, InterpretationsFactory.MaxSearchWidth, InterpretationsFactory.MaxConstraintLength); if (!selectedNodes.Contains(targetNode)) { throw new NotSupportedException("Cannot constraint nodes without target"); } _originalRemainingNodes = new HashSet <NodeReference>(selectedNodes.Except(new[] { targetNode })); }
public void Create_FromOnePath_CreatesPath() { const string part1 = "C:\\tmp"; var factory = new PathFactory(); var expected = IsWindows ? (IPath)new WindowsPath(part1) : new PosixPath(part1); var actual = factory.Create(part1); Assert.AreEqual(expected, actual); }
public void Create_WithNormCaseOption_CreatesPathAndNormalizesCase() { const string part1 = "C:\\TmP"; var factory = new PathFactory(); var expected = (IsWindows ? (IPath) new WindowsPath(part1) : new PosixPath(part1)).NormCase(); var actual = factory.Create(part1); Assert.AreEqual(expected, actual); }
public void TestPathNormalization() { var ret = PathFactory.NormalizePath("C"); var ret1 = PathFactory.NormalizePath(string.Empty); var ret2 = PathFactory.NormalizePath(null); Assert.AreEqual(ret, ret1); Assert.AreEqual(ret1, ret2); Assert.AreEqual(ret2, null); }
public void Create_FromOnePath_CreatesPath() { const string part1 = "C:\\tmp"; var factory = new PathFactory(); var expected = IsWindows ? (IPath) new WindowsPath(part1) : new PosixPath(part1); var actual = factory.Create(part1); Assert.AreEqual(expected, actual); }
public void Create_FromMultiplePaths_CreatesPath() { const string part1 = "C:\\"; const string part2 = "tmp"; var factory = new PathFactory(); var expected = IsWindows ? (IPath) new WindowsPath(part1, part2) : new PosixPath(part1, part2); var actual = factory.Create(part1, part2); Assert.Equal(expected, actual); }
internal Node(JToken json) { if (json == null) { throw new ArgumentNullException(nameof(json)); } m_path = PathFactory.Create(json[JsonNames.Bounds]); m_visible = (bool)json[JsonNames.Visible]; m_style = (string)json[JsonNames.Style]; m_componentName = (string)json[JsonNames.ComponentName]; m_componentType = (string)json[JsonNames.ComponentType]; }
public List <Provider> GetAllProviders() { List <Provider> providers = new List <Provider>(); var pizzaDB = new Entity.PizzaDBEntities();//EntitiesRepository AppDomain.CurrentDomain.SetData("DataDirectory", PathFactory.DatabasePath()); foreach (var es in pizzaDB.Providers) { providers.Add(MapEntityToProvider(es)); } return(providers); }
public void Create_WithExpandEnvVarsOption_CreatesPathExpandsVars() { Environment.SetEnvironmentVariable("MYCUSTOMBIN", "bin"); const string expectedDir = @"C:\bin\myprogram.exe"; const string unexpandedDir = @"C:\%MYCUSTOMBIN%\myprogram.exe"; var factory = new PathFactory(); var expected = (IsWindows ? (IPath)new WindowsPath(expectedDir) : new PosixPath(expectedDir)).NormCase(); var options = new PathFactoryOptions { AutoExpandEnvironmentVariables = true }; var actual = factory.Create(unexpandedDir, options); Assert.AreEqual(expected, actual); }
public WinFilePath(PathFactory factory, PlatformPathTypes platformPathType, PathTypes pathType, string path, string[] components) : base(factory, platformPathType, pathType, path, components) { }
public void Create_WithExpandUserOption_CreatesPathAndExpandsUser() { var userDir = Environment.GetEnvironmentVariable("USERPROFILE"); var expectedDir = userDir + @"\tmp"; const string unexpandedDir = @"~\tmp"; var factory = new PathFactory(); var expected = (IsWindows ? (IPath)new WindowsPath(expectedDir) : new PosixPath(expectedDir)).NormCase(); var options = new PathFactoryOptions { AutoExpandUserDirectory = true }; var actual = factory.Create(unexpandedDir, options); Assert.AreEqual(expected, actual); }
public void Create_WithNormCaseOption_CreatesPathAndNormalizesCase() { const string part1 = "C:\\TmP"; var factory = new PathFactory(); var expected = (IsWindows ? (IPath)new WindowsPath(part1) : new PosixPath(part1)).NormCase(); var actual = factory.Create(part1); Assert.AreEqual(expected, actual); }
public void Create_WithExpandUserOptionAndExplicitUserDirectory_CreatesPathAndExpandsUser() { const string expectedDir = @"c:\users\fake\tmp"; const string unexpandedDir = @"~\tmp"; var factory = new PathFactory(); var expected = (IsWindows ? (IPath)new WindowsPath(expectedDir) : new PosixPath(expectedDir)).NormCase(); var options = new PathFactoryOptions { AutoExpandUserDirectory = true, UserDirectory = factory.Create(@"C:\users\fake") }; var actual = factory.Create(unexpandedDir, options); Assert.AreEqual(expected, actual); }