daily update on 20241002 by nitload youmu, intrinsic function rebuild, syntax style arrange
This commit is contained in:
@@ -29,7 +29,6 @@
|
||||
//-----------------------------------------------------------------------
|
||||
//-----------------------------------------------------------------------
|
||||
|
||||
|
||||
using StgSharp.Entities;
|
||||
|
||||
using System;
|
||||
@@ -44,17 +43,16 @@ using System.Threading.Tasks;
|
||||
|
||||
namespace StgSharp.BluePrint
|
||||
{
|
||||
|
||||
/// <summary>
|
||||
///
|
||||
///
|
||||
/// </summary>
|
||||
/// <risk>
|
||||
/// Reset pipeline has risk, this operation is a direct operation to port
|
||||
/// in current node, the port on the other node cannot get the change.
|
||||
/// Reset pipeline has risk, this operation is a direct operation to port in current node, the
|
||||
/// port on the other node cannot get the change.
|
||||
/// </risk>
|
||||
#pragma warning disable CA1036
|
||||
public class BlueprintNode : IComparable<BlueprintNode>
|
||||
#pragma warning restore CA1036
|
||||
#pragma warning restore CA1036
|
||||
{
|
||||
|
||||
private protected bool levelAvailable, nativeRequested;
|
||||
@@ -64,8 +62,10 @@ namespace StgSharp.BluePrint
|
||||
private IConvertableToBlueprintNode mainOperation;
|
||||
private string name;
|
||||
|
||||
internal BlueprintNode(string name,
|
||||
IConvertableToBlueprintNode node, bool isNative)
|
||||
internal BlueprintNode(
|
||||
string name,
|
||||
IConvertableToBlueprintNode node,
|
||||
bool isNative )
|
||||
{
|
||||
this.levelAvailable = false;
|
||||
this.name = name;
|
||||
@@ -73,45 +73,39 @@ namespace StgSharp.BluePrint
|
||||
mainOperation = node;
|
||||
_inputInterfaces = new Dictionary<string, BlueprintPipeline>();
|
||||
_outputInterfaces = new Dictionary<string, BlueprintPipeline>();
|
||||
foreach (string portName in node.InputInterfacesName)
|
||||
{
|
||||
_inputInterfaces.Add(portName, null!);
|
||||
foreach( string portName in node.InputInterfacesName ) {
|
||||
_inputInterfaces.Add( portName, null! );
|
||||
}
|
||||
|
||||
foreach (string portName in node.OutputInterfacesName)
|
||||
{
|
||||
_outputInterfaces.Add(portName, null!);
|
||||
foreach( string portName in node.OutputInterfacesName ) {
|
||||
_outputInterfaces.Add( portName, null! );
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
#pragma warning disable CS8618
|
||||
internal BlueprintNode(string name, bool isNative,
|
||||
#pragma warning disable CS8618
|
||||
internal BlueprintNode(
|
||||
string name,
|
||||
bool isNative,
|
||||
string[] inputPorts,
|
||||
string[] outputPorts
|
||||
)
|
||||
#pragma warning restore CS8618
|
||||
string[] outputPorts )
|
||||
#pragma warning restore CS8618
|
||||
{
|
||||
if ((inputPorts == null) || (inputPorts.Length == 0))
|
||||
{
|
||||
throw new ArgumentNullException(nameof(inputPorts));
|
||||
if( ( inputPorts == null ) || ( inputPorts.Length == 0 ) ) {
|
||||
throw new ArgumentNullException( nameof( inputPorts ) );
|
||||
}
|
||||
if ((outputPorts == null) || (outputPorts.Length == 0))
|
||||
{
|
||||
throw new ArgumentNullException(nameof(outputPorts));
|
||||
if( ( outputPorts == null ) || ( outputPorts.Length == 0 ) ) {
|
||||
throw new ArgumentNullException( nameof( outputPorts ) );
|
||||
}
|
||||
levelAvailable = false;
|
||||
this.name = name;
|
||||
IsNative = isNative;
|
||||
_inputInterfaces = new Dictionary<string, BlueprintPipeline>();
|
||||
_outputInterfaces = new Dictionary<string, BlueprintPipeline>();
|
||||
foreach (string portName in inputPorts)
|
||||
{
|
||||
_inputInterfaces.Add(portName, null!);
|
||||
foreach( string portName in inputPorts ) {
|
||||
_inputInterfaces.Add( portName, null! );
|
||||
}
|
||||
foreach (string portName in outputPorts)
|
||||
{
|
||||
_outputInterfaces.Add(portName, null!);
|
||||
foreach( string portName in outputPorts ) {
|
||||
_outputInterfaces.Add( portName, null! );
|
||||
}
|
||||
}
|
||||
|
||||
@@ -125,19 +119,15 @@ namespace StgSharp.BluePrint
|
||||
{
|
||||
get
|
||||
{
|
||||
if (levelAvailable)
|
||||
{
|
||||
if( levelAvailable ) {
|
||||
return _level;
|
||||
}
|
||||
_level = 0;
|
||||
foreach (KeyValuePair<string, BlueprintPipeline> item in _inputInterfaces)
|
||||
{
|
||||
if (item.Value == null)
|
||||
{
|
||||
foreach( KeyValuePair<string, BlueprintPipeline> item in _inputInterfaces ) {
|
||||
if( item.Value == null ) {
|
||||
continue;
|
||||
}
|
||||
if (_level <= item.Value.Level)
|
||||
{
|
||||
if( _level <= item.Value.Level ) {
|
||||
_level = item.Value.Level;
|
||||
}
|
||||
}
|
||||
@@ -149,6 +139,7 @@ namespace StgSharp.BluePrint
|
||||
public string Name => name;
|
||||
|
||||
internal Dictionary<string, BlueprintPipeline> InputInterfaces => _inputInterfaces;
|
||||
|
||||
internal Dictionary<string, BlueprintPipeline> OutputInterfaces => _outputInterfaces;
|
||||
|
||||
internal IConvertableToBlueprintNode Value
|
||||
@@ -156,140 +147,124 @@ namespace StgSharp.BluePrint
|
||||
get => mainOperation;
|
||||
}
|
||||
|
||||
|
||||
public void AddAfter(
|
||||
BlueprintNode former,
|
||||
string formerOutputPortName,
|
||||
string thisInputPortName)
|
||||
string thisInputPortName )
|
||||
{
|
||||
this.levelAvailable = false;
|
||||
BlueprintPipeline pipeline = new BlueprintPipeline(former, this);
|
||||
if (former is BeginningNode bnode)
|
||||
{
|
||||
bnode.SetCertainOutputPort(formerOutputPortName, pipeline);
|
||||
BlueprintPipeline pipeline = new BlueprintPipeline( former, this );
|
||||
if( former is BeginningNode bnode ) {
|
||||
bnode.SetCertainOutputPort( formerOutputPortName, pipeline );
|
||||
} else {
|
||||
former.SetCertainOutputPort( formerOutputPortName, pipeline );
|
||||
}
|
||||
else
|
||||
{
|
||||
former.SetCertainOutputPort(formerOutputPortName, pipeline);
|
||||
}
|
||||
SetCertainInputPort(thisInputPortName, pipeline);
|
||||
SetCertainInputPort( thisInputPortName, pipeline );
|
||||
}
|
||||
|
||||
|
||||
public void AddBefore(
|
||||
BlueprintNode after,
|
||||
string thisOutputPortName,
|
||||
string afterInputPortName)
|
||||
string afterInputPortName )
|
||||
{
|
||||
this.levelAvailable = false;
|
||||
BlueprintPipeline pipeline = new BlueprintPipeline(this, after);
|
||||
if (after is EndingNode enode)
|
||||
{
|
||||
enode.SetCertainInputPort(afterInputPortName, pipeline);
|
||||
BlueprintPipeline pipeline = new BlueprintPipeline( this, after );
|
||||
if( after is EndingNode enode ) {
|
||||
enode.SetCertainInputPort( afterInputPortName, pipeline );
|
||||
} else {
|
||||
after.SetCertainInputPort( afterInputPortName, pipeline );
|
||||
}
|
||||
else
|
||||
{
|
||||
after.SetCertainInputPort(afterInputPortName, pipeline);
|
||||
}
|
||||
SetCertainOutputPort(thisOutputPortName, pipeline);
|
||||
SetCertainOutputPort( thisOutputPortName, pipeline );
|
||||
}
|
||||
|
||||
public int CompareTo(BlueprintNode other)
|
||||
public int CompareTo( BlueprintNode other )
|
||||
{
|
||||
#pragma warning disable CA1062
|
||||
return this.Level.CompareTo(other.Level);
|
||||
#pragma warning restore CA1062
|
||||
#pragma warning disable CA1062
|
||||
return this.Level.CompareTo( other.Level );
|
||||
#pragma warning restore CA1062
|
||||
}
|
||||
|
||||
|
||||
public virtual void Run()
|
||||
{
|
||||
try
|
||||
{
|
||||
try {
|
||||
//Console.WriteLine(name);
|
||||
BlueprintPipeline.WaitAll(_inputInterfaces);
|
||||
if (mainOperation != null)
|
||||
{
|
||||
mainOperation.ExecuteMain(in _inputInterfaces, in _outputInterfaces);
|
||||
BlueprintPipeline.WaitAll( _inputInterfaces );
|
||||
if( mainOperation != null ) {
|
||||
mainOperation.ExecuteMain(
|
||||
in _inputInterfaces, in _outputInterfaces );
|
||||
}
|
||||
}
|
||||
catch (Exception)
|
||||
{
|
||||
catch( Exception ) {
|
||||
throw;
|
||||
}
|
||||
}
|
||||
|
||||
#region port operation
|
||||
|
||||
public BlueprintPipeline GetCertainInputPort(string name)
|
||||
public BlueprintPipeline GetCertainInputPort( string name )
|
||||
{
|
||||
BlueprintPipeline ret;
|
||||
if (!_inputInterfaces.TryGetValue(name, out ret))
|
||||
{
|
||||
throw new Exception($"Cannot find the interface named {name} in node {Name}.");
|
||||
if( !_inputInterfaces.TryGetValue( name, out ret ) ) {
|
||||
throw new Exception(
|
||||
$"Cannot find the interface named {name} in node {Name}." );
|
||||
}
|
||||
return ret;
|
||||
}
|
||||
|
||||
|
||||
public BlueprintPipeline GetCertainOutputPort(string name)
|
||||
public BlueprintPipeline GetCertainOutputPort( string name )
|
||||
{
|
||||
BlueprintPipeline ret;
|
||||
if (!_outputInterfaces.TryGetValue(name, out ret))
|
||||
{
|
||||
throw new Exception($"Cannot find the interface named {name} in node {Name}.");
|
||||
if( !_outputInterfaces.TryGetValue( name, out ret ) ) {
|
||||
throw new Exception(
|
||||
$"Cannot find the interface named {name} in node {Name}." );
|
||||
}
|
||||
return ret;
|
||||
}
|
||||
|
||||
public void SetCertainInputPort(string name, BlueprintPipeline pipeline)
|
||||
public void SetCertainInputPort(
|
||||
string name,
|
||||
BlueprintPipeline pipeline )
|
||||
{
|
||||
if (!_inputInterfaces.ContainsKey(name))
|
||||
{
|
||||
throw new Exception($"Cannot find the interface named {name} in node {Name}.");
|
||||
if( !_inputInterfaces.ContainsKey( name ) ) {
|
||||
throw new Exception(
|
||||
$"Cannot find the interface named {name} in node {Name}." );
|
||||
}
|
||||
_inputInterfaces[name] = pipeline;
|
||||
_inputInterfaces[ name ] = pipeline;
|
||||
}
|
||||
|
||||
public void SetCertainOutputPort(string name, BlueprintPipeline pipeline)
|
||||
public void SetCertainOutputPort(
|
||||
string name,
|
||||
BlueprintPipeline pipeline )
|
||||
{
|
||||
if (!_outputInterfaces.ContainsKey(name))
|
||||
{
|
||||
throw new Exception($"Cannot find the interface named {name} in node {Name}.");
|
||||
if( !_outputInterfaces.ContainsKey( name ) ) {
|
||||
throw new Exception(
|
||||
$"Cannot find the interface named {name} in node {Name}." );
|
||||
}
|
||||
_outputInterfaces[name] = pipeline;
|
||||
_outputInterfaces[ name ] = pipeline;
|
||||
}
|
||||
|
||||
#endregion
|
||||
|
||||
|
||||
}//--------------------------------- end of class -----------------------------------
|
||||
|
||||
|
||||
|
||||
public class BlueprintNodeRunException : Exception
|
||||
{
|
||||
|
||||
protected BlueprintNodeRunException(SerializationInfo info, StreamingContext context) : base(info, context)
|
||||
{
|
||||
}
|
||||
protected BlueprintNodeRunException(
|
||||
SerializationInfo info,
|
||||
StreamingContext context )
|
||||
: base( info, context ) { }
|
||||
|
||||
public BlueprintNodeRunException()
|
||||
{
|
||||
}
|
||||
public BlueprintNodeRunException() { }
|
||||
|
||||
public BlueprintNodeRunException(Exception ex) : base(string.Empty, ex)
|
||||
{
|
||||
}
|
||||
public BlueprintNodeRunException( Exception ex )
|
||||
: base( string.Empty, ex ) { }
|
||||
|
||||
public BlueprintNodeRunException(string message) : base(message)
|
||||
{
|
||||
}
|
||||
public BlueprintNodeRunException( string message ) : base( message ) { }
|
||||
|
||||
public BlueprintNodeRunException(string message, Exception innerException) : base(message, innerException)
|
||||
{
|
||||
}
|
||||
public BlueprintNodeRunException(
|
||||
string message,
|
||||
Exception innerException )
|
||||
: base( message, innerException ) { }
|
||||
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user