コード例 #1
0
ファイル: XML_IO.cs プロジェクト: alrehamy/sones
        /// <summary>
        /// Parsing an edge.
        /// </summary>
        /// <param name="myEdge">The current XML node.</param>
        /// <returns>An tuple with the edge name and the edge view.</returns>
        private Tuple <String, IEdgeView> ParseEdge(XmlNode myEdge)
        {
            IEdgeView  edgeView     = null;
            var        edgeProps    = new Dictionary <String, Object>();
            var        singleEdges  = new List <ISingleEdgeView>();
            var        edge         = myEdge.FirstChild;
            var        name         = String.Empty;
            VertexView targetVertex = null;
            Boolean    isHyperEdge  = false;

            isHyperEdge = myEdge.Attributes["xsi:type"].Value == "HyperEdgeView";


            if (edge.HasChildNodes)
            {
                while (edge != null)
                {
                    if (edge.HasChildNodes)
                    {
                        switch (edge.Name)
                        {
                        case "Name":
                            name = edge.InnerText;
                            break;

                        case "Properties":
                            ParseEdgeProperties(edge.FirstChild, ref edgeProps);
                            break;

                        case "SingleEdge":
                            singleEdges.Add(ParseSingleEdge(edge));
                            break;

                        case "TargetVertex":
                            targetVertex = ParseVertex(edge);
                            break;
                        }
                    }

                    edge = edge.NextSibling;
                }
            }

            if (isHyperEdge)
            {
                edgeView = new sones.GraphQL.Result.HyperEdgeView(edgeProps, singleEdges);
            }
            else
            {
                edgeView = new sones.GraphQL.Result.SingleEdgeView(edgeProps, targetVertex);
            }

            return(new Tuple <string, IEdgeView>(name, edgeView));
        }
コード例 #2
0
        private String GenerateEdgeViewHTML(IEdgeView aEdge)
        {
            StringBuilder Output = new StringBuilder();

            Output.Append("<table class=\"gql_table\"border=\"1\"> <!-- EdgeView -->");

            #region Edge Properties
            if (aEdge.GetCountOfProperties() > 0)
            {
                Output.Append("<tr><td style=\"width:250px\">properties</td><td style=\"width:400px\">");
                Output.Append("<table class=\"gql_table\"border=\"1\"><tr><td style=\"width:400px\"> <!-- EdgeViewProperties -->");

                foreach (var _property in aEdge.GetAllProperties())
                {
                    if (_property.Item2 == null)
                    {
                        Output.Append(EscapeForXMLandHTML(_property.Item1)).Append("</td><td style=\"width:400px\"></td></tr>");
                    }
                    else
                    if (_property.Item2 is Stream)
                    {
                        Output.Append(EscapeForXMLandHTML(_property.Item1)).Append("</td><td style=\"width:400px\">BinaryProperty</td></tr>");
                    }
                    else
                    {
                        Output.Append(EscapeForXMLandHTML(_property.Item1)).Append("</td><td style=\"width:400px\">").Append(EscapeForXMLandHTML(_property.Item2.ToString())).Append("</td></tr>");
                    }
                }

                Output.Append("</table></td></tr> <!-- EdgeViewProperties -->");
            }
            #endregion


            #region Target Vertices
            Output.Append("<tr><td style=\"width:250px\">targetvertices</td><td style=\"width:400px\">");
            Output.Append("<table class=\"gql_table\"border=\"1\"><tr><td style=\"width:400px\"> <!-- TargetVertices -->");

            foreach (IVertexView _vertex in aEdge.GetTargetVertices())
            {
                Output.Append("<table class=\"gql_table\" border=\"1\"> <!-- Vertices-2 -->");
                Output.Append(GenerateVertexViewHTML(_vertex));
                Output.Append("</table> <!-- Vertices-2 -->");
            }

            Output.Append("</td></table> <!-- TargetVertices -->");

            Output.Append("</table></td></tr> <!-- EdgesView -->");

            return(Output.ToString());

            #endregion
        }
コード例 #3
0
ファイル: QueryResultComparer.cs プロジェクト: alrehamy/sones
        public bool Equals(IEdgeView x, IEdgeView y)
        {
            if (x.GetCountOfProperties() != y.GetCountOfProperties())
            {
                return(false);
            }

            var xProperties = x.GetAllProperties().ToList();
            var yProperties = y.GetAllProperties().ToList();

            if (xProperties.Count != yProperties.Count)
            {
                return(false);
            }

            for (int i = 0; i <= xProperties.Count; i++)
            {
                if (xProperties[i].PropertyName != xProperties[i].PropertyName)
                {
                    return(false);
                }

                if (!xProperties[i].Property.Equals(xProperties[i].Property))
                {
                    return(false);
                }
            }

            var xTargetVertices = x.GetTargetVertices().ToList();
            var yTargetVertices = y.GetTargetVertices().ToList();

            if (xTargetVertices.Count != xTargetVertices.Count)
            {
                return(false);
            }


            for (int i = 0; i <= xTargetVertices.Count; i++)
            {
                if (!this.Equals(xTargetVertices[i], xTargetVertices[i]))
                {
                    return(false);
                }
            }


            return(true);
        }
コード例 #4
0
ファイル: TEXT_IO.cs プロジェクト: anukat2015/sones
        /// <summary>
        /// Generates an text edge view.
        /// </summary>
        /// <param name="aEdge">The edge.</param>
        /// <param name="Header">The header.</param>
        /// <returns>An string that contains the text edge view.</returns>       
        private String GenerateEdgeViewText(String Header, IEdgeView aEdge)
        {
            StringBuilder Output = new StringBuilder();

            #region Edge Properties

            Output.AppendLine(Header + "\t Edge");

            Output.AppendLine(Header + "\t Properties");

            if (aEdge.GetCountOfProperties() > 0)
            {
                foreach (var _property in aEdge.GetAllProperties())
                {
                    if (_property.Item2 == null)
                    {
                        Output.AppendLine(Header + "\t\t" + _property.Item1);
                    }
                    else
                    {
                        if (_property.Item2 is Stream)
                        {
                            Output.AppendLine(Header + "\t\t" + _property.Item1 + "\t BinaryProperty");
                        }
                        else
                        {
                            if (_property.Item2 is ICollectionWrapper)
                            {
                                var prefix = Header + "\t\t";
                                Output.AppendLine(prefix + _property.Item1 + "\t");

                                HandleListProperties((ICollectionWrapper)_property.Item2, prefix, ref Output);
                            }
                            else
                            {
                                Output.AppendLine(Header + "\t\t" + _property.Item1 + "\t " + _property.Item2.ToString());
                            }
                        }
                    }
                }
            }

            #endregion

            if (aEdge is IHyperEdgeView)
            {
                foreach (var singleEdge in ((IHyperEdgeView)aEdge).GetAllEdges())
                {
                    Output.AppendLine(Header + "\t SingleEdge");
                    Output.AppendLine(Header + "\t\t\tProperties");
                    foreach (var _property in singleEdge.GetAllProperties())
                    {
                        if (_property.Item2 == null)
                        {
                            Output.AppendLine(Header + "\t\t\t\t " + _property.Item1);
                        }
                        else
                        {
                            if (_property.Item2 is Stream)
                            {
                                Output.AppendLine(Header + "\t\t\t\t " + _property.Item1 + "\t\t\t BinaryProperty");
                            }
                            else
                            {
                                if (_property.Item2 is ICollectionWrapper)
                                {
                                    var prefix = Header + "\t\t";

                                    Output.AppendLine(Header + "\t\t\t\t " + _property.Item1);

                                    HandleListProperties((ICollectionWrapper)_property.Item2, prefix + "\t\t\t\t", ref Output);
                                }
                                else
                                {
                                    Output.AppendLine(Header + "\t\t\t\t " + _property.Item1 + "\t\t " + _property.Item2.ToString());
                                }
                            }
                        }
                    }

                    if (singleEdge.GetTargetVertex() != null)
                    {
                        Output.AppendLine(Header + "\t\t\tTargetVertex");
                        Output.Append(GenerateVertexViewText(Header + "\t\t\t", singleEdge.GetTargetVertex()));
                    }
                }
            }
            else
            {
                if (((ISingleEdgeView)aEdge).GetTargetVertex() != null)
                {
                    Output.AppendLine(Header + "\t\t\t\tTargetVertex");
                    Output.Append(GenerateVertexViewText(Header + "\t\t\t", ((ISingleEdgeView)aEdge).GetTargetVertex()));
                }

            }

            return Output.ToString();
        }
コード例 #5
0
        /// <summary>
        /// Generates an text edge view.
        /// </summary>
        /// <param name="aEdge">The edge.</param>
        /// <param name="Header">The header.</param>
        /// <returns>An string that contains the text edge view.</returns>
        private String GenerateEdgeViewText(String Header, IEdgeView aEdge)
        {
            StringBuilder Output = new StringBuilder();

            #region Edge Properties

            Output.AppendLine(Header + "\t Edge");

            Output.AppendLine(Header + "\t Properties");

            if (aEdge.GetCountOfProperties() > 0)
            {
                foreach (var _property in aEdge.GetAllProperties())
                {
                    if (_property.Property == null)
                    {
                        Output.AppendLine(Header + "\t\t" + _property.Property);
                    }
                    else
                    {
                        if (_property.Property is Stream)
                        {
                            Output.AppendLine(Header + "\t\t" + _property.Property + "\t BinaryProperty");
                        }
                        else
                        {
                            if (_property.Property is ICollectionWrapper)
                            {
                                var prefix = Header + "\t\t";
                                Output.AppendLine(prefix + _property.Property + "\t");

                                HandleListProperties((ICollectionWrapper)_property.Property, prefix, ref Output);
                            }
                            else
                            {
                                Output.AppendLine(Header + "\t\t" + _property.Property + "\t " + _property.Property.ToString());
                            }
                        }
                    }
                }
            }

            #endregion

            if (aEdge is IHyperEdgeView)
            {
                foreach (var singleEdge in ((IHyperEdgeView)aEdge).GetAllEdges())
                {
                    Output.AppendLine(Header + "\t SingleEdge");
                    Output.AppendLine(Header + "\t\t\tProperties");
                    foreach (var _property in singleEdge.GetAllProperties())
                    {
                        if (_property.Property == null)
                        {
                            Output.AppendLine(Header + "\t\t\t\t " + _property.PropertyName);
                        }
                        else
                        {
                            if (_property.Property is Stream)
                            {
                                Output.AppendLine(Header + "\t\t\t\t " + _property.PropertyName + "\t\t\t BinaryProperty");
                            }
                            else
                            {
                                if (_property.Property is ICollectionWrapper)
                                {
                                    var prefix = Header + "\t\t";

                                    Output.AppendLine(Header + "\t\t\t\t " + _property.PropertyName);

                                    HandleListProperties((ICollectionWrapper)_property.Property, prefix + "\t\t\t\t", ref Output);
                                }
                                else
                                {
                                    Output.AppendLine(Header + "\t\t\t\t " + _property.PropertyName + "\t\t " + _property.Property.ToString());
                                }
                            }
                        }
                    }

                    if (singleEdge.GetTargetVertex() != null)
                    {
                        Output.AppendLine(Header + "\t\t\tTargetVertex");
                        Output.Append(GenerateVertexViewText(Header + "\t\t\t", singleEdge.GetTargetVertex()));
                    }
                }
            }
            else
            {
                if (((ISingleEdgeView)aEdge).GetTargetVertex() != null)
                {
                    Output.AppendLine(Header + "\t\t\t\tTargetVertex");
                    Output.Append(GenerateVertexViewText(Header + "\t\t\t", ((ISingleEdgeView)aEdge).GetTargetVertex()));
                }
            }

            return(Output.ToString());
        }
コード例 #6
0
ファイル: JSON_IO.cs プロジェクト: loubo/sones
        /// <summary>
        /// Generates an json edge view.
        /// </summary>
        /// <param name="aEdge">The edge.</param>
        /// <returns>An jarray contains the json edge view.</returns>
        private JArray GenerateEdgeViewJSON(IEdgeView aEdge)
        {
            JArray Output = new JArray();

            #region Edge Properties

            foreach (var _property in aEdge.GetAllProperties())
            {
                JProperty _newEdge = null;

                if (_property.Item2 == null)
                {
                    _newEdge = new JProperty(_property.Item1, "");
                }
                else
                {
                    if (_property.Item2 is Stream)
                    {
                        _newEdge = new JProperty(_property.Item1, "BinaryProperty");
                    }
                    else
                    {
                        if (_property.Item2 is ICollectionWrapper)
                        {
                            _newEdge = new JProperty(_property.Item1, HandleListProperties((ICollectionWrapper)_property.Item2));
                        }
                        else
                        {
                            _newEdge = new JProperty(_property.Item1, _property.Item2.ToString());
                        }
                    }
                }

                Output.Add(new JObject(new JProperty("Properties", new JObject(_newEdge))));
            }
            #endregion

            if (aEdge is IHyperEdgeView)
            {
                var edgeProperties = new JArray();

                foreach (var singleEdge in ((IHyperEdgeView)aEdge).GetAllEdges())
                {
                    foreach (var singleEdgeProp in singleEdge.GetAllProperties())
                    {
                        if (singleEdgeProp.Item2 is ICollectionWrapper)
                        {
                            edgeProperties.Add(new JObject(new JProperty(singleEdgeProp.Item1, HandleListProperties((ICollectionWrapper)singleEdgeProp.Item2))));
                        }
                        else
                        {
                            edgeProperties.Add(new JObject(new JProperty(singleEdgeProp.Item1, singleEdgeProp.Item2.ToString())));
                        }
                    }

                    Output.Add(new JObject(new JProperty("SingleEdge", new JObject(new JProperty("Properties", new JArray(edgeProperties))), new JObject(new JProperty("TargetVertex", GenerateVertexViewJSON(singleEdge.GetTargetVertex()))))));

                    edgeProperties.Clear();
                }

            }
            else
            {
                Output.Add(new JObject(new JProperty("TargetVertex", GenerateVertexViewJSON(((ISingleEdgeView)aEdge).GetTargetVertex()))));
            }

            return Output;
        }
コード例 #7
0
ファイル: JSON_IO.cs プロジェクト: zhouweiaccp/sones
        /// <summary>
        /// Generates an json edge view.
        /// </summary>
        /// <param name="aEdge">The edge.</param>
        /// <returns>An jarray contains the json edge view.</returns>
        private JArray GenerateEdgeViewJSON(IEdgeView aEdge)
        {
            JArray Output = new JArray();

            #region Edge Properties

            JObject _properties = new JObject();

            foreach (var _property in aEdge.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()));
                        }
                    }
                }
            }

            Output.Add(new JObject(new JProperty("Properties", new JObject(_properties))));

            #endregion

            if (aEdge is IHyperEdgeView)
            {
                var edgeProperties = new JArray();

                foreach (var singleEdge in ((IHyperEdgeView)aEdge).GetAllEdges())
                {
                    JObject _singleEdgeProperties = new JObject();

                    foreach (var singleEdgeProp in singleEdge.GetAllProperties())
                    {
                        if (singleEdgeProp.Item2 is ICollectionWrapper)
                        {
                            _singleEdgeProperties.Add(new JProperty(singleEdgeProp.Item1, HandleListProperties((ICollectionWrapper)singleEdgeProp.Item2)));
                            //edgeProperties.Add(new JObject(new JProperty(singleEdgeProp.Item1, HandleListProperties((ICollectionWrapper)singleEdgeProp.Item2))));
                        }
                        else
                        {
                            _singleEdgeProperties.Add(new JProperty(singleEdgeProp.Item1, singleEdgeProp.Item2.ToString()));
                            //edgeProperties.Add(new JObject(new JProperty(singleEdgeProp.Item1, singleEdgeProp.Item2.ToString())));
                        }
                    }

                    //Output.Add(new JObject(new JProperty("SingleEdge", new JObject(new JProperty("Properties", new JArray(edgeProperties))), new JObject(new JProperty("TargetVertex", GenerateVertexViewJSON(singleEdge.GetTargetVertex()))))));
                    Output.Add(new JObject(new JProperty("SingleEdge", new JObject(new JProperty("Properties", new JObject(_singleEdgeProperties))), new JObject(new JProperty("TargetVertex", GenerateVertexViewJSON(singleEdge.GetTargetVertex()))))));
                    edgeProperties.Clear();
                }
            }
            else
            {
                Output.Add(new JObject(new JProperty("TargetVertex", GenerateVertexViewJSON(((ISingleEdgeView)aEdge).GetTargetVertex()))));
            }

            return(Output);
        }
コード例 #8
0
ファイル: HTML_IO.cs プロジェクト: ramz/sones
        private String GenerateEdgeViewHTML(IEdgeView aEdge)
        {
            StringBuilder Output = new StringBuilder();
            Output.Append("<table class=\"gql_table\"border=\"1\"> <!-- EdgeView -->");

            #region Edge Properties
            if (aEdge.GetCountOfProperties() > 0)
            {
                Output.Append("<tr><td style=\"width:250px\">properties</td><td style=\"width:400px\">");
                Output.Append("<table class=\"gql_table\"border=\"1\"><tr><td style=\"width:400px\"> <!-- EdgeViewProperties -->");

                foreach (var _property in aEdge.GetAllProperties())
                {
                    if (_property.Item2 == null)
                        Output.Append(EscapeForXMLandHTML(_property.Item1)).Append("</td><td style=\"width:400px\"></td></tr>");
                    else
                        if (_property.Item2 is Stream)
                        {
                            Output.Append(EscapeForXMLandHTML(_property.Item1)).Append("</td><td style=\"width:400px\">BinaryProperty</td></tr>");
                        }
                        else
                            Output.Append(EscapeForXMLandHTML(_property.Item1)).Append("</td><td style=\"width:400px\">").Append(EscapeForXMLandHTML(_property.Item2.ToString())).Append("</td></tr>");
                }

                Output.Append("</table></td></tr> <!-- EdgeViewProperties -->");
            }
            #endregion

            #region Target Vertices
            Output.Append("<tr><td style=\"width:250px\">targetvertices</td><td style=\"width:400px\">");
            Output.Append("<table class=\"gql_table\"border=\"1\"><tr><td style=\"width:400px\"> <!-- TargetVertices -->");

            foreach (IVertexView _vertex in aEdge.GetTargetVertices())
            {
                Output.Append("<table class=\"gql_table\" border=\"1\"> <!-- Vertices-2 -->");
                Output.Append(GenerateVertexViewHTML(_vertex));
                Output.Append("</table> <!-- Vertices-2 -->");
            }

            Output.Append("</td></table> <!-- TargetVertices -->");

            Output.Append("</table></td></tr> <!-- EdgesView -->");

            return Output.ToString();
            #endregion
        }
コード例 #9
0
ファイル: QueryResultComparer.cs プロジェクト: alrehamy/sones
 public int GetHashCode(IEdgeView obj)
 {
     throw new NotImplementedException();
 }