shite
This commit is contained in:
@@ -5,11 +5,12 @@ using System.Text;
|
||||
|
||||
namespace Core
|
||||
{
|
||||
enum ComponentType
|
||||
public enum ComponentType
|
||||
{
|
||||
EQ_ADD,
|
||||
EQ_SUB,
|
||||
EQ_DIV,
|
||||
EQ_MUL
|
||||
EQ_MUL,
|
||||
QZ_VAR
|
||||
}
|
||||
}
|
||||
|
||||
+10
-4
@@ -1,17 +1,18 @@
|
||||
<?xml version="1.0" encoding="utf-8"?>
|
||||
<Project ToolsVersion="4.0" DefaultTargets="Build" xmlns="http://schemas.microsoft.com/developer/msbuild/2003">
|
||||
<Project ToolsVersion="12.0" DefaultTargets="Build" xmlns="http://schemas.microsoft.com/developer/msbuild/2003">
|
||||
<PropertyGroup>
|
||||
<Configuration Condition=" '$(Configuration)' == '' ">Debug</Configuration>
|
||||
<Platform Condition=" '$(Platform)' == '' ">AnyCPU</Platform>
|
||||
<ProductVersion>8.0.30703</ProductVersion>
|
||||
<SchemaVersion>2.0</SchemaVersion>
|
||||
<ProjectGuid>b198255b-c87f-4484-9511-56c8143cad52</ProjectGuid>
|
||||
<ProjectGuid>{B198255B-C87F-4484-9511-56C8143CAD52}</ProjectGuid>
|
||||
<OutputType>Library</OutputType>
|
||||
<AppDesignerFolder>Properties</AppDesignerFolder>
|
||||
<RootNamespace>Core</RootNamespace>
|
||||
<AssemblyName>Core</AssemblyName>
|
||||
<TargetFrameworkVersion>v4.0</TargetFrameworkVersion>
|
||||
<TargetFrameworkVersion>v4.8</TargetFrameworkVersion>
|
||||
<FileAlignment>512</FileAlignment>
|
||||
<TargetFrameworkProfile />
|
||||
</PropertyGroup>
|
||||
<PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'Debug|AnyCPU' ">
|
||||
<DebugSymbols>true</DebugSymbols>
|
||||
@@ -21,6 +22,7 @@
|
||||
<DefineConstants>DEBUG;TRACE</DefineConstants>
|
||||
<ErrorReport>prompt</ErrorReport>
|
||||
<WarningLevel>4</WarningLevel>
|
||||
<Prefer32Bit>false</Prefer32Bit>
|
||||
</PropertyGroup>
|
||||
<PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'Release|AnyCPU' ">
|
||||
<DebugType>pdbonly</DebugType>
|
||||
@@ -29,6 +31,7 @@
|
||||
<DefineConstants>TRACE</DefineConstants>
|
||||
<ErrorReport>prompt</ErrorReport>
|
||||
<WarningLevel>4</WarningLevel>
|
||||
<Prefer32Bit>false</Prefer32Bit>
|
||||
</PropertyGroup>
|
||||
<ItemGroup>
|
||||
<Reference Include="System" />
|
||||
@@ -40,8 +43,11 @@
|
||||
<Reference Include="System.Xml" />
|
||||
</ItemGroup>
|
||||
<ItemGroup>
|
||||
<Compile Include="Class1.cs" />
|
||||
<Compile Include="ComponentType.cs" />
|
||||
<Compile Include="IEquationComponent.cs" />
|
||||
<Compile Include="Operations.cs" />
|
||||
<Compile Include="Properties\AssemblyInfo.cs" />
|
||||
<Compile Include="Registrate.cs" />
|
||||
</ItemGroup>
|
||||
<Import Project="$(MSBuildToolsPath)\Microsoft.CSharp.targets" />
|
||||
<!-- To modify your build process, add your task inside one of the targets below and uncomment it.
|
||||
|
||||
@@ -7,9 +7,9 @@ namespace Core
|
||||
{
|
||||
interface IEquationComponent
|
||||
{
|
||||
public ComponentType Type { get; set; }
|
||||
public string Arg1 { get; set; }
|
||||
public string Arg2 { get; set; }
|
||||
public void Operate();
|
||||
ComponentType Type { get; set; }
|
||||
string Arg1 { get; set; }
|
||||
string Arg2 { get; set; }
|
||||
void Operate();
|
||||
}
|
||||
}
|
||||
|
||||
+88
-3
@@ -7,9 +7,94 @@ namespace Core
|
||||
{
|
||||
public class Operations
|
||||
{
|
||||
public void EquParserLoop(string equ, out float output) {
|
||||
if (equ != "") { output = 0.0f; }
|
||||
else { output = 0.0f; }
|
||||
public Dictionary<string, float> Variables = new Dictionary<string, float>();
|
||||
|
||||
private float ResolveValue(string value)
|
||||
{
|
||||
// Checks if the value contains any letters
|
||||
if (!value.Any(char.IsLetter))
|
||||
{
|
||||
float.TryParse(value, out float result);
|
||||
return result;
|
||||
}
|
||||
else
|
||||
{
|
||||
Variables.TryGetValue(value, out float result);
|
||||
return result;
|
||||
}
|
||||
}
|
||||
public float ExecuteCommand(ComponentType type, string val1, string val2)
|
||||
{
|
||||
switch (type)
|
||||
{
|
||||
default: return 2;
|
||||
case ComponentType.EQ_ADD:
|
||||
float a = ResolveValue(val1);
|
||||
float b = ResolveValue(val2);
|
||||
return a + b;
|
||||
case ComponentType.EQ_SUB:
|
||||
float aS = ResolveValue(val1);
|
||||
float bS = ResolveValue(val2);
|
||||
return aS - bS;
|
||||
case ComponentType.EQ_MUL:
|
||||
float aM = ResolveValue(val1);
|
||||
float bM = ResolveValue(val2);
|
||||
return aM * bM;
|
||||
case ComponentType.EQ_DIV:
|
||||
float aD = ResolveValue(val1);
|
||||
float bD = ResolveValue(val2);
|
||||
return aD / bD;
|
||||
|
||||
case ComponentType.QZ_VAR:
|
||||
float val = 0.0f;
|
||||
float.TryParse(val2, out val);
|
||||
if (Variables.ContainsKey(val1))
|
||||
{
|
||||
Variables[val1] = val;
|
||||
}
|
||||
else
|
||||
{
|
||||
Variables.Add(val1, val);
|
||||
}
|
||||
return val;
|
||||
|
||||
}
|
||||
}
|
||||
public float EquParserLoop(string equ)
|
||||
{
|
||||
if (equ != "")
|
||||
{
|
||||
string[] tokens = equ.Split(new char[] { ' ', ',' }, StringSplitOptions.RemoveEmptyEntries);
|
||||
if (tokens.Length >= 3)
|
||||
{
|
||||
string command = tokens[0]; // "ADD" or "VAR"
|
||||
string val1 = tokens[1]; // "X"
|
||||
string val2 = tokens[2]; // "0" or "10"
|
||||
|
||||
switch (command)
|
||||
{
|
||||
default: return 0;
|
||||
case "ADD":
|
||||
Console.WriteLine("[CommandParser] Executed command ADD");
|
||||
return ExecuteCommand(ComponentType.EQ_ADD, val1, val2);
|
||||
case "SUB":
|
||||
Console.WriteLine("[CommandParser] Executed command ADD");
|
||||
return ExecuteCommand(ComponentType.EQ_SUB, val1, val2);
|
||||
case "MUL":
|
||||
Console.WriteLine("[CommandParser] Executed command ADD");
|
||||
return ExecuteCommand(ComponentType.EQ_MUL, val1, val2);
|
||||
case "DIV":
|
||||
Console.WriteLine("[CommandParser] Executed command ADD");
|
||||
return ExecuteCommand(ComponentType.EQ_DIV, val1, val2);
|
||||
case "VAR":
|
||||
Console.WriteLine("[CommandParser] Executed command ADD");
|
||||
return ExecuteCommand(ComponentType.QZ_VAR, val1, val2);
|
||||
}
|
||||
}
|
||||
else { return 0; }
|
||||
}
|
||||
|
||||
else { return 0; }
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
+1
-1
@@ -5,7 +5,7 @@ using System.Text;
|
||||
|
||||
namespace Core
|
||||
{
|
||||
class Class1
|
||||
class Registrate
|
||||
{
|
||||
}
|
||||
}
|
||||
|
||||
Binary file not shown.
Binary file not shown.
@@ -0,0 +1,4 @@
|
||||
// <autogenerated />
|
||||
using System;
|
||||
using System.Reflection;
|
||||
[assembly: global::System.Runtime.Versioning.TargetFrameworkAttribute(".NETFramework,Version=v4.0", FrameworkDisplayName = ".NET Framework 4")]
|
||||
@@ -0,0 +1,4 @@
|
||||
// <autogenerated />
|
||||
using System;
|
||||
using System.Reflection;
|
||||
[assembly: global::System.Runtime.Versioning.TargetFrameworkAttribute(".NETFramework,Version=v4.8", FrameworkDisplayName = ".NET Framework 4.8")]
|
||||
Binary file not shown.
@@ -0,0 +1 @@
|
||||
3e45e6502454303d51fd05c670a9d135872dffc387ca9c06751f794b9bdd86b7
|
||||
@@ -0,0 +1,6 @@
|
||||
C:\Users\Administrator\MathApp\Core\bin\Debug\Core.dll
|
||||
C:\Users\Administrator\MathApp\Core\bin\Debug\Core.pdb
|
||||
C:\Users\Administrator\MathApp\Core\obj\Debug\Core.csproj.AssemblyReference.cache
|
||||
C:\Users\Administrator\MathApp\Core\obj\Debug\Core.csproj.CoreCompileInputs.cache
|
||||
C:\Users\Administrator\MathApp\Core\obj\Debug\Core.dll
|
||||
C:\Users\Administrator\MathApp\Core\obj\Debug\Core.pdb
|
||||
Binary file not shown.
Binary file not shown.
Binary file not shown.
Reference in New Issue
Block a user