Patterns: Add Custom module
This commit is contained in:
parent
2a53d24a91
commit
b4528788e3
37
Patterns/Modules/Custom.vb
Normal file
37
Patterns/Modules/Custom.vb
Normal file
@ -0,0 +1,37 @@
|
|||||||
|
Imports DigitalData.Modules.Logging
|
||||||
|
|
||||||
|
Namespace Modules
|
||||||
|
''' <summary>
|
||||||
|
''' Custom Patterns that are defined at runtime
|
||||||
|
''' </summary>
|
||||||
|
Public Class Custom
|
||||||
|
Inherits BaseModule
|
||||||
|
Implements IModule
|
||||||
|
|
||||||
|
Public Property PatternIdentifier As String = "CUST" Implements IModule.PatternIdentifier
|
||||||
|
Public Property IsComplex As Boolean = False Implements IModule.IsComplex
|
||||||
|
|
||||||
|
Public Sub New(pLogConfig As LogConfig)
|
||||||
|
MyBase.New(pLogConfig)
|
||||||
|
End Sub
|
||||||
|
|
||||||
|
Public Function Replace(pInput As String, pCustomValues As Dictionary(Of String, String)) As String
|
||||||
|
Dim oResult = pInput
|
||||||
|
Dim oCounter = 0
|
||||||
|
Dim oNow As Date = Now
|
||||||
|
|
||||||
|
Logger.Trace("Replacing Custom Patterns")
|
||||||
|
|
||||||
|
While HasPattern(oResult, PatternIdentifier)
|
||||||
|
For Each oCustomValue In pCustomValues
|
||||||
|
If ContainsPatternAndValue(oResult, PatternIdentifier, oCustomValue.Key) Then
|
||||||
|
oResult = ReplacePattern(oResult, PatternIdentifier, oCustomValue.Value)
|
||||||
|
End If
|
||||||
|
Next
|
||||||
|
IncrementCounterOrThrow(oCounter)
|
||||||
|
End While
|
||||||
|
|
||||||
|
Return oResult
|
||||||
|
End Function
|
||||||
|
End Class
|
||||||
|
End Namespace
|
||||||
@ -91,6 +91,7 @@
|
|||||||
<Compile Include="Modules\Globix\GlobixAutomatic.vb" />
|
<Compile Include="Modules\Globix\GlobixAutomatic.vb" />
|
||||||
<Compile Include="Modules\IDB.vb" />
|
<Compile Include="Modules\IDB.vb" />
|
||||||
<Compile Include="Modules\Globix\GlobixManual.vb" />
|
<Compile Include="Modules\Globix\GlobixManual.vb" />
|
||||||
|
<Compile Include="Modules\Custom.vb" />
|
||||||
<Compile Include="Modules\Windream.vb" />
|
<Compile Include="Modules\Windream.vb" />
|
||||||
<Compile Include="Modules\User.vb" />
|
<Compile Include="Modules\User.vb" />
|
||||||
<Compile Include="IModule.vb" />
|
<Compile Include="IModule.vb" />
|
||||||
|
|||||||
@ -139,6 +139,23 @@ Public Class Patterns2
|
|||||||
End Try
|
End Try
|
||||||
End Function
|
End Function
|
||||||
|
|
||||||
|
Public Function ReplaceCustomValues(pInput As String, pCustomValues As Dictionary(Of String, String)) As String
|
||||||
|
Logger.Debug("Replacing Custom Values")
|
||||||
|
|
||||||
|
Dim oResult = pInput
|
||||||
|
|
||||||
|
Try
|
||||||
|
Dim oCustom = New Modules.Custom(LogConfig)
|
||||||
|
oResult = oCustom.Replace(oResult, pCustomValues)
|
||||||
|
|
||||||
|
Return oResult
|
||||||
|
Catch ex As Exception
|
||||||
|
Logger.Warn("Error occurred while replacing Globix Values")
|
||||||
|
Logger.Error(ex)
|
||||||
|
Return oResult
|
||||||
|
End Try
|
||||||
|
End Function
|
||||||
|
|
||||||
#Region "Helper Functions"
|
#Region "Helper Functions"
|
||||||
''' <summary>
|
''' <summary>
|
||||||
''' Wraps a pattern-type and -value in the common format: {#type#value}
|
''' Wraps a pattern-type and -value in the common format: {#type#value}
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user