Skip to content

Commit 510e04b

Browse files
author
Wayfarer
committed
sync back weaver
1 parent 644a861 commit 510e04b

49 files changed

Lines changed: 1533 additions & 606 deletions

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

CommonLibraryTests/IoFileSearch.cs

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -167,7 +167,6 @@ public async Task GetFileInformationAsync()
167167
Assert.IsFalse(check, "File not deleted");
168168
}
169169

170-
171170
/// <summary>
172171
/// Simple Check for getting files Contained in a Folder
173172
/// Check Lock Status

CoreLibrary.sln

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -77,7 +77,12 @@ Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "CommonExtendedObjectsTests"
7777
EndProject
7878
Project("{2150E333-8FDC-42A3-9474-1A3956D46DE8}") = "Projektmappenelemente", "Projektmappenelemente", "{84D27F74-D2BA-6C25-2661-968F101900D9}"
7979
ProjectSection(SolutionItems) = preProject
80+
.gitattributes = .gitattributes
81+
.gitignore = .gitignore
8082
.github\workflows\dotnet.yml = .github\workflows\dotnet.yml
83+
License.txt = License.txt
84+
README.md = README.md
85+
Todo.txt = Todo.txt
8186
EndProjectSection
8287
EndProject
8388
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "CoreViewer", "CoreViewer\CoreViewer.csproj", "{B17F7012-EB24-4A3A-9A97-9779E5116D66}"

Lector/SampleCommand.cs

Lines changed: 0 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -92,14 +92,5 @@ public CommandResult Execute(params string[] args)
9292
var target = args[0];
9393
return new CommandResult { Message = $"[Preview] This would process '{target}'", Success = true };
9494
}
95-
96-
/// <inheritdoc />
97-
/// <summary>
98-
/// No extension handling required: all feedback handled via IFeedback.
99-
/// </summary>
100-
public CommandResult InvokeExtension(string extensionName, params string[] args)
101-
{
102-
return CommandResult.Fail($"Unknown extension '{extensionName}'.");
103-
}
10495
}
10596
}

Lector/SampleExtension.cs

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -34,8 +34,7 @@ public sealed class SampleExtension : ICommandExtension
3434
/// <summary>
3535
/// Wraps the execution of the command. Can run before/after logic or inject feedback.
3636
/// </summary>
37-
public CommandResult Invoke(ICommand command, string[] extensionArgs, Func<string[], CommandResult> executor,
38-
string[] commandArgs)
37+
public CommandResult Invoke(ICommand command, string[] extensionArgs, Func<string[], CommandResult> executor, string[] commandArgs)
3938
{
4039
// Before hook
4140
BeforeExecute(command, commandArgs);

Todo.txt

Lines changed: 1 addition & 19 deletions
Original file line numberDiff line numberDiff line change
@@ -9,12 +9,6 @@ CommonControls
99
- Improve ImageZoom, especial zooming and start Position of scrollbars on screen and positioning, overwork generation of the circle
1010
- rework color picker
1111

12-
Lightvector
13-
- Add save function for curves, etc
14-
- finish and add more features
15-
16-
Make a separate Interpreter Project with Mathmatics as an example
17-
1812
Enum at RunTime
1913

2014
https://stackoverflow.com/questions/857414/dynamically-create-an-enum
@@ -42,16 +36,4 @@ eb.DefineLiteral("High", 1);
4236

4337
// Create the type and save the assembly.
4438
Type finished = eb.CreateType();
45-
ab.Save(aName.Name + ".dll");
46-
47-
48-
49-
Using:
50-
51-
System.Reflection.Assembly ass = System.Reflection.Assembly.LoadFrom("TempAssembly.dll");
52-
System.Type enumTest = ass.GetType("Elevation");
53-
string[] values = enumTest .GetEnumNames();
54-
55-
56-
TODO Debugger
57-
Add search lines with like, not like!
39+
ab.Save(aName.Name + ".dll");

Weaver/CommandSignature.cs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -15,4 +15,4 @@ namespace Weaver
1515
/// <param name="Name">The name of the command.</param>
1616
/// <param name="ParameterCount">The number of parameters the command expects.</param>
1717
public record CommandSignature(string Namespace, string Name, int ParameterCount);
18-
}
18+
}

Weaver/Core/CommandExtension.cs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -46,4 +46,4 @@ public sealed class CommandExtension
4646
/// </value>
4747
public bool IsPreview { get; init; }
4848
}
49-
}
49+
}

Weaver/Core/DeleteValueCommand.cs renamed to Weaver/Core/Commands/DeleteValueCommand.cs

Lines changed: 2 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
/*
22
* COPYRIGHT: See COPYING in the top level directory
3-
* PROJECT: Weaver.Core
3+
* PROJECT: Weaver.Core.Commands
44
* FILE: DeleteValueCommand.cs
55
* PURPOSE: Deletes a stored value from the Scripter Engine.
66
* PROGRAMMER: Peter Geinitz (Wayfarer)
@@ -61,9 +61,5 @@ public CommandResult Execute(params string[] args)
6161
? CommandResult.Ok($"Deleted variable '{key}'.")
6262
: CommandResult.Fail($"Variable '{key}' not found.");
6363
}
64-
65-
/// <inheritdoc />
66-
public CommandResult InvokeExtension(string extensionName, params string[] args)
67-
=> CommandResult.Fail("'deleteValue' has no extensions.");
6864
}
69-
}
65+
}
Lines changed: 23 additions & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
/*
22
* COPYRIGHT: See COPYING in the top level directory
3-
* PROJECT: Weaver.Core
3+
* PROJECT: Weaver.Core.Commands
44
* FILE: EvaluateCommand.cs
55
* PURPOSE: Does double duty as internal command and extension to evaluate expressions. It can be either used as calculator or expression evaluator.
66
* PROGRAMMER: Peter Geinitz (Wayfarer)
@@ -10,12 +10,12 @@
1010
using Weaver.Interfaces;
1111
using Weaver.Messages;
1212

13-
namespace Weaver.Core
13+
namespace Weaver.Core.Commands
1414
{
1515
/// <summary>
1616
/// Simple Commmand to evaluate expressions or do simple calculations.
1717
/// </summary>
18-
/// <seealso cref="Weaver.Interfaces.ICommand" />
18+
/// <seealso cref="ICommand" />
1919
internal class EvaluateCommand : ICommand
2020
{
2121
/// <inheritdoc />
@@ -64,7 +64,6 @@ public CommandResult Execute(string[] args)
6464
// If no expression, maybe store previous pipeline value or return null
6565
if (string.IsNullOrWhiteSpace(expression))
6666
{
67-
// Allow empty input if .store() will handle it
6867
return CommandResult.Ok(null);
6968
}
7069

@@ -73,30 +72,40 @@ public CommandResult Execute(string[] args)
7372
{
7473
foreach (var variable in _registry.GetAll())
7574
{
76-
if (variable.Value.Value == null)
75+
var key = variable.Key;
76+
var (valueObj, valueType) = variable.Value;
77+
78+
if (valueObj == null)
7779
continue;
7880

79-
var key = variable.Key;
80-
var val = variable.Value.Value.ToString() ?? "0";
81-
expression = expression.Replace(key, val, StringComparison.OrdinalIgnoreCase);
81+
string replacement = valueType switch
82+
{
83+
EnumTypes.Wint => Convert.ToInt64(valueObj).ToString(),
84+
EnumTypes.Wdouble => Convert.ToDouble(valueObj).ToString(CultureInfo.InvariantCulture),
85+
EnumTypes.Wbool => Convert.ToBoolean(valueObj) ? "1" : "0",
86+
EnumTypes.Wstring => valueObj.ToString() ?? "",
87+
_ => valueObj.ToString() ?? ""
88+
};
89+
90+
expression = expression.Replace(key, replacement, StringComparison.OrdinalIgnoreCase);
8291
}
8392
}
8493

8594
object? result;
8695
EnumTypes type;
8796

88-
var isBooleanExpr = _evaluator.IsBooleanExpression(expression);
97+
bool isBooleanExpr = _evaluator.IsBooleanExpression(expression);
8998

9099
try
91100
{
92101
if (isBooleanExpr)
93102
{
94-
result = _evaluator.Evaluate(expression);
103+
result = _evaluator.Evaluate(expression); // returns bool
95104
type = EnumTypes.Wbool;
96105
}
97106
else
98107
{
99-
result = _evaluator.EvaluateNumeric(expression);
108+
result = _evaluator.EvaluateNumeric(expression); // returns double
100109
type = EnumTypes.Wdouble;
101110
}
102111
}
@@ -120,6 +129,7 @@ public CommandResult Execute(string[] args)
120129
}
121130

122131
_registry.Set(targetVar, result!, type);
132+
123133
return CommandResult.Ok(
124134
$"Stored '{result}' in '{targetVar}'.",
125135
result,
@@ -128,7 +138,7 @@ public CommandResult Execute(string[] args)
128138
}
129139

130140
// Return computed result
131-
var message = type switch
141+
string message = type switch
132142
{
133143
EnumTypes.Wbool => result?.ToString() ?? "false",
134144
EnumTypes.Wdouble => Convert.ToDouble(result).ToString(CultureInfo.InvariantCulture),
@@ -138,10 +148,5 @@ public CommandResult Execute(string[] args)
138148
return CommandResult.Ok(message, result, type);
139149
}
140150

141-
/// <inheritdoc />
142-
public CommandResult InvokeExtension(string extensionName, string[] args)
143-
{
144-
return CommandResult.Fail($"'{Name}' has no extensions.");
145-
}
146151
}
147-
}
152+
}
Lines changed: 3 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
/*
22
* COPYRIGHT: See COPYING in the top level directory
3-
* PROJECT: Weaver.Core
3+
* PROJECT: Weaver.Core.Commands
44
* FILE: GetValueCommand.cs
55
* PURPOSE: Retrieves a stored value and type from the Scripter Engine.
66
* PROGRAMMER: Peter Geinitz (Wayfarer)
@@ -9,7 +9,7 @@
99
using Weaver.Interfaces;
1010
using Weaver.Messages;
1111

12-
namespace Weaver.Core
12+
namespace Weaver.Core.Commands
1313
{
1414
/// <inheritdoc />
1515
/// <summary>
@@ -75,11 +75,5 @@ public CommandResult Execute(params string[] args)
7575
type
7676
);
7777
}
78-
79-
/// <inheritdoc />
80-
public CommandResult InvokeExtension(string extensionName, params string[] args)
81-
{
82-
return CommandResult.Fail($"'{Name}' has no extensions.");
83-
}
8478
}
85-
}
79+
}

0 commit comments

Comments
 (0)