public ServiceVertexView(IVertexView myVertexView) { var singleEdges = myVertexView.GetAllSingleEdges(); SingleEdges = (singleEdges == null) ? null : singleEdges.Select(x => new Tuple <string, ServiceSingleEdgeView>(x.Item1, new ServiceSingleEdgeView(x.Item2))).ToList(); var hyperEdges = myVertexView.GetAllHyperEdges(); HyperEdges = (hyperEdges == null) ? null : hyperEdges.Select(x => new Tuple <string, ServiceHyperEdgeView>(x.Item1, new ServiceHyperEdgeView(x.Item2))).ToList(); var properties = myVertexView.GetAllProperties(); if (properties == null) { Properties = null; } else { Properties = properties.Select(x => { object value = ConvertHelper.ToServiceObject(x.Item2); if (value != null) { return(new Tuple <string, object>(x.Item1, value)); } else { return(x); } }).ToList(); } }
public ServiceVertexView(IVertexView myVertexView) { var singleEdges = myVertexView.GetAllSingleEdges(); SingleEdges = (singleEdges == null) ? null : singleEdges.ToDictionary(_ => _.EdgeName, _ => new ServiceSingleEdgeView(_.Edge)); var hyperEdges = myVertexView.GetAllHyperEdges(); HyperEdges = (hyperEdges == null) ? null : hyperEdges.ToDictionary(_ => _.EdgeName, _ => new ServiceHyperEdgeView(_.Edge)); var properties = myVertexView.GetAllProperties(); if (properties == null) { Properties = null; } else { Properties = properties.ToDictionary(_ => _.PropertyName, _ => { object value = ConvertHelper.ToServiceObject(_.Property); if (value != null) { return(value); } else { return(_.Property); } }); } }
private String GenerateVertexViewHTML(IVertexView aVertex) { StringBuilder Output = new StringBuilder(); // take one IVertexView and traverse through it #region Vertex Properties if (aVertex.GetCountOfProperties() > 0) { //Output.Append("<table class=\"gql_table\" border=\"1\"> <!-- VertexProperties -->"); foreach (var _property in aVertex.GetAllProperties()) { if (_property.Item2 == null) { Output.Append("<tr><td style=\"width:250px\">").Append(EscapeForXMLandHTML(_property.Item1)).Append("</td><td style=\"width:400px\"></td></tr>"); } else if (_property.Item2 is Stream) { Output.Append("<tr><td style=\"width:250px\">").Append(EscapeForXMLandHTML(_property.Item1)).Append("</td><td style=\"width:400px\">BinaryProperty</td></tr>"); } else { Output.Append("<tr><td style=\"width:250px\">").Append(EscapeForXMLandHTML(_property.Item1)).Append("</td><td style=\"width:400px\">").Append(EscapeForXMLandHTML(_property.Item2.ToString())).Append("</td></tr>"); } } //Output.Append("</table> <!-- VertexProperties -->"); } #endregion #region Edges Output.Append("<tr><td><td><table class=\"gql_table\"border=\"1\"> <!-- Edges -->"); Output.Append("<tr><td style=\"width:250px\">edges</td><td style=\"width:400px\">"); foreach (var _edge in aVertex.GetAllEdges()) { if (_edge.Item2 == null) { Output.Append("<tr><td style=\"width:250px\">").Append(EscapeForXMLandHTML(_edge.Item1)).Append("</td><td style=\"width:400px\"></td></tr>"); } else { Output.Append("<tr><td style=\"width:250px\">").Append(EscapeForXMLandHTML(_edge.Item1)).Append("</td><td style=\"width:400px\">").Append(GenerateEdgeViewHTML(_edge.Item2)).Append("</td></tr>"); } } Output.Append("</td></td></tr>"); Output.Append("</table> <!-- Edges -->"); // add to the results... //_results.Add(new JObject(new JProperty("edges", _edges))); #endregion return(Output.ToString()); }
public ServiceVertexView(IVertexView myVertexView) { var singleEdges = myVertexView.GetAllSingleEdges(); SingleEdges = (singleEdges == null) ? null : singleEdges.Select(x => new Tuple<string, ServiceSingleEdgeView>(x.Item1, new ServiceSingleEdgeView(x.Item2))).ToList(); var hyperEdges = myVertexView.GetAllHyperEdges(); HyperEdges = (hyperEdges == null) ? null : hyperEdges.Select(x => new Tuple<string, ServiceHyperEdgeView>(x.Item1, new ServiceHyperEdgeView(x.Item2))).ToList(); var properties = myVertexView.GetAllProperties(); if (properties == null) Properties = null; else Properties = properties.Select(x => { object value = ConvertHelper.ToServiceObject(x.Item2); if (value != null) return new Tuple<string, object>(x.Item1, value); else return x; }).ToList(); }
public ServiceVertexView(IVertexView myVertexView) { var singleEdges = myVertexView.GetAllSingleEdges(); SingleEdges = (singleEdges == null) ? null : singleEdges.ToDictionary(_ => _.EdgeName, _ => new ServiceSingleEdgeView(_.Edge)); var hyperEdges = myVertexView.GetAllHyperEdges(); HyperEdges = (hyperEdges == null) ? null : hyperEdges.ToDictionary(_ => _.EdgeName, _ => new ServiceHyperEdgeView(_.Edge)); var properties = myVertexView.GetAllProperties(); if (properties == null) Properties = null; else Properties = properties.ToDictionary(_ => _.PropertyName, _ => { object value = ConvertHelper.ToServiceObject(_.Property); if (value != null) return value; else return _.Property; }); }
/// <summary> /// Generates an text vertex view. /// </summary> /// <param name="aVertex">The vertex.</param> /// <param name="Header">The header.</param> /// <returns>An string, that contains the text vertex view.</returns> private String GenerateVertexViewText(String Header, IVertexView aVertex) { StringBuilder Output = new StringBuilder(); // take one IVertexView and traverse through it #region Vertex Properties Output.AppendLine(); if (aVertex.GetCountOfProperties() > 0) { foreach (var _property in aVertex.GetAllProperties()) { if (_property.Item2 == null) { Output.AppendLine(Header + _property.Item1); } else { if (_property.Item2 is Stream) { Output.AppendLine(Header + _property.Item1 + "\t BinaryProperty"); } else { if (_property.Item2 is ICollectionWrapper) { Output.AppendLine(Header + _property.Item1); HandleListProperties((ICollectionWrapper)_property.Item2, Header, ref Output); } else { Output.AppendLine(Header + _property.Item1 + "\t " + _property.Item2.ToString()); } } } } } #endregion #region Edges Output.AppendLine(Header + "\t Edges:"); foreach (var _edge in aVertex.GetAllEdges()) { if (_edge.Item2 == null) { Output.AppendLine(Header+"\t\t"+_edge.Item1); } else { Output.AppendLine(Header+"\t\t"+_edge.Item2.GetType().Name); Output.AppendLine(Header+"\t\t"+_edge.Item1).Append(GenerateEdgeViewText(Header+"\t\t\t",_edge.Item2)); } } #endregion return Output.ToString(); }
/// <summary> /// Generates an text vertex view. /// </summary> /// <param name="aVertex">The vertex.</param> /// <param name="Header">The header.</param> /// <returns>An string, that contains the text vertex view.</returns> private String GenerateVertexViewText(String Header, IVertexView aVertex) { StringBuilder Output = new StringBuilder(); // take one IVertexView and traverse through it #region Vertex Properties Output.AppendLine(); if (aVertex.GetCountOfProperties() > 0) { foreach (var _property in aVertex.GetAllProperties()) { if (_property.Property == null) { Output.AppendLine(Header + _property.PropertyName); } else { if (_property.Property is Stream) { Output.AppendLine(Header + _property.PropertyName + "\t BinaryProperty"); } else { if (_property.Property is ICollectionWrapper) { Output.AppendLine(Header + _property.PropertyName); HandleListProperties((ICollectionWrapper)_property.Property, Header, ref Output); } else { Output.AppendLine(Header + _property.PropertyName + "\t " + _property.Property.ToString()); } } } } } #endregion #region Edges Output.AppendLine(Header + "\t Edges:"); foreach (var _edge in aVertex.GetAllEdges()) { if (_edge.Edge == null) { Output.AppendLine(Header + "\t\t" + _edge.EdgeName); } else { Output.AppendLine(Header + "\t\t" + _edge.Edge.GetType().Name); Output.AppendLine(Header + "\t\t" + _edge.EdgeName).Append(GenerateEdgeViewText(Header + "\t\t\t", _edge.Edge)); } } #endregion return(Output.ToString()); }
/// <summary> /// Generates a xml vertex view class. /// </summary> /// <param name="aVertex">The vertex view of the query result.</param> /// <returns>An generated xml class.</returns> private SchemaToClassesGenerator.VertexView GenerateVertexView(IVertexView aVertex) { var resultVertex = new SchemaToClassesGenerator.VertexView(); if (aVertex != null) { #region properties List<Property> properties = new List<Property>(); foreach (var aProperty in aVertex.GetAllProperties()) { var property = new Property(); property.ID = aProperty.Item1; if (aProperty.Item2 != null) { if (aProperty.Item2 is ICollectionWrapper) { HandleListProperties((ICollectionWrapper)aProperty.Item2, ref property); } else { if (aProperty.Item2.GetType().IsSubclassOf(typeof(AUserdefinedDataType))) { property.Value = ((AUserdefinedDataType)aProperty.Item2).Value; } else { property.Value = aProperty.Item2.ToString(); } property.Type = aProperty.Item2.GetType().Name; } } else { property.Value = String.Empty; property.Type = "null"; } properties.Add(property); } resultVertex.Properties = properties.ToArray(); #endregion #region binaries List<BinaryData> binProperties = new List<BinaryData>(); foreach (var aProperty in aVertex.GetAllBinaryProperties()) { var binProp = new BinaryData(); binProp.ID = aProperty.Item1; var content = new byte[aProperty.Item2.Length]; aProperty.Item2.Read(content, 0, content.Length); binProp.Content = content; binProperties.Add(binProp); } resultVertex.BinaryProperties = binProperties.ToArray(); #endregion #region edges List<SchemaToClassesGenerator.EdgeView> edges = new List<SchemaToClassesGenerator.EdgeView>(); foreach (var aEdge in aVertex.GetAllEdges()) { if (aEdge.Item2 is IHyperEdgeView) { List<Tuple<SchemaToClassesGenerator.VertexView, IEnumerable<Tuple<String, Object>>>> innerVertices = new List<Tuple<SchemaToClassesGenerator.VertexView, IEnumerable<Tuple<String, Object>>>>(); #region single edges foreach (var SingleEdges in ((sones.GraphQL.Result.HyperEdgeView)aEdge.Item2).GetAllEdges()) { innerVertices.Add(new Tuple<SchemaToClassesGenerator.VertexView, IEnumerable<Tuple<String, Object>>>(GenerateVertexView(SingleEdges.GetTargetVertex()), SingleEdges.GetAllProperties())); } #endregion var hyperEdge = new SchemaToClassesGenerator.HyperEdgeView(); hyperEdge.Name = aEdge.Item1; #region set hyperedge properties var edgeProperties = aEdge.Item2.GetAllProperties().ToArray(); hyperEdge.Properties = new Property[edgeProperties.Count()]; for (Int32 i = 0; i < edgeProperties.Count(); i++) { hyperEdge.Properties[i] = new Property(); hyperEdge.Properties[i].ID = edgeProperties[i].Item1; if (edgeProperties[i].Item2 is ICollectionWrapper) { HandleListProperties((ICollectionWrapper)edgeProperties[i].Item2, ref hyperEdge.Properties[i]); } else { if (edgeProperties[i].Item2.GetType().IsSubclassOf(typeof(AUserdefinedDataType))) { hyperEdge.Properties[i].Value = ((AUserdefinedDataType)edgeProperties[i].Item2).Value; } else { hyperEdge.Properties[i].Value = edgeProperties[i].Item2.ToString(); } hyperEdge.Properties[i].Type = edgeProperties[i].Item2.GetType().Name; } } #endregion hyperEdge.SingleEdge = new SchemaToClassesGenerator.SingleEdgeView[innerVertices.Count]; for (Int32 i = 0; i < innerVertices.Count; i++) { hyperEdge.SingleEdge[i] = new SchemaToClassesGenerator.SingleEdgeView(); var SingleEdgesProperties = innerVertices[i].Item2.ToArray(); hyperEdge.SingleEdge[i].Properties = new Property[SingleEdgesProperties.Count()]; #region single edge properties for (Int32 j = 0; j < SingleEdgesProperties.Count(); j++) { hyperEdge.SingleEdge[i].Properties[j] = new Property(); hyperEdge.SingleEdge[i].Properties[j].ID = SingleEdgesProperties[j].Item1; if (SingleEdgesProperties[j].Item2 is ICollectionWrapper) { HandleListProperties((ICollectionWrapper)SingleEdgesProperties[j].Item2, ref hyperEdge.SingleEdge[i].Properties[j]); } else { if (SingleEdgesProperties[j].Item2.GetType().IsSubclassOf(typeof(AUserdefinedDataType))) { hyperEdge.SingleEdge[i].Properties[j].Value = ((AUserdefinedDataType)SingleEdgesProperties[j].Item2).Value; } else { hyperEdge.SingleEdge[i].Properties[j].Value = SingleEdgesProperties[j].Item2.ToString(); } hyperEdge.SingleEdge[i].Properties[j].Type = SingleEdgesProperties[j].Item2.GetType().Name; } } #endregion #region target vertex hyperEdge.SingleEdge[i].TargetVertex = new SchemaToClassesGenerator.VertexView(); if (innerVertices[i].Item1.Properties != null) { hyperEdge.SingleEdge[i].TargetVertex.Properties = innerVertices[i].Item1.Properties.ToArray(); } if (innerVertices[i].Item1.BinaryProperties != null) { hyperEdge.SingleEdge[i].TargetVertex.BinaryProperties = innerVertices[i].Item1.BinaryProperties.ToArray(); } if (innerVertices[i].Item1.Edges != null) { hyperEdge.SingleEdge[i].TargetVertex.Edges = innerVertices[i].Item1.Edges.ToArray(); } #endregion } edges.Add(hyperEdge); } else { var SingleEdges = new SchemaToClassesGenerator.SingleEdgeView(); SingleEdges.Name = aEdge.Item1; var edgeProperties = aEdge.Item2.GetAllProperties().ToArray(); #region properties SingleEdges.Properties = new Property[edgeProperties.Count()]; for (Int32 i = 0; i < edgeProperties.Count(); i++) { SingleEdges.Properties[i] = new Property(); SingleEdges.Properties[i].ID = edgeProperties[i].Item1; if (edgeProperties[i].Item2 is ICollectionWrapper) { HandleListProperties((ICollectionWrapper)edgeProperties[i].Item2, ref SingleEdges.Properties[i]); } else { if (edgeProperties[i].Item2.GetType().IsSubclassOf(typeof(AUserdefinedDataType))) { SingleEdges.Properties[i].Value = ((AUserdefinedDataType)edgeProperties[i].Item2).Value; } else { SingleEdges.Properties[i].Value = edgeProperties[i].Item2.ToString(); } SingleEdges.Properties[i].Type = edgeProperties[i].Item2.GetType().Name; } } #endregion #region target vertex SingleEdges.TargetVertex = new SchemaToClassesGenerator.VertexView(); var edgeTargetVertex = ((sones.GraphQL.Result.SingleEdgeView)aEdge.Item2).GetTargetVertex(); var targetVertex = GenerateVertexView(edgeTargetVertex); if (edgeTargetVertex != null) { SingleEdges.TargetVertex.Properties = targetVertex.Properties.ToArray(); SingleEdges.TargetVertex.BinaryProperties = targetVertex.BinaryProperties.ToArray(); SingleEdges.TargetVertex.Edges = targetVertex.Edges.ToArray(); } #endregion edges.Add(SingleEdges); } #endregion } resultVertex.Edges = edges.ToArray(); #endregion } return resultVertex; }
/// <summary> /// Generates an json vertex view. /// </summary> /// <param name="aVertex">The vertex.</param> /// <returns>An jarray contains the json vertex view.</returns> private JArray GenerateVertexViewJSON(IVertexView aVertex) { JArray _results = new JArray(); if (aVertex != null) { // take one IVertexView and traverse through it #region Vertex Properties JObject _properties = new JObject(); foreach (var _property in aVertex.GetAllProperties()) { if (_property.Item2 == null) _properties.Add(new JProperty(_property.Item1, "")); else if (_property.Item2 is Stream) { _properties.Add(new JProperty(_property.Item1, "BinaryProperty")); } else { if (_property.Item2 is ICollectionWrapper) { _properties.Add(new JProperty(_property.Item1, HandleListProperties((ICollectionWrapper)_property.Item2))); } else { _properties.Add(new JProperty(_property.Item1, _property.Item2.ToString())); } } } // add to the results... _results.Add(new JObject(new JProperty("Properties", new JObject(_properties)))); #endregion #region Edges JArray _edges = new JArray(); foreach (var _edge in aVertex.GetAllEdges()) { if (_edge.Item2 == null) { _edges.Add(new JObject(new JProperty(_edge.Item1, ""))); } else { JArray _newEdge = GenerateEdgeViewJSON(_edge.Item2); _edges.Add(new JObject(new JProperty(_edge.Item2.GetType().Name, new JObject(new JProperty(_edge.Item1, _newEdge))))); } } // add to the results... _results.Add(new JObject(new JProperty("Edges", _edges))); #endregion } return _results; }
/// <summary> /// Generates an json vertex view. /// </summary> /// <param name="aVertex">The vertex.</param> /// <returns>An jarray contains the json vertex view.</returns> private JArray GenerateVertexViewJSON(IVertexView aVertex) { JArray _results = new JArray(); if (aVertex != null) { // take one IVertexView and traverse through it #region Vertex Properties JObject _properties = new JObject(); foreach (var _property in aVertex.GetAllProperties()) { if (_property.Item2 == null) { _properties.Add(new JProperty(_property.Item1, "")); } else if (_property.Item2 is Stream) { _properties.Add(new JProperty(_property.Item1, "BinaryProperty")); } else { if (_property.Item2 is ICollectionWrapper) { _properties.Add(new JProperty(_property.Item1, HandleListProperties((ICollectionWrapper)_property.Item2))); } else { _properties.Add(new JProperty(_property.Item1, _property.Item2.ToString())); } } } // add to the results... _results.Add(new JObject(new JProperty("Properties", new JObject(_properties)))); #endregion #region Edges JArray _edges = new JArray(); foreach (var _edge in aVertex.GetAllEdges()) { if (_edge.Item2 == null) { _edges.Add(new JObject(new JProperty(_edge.Item1, ""))); } else { JArray _newEdge = GenerateEdgeViewJSON(_edge.Item2); _edges.Add(new JObject(new JProperty(_edge.Item2.GetType().Name, new JObject(new JProperty(_edge.Item1, _newEdge))))); } } // add to the results... _results.Add(new JObject(new JProperty("Edges", _edges))); #endregion } return(_results); }
private String GenerateVertexViewHTML(IVertexView aVertex) { StringBuilder Output = new StringBuilder(); // take one IVertexView and traverse through it #region Vertex Properties if (aVertex.GetCountOfProperties() > 0) { //Output.Append("<table class=\"gql_table\" border=\"1\"> <!-- VertexProperties -->"); foreach (var _property in aVertex.GetAllProperties()) { if (_property.Item2 == null) Output.Append("<tr><td style=\"width:250px\">").Append(EscapeForXMLandHTML(_property.Item1)).Append("</td><td style=\"width:400px\"></td></tr>"); else if (_property.Item2 is Stream) Output.Append("<tr><td style=\"width:250px\">").Append(EscapeForXMLandHTML(_property.Item1)).Append("</td><td style=\"width:400px\">BinaryProperty</td></tr>"); else Output.Append("<tr><td style=\"width:250px\">").Append(EscapeForXMLandHTML(_property.Item1)).Append("</td><td style=\"width:400px\">").Append(EscapeForXMLandHTML(_property.Item2.ToString())).Append("</td></tr>"); } //Output.Append("</table> <!-- VertexProperties -->"); } #endregion #region Edges Output.Append("<tr><td><td><table class=\"gql_table\"border=\"1\"> <!-- Edges -->"); Output.Append("<tr><td style=\"width:250px\">edges</td><td style=\"width:400px\">"); foreach (var _edge in aVertex.GetAllEdges()) { if (_edge.Item2 == null) { Output.Append("<tr><td style=\"width:250px\">").Append(EscapeForXMLandHTML(_edge.Item1)).Append("</td><td style=\"width:400px\"></td></tr>"); } else { Output.Append("<tr><td style=\"width:250px\">").Append(EscapeForXMLandHTML(_edge.Item1)).Append("</td><td style=\"width:400px\">").Append(GenerateEdgeViewHTML(_edge.Item2)).Append("</td></tr>"); } } Output.Append("</td></td></tr>"); Output.Append("</table> <!-- Edges -->"); // add to the results... //_results.Add(new JObject(new JProperty("edges", _edges))); #endregion return Output.ToString(); }
public bool Equals(IVertexView x, IVertexView y) { if (x.GetCountOfProperties() != y.GetCountOfProperties()) { return(false); } var xProperties = x.GetAllProperties().ToList(); var yProperties = y.GetAllProperties().ToList(); if (xProperties.Count != xProperties.Count) { return(false); } for (int i = 0; i <= xProperties.Count; i++) { if (xProperties[i].PropertyName != yProperties[i].PropertyName) { return(false); } if (!xProperties[i].Property.Equals(yProperties[i].Property)) { return(false); } } var xBinaryProperties = x.GetAllBinaryProperties().ToList(); var yBinaryProperties = y.GetAllBinaryProperties().ToList(); if (xBinaryProperties.Count != yBinaryProperties.Count) { return(false); } for (int i = 0; i <= xBinaryProperties.Count; i++) { if (xBinaryProperties[i].PropertyName != yBinaryProperties[i].PropertyName) { return(false); } if (!xBinaryProperties[i].BinaryPropery.Equals(yBinaryProperties[i].BinaryPropery)) { return(false); } } var xEdges = x.GetAllEdges().ToList(); var yEdges = y.GetAllEdges().ToList(); if (xEdges.Count != yEdges.Count) { return(false); } for (int i = 0; i <= xEdges.Count; i++) { if (xEdges[i].EdgeName != xEdges[i].EdgeName) { return(false); } if (!this.Equals(xEdges[i].Edge, yEdges[i].Edge)) { return(false); } } return(true); }
/// <summary> /// Generates a xml vertex view class. /// </summary> /// <param name="aVertex">The vertex view of the query result.</param> /// <returns>An generated xml class.</returns> private SchemaToClassesGenerator.VertexView GenerateVertexView(IVertexView aVertex) { var resultVertex = new SchemaToClassesGenerator.VertexView(); if (aVertex != null) { #region properties List <Property> properties = new List <Property>(); foreach (var aProperty in aVertex.GetAllProperties()) { var property = new Property(); property.ID = aProperty.PropertyName; if (aProperty.Property != null) { if (aProperty.Property is ICollectionWrapper) { HandleListProperties((ICollectionWrapper)aProperty.Property, ref property); } else { property.Value = aProperty.Property.ToString(); property.Type = aProperty.Property.GetType().Name; } } else { property.Value = String.Empty; property.Type = "null"; } properties.Add(property); } resultVertex.Properties = properties.ToArray(); #endregion #region binaries List <BinaryData> binProperties = new List <BinaryData>(); foreach (var aProperty in aVertex.GetAllBinaryProperties()) { var binProp = new BinaryData(); binProp.ID = aProperty.PropertyName; var content = new byte[aProperty.BinaryPropery.Length]; aProperty.BinaryPropery.Read(content, 0, content.Length); binProp.Content = content; binProperties.Add(binProp); } resultVertex.BinaryProperties = binProperties.ToArray(); #endregion #region edges List <SchemaToClassesGenerator.EdgeView> edges = new List <SchemaToClassesGenerator.EdgeView>(); foreach (var aEdge in aVertex.GetAllEdges()) { if (aEdge.Edge is IHyperEdgeView) { List <Tuple <SchemaToClassesGenerator.VertexView, IEnumerable <PropertyViewContainer> > > innerVertices = new List <Tuple <SchemaToClassesGenerator.VertexView, IEnumerable <PropertyViewContainer> > >(); #region single edges foreach (var SingleEdges in ((sones.GraphQL.Result.HyperEdgeView)aEdge.Edge).GetAllEdges()) { innerVertices.Add(new Tuple <SchemaToClassesGenerator.VertexView, IEnumerable <PropertyViewContainer> >(GenerateVertexView(SingleEdges.GetTargetVertex()), SingleEdges.GetAllProperties())); } #endregion var hyperEdge = new SchemaToClassesGenerator.HyperEdgeView(); hyperEdge.Name = aEdge.EdgeName; #region set hyperedge properties var edgeProperties = aEdge.Edge.GetAllProperties().ToArray(); hyperEdge.Properties = new Property[edgeProperties.Count()]; for (Int32 i = 0; i < edgeProperties.Count(); i++) { hyperEdge.Properties[i] = new Property(); hyperEdge.Properties[i].ID = edgeProperties[i].PropertyName; if (edgeProperties[i].Property is ICollectionWrapper) { HandleListProperties((ICollectionWrapper)edgeProperties[i].Property, ref hyperEdge.Properties[i]); } else { hyperEdge.Properties[i].Type = edgeProperties[i].Property.GetType().Name; hyperEdge.Properties[i].Value = edgeProperties[i].Property.ToString(); } } #endregion hyperEdge.SingleEdge = new SchemaToClassesGenerator.SingleEdgeView[innerVertices.Count]; for (Int32 i = 0; i < innerVertices.Count; i++) { hyperEdge.SingleEdge[i] = new SchemaToClassesGenerator.SingleEdgeView(); var SingleEdgesProperties = innerVertices[i].Item2.ToArray(); hyperEdge.SingleEdge[i].Properties = new Property[SingleEdgesProperties.Count()]; #region single edge properties for (Int32 j = 0; j < SingleEdgesProperties.Count(); j++) { hyperEdge.SingleEdge[i].Properties[j] = new Property(); hyperEdge.SingleEdge[i].Properties[j].ID = SingleEdgesProperties[j].PropertyName; if (SingleEdgesProperties[j].Property is ICollectionWrapper) { HandleListProperties((ICollectionWrapper)SingleEdgesProperties[j].Property, ref hyperEdge.SingleEdge[i].Properties[j]); } else { hyperEdge.SingleEdge[i].Properties[j].Type = SingleEdgesProperties[j].Property.GetType().Name; hyperEdge.SingleEdge[i].Properties[j].Value = SingleEdgesProperties[j].Property.ToString(); } } #endregion #region target vertex hyperEdge.SingleEdge[i].TargetVertex = new SchemaToClassesGenerator.VertexView(); if (innerVertices[i].Item1.Properties != null) { hyperEdge.SingleEdge[i].TargetVertex.Properties = innerVertices[i].Item1.Properties.ToArray(); } if (innerVertices[i].Item1.BinaryProperties != null) { hyperEdge.SingleEdge[i].TargetVertex.BinaryProperties = innerVertices[i].Item1.BinaryProperties.ToArray(); } if (innerVertices[i].Item1.Edges != null) { hyperEdge.SingleEdge[i].TargetVertex.Edges = innerVertices[i].Item1.Edges.ToArray(); } #endregion } edges.Add(hyperEdge); } else { var SingleEdges = new SchemaToClassesGenerator.SingleEdgeView(); SingleEdges.Name = aEdge.EdgeName; var edgeProperties = aEdge.Edge.GetAllProperties().ToArray(); #region properties SingleEdges.Properties = new Property[edgeProperties.Count()]; for (Int32 i = 0; i < edgeProperties.Count(); i++) { SingleEdges.Properties[i] = new Property(); SingleEdges.Properties[i].ID = edgeProperties[i].PropertyName; if (edgeProperties[i].Property is ICollectionWrapper) { HandleListProperties((ICollectionWrapper)edgeProperties[i].Property, ref SingleEdges.Properties[i]); } else { SingleEdges.Properties[i].Type = edgeProperties[i].Property.GetType().Name; SingleEdges.Properties[i].Value = edgeProperties[i].Property.ToString(); } } #endregion #region target vertex SingleEdges.TargetVertex = new SchemaToClassesGenerator.VertexView(); var edgeTargetVertex = ((sones.GraphQL.Result.SingleEdgeView)aEdge.Edge).GetTargetVertex(); var targetVertex = GenerateVertexView(edgeTargetVertex); if (edgeTargetVertex != null) { SingleEdges.TargetVertex.Properties = targetVertex.Properties.ToArray(); SingleEdges.TargetVertex.BinaryProperties = targetVertex.BinaryProperties.ToArray(); SingleEdges.TargetVertex.Edges = targetVertex.Edges.ToArray(); } #endregion edges.Add(SingleEdges); } #endregion } resultVertex.Edges = edges.ToArray(); #endregion } return(resultVertex); }
/// <summary> /// Generates an text vertex view. /// </summary> /// <param name="aVertex">The vertex.</param> /// <param name="Header">The header.</param> /// <returns>An string, that contains the text vertex view.</returns> private String GenerateVertexViewText(String Header, IVertexView aVertex) { StringBuilder Output = new StringBuilder(); // take one IVertexView and traverse through it #region Vertex Properties Output.AppendLine(); if (aVertex.GetCountOfProperties() > 0) { foreach (var _property in aVertex.GetAllProperties()) { if (_property.Item2 == null) { Output.AppendLine(Header + _property.Item1); } else { if (_property.Item2 is Stream) { Output.AppendLine(Header + _property.Item1 + "\t BinaryProperty"); } else { if (_property.Item2 is ICollectionWrapper) { Output.AppendLine(Header + _property.Item1); HandleListProperties((ICollectionWrapper)_property.Item2, Header, ref Output); } else { if (_property.Item2.GetType().IsSubclassOf(typeof(AUserdefinedDataType))) { Output.AppendLine(Header + _property.Item1 + "\t " + ((AUserdefinedDataType)_property.Item2).Value); } else { Output.AppendLine(Header + _property.Item1 + "\t " + _property.Item2.ToString()); } } } } } } #endregion #region Edges Output.AppendLine(Header + "\t Edges:"); foreach (var _edge in aVertex.GetAllEdges()) { if (_edge.Item2 == null) { Output.AppendLine(Header + "\t\t" + _edge.Item1); } else { Output.AppendLine(Header + "\t\t" + _edge.Item2.GetType().Name); Output.AppendLine(Header + "\t\t" + _edge.Item1).Append(GenerateEdgeViewText(Header + "\t\t\t", _edge.Item2)); } } #endregion return(Output.ToString()); }