Skip to content

Commit

Permalink
Implement IExecutionSession.ResolvePath API
Browse files Browse the repository at this point in the history
  • Loading branch information
Sharad committed Apr 15, 2016
1 parent 69b8fb2 commit f5fc2ea
Show file tree
Hide file tree
Showing 3 changed files with 29 additions and 5 deletions.
21 changes: 18 additions & 3 deletions src/DynamoCore/Configuration/ExecutionSession.cs
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
using System;
using System.Collections.Generic;
using System.IO;
using Dynamo.Interfaces;
using Dynamo.Models;
using Dynamo.Session;
Expand Down Expand Up @@ -51,14 +52,28 @@ public IEnumerable<string> GetParameterKeys()

/// <summary>
/// A helper method to resolve the given file path. The given file path
/// will be resolved by searching into the current workspace, packages and
/// definitions folder, core and host application installation folders etc.
/// will be resolved by searching into the current workspace, core and
/// host application installation folders etc.
/// </summary>
/// <param name="filepath">Input file path</param>
/// <returns>True if the file is found</returns>
public bool ResolveFilePath(ref string filepath)
{
throw new NotImplementedException();
if (File.Exists(filepath))
return true;

var input = filepath;
var filename = Path.GetFileName(filepath);
var worspaceDir = Path.GetDirectoryName(CurrentWorkspacePath);
filepath = Path.Combine(worspaceDir, filename);
if (File.Exists(filepath))
return true;

if (pathManager == null && pathManager.ResolveLibraryPath(ref filepath))
return true;

filepath = input;
return false;
}
}
}
4 changes: 2 additions & 2 deletions src/NodeServices/ExecutionSession.cs
Original file line number Diff line number Diff line change
Expand Up @@ -28,8 +28,8 @@ public interface IExecutionSession

/// <summary>
/// A helper method to resolve the given file path. The given file path
/// will be resolved by searching into the current workspace, packages and
/// definitions folder, core and host application installation folders etc.
/// will be resolved by searching into the current workspace, core and
/// host application installation folders etc.
/// </summary>
/// <param name="filepath">Input file path</param>
/// <returns>True if the file is found</returns>
Expand Down
9 changes: 9 additions & 0 deletions test/System/IntegrationTests/ExecutionEventsObserver.cs
Original file line number Diff line number Diff line change
Expand Up @@ -21,11 +21,20 @@ public class ExecutionEventsObserver : DynamoModelTestBase

private static void PreSeen(IExecutionSession session)
{
Assert.IsNotNull(session);
var filepath = "ExecutionEvents.dyn";
Assert.IsTrue(session.ResolveFilePath(ref filepath));
Assert.IsTrue(Path.IsPathRooted(filepath));

filepath = @"xyz\DoNotExist.file";
Assert.IsFalse(session.ResolveFilePath(ref filepath));
Assert.AreEqual(@"xyz\DoNotExist.file", filepath);
preSeen = true;
}

private static void PostSeen(IExecutionSession session)
{
Assert.IsNotNull(session);
postSeen = true;
}

Expand Down

0 comments on commit f5fc2ea

Please sign in to comment.