예제 #1
0
        public static IGraphModel FromTypes(Type[] vertexTypes, Type[] edgeTypes)
        {
            var verticesModel = GraphElementModel.FromTypes(vertexTypes);
            var edgesModel    = GraphElementModel.FromTypes(edgeTypes);

            return(new GraphModelImpl(
                       verticesModel,
                       edgesModel,
                       GraphElementPropertyModel.FromGraphElementModels(verticesModel, edgesModel)));
        }
예제 #2
0
            public AssemblyGraphModel(Type vertexBaseType, Type edgeBaseType, IEnumerable <Assembly> assemblies, ILogger logger)
            {
                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}.");
                }

                var assemblyArray = assemblies
                                    .Append(vertexBaseType.Assembly)
                                    .Append(edgeBaseType.Assembly)
                                    .Distinct()
                                    .ToArray();

                VerticesModel   = new AssemblyGraphElementModel(vertexBaseType, assemblyArray, logger);
                EdgesModel      = new AssemblyGraphElementModel(edgeBaseType, assemblyArray, logger);
                PropertiesModel = GraphElementPropertyModel.FromGraphElementModels(VerticesModel, EdgesModel);
            }
예제 #3
0
        public static IGraphModel FromBaseTypes(Type vertexBaseType, Type edgeBaseType, Func <IAssemblyLookupBuilder, IAssemblyLookupSet> assemblyLookupTransformation, ILogger?logger = null)
        {
            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}.");
            }

            var assemblies = assemblyLookupTransformation(new AssemblyLookupSet(new [] { vertexBaseType, edgeBaseType }, ImmutableList <Assembly> .Empty))
                             .Assemblies;

            var verticesModel = GraphElementModel.FromBaseType(vertexBaseType, assemblies, logger);
            var edgesModel    = GraphElementModel.FromBaseType(edgeBaseType, assemblies, logger);

            return(new GraphModelImpl(
                       verticesModel,
                       edgesModel,
                       GraphElementPropertyModel.FromGraphElementModels(verticesModel, edgesModel)));
        }