Skip to content

Commit c72fe2f

Browse files
committed
Add project files.
1 parent 739c3b0 commit c72fe2f

29 files changed

Lines changed: 7832 additions & 0 deletions

AI_AgentModel.vb

Lines changed: 127 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,127 @@
1+
Imports System.Runtime.Remoting.Messaging
2+
Imports AI_Contracts
3+
Public Class AI_AgentModel
4+
Private PreviousResponses As List(Of String)
5+
Private PreviousUserInputs As List(Of String)
6+
Public PreviousResponse As String
7+
Public PreviousUserInput As String
8+
Public UserInput As String
9+
Public Response As String
10+
Private PLUGIN_FOLDER As String = Application.StartupPath & "\Plugins"
11+
12+
13+
14+
'Responses Are Genearated Externally
15+
#Region "Responses"
16+
''' <summary>
17+
''' Responses will be generated from External Compiled Plugins
18+
''' </summary>
19+
''' <param name="UserInput"></param>
20+
''' <returns></returns>
21+
Public Function GET_RESPONSE(ByRef UserInput As String) As String
22+
GET_RESPONSE = GetPluginResponse(UserInput, PreviousUserInput, PreviousResponse)
23+
End Function
24+
Private Function GetPluginResponse(ByRef UserInput As String, ByRef PrevUSerInput As String, ByRef PrevResponse As String) As String
25+
GetPluginResponse = ExecutePlugins(UserInput, ScanPlugins)
26+
End Function
27+
#End Region
28+
29+
Public Sub New(ByRef Path As String)
30+
PLUGIN_FOLDER = Path
31+
End Sub
32+
Public Sub New()
33+
34+
End Sub
35+
#Region "Plugins"
36+
37+
38+
''' <summary>
39+
''' Scans and Loads Plugins
40+
''' </summary>
41+
Private Function ScanPlugins() As ICollection(Of IPlugin)
42+
Return GET_PLUGINS(PLUGIN_FOLDER)
43+
End Function
44+
''' <summary>
45+
''' Resets the plugin folder and reloads plugins found
46+
''' </summary>
47+
''' <param name="Path"></param>
48+
Public Sub SET_PLUGIN_FOLDER(ByRef Path As String)
49+
PLUGIN_FOLDER = Path
50+
ScanPlugins()
51+
End Sub
52+
''' <summary>
53+
''' This populates the Plugins Responses Variable with all the responses and Plugins names
54+
''' </summary>
55+
''' <param name="_userInput"></param>
56+
''' <remarks></remarks>
57+
Private Function ExecutePlugins(ByVal _userInput As String, ByRef Plugins As ICollection(Of IPlugin)) As String
58+
Dim responded = False
59+
60+
61+
Dim Str As String = ""
62+
63+
'Plugins
64+
If Plugins IsNot Nothing Then
65+
For Each NewPlugin In Plugins
66+
If IsNotTest(NewPlugin.Response) = True Then
67+
If NewPlugin.Response <> "" Or NewPlugin.Response <> " " Then
68+
Str = LCase(RTrim(LTrim(Str)) & NewPlugin.Response)
69+
End If
70+
Else
71+
End If
72+
Next
73+
End If
74+
75+
Return Str
76+
End Function
77+
Private Function IsNotTest(ByVal _Response As String) As Boolean
78+
If LCase(_Response).Contains(LCase("plugintest")) = False Then
79+
Return True
80+
Else
81+
Return False
82+
End If
83+
End Function
84+
''' <summary>
85+
''' Loads the plugins into the class
86+
''' </summary>
87+
''' <param name="path">Pathname directory which contains files of type</param>
88+
''' <returns></returns>
89+
''' <remarks></remarks>
90+
Private Function GET_PLUGINS(path As String) As ICollection(Of IPlugin)
91+
On Error Resume Next
92+
Dim dllFileNames As String()
93+
If IO.Directory.Exists(path) Then
94+
dllFileNames = IO.Directory.GetFiles(path, "*.dll")
95+
Dim assemblies As ICollection(Of Reflection.Assembly) = New List(Of Reflection.Assembly)(dllFileNames.Length)
96+
For Each dllFile As String In dllFileNames
97+
Dim an As Reflection.AssemblyName = Reflection.AssemblyName.GetAssemblyName(dllFile)
98+
Dim assembly As Reflection.Assembly = Reflection.Assembly.Load(an)
99+
assemblies.Add(assembly)
100+
Next
101+
Dim pluginType As Type = GetType(IPlugin)
102+
Dim pluginTypes As ICollection(Of Type) = New List(Of Type)
103+
For Each assembly As Reflection.Assembly In assemblies
104+
If assembly <> Nothing Then
105+
Dim types As Type() = assembly.GetTypes()
106+
For Each type As Type In types
107+
If type.IsInterface Or type.IsAbstract Then
108+
Continue For
109+
Else
110+
If type.GetInterface(pluginType.FullName) <> Nothing Then
111+
pluginTypes.Add(type)
112+
End If
113+
End If
114+
Next
115+
End If
116+
Next
117+
Dim plugins As ICollection(Of IPlugin) = New List(Of IPlugin)(pluginTypes.Count)
118+
For Each type As Type In pluginTypes
119+
Dim plugin As IPlugin = Activator.CreateInstance(type)
120+
plugins.Add(plugin)
121+
Next
122+
Return plugins
123+
End If
124+
Return Nothing
125+
End Function
126+
#End Region
127+
End Class

AI_Contracts/AI_Contracts.vbproj

Lines changed: 121 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,121 @@
1+
<?xml version="1.0" encoding="utf-8"?>
2+
<Project ToolsVersion="15.0" xmlns="http://schemas.microsoft.com/developer/msbuild/2003">
3+
<Import Project="$(MSBuildExtensionsPath)\$(MSBuildToolsVersion)\Microsoft.Common.props" Condition="Exists('$(MSBuildExtensionsPath)\$(MSBuildToolsVersion)\Microsoft.Common.props')" />
4+
<PropertyGroup>
5+
<Configuration Condition=" '$(Configuration)' == '' ">Debug</Configuration>
6+
<Platform Condition=" '$(Platform)' == '' ">AnyCPU</Platform>
7+
<ProjectGuid>{FFD99FAF-EAE8-41AA-BEAA-66CEDF5C5951}</ProjectGuid>
8+
<OutputType>Library</OutputType>
9+
<StartupObject>
10+
</StartupObject>
11+
<RootNamespace>AI_Contracts</RootNamespace>
12+
<AssemblyName>AI_Contracts</AssemblyName>
13+
<FileAlignment>512</FileAlignment>
14+
<MyType>Windows</MyType>
15+
<TargetFrameworkVersion>v4.7.2</TargetFrameworkVersion>
16+
<AutoGenerateBindingRedirects>true</AutoGenerateBindingRedirects>
17+
<Deterministic>true</Deterministic>
18+
</PropertyGroup>
19+
<PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'Debug|AnyCPU' ">
20+
<PlatformTarget>AnyCPU</PlatformTarget>
21+
<DebugSymbols>true</DebugSymbols>
22+
<DebugType>full</DebugType>
23+
<DefineDebug>true</DefineDebug>
24+
<DefineTrace>true</DefineTrace>
25+
<OutputPath>bin\Debug\</OutputPath>
26+
<DocumentationFile>AI_Contracts.xml</DocumentationFile>
27+
<NoWarn>42016,41999,42017,42018,42019,42032,42036,42020,42021,42022</NoWarn>
28+
</PropertyGroup>
29+
<PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'Release|AnyCPU' ">
30+
<PlatformTarget>AnyCPU</PlatformTarget>
31+
<DebugType>pdbonly</DebugType>
32+
<DefineDebug>false</DefineDebug>
33+
<DefineTrace>true</DefineTrace>
34+
<Optimize>true</Optimize>
35+
<OutputPath>bin\Release\</OutputPath>
36+
<DocumentationFile>AI_Contracts.xml</DocumentationFile>
37+
<NoWarn>42016,41999,42017,42018,42019,42032,42036,42020,42021,42022</NoWarn>
38+
</PropertyGroup>
39+
<PropertyGroup>
40+
<OptionExplicit>On</OptionExplicit>
41+
</PropertyGroup>
42+
<PropertyGroup>
43+
<OptionCompare>Binary</OptionCompare>
44+
</PropertyGroup>
45+
<PropertyGroup>
46+
<OptionStrict>Off</OptionStrict>
47+
</PropertyGroup>
48+
<PropertyGroup>
49+
<OptionInfer>On</OptionInfer>
50+
</PropertyGroup>
51+
<ItemGroup>
52+
<Reference Include="System" />
53+
<Reference Include="System.Data" />
54+
<Reference Include="System.Deployment" />
55+
<Reference Include="System.Drawing" />
56+
<Reference Include="System.Web.Extensions" />
57+
<Reference Include="System.Windows.Forms" />
58+
<Reference Include="System.Xml" />
59+
<Reference Include="System.Core" />
60+
<Reference Include="System.Xml.Linq" />
61+
<Reference Include="System.Data.DataSetExtensions" />
62+
<Reference Include="System.Net.Http" />
63+
</ItemGroup>
64+
<ItemGroup>
65+
<Import Include="Microsoft.VisualBasic" />
66+
<Import Include="System" />
67+
<Import Include="System.Collections" />
68+
<Import Include="System.Collections.Generic" />
69+
<Import Include="System.Data" />
70+
<Import Include="System.Drawing" />
71+
<Import Include="System.Diagnostics" />
72+
<Import Include="System.Windows.Forms" />
73+
<Import Include="System.Linq" />
74+
<Import Include="System.Xml.Linq" />
75+
<Import Include="System.Threading.Tasks" />
76+
</ItemGroup>
77+
<ItemGroup>
78+
<Compile Include="Extensions\Extensions_Files.vb" />
79+
<Compile Include="Extensions\Extensions_Maths.vb" />
80+
<Compile Include="Extensions\Extensions_String.vb" />
81+
<Compile Include="Extensions\Extensions_TabControl.vb" />
82+
<Compile Include="Iplugin.vb" />
83+
<Compile Include="My Project\AssemblyInfo.vb" />
84+
<Compile Include="My Project\Application.Designer.vb">
85+
<AutoGen>True</AutoGen>
86+
<DependentUpon>Application.myapp</DependentUpon>
87+
<DesignTime>True</DesignTime>
88+
</Compile>
89+
<Compile Include="My Project\Resources.Designer.vb">
90+
<AutoGen>True</AutoGen>
91+
<DesignTime>True</DesignTime>
92+
<DependentUpon>Resources.resx</DependentUpon>
93+
</Compile>
94+
<Compile Include="My Project\Settings.Designer.vb">
95+
<AutoGen>True</AutoGen>
96+
<DependentUpon>Settings.settings</DependentUpon>
97+
<DesignTimeSharedInput>True</DesignTimeSharedInput>
98+
</Compile>
99+
</ItemGroup>
100+
<ItemGroup>
101+
<EmbeddedResource Include="My Project\Resources.resx">
102+
<Generator>VbMyResourcesResXFileCodeGenerator</Generator>
103+
<LastGenOutput>Resources.Designer.vb</LastGenOutput>
104+
<CustomToolNamespace>My.Resources</CustomToolNamespace>
105+
<SubType>Designer</SubType>
106+
</EmbeddedResource>
107+
</ItemGroup>
108+
<ItemGroup>
109+
<None Include="My Project\Application.myapp">
110+
<Generator>MyApplicationCodeGenerator</Generator>
111+
<LastGenOutput>Application.Designer.vb</LastGenOutput>
112+
</None>
113+
<None Include="My Project\Settings.settings">
114+
<Generator>SettingsSingleFileGenerator</Generator>
115+
<CustomToolNamespace>My</CustomToolNamespace>
116+
<LastGenOutput>Settings.Designer.vb</LastGenOutput>
117+
</None>
118+
<None Include="App.config" />
119+
</ItemGroup>
120+
<Import Project="$(MSBuildToolsPath)\Microsoft.VisualBasic.targets" />
121+
</Project>

AI_Contracts/App.config

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,6 @@
1+
<?xml version="1.0" encoding="utf-8" ?>
2+
<configuration>
3+
<startup>
4+
<supportedRuntime version="v4.0" sku=".NETFramework,Version=v4.7.2" />
5+
</startup>
6+
</configuration>

0 commit comments

Comments
 (0)