@@ -11,7 +11,7 @@ Public Class AI_AgentModel
1111 Public UserInput As String
1212 Public Response As String
1313
14- Private PLUGIN_FOLDER As String = Application.StartupPath & "\Plugins"
14+
1515 Public Sentiment As New Emotional_State
1616
1717 'Responses Are Genearated Externally
@@ -51,94 +51,5 @@ Public Class AI_AgentModel
5151 Public Sub New ()
5252
5353 End Sub
54- # Region "Plugins"
55-
56-
57- ''' <summary>
58- ''' Scans and Loads Plugins
59- ''' </summary>
60- Private Function ScanPlugins() As ICollection( Of IPlugin)
61- Return GET_PLUGINS(PLUGIN_FOLDER)
62- End Function
63- ''' <summary>
64- ''' Resets the plugin folder and reloads plugins found
65- ''' </summary>
66- ''' <param name="Path"></param>
67- Public Sub SET_PLUGIN_FOLDER( ByRef Path As String )
68- PLUGIN_FOLDER = Path
69- ScanPlugins()
70- End Sub
71- ''' <summary>
72- ''' This populates the Plugins Responses Variable with all the responses and Plugins names
73- ''' </summary>
74- ''' <param name="_userInput"></param>
75- ''' <remarks></remarks>
76- Private Function ExecutePlugins( ByVal _userInput As String , ByRef Plugins As ICollection( Of IPlugin)) As String
77- Dim Str As String = ""
7854
79- 'Plugins
80- If Plugins IsNot Nothing Then
81- For Each NewPlugin In Plugins
82- NewPlugin.GetResponse(_userInput)
83- If IsNotTest(NewPlugin.Response) = True Then
84- If NewPlugin.Response <> "" Or NewPlugin.Response <> " " Then
85- Str &= LCase(RTrim(LTrim(Str)) & NewPlugin.Response)
86- End If
87- Else
88- End If
89- Next
90- End If
91-
92- Return Str
93- End Function
94- Private Function IsNotTest( ByVal _Response As String ) As Boolean
95- If LCase(_Response).Contains(LCase( "plugintest" )) = False Then
96- Return True
97- Else
98- Return False
99- End If
100- End Function
101- ''' <summary>
102- ''' Loads the plugins into the class
103- ''' </summary>
104- ''' <param name="path">Pathname directory which contains files of type</param>
105- ''' <returns></returns>
106- ''' <remarks></remarks>
107- Private Function GET_PLUGINS(path As String ) As ICollection( Of IPlugin)
108- On Error Resume Next
109- Dim dllFileNames As String ()
110- If IO.Directory.Exists(path) Then
111- dllFileNames = IO.Directory.GetFiles(path, "*.dll" )
112- Dim assemblies As ICollection( Of Reflection.Assembly) = New List( Of Reflection.Assembly)(dllFileNames.Length)
113- For Each dllFile As String In dllFileNames
114- Dim an As Reflection.AssemblyName = Reflection.AssemblyName.GetAssemblyName(dllFile)
115- Dim assembly As Reflection.Assembly = Reflection.Assembly.Load(an)
116- assemblies.Add( assembly )
117- Next
118- Dim pluginType As Type = GetType (IPlugin)
119- Dim pluginTypes As ICollection( Of Type) = New List( Of Type)
120- For Each assembly As Reflection.Assembly In assemblies
121- If assembly <> Nothing Then
122- Dim types As Type() = assembly .GetTypes()
123- For Each type As Type In types
124- If type.IsInterface Or type.IsAbstract Then
125- Continue For
126- Else
127- If type.GetInterface(pluginType.FullName) <> Nothing Then
128- pluginTypes.Add(type)
129- End If
130- End If
131- Next
132- End If
133- Next
134- Dim plugins As ICollection( Of IPlugin) = New List( Of IPlugin)(pluginTypes.Count)
135- For Each type As Type In pluginTypes
136- Dim plugin As IPlugin = Activator.CreateInstance(type)
137- plugins.Add(plugin)
138- Next
139- Return plugins
140- End If
141- Return Nothing
142- End Function
143- # End Region
14455End Class
0 commit comments