Skip to content

Commit 72971df

Browse files
committed
Normalize line endings
1 parent 41e5ff1 commit 72971df

File tree

10 files changed

+465
-465
lines changed

10 files changed

+465
-465
lines changed
Lines changed: 77 additions & 77 deletions
Original file line numberDiff line numberDiff line change
@@ -1,77 +1,77 @@
1-
using Bonsai.Expressions;
2-
using System;
3-
using System.Collections.Generic;
4-
using System.ComponentModel;
5-
using System.Linq;
6-
using System.Linq.Expressions;
7-
using System.Reactive.Linq;
8-
using System.Reflection;
9-
10-
namespace Bonsai.Scripting
11-
{
12-
/// <summary>
13-
/// Represents an operator that uses an expression script to filter the elements
14-
/// of an observable sequence.
15-
/// </summary>
16-
[Obsolete]
17-
[DefaultProperty(nameof(Expression))]
18-
[WorkflowElementCategory(ElementCategory.Condition)]
19-
[TypeDescriptionProvider(typeof(ExpressionConditionTypeDescriptionProvider))]
20-
[Description("An expression script used to filter the elements of the sequence.")]
21-
public class ExpressionCondition : SingleArgumentExpressionBuilder, IScriptingElement
22-
{
23-
static readonly MethodInfo whereMethod = typeof(Observable).GetMethods()
24-
.Single(m => m.Name == nameof(Observable.Where) &&
25-
m.GetParameters().Length == 2 &&
26-
m.GetParameters()[1].ParameterType.GetGenericTypeDefinition() == typeof(Func<,>));
27-
28-
/// <summary>
29-
/// Gets or sets the name of the expression condition.
30-
/// </summary>
31-
[Externalizable(false)]
32-
[Category(nameof(CategoryAttribute.Design))]
33-
[Description("The name of the expression condition.")]
34-
public string Name { get; set; }
35-
36-
/// <summary>
37-
/// Gets or sets a description for the expression condition.
38-
/// </summary>
39-
[Externalizable(false)]
40-
[Category(nameof(CategoryAttribute.Design))]
41-
[Description("A description for the expression condition.")]
42-
[Editor(DesignTypes.MultilineStringEditor, DesignTypes.UITypeEditor)]
43-
public string Description { get; set; }
44-
45-
/// <summary>
46-
/// Gets or sets the expression that determines which elements to filter.
47-
/// </summary>
48-
[Editor("Bonsai.Scripting.Expressions.Design.ExpressionScriptEditor, Bonsai.Scripting.Expressions.Design", DesignTypes.UITypeEditor)]
49-
[Description("The expression that determines which elements to filter.")]
50-
public string Expression { get; set; } = "it";
51-
52-
/// <inheritdoc/>
53-
public override Expression Build(IEnumerable<Expression> arguments)
54-
{
55-
var source = arguments.First();
56-
var sourceType = source.Type.GetGenericArguments()[0];
57-
var predicate = global::System.Linq.Dynamic.DynamicExpression.ParseLambda(sourceType, typeof(bool), Expression);
58-
return System.Linq.Expressions.Expression.Call(whereMethod.MakeGenericMethod(sourceType), source, predicate);
59-
}
60-
61-
class ExpressionConditionTypeDescriptionProvider : TypeDescriptionProvider
62-
{
63-
static readonly TypeDescriptionProvider parentProvider = TypeDescriptor.GetProvider(typeof(ExpressionCondition));
64-
65-
public ExpressionConditionTypeDescriptionProvider()
66-
: base(parentProvider)
67-
{
68-
}
69-
70-
public override ICustomTypeDescriptor GetExtendedTypeDescriptor(object instance)
71-
{
72-
return new ScriptingElementTypeDescriptor(instance,
73-
"An expression script used to filter the elements of the sequence.");
74-
}
75-
}
76-
}
77-
}
1+
using Bonsai.Expressions;
2+
using System;
3+
using System.Collections.Generic;
4+
using System.ComponentModel;
5+
using System.Linq;
6+
using System.Linq.Expressions;
7+
using System.Reactive.Linq;
8+
using System.Reflection;
9+
10+
namespace Bonsai.Scripting
11+
{
12+
/// <summary>
13+
/// Represents an operator that uses an expression script to filter the elements
14+
/// of an observable sequence.
15+
/// </summary>
16+
[Obsolete]
17+
[DefaultProperty(nameof(Expression))]
18+
[WorkflowElementCategory(ElementCategory.Condition)]
19+
[TypeDescriptionProvider(typeof(ExpressionConditionTypeDescriptionProvider))]
20+
[Description("An expression script used to filter the elements of the sequence.")]
21+
public class ExpressionCondition : SingleArgumentExpressionBuilder, IScriptingElement
22+
{
23+
static readonly MethodInfo whereMethod = typeof(Observable).GetMethods()
24+
.Single(m => m.Name == nameof(Observable.Where) &&
25+
m.GetParameters().Length == 2 &&
26+
m.GetParameters()[1].ParameterType.GetGenericTypeDefinition() == typeof(Func<,>));
27+
28+
/// <summary>
29+
/// Gets or sets the name of the expression condition.
30+
/// </summary>
31+
[Externalizable(false)]
32+
[Category(nameof(CategoryAttribute.Design))]
33+
[Description("The name of the expression condition.")]
34+
public string Name { get; set; }
35+
36+
/// <summary>
37+
/// Gets or sets a description for the expression condition.
38+
/// </summary>
39+
[Externalizable(false)]
40+
[Category(nameof(CategoryAttribute.Design))]
41+
[Description("A description for the expression condition.")]
42+
[Editor(DesignTypes.MultilineStringEditor, DesignTypes.UITypeEditor)]
43+
public string Description { get; set; }
44+
45+
/// <summary>
46+
/// Gets or sets the expression that determines which elements to filter.
47+
/// </summary>
48+
[Editor("Bonsai.Scripting.Expressions.Design.ExpressionScriptEditor, Bonsai.Scripting.Expressions.Design", DesignTypes.UITypeEditor)]
49+
[Description("The expression that determines which elements to filter.")]
50+
public string Expression { get; set; } = "it";
51+
52+
/// <inheritdoc/>
53+
public override Expression Build(IEnumerable<Expression> arguments)
54+
{
55+
var source = arguments.First();
56+
var sourceType = source.Type.GetGenericArguments()[0];
57+
var predicate = global::System.Linq.Dynamic.DynamicExpression.ParseLambda(sourceType, typeof(bool), Expression);
58+
return System.Linq.Expressions.Expression.Call(whereMethod.MakeGenericMethod(sourceType), source, predicate);
59+
}
60+
61+
class ExpressionConditionTypeDescriptionProvider : TypeDescriptionProvider
62+
{
63+
static readonly TypeDescriptionProvider parentProvider = TypeDescriptor.GetProvider(typeof(ExpressionCondition));
64+
65+
public ExpressionConditionTypeDescriptionProvider()
66+
: base(parentProvider)
67+
{
68+
}
69+
70+
public override ICustomTypeDescriptor GetExtendedTypeDescriptor(object instance)
71+
{
72+
return new ScriptingElementTypeDescriptor(instance,
73+
"An expression script used to filter the elements of the sequence.");
74+
}
75+
}
76+
}
77+
}

Bonsai.Scripting/ExpressionSink.cs

Lines changed: 85 additions & 85 deletions
Original file line numberDiff line numberDiff line change
@@ -1,85 +1,85 @@
1-
using Bonsai.Expressions;
2-
using System;
3-
using System.Collections.Generic;
4-
using System.ComponentModel;
5-
using System.Linq;
6-
using System.Linq.Expressions;
7-
using System.Reactive.Linq;
8-
using System.Reflection;
9-
10-
namespace Bonsai.Scripting
11-
{
12-
/// <summary>
13-
/// Represents an operator that uses an expression script to invoke an action for
14-
/// each element of an observable sequence.
15-
/// </summary>
16-
[Obsolete]
17-
[DefaultProperty(nameof(Expression))]
18-
[WorkflowElementCategory(ElementCategory.Sink)]
19-
[TypeDescriptionProvider(typeof(ExpressionSinkTypeDescriptionProvider))]
20-
[Description("An expression script used to invoke an action for each element of the sequence.")]
21-
public class ExpressionSink : SingleArgumentExpressionBuilder, IScriptingElement
22-
{
23-
static readonly MethodInfo doMethod = typeof(Observable).GetMethods()
24-
.Single(m => m.Name == nameof(Observable.Do) &&
25-
m.GetParameters().Length == 2 &&
26-
m.GetParameters()[1].ParameterType.GetGenericTypeDefinition() == typeof(Action<>));
27-
28-
/// <summary>
29-
/// Gets or sets the name of the expression sink.
30-
/// </summary>
31-
[Externalizable(false)]
32-
[Category(nameof(CategoryAttribute.Design))]
33-
[Description("The name of the expression sink.")]
34-
public string Name { get; set; }
35-
36-
/// <summary>
37-
/// Gets or sets a description for the expression sink.
38-
/// </summary>
39-
[Externalizable(false)]
40-
[Category(nameof(CategoryAttribute.Design))]
41-
[Description("A description for the expression sink.")]
42-
[Editor(DesignTypes.MultilineStringEditor, DesignTypes.UITypeEditor)]
43-
public string Description { get; set; }
44-
45-
/// <summary>
46-
/// Gets or sets the expression that determines the action to perform
47-
/// on the input elements.
48-
/// </summary>
49-
[Editor("Bonsai.Scripting.Expressions.Design.ExpressionScriptEditor, Bonsai.Scripting.Expressions.Design", DesignTypes.UITypeEditor)]
50-
[Description("The expression that determines the action to perform on the input elements.")]
51-
public string Expression { get; set; }
52-
53-
/// <inheritdoc/>
54-
public override Expression Build(IEnumerable<Expression> arguments)
55-
{
56-
var expression = Expression;
57-
var source = arguments.First();
58-
if (!string.IsNullOrEmpty(expression))
59-
{
60-
var sourceType = source.Type.GetGenericArguments()[0];
61-
var actionType = System.Linq.Expressions.Expression.GetActionType(sourceType);
62-
var itParameter = new[] { System.Linq.Expressions.Expression.Parameter(sourceType, string.Empty) };
63-
var onNext = global::System.Linq.Dynamic.DynamicExpression.ParseLambda(actionType, itParameter, null, Expression);
64-
return System.Linq.Expressions.Expression.Call(doMethod.MakeGenericMethod(sourceType), source, onNext);
65-
}
66-
else return source;
67-
}
68-
69-
class ExpressionSinkTypeDescriptionProvider : TypeDescriptionProvider
70-
{
71-
static readonly TypeDescriptionProvider parentProvider = TypeDescriptor.GetProvider(typeof(ExpressionSink));
72-
73-
public ExpressionSinkTypeDescriptionProvider()
74-
: base(parentProvider)
75-
{
76-
}
77-
78-
public override ICustomTypeDescriptor GetExtendedTypeDescriptor(object instance)
79-
{
80-
return new ScriptingElementTypeDescriptor(instance,
81-
"An expression script used to invoke an action for each element of the sequence.");
82-
}
83-
}
84-
}
85-
}
1+
using Bonsai.Expressions;
2+
using System;
3+
using System.Collections.Generic;
4+
using System.ComponentModel;
5+
using System.Linq;
6+
using System.Linq.Expressions;
7+
using System.Reactive.Linq;
8+
using System.Reflection;
9+
10+
namespace Bonsai.Scripting
11+
{
12+
/// <summary>
13+
/// Represents an operator that uses an expression script to invoke an action for
14+
/// each element of an observable sequence.
15+
/// </summary>
16+
[Obsolete]
17+
[DefaultProperty(nameof(Expression))]
18+
[WorkflowElementCategory(ElementCategory.Sink)]
19+
[TypeDescriptionProvider(typeof(ExpressionSinkTypeDescriptionProvider))]
20+
[Description("An expression script used to invoke an action for each element of the sequence.")]
21+
public class ExpressionSink : SingleArgumentExpressionBuilder, IScriptingElement
22+
{
23+
static readonly MethodInfo doMethod = typeof(Observable).GetMethods()
24+
.Single(m => m.Name == nameof(Observable.Do) &&
25+
m.GetParameters().Length == 2 &&
26+
m.GetParameters()[1].ParameterType.GetGenericTypeDefinition() == typeof(Action<>));
27+
28+
/// <summary>
29+
/// Gets or sets the name of the expression sink.
30+
/// </summary>
31+
[Externalizable(false)]
32+
[Category(nameof(CategoryAttribute.Design))]
33+
[Description("The name of the expression sink.")]
34+
public string Name { get; set; }
35+
36+
/// <summary>
37+
/// Gets or sets a description for the expression sink.
38+
/// </summary>
39+
[Externalizable(false)]
40+
[Category(nameof(CategoryAttribute.Design))]
41+
[Description("A description for the expression sink.")]
42+
[Editor(DesignTypes.MultilineStringEditor, DesignTypes.UITypeEditor)]
43+
public string Description { get; set; }
44+
45+
/// <summary>
46+
/// Gets or sets the expression that determines the action to perform
47+
/// on the input elements.
48+
/// </summary>
49+
[Editor("Bonsai.Scripting.Expressions.Design.ExpressionScriptEditor, Bonsai.Scripting.Expressions.Design", DesignTypes.UITypeEditor)]
50+
[Description("The expression that determines the action to perform on the input elements.")]
51+
public string Expression { get; set; }
52+
53+
/// <inheritdoc/>
54+
public override Expression Build(IEnumerable<Expression> arguments)
55+
{
56+
var expression = Expression;
57+
var source = arguments.First();
58+
if (!string.IsNullOrEmpty(expression))
59+
{
60+
var sourceType = source.Type.GetGenericArguments()[0];
61+
var actionType = System.Linq.Expressions.Expression.GetActionType(sourceType);
62+
var itParameter = new[] { System.Linq.Expressions.Expression.Parameter(sourceType, string.Empty) };
63+
var onNext = global::System.Linq.Dynamic.DynamicExpression.ParseLambda(actionType, itParameter, null, Expression);
64+
return System.Linq.Expressions.Expression.Call(doMethod.MakeGenericMethod(sourceType), source, onNext);
65+
}
66+
else return source;
67+
}
68+
69+
class ExpressionSinkTypeDescriptionProvider : TypeDescriptionProvider
70+
{
71+
static readonly TypeDescriptionProvider parentProvider = TypeDescriptor.GetProvider(typeof(ExpressionSink));
72+
73+
public ExpressionSinkTypeDescriptionProvider()
74+
: base(parentProvider)
75+
{
76+
}
77+
78+
public override ICustomTypeDescriptor GetExtendedTypeDescriptor(object instance)
79+
{
80+
return new ScriptingElementTypeDescriptor(instance,
81+
"An expression script used to invoke an action for each element of the sequence.");
82+
}
83+
}
84+
}
85+
}

0 commit comments

Comments
 (0)