Skip to content

Commit da42eb0

Browse files
committed
api update
1 parent cff8e19 commit da42eb0

File tree

5 files changed

+21
-8
lines changed

5 files changed

+21
-8
lines changed

ManagedCode.Orleans.Graph.Tests/Cluster/TestSiloConfigurations.cs

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -11,9 +11,9 @@ public void Configure(ISiloBuilder siloBuilder)
1111
siloBuilder.AddOrleansGraph()
1212
.CreateGraph(graph =>
1313
{
14-
graph.AddGrainTransition<IGrainA, IGrainB>().WithReentrancy().AllMethods();
15-
graph.AddGrainTransition<IGrainB, IGrainC>().WithReentrancy().AllMethods();
16-
graph.AddGrainTransition<IGrainC, IGrainD>().WithReentrancy().AllMethods();
14+
graph.AddGrainTransition<IGrainA, IGrainB>().AllMethods().WithReentrancy();
15+
graph.AddGrainTransition<IGrainB, IGrainC>().AllMethods().WithReentrancy();
16+
graph.AddGrainTransition<IGrainC, IGrainD>().AllMethods().WithReentrancy();
1717
});
1818
}
1919
}

ManagedCode.Orleans.Graph.Tests/GrainGraphManagerTests.cs

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -15,6 +15,7 @@ public void IsTransitionAllowed_SingleValidTransition_ReturnsTrue()
1515
.From<IGrainA>()
1616
.To<IGrainB>()
1717
.AllMethods()
18+
.And()
1819
.Build();
1920

2021
var callHistory = new CallHistory();
@@ -48,6 +49,7 @@ public void IsTransitionAllowed_EmptyCallHistory_ReturnsFalse()
4849
.From<IGrainA>()
4950
.To<IGrainB>()
5051
.AllMethods()
52+
.And()
5153
.Build();
5254

5355
var callHistory = new CallHistory();
@@ -116,6 +118,7 @@ public void IsTransitionAllowed_DisallowedTransition_ReturnsFalse()
116118
.From<IGrainA>()
117119
.To<IGrainB>()
118120
.AllMethods()
121+
.And()
119122
.Build();
120123

121124
var callHistory = new CallHistory();
@@ -136,6 +139,7 @@ public void IsTransitionAllowed_MultipleValidTransitions_ReturnsTrue()
136139
.From<IGrainB>()
137140
.To<IGrainC>()
138141
.AllMethods()
142+
.And()
139143
.Build();
140144

141145
var callHistory = new CallHistory();
@@ -186,6 +190,7 @@ public void IsTransitionAllowed_DetectsComplexLoop_ThrowsExceptionOnBuild()
186190
.From<IGrainD>()
187191
.To<IGrainA>()
188192
.AllMethods()
193+
.And()
189194
.Build();
190195
});
191196

@@ -203,6 +208,7 @@ public void IsTransitionAllowed_DetectsSimpleLoop_ReturnsFalse()
203208
.From<IGrainB>()
204209
.To<IGrainC>()
205210
.AllMethods()
211+
.And()
206212
.Build();
207213

208214
var callHistory = new CallHistory();
@@ -227,6 +233,7 @@ public void IsTransitionAllowed_NoLoop_ReturnsTrue()
227233
.From<IGrainB>()
228234
.To<IGrainC>()
229235
.AllMethods()
236+
.And()
230237
.Build();
231238

232239
var callHistory = new CallHistory();

ManagedCode.Orleans.Graph/Builder/Interfaces/IMethodBuilder.cs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -62,8 +62,8 @@ public interface IMethodBuilder<TSource, TTarget> where TSource : IGrain where T
6262
/// <summary>
6363
/// Specifies that all methods should be included.
6464
/// </summary>
65-
/// <returns>An instance of <see cref="IGrainCallsBuilder"/>.</returns>
66-
IGrainCallsBuilder AllMethods();
65+
/// <returns>The current instance of <see cref="IMethodBuilder{TSource, TTarget}"/>.</returns>
66+
IMethodBuilder<TSource, TTarget> AllMethods();
6767

6868

6969
/// <summary>

ManagedCode.Orleans.Graph/Builder/MethodBuilder.cs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -42,10 +42,10 @@ public IMethodBuilder<TSource, TTarget> WithReentrancy()
4242
return this;
4343
}
4444

45-
public IGrainCallsBuilder AllMethods()
45+
public IMethodBuilder<TSource, TTarget> AllMethods()
4646
{
4747
_parent.AddMethodRule(_sourceType, _targetType, "*", "*");
48-
return _parent;
48+
return this;
4949
}
5050

5151
public IGrainCallsBuilder And() => _parent;

ManagedCode.Orleans.Graph/Common/DirectedGraph.cs

Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -35,11 +35,17 @@ public void AddTransition(string source, string target, GrainTransition transiti
3535
AddVertex(source);
3636
AddVertex(target);
3737

38+
// Remove existing transitions between the same source and target
39+
if (_adjacencyList[source].ContainsKey(target))
40+
{
41+
_adjacencyList[source][target].Clear();
42+
}
43+
3844
if (!_adjacencyList[source].ContainsKey(target))
3945
{
4046
_adjacencyList[source][target] = new HashSet<GrainTransition>();
4147
}
42-
48+
4349
_adjacencyList[source][target].Add(transition);
4450

4551
if (!transition.IsReentrant && HasCycle())

0 commit comments

Comments
 (0)