public MetaItem AddMetaItem(string word, string cultureName) { if (string.IsNullOrEmpty(word)) { throw new ArgumentNullException("word", "Word cannot be null or empty."); } if (_graph.Vertices.Any(v => v.Data.Type.Equals(VertexType.Word) && v.Data.Value.Equals(word))) { throw new InvalidOperationException("Cannot add the same MetaItem twice"); } var metaItemVertex = new HaymanVertex(VertexId.NewVertexId, null) { VertexData = new HaymanVertexData { Type = VertexType.MetaItem } }; var wordVertex = new HaymanVertex(VertexId.NewVertexId, null) { VertexData = new HaymanVertexData { Type = VertexType.Word, Value = word, CultureName = cultureName } }; _graph.AddVertex(metaItemVertex); _graph.AddVertex(wordVertex); _graph.AddEdge(wordVertex, metaItemVertex, EdgeId.NewEdgeId, "", null); return new MetaItem(this, metaItemVertex.Id.ToString()); }
public Word AddWord(string word, string cultureName) { var wordVertex = new HaymanVertex(VertexId.NewVertexId, null) { VertexData = new HaymanVertexData { Type = VertexType.Word, CultureName = cultureName } }; _graph.AddVertex(wordVertex); return new Word(this, wordVertex.Id.ToString()); }
public bool Equals(HaymanVertex other) { if (ReferenceEquals(null, other)) return false; if (ReferenceEquals(this, other)) return true; return Equals(other._id, _id); }