-
Notifications
You must be signed in to change notification settings - Fork 0
/
PlaceHolderResolver.vb
28 lines (20 loc) · 1.02 KB
/
PlaceHolderResolver.vb
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
Imports DbToGo.Data
Imports DbToGo.MetaData
Imports System.Text
Imports System.IO
Public Class MainPlaceHolderResolver
Public Delegate Function PlaceHolderResolvingFunction(source As String, errorText As StringBuilder) As String
Public Shared Function Resolve(source As String, errorText As StringBuilder) As String
Dim fileName = State.ActiveThumbnail.FileName
Dim fileNameWithoutExt = State.ActiveThumbnail.FileNameWithoutExt
Dim linkedUrl As String = Database.PictureEntries(fileNameWithoutExt).LinkedFileInfo.FullPath
If (source.Contains("{LinkedFile}") AndAlso linkedUrl IsNot Nothing) Then
linkedUrl = FileSystem.Extensions.ResolveDriveAlias(linkedUrl, errorText)
End If
source = source.Replace("{LinkedFile}", linkedUrl)
source = source.Replace("{FileNameWithoutExtension}", Path.GetFileNameWithoutExtension(State.ActiveThumbnail.SourceFile))
source = source.Replace("{FileName}", fileName)
source = source.Replace("{File}", State.ActiveThumbnail.SourceFile)
Return source
End Function
End Class