示例#1
0
        private void LoadConcepts()
        {
            var currentAssembly = Assembly.GetExecutingAssembly();
            var resourceName    = "MathIO.Source.Concepts.json";

            using (Stream stream = currentAssembly.GetManifestResourceStream(resourceName))
                using (var file = new StreamReader(stream))
                    using (var reader = new JsonTextReader(file))
                    {
                        var jArray = (JArray)JToken.ReadFrom(reader);
                        foreach (JToken jt in jArray)
                        {
                            var jo = jt as JObject;
                            Debug.Assert(jo != null);

                            var concept = (string)jo.GetValue("concept");
                            var topic   = (string)jo.GetValue("topic");

                            var ignore = (bool)jo.GetValue("ignore");
                            if (ignore)
                            {
                                continue;
                            }

                            var isError = (bool)jo.GetValue("isError");

                            var conceptNode = new ConceptNode(concept, topic, isError);

                            if (!ConceptGraph.ContainsVertex(conceptNode))
                            {
                                ConceptGraph.AddVertex(conceptNode);
                            }

                            var dependencies = jo.GetValue("dependencies") as JArray;
                            if (dependencies == null)
                            {
                                continue;
                            }
                            foreach (JToken dependToken in dependencies)
                            {
                                var dependentConcept = (string)dependToken;
                                if (dependentConcept == null)
                                {
                                    continue;
                                }

                                ConceptNode cn = ConceptGraph.SearchConceptNode(dependentConcept);
                                if (cn == null)
                                {
                                    cn = new ConceptNode(dependentConcept);
                                    ConceptGraph.AddVertex(cn);
                                }
                                ConceptGraph.AddEdge(new Edge <ConceptNode>(cn, conceptNode));
                            }
                        }
                    }
        }
示例#2
0
 public ConceptEdge(ConceptNode _source, ConceptNode _target)
 {
     SourceConcept = _source;
     TargetConcept = _target;
 }