public static IGraphModel FromAssembly(Assembly assembly, Type vertexBaseType, Type edgeBaseType, IGraphElementNamingStrategy namingStrategy) { if (vertexBaseType.IsAssignableFrom(edgeBaseType)) { throw new ArgumentException($"{vertexBaseType} may not be in the inheritance hierarchy of {edgeBaseType}."); } if (edgeBaseType.IsAssignableFrom(vertexBaseType)) { throw new ArgumentException($"{edgeBaseType} may not be in the inheritance hierarchy of {vertexBaseType}."); } return(new GraphModelImpl( assembly .DefinedTypes .Where(typeInfo => vertexBaseType.IsAssignableFrom(typeInfo.AsType())) .ToImmutableDictionary( type => type.AsType(), type => namingStrategy.GetLabelForType(type.AsType())), assembly .DefinedTypes .Where(typeInfo => edgeBaseType.IsAssignableFrom(typeInfo.AsType())) .ToImmutableDictionary( type => type.AsType(), type => namingStrategy.GetLabelForType(type.AsType())))); }
public static IGraphModel FromAssembly <TVertex, TEdge>(Assembly assembly, IGraphElementNamingStrategy namingStrategy) { return(FromAssembly(assembly, typeof(TVertex), typeof(TEdge), namingStrategy)); }