Exemplo n.º 1
0
        public string GenerateOutputResult(IQueryResult myQueryResult, Dictionary <String, String> myParams)
        {
            var result = new SchemaToClassesGenerator.Result();

            result.Version = IOInterfaceCompatibility.MaxVersion.ToString();

            result.Query = new Query()
            {
                Duration = myQueryResult.Duration, ResultType = Enum.GetName(typeof(ResultType), myQueryResult.TypeOfResult), Language = myQueryResult.NameOfQuerylanguage, Value = myQueryResult.Query, VerticesCount = myQueryResult.Vertices.LongCount(), Error = myQueryResult.Error == null ? null : HandleQueryExceptions(myQueryResult)
            };

            List <SchemaToClassesGenerator.VertexView> vertices = new List <SchemaToClassesGenerator.VertexView>();

            foreach (var aVertex in myQueryResult.Vertices)
            {
                vertices.Add(GenerateVertexView(aVertex));
            }

            result.VertexViews = vertices.ToArray();

            var stream = new MemoryStream();

            var writer = new System.Xml.Serialization.XmlSerializer(result.GetType());

            writer.Serialize(stream, result);

            return(System.Text.Encoding.UTF8.GetString(stream.ToArray()));
        }
Exemplo n.º 2
0
        public string GenerateOutputResult(IQueryResult myQueryResult, Dictionary<String, String> myParams)
        {
            var result = new SchemaToClassesGenerator.Result();

            result.Version = IOInterfaceCompatibility.MaxVersion.ToString();

            result.Query = new Query() { Duration = myQueryResult.Duration, ResultType = Enum.GetName(typeof(ResultType), myQueryResult.TypeOfResult), Language = myQueryResult.NameOfQuerylanguage, Value = myQueryResult.Query, VerticesCount = myQueryResult.Vertices.LongCount(), Error = myQueryResult.Error == null ? null : HandleQueryExceptions(myQueryResult) };

            List<SchemaToClassesGenerator.VertexView> vertices = new List<SchemaToClassesGenerator.VertexView>();

            foreach (var aVertex in myQueryResult.Vertices)
            {
                vertices.Add(GenerateVertexView(aVertex));
            }

            result.VertexViews = vertices.ToArray();
            
            var stream = new MemoryStream();

            var writer = new System.Xml.Serialization.XmlSerializer(result.GetType());
            writer.Serialize(stream, result);

            return System.Text.Encoding.UTF8.GetString(stream.ToArray());
        }