// Returns the resulting source for this SourceItem.
// If Path is filled in, and file exists, takes source from there.
// Else returns Code value.
public string GetSource(string pathResolveRoot)
{
if (!string.IsNullOrEmpty(Path))
{
if (Path.StartsWith("packed:"))
{
string resourceName = Path.Substring(7);
byte[] sourceBytes = ExcelIntegration.GetSourceBytes(resourceName);
return(Encoding.UTF8.GetString(sourceBytes));
}
else
{
// Try to read from a file.
string resolvedPath = DnaLibrary.ResolvePath(Path, pathResolveRoot);
if (resolvedPath == null)
{
Debug.Print("Source path {0} could not be resolved.", Path);
}
else
{
return(File.ReadAllText(resolvedPath).Trim());
}
}
}
return(Code);
}