-
Notifications
You must be signed in to change notification settings - Fork 16
Expand file tree
/
Copy pathContainerExtensions.cs
More file actions
49 lines (42 loc) · 1.76 KB
/
Copy pathContainerExtensions.cs
File metadata and controls
49 lines (42 loc) · 1.76 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
using System;
using System.Collections.Generic;
using System.Linq;
using OSPSuite.Core.Domain;
using OSPSuite.Core.Domain.Builder;
using OSPSuite.Utility.Extensions;
namespace MoBi.Core.Domain.Extensions
{
public static class ContainerExtensions
{
public static bool CanSetBuildModeForParameters(this IContainer container)
{
return container.IsAnImplementationOf<ReactionBuilder>() ||
container.IsAnImplementationOf<MoleculeBuilder>();
}
public static IEnumerable<ParameterBuildMode> AvailableBuildModeForParameters(this IContainer container)
{
yield return ParameterBuildMode.Local;
yield return ParameterBuildMode.Global;
}
public static ParameterBuildMode DefaultParameterBuildMode(this IContainer container)
{
var needsGlobalParameter = container.IsAnImplementationOf<TransporterMoleculeContainer>() ||
container.IsAnImplementationOf<ReactionBuilder>() ||
container.IsAnImplementationOf<InteractionContainer>();
return needsGlobalParameter ? ParameterBuildMode.Global : ParameterBuildMode.Local;
}
public static IContainer WithTag(this IContainer container, string tag)
{
container.AddTag(tag);
return container;
}
public static IEnumerable<T> GetChildrenSortedByName<T>(this IContainer container, Func<T, bool> pred) where T : class, IEntity
{
return container.GetChildren(pred).OrderBy(x => x.Name, new IndexedNameComparer());
}
public static IEnumerable<T> GetChildrenSortedByName<T>(this IContainer container) where T : class, IEntity
{
return container.GetChildrenSortedByName<T>(x => true);
}
}
}