Skip to content

Commit

Permalink
Reorder method declaration order for readability
Browse files Browse the repository at this point in the history
  • Loading branch information
glopesdev committed Jun 13, 2023
1 parent 696b914 commit 82daed2
Showing 1 changed file with 33 additions and 33 deletions.
66 changes: 33 additions & 33 deletions Bonsai.Editor/GraphModel/WorkflowEditor.cs
Original file line number Diff line number Diff line change
Expand Up @@ -964,6 +964,39 @@ static string MakeGenericType(string typeName, ExpressionBuilder builder, out El
return genericType.MakeGenericType(inspectBuilder.ObservableType).AssemblyQualifiedName;
}

private void ConfigureBuilder(ExpressionBuilder builder, GraphNode selectedNode, string arguments)
{
if (string.IsNullOrEmpty(arguments)) return;
// TODO: This special case for binary operator operands should be avoided in the future
if (builder is BinaryOperatorBuilder binaryOperator && selectedNode != null)
{
if (GetGraphNodeTag(selectedNode).Value is InspectBuilder inputBuilder &&
inputBuilder.ObservableType != null)
{
binaryOperator.Build(Expression.Parameter(typeof(IObservable<>).MakeGenericType(inputBuilder.ObservableType)));
}
}

var workflowElement = ExpressionBuilder.GetWorkflowElement(builder);
var defaultProperty = TypeDescriptor.GetDefaultProperty(workflowElement);
if (defaultProperty != null &&
!defaultProperty.IsReadOnly &&
defaultProperty.Converter != null &&
defaultProperty.Converter.CanConvertFrom(typeof(string)))
{
try
{
var context = new TypeDescriptorContext(workflowElement, defaultProperty, serviceProvider);
var propertyValue = defaultProperty.Converter.ConvertFromString(context, arguments);
defaultProperty.SetValue(workflowElement, propertyValue);
}
catch (Exception ex)
{
throw new SystemException(ex.Message, ex);
}
}
}

public void CreateGraphNode(
string typeName,
ElementCategory elementCategory,
Expand Down Expand Up @@ -1039,39 +1072,6 @@ public void CreateGraphNode(
commandExecutor.EndCompositeCommand();
}

private void ConfigureBuilder(ExpressionBuilder builder, GraphNode selectedNode, string arguments)
{
if (string.IsNullOrEmpty(arguments)) return;
// TODO: This special case for binary operator operands should be avoided in the future
if (builder is BinaryOperatorBuilder binaryOperator && selectedNode != null)
{
if (GetGraphNodeTag(selectedNode).Value is InspectBuilder inputBuilder &&
inputBuilder.ObservableType != null)
{
binaryOperator.Build(Expression.Parameter(typeof(IObservable<>).MakeGenericType(inputBuilder.ObservableType)));
}
}

var workflowElement = ExpressionBuilder.GetWorkflowElement(builder);
var defaultProperty = TypeDescriptor.GetDefaultProperty(workflowElement);
if (defaultProperty != null &&
!defaultProperty.IsReadOnly &&
defaultProperty.Converter != null &&
defaultProperty.Converter.CanConvertFrom(typeof(string)))
{
try
{
var context = new TypeDescriptorContext(workflowElement, defaultProperty, serviceProvider);
var propertyValue = defaultProperty.Converter.ConvertFromString(context, arguments);
defaultProperty.SetValue(workflowElement, propertyValue);
}
catch (Exception ex)
{
throw new SystemException(ex.Message, ex);
}
}
}

public void CreateGraphNode(
ExpressionBuilder builder,
GraphNode selectedNode,
Expand Down

0 comments on commit 82daed2

Please sign in to comment.