-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #3 from nhsconnect/develop
Improvements to the manual file import
- Loading branch information
Showing
6 changed files
with
47 additions
and
7 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,21 @@ | ||
using System; | ||
using System.Linq; | ||
|
||
namespace gpconnect_analytics.Helpers | ||
{ | ||
public static class AttributeExtensions | ||
{ | ||
public static FileTypes? GetFileType<FilePath>(this string filePath) | ||
{ | ||
return GetValueFromPath<FilePath>(filePath); | ||
} | ||
|
||
public static FileTypes? GetValueFromPath<FilePath>(string filePath) | ||
{ | ||
var fileType = typeof(FilePath).GetFields() | ||
.Where(x => Attribute.GetCustomAttribute(x, typeof(FilePathAttribute)) is FilePathAttribute filePathAttribute && filePath.Contains(filePathAttribute?.FilePath)) | ||
.FirstOrDefault(); | ||
return fileType != null ? (FileTypes)fileType.GetValue(filePath) : (FileTypes?)null; | ||
} | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,14 @@ | ||
using System; | ||
|
||
namespace gpconnect_analytics.Helpers | ||
{ | ||
public class FilePathAttribute : Attribute | ||
{ | ||
public string FilePath { get; protected set; } = ""; | ||
|
||
public FilePathAttribute(string value) | ||
{ | ||
FilePath = value; | ||
} | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters