Skip to content

Commit

Permalink
code cleanup/test fixes
Browse files Browse the repository at this point in the history
code cleanup as well as fixing issues located from the unit testing for timing items.
  • Loading branch information
roger-castaldo committed Jun 15, 2023
1 parent 1a3739e commit 860ead7
Show file tree
Hide file tree
Showing 27 changed files with 522 additions and 532 deletions.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file modified BpmEngine/.vs/BPMNEngine/v17/.suo
Binary file not shown.
14 changes: 6 additions & 8 deletions BpmEngine/Attributes/AttributeRegex.cs
Original file line number Diff line number Diff line change
Expand Up @@ -9,21 +9,19 @@ namespace BPMNEngine.Attributes
[AttributeUsage(AttributeTargets.Class,AllowMultiple=true,Inherited=true)]
internal class AttributeRegex : Attribute
{
private string _name;
public string Name { get { return _name; } }
private Regex _reg;
public Regex Reg { get { return _reg; } }
public string Name { get; private set; }
public Regex Reg { get; private set; }

public AttributeRegex(string name, string regex)
{
_name = name;
_reg=new Regex(regex,RegexOptions.Compiled|RegexOptions.ECMAScript);
Name = name;
Reg=new Regex(regex,RegexOptions.Compiled|RegexOptions.ECMAScript);
}

public bool IsValid(AElement elem)
{
if (elem[_name]!=null)
return _reg.IsMatch(elem[_name]);
if (elem[Name]!=null)
return Reg.IsMatch(elem[Name]);
return true;
}
}
Expand Down
8 changes: 4 additions & 4 deletions BpmEngine/BPMNEngine.csproj
Original file line number Diff line number Diff line change
@@ -1,8 +1,8 @@
<Project Sdk="Microsoft.NET.Sdk">
<PropertyGroup>
<TargetFrameworks>net6.0;net7.0</TargetFrameworks>
<RootNamespace>BpmEngine</RootNamespace>
<PackageId>BpmEngine</PackageId>
<RootNamespace>BPMNEngine</RootNamespace>
<PackageId>BPMNEngine</PackageId>
<Version>3.0-beta1</Version>
<Authors>Roger Castaldo</Authors>
<Description>A BPMN Engine written in .net. The engine attempts to read in a bpmn notation xml document defining both the process(s) as well as the diagrams. From here you can then load/unload the state, render the diagram in its current state or animated into a gif. Using the delegates for a process, you intercept and handle task and condition checking by reading additional xml held within flow and task objects.</Description>
Expand All @@ -24,8 +24,8 @@
<DefineConstants>TRACE;DEBUG;</DefineConstants>
</PropertyGroup>
<PropertyGroup Condition="'$(Configuration)|$(TargetFramework)|$(Platform)'=='Debug|netstandard2.0|AnyCPU'">
<DocumentationFile>..\BPMEngine.Wiki\BpmEngine.xml</DocumentationFile>
<DocumentationMarkdown>..\BPMEngine.Wiki\BpmEngine.md</DocumentationMarkdown>
<DocumentationFile>..\BPMNEngine.Wiki\BPMNEngine.xml</DocumentationFile>
<DocumentationMarkdown>..\BPMNEngine.Wiki\BPMNEngine.md</DocumentationMarkdown>
</PropertyGroup>
<ItemGroup>
<None Remove="Drawing\Icons\IconParts\resources\CenterPlus.png" />
Expand Down
273 changes: 137 additions & 136 deletions BpmEngine/BusinessProcess.cs

Large diffs are not rendered by default.

2 changes: 1 addition & 1 deletion BpmEngine/Drawing/Icons/IconParts/EmbeddedResourceIcon.cs
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@ internal abstract class EmbeddedResourceIcon

public void Add(ICanvas surface,int iconSize, Color color)
{
var icon = SKImage.FromEncodedData(GetType().GetTypeInfo().Assembly.GetManifestResourceStream(string.Format("BpmEngine.Drawing.Icons.IconParts.resources.{0}", _resourceName)));
var icon = SKImage.FromEncodedData(GetType().GetTypeInfo().Assembly.GetManifestResourceStream(string.Format("BPMNEngine.Drawing.Icons.IconParts.resources.{0}", _resourceName)));
var bmp = SKBitmap.FromImage(icon);
var image = Diagram.ProduceImage(icon.Width,icon.Height);
for(int x = 0; x<bmp.Width; x++)
Expand Down
24 changes: 6 additions & 18 deletions BpmEngine/Elements/AElement.cs
Original file line number Diff line number Diff line change
Expand Up @@ -34,22 +34,10 @@ public Definition Definition
public string id
{
get {
string ret = null; ;
if (_cachedID == null)
{
ret = this["id"];
if (ret == null)
{
if (_cachedID == null)
_cachedID = Utility.FindXPath(Definition,_element);
ret = _cachedID;
}
else
_cachedID = ret;
}
else
ret = _cachedID;
return ret;
var ret = _cachedID??this["id"];
if (ret==null)
_cachedID = Utility.FindXPath(Definition, _element);
return ret??_cachedID;
}
}

Expand Down Expand Up @@ -81,8 +69,8 @@ public AElement(XmlElement elem,XmlPrefixMap map,AElement parent)
public sealed override string ToString()
{
if (this.GetType().Name == "TextAnnotation")
return (string)this.GetType().GetProperty("Content").GetValue(this, new object[] { });
return (this["name"]==null ? "" : this["name"]);
return (string)this.GetType().GetProperty("Content").GetValue(this, Array.Empty<object>());
return this["name"]??String.Empty;
}

public virtual bool IsValid(out string[] err)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@ namespace BPMNEngine.Elements.Processes.Events.Definitions.TimerDefinition
[ValidParent(typeof(ExtensionElements))]
internal class XDateString : AElement
{
protected string _Code => this["Code"] ??
protected string Code => this["Code"] ??
SubNodes.Where(n=>n.NodeType==XmlNodeType.Text).Select(n=>n.Value).FirstOrDefault() ??
SubNodes.Where(n=>n.NodeType==XmlNodeType.CDATA).Select(n=>((XmlCDataSection)n).Value).FirstOrDefault() ??
String.Empty;
Expand All @@ -24,7 +24,7 @@ public XDateString(XmlElement elem, XmlPrefixMap map, AElement parent) : base(el

public override bool IsValid(out string[] err)
{
if (String.IsNullOrEmpty(_Code))
if (String.IsNullOrEmpty(Code))
{
err = new string[] { "No Date String Specified" };
return false;
Expand All @@ -34,9 +34,9 @@ public override bool IsValid(out string[] err)

public DateTime GetTime(IReadonlyVariables variables)
{
if (String.IsNullOrEmpty(_Code))
if (String.IsNullOrEmpty(Code))
throw new Exception("Invalid Date String Specified");
var ds = new DateString(_Code);
var ds = new DateString(Code);
return ds.GetTime(variables);
}
}
Expand Down
2 changes: 1 addition & 1 deletion BpmEngine/Elements/Processes/Events/StartEvent.cs
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,7 @@ internal bool IsEventStartValid(IReadonlyVariables variables, IsEventStartValid

public override bool IsValid(out string[] err)
{
if (Incoming.Any() && !SubType.HasValue)
if (Incoming.Any(id=> !Definition.MessageFlows.Any(mf=>mf.id==id)) && !SubType.HasValue)
{
err = new string[] { "Start Events cannot have an incoming path." };
return false;
Expand Down
2 changes: 1 addition & 1 deletion BpmEngine/Elements/Processes/Scripts/ACompiledScript.cs
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,7 @@ internal abstract class ACompiledScript : AScript
protected string _FunctionName { get { return _functionName; } }

private IEnumerable<string> _Imports
=> new string[] { "System", "BpmEngine", "BpmEngine.Interfaces", "System.Linq" }
=> new string[] { "System", "BPMNEngine", "BPMNEngine.Interfaces", "System.Linq" }
.Concat(SubNodes
.Where(n => n.NodeType==XmlNodeType.Element && n.Name.ToLower()=="using")
.Select(n => n.InnerText)
Expand Down
2 changes: 1 addition & 1 deletion BpmEngine/Elements/Processes/Scripts/Javascript.cs
Original file line number Diff line number Diff line change
Expand Up @@ -33,7 +33,7 @@ static Javascript()
{
try
{
_jintAssembly = Assembly.LoadFile(typeof(Javascript).Assembly.Location.Replace("BpmEngine.dll", "Jint.dll"));
_jintAssembly = Assembly.LoadFile(typeof(Javascript).Assembly.Location.Replace("BPMNEngine.dll", "Jint.dll"));
}
catch (Exception)
{
Expand Down

0 comments on commit 860ead7

Please sign in to comment.