Exemplo n.º 1
0
        private Representation GetRepresentation(object r)
        {
            if (r == null)
            {
                return(ValueRepresentation.String(null));
            }

            if (r is Path)
            {
                return(new PathRepresentation <>(( Path )r));
            }

            if (r is System.Collections.IEnumerable)
            {
                return(HandleIterable((System.Collections.IEnumerable)r));
            }

            if (r is Node)
            {
                return(new NodeRepresentation(( Node )r));
            }

            if (r is Relationship)
            {
                return(new RelationshipRepresentation(( Relationship )r));
            }

            return(_representationDispatcher.dispatch(r, ""));
        }
Exemplo n.º 2
0
//JAVA TO C# CONVERTER TODO TASK: Most Java annotations will not have direct .NET equivalent attributes:
//ORIGINAL LINE: @Test public void canProvideJsonOutputFormat()
        public virtual void CanProvideJsonOutputFormat()
        {
            OutputFormat format = _repository.outputFormat(new IList <MediaType> {
                MediaType.APPLICATION_JSON_TYPE
            }, null, null);

            assertNotNull(format);
            assertEquals("\"test\"", format.Assemble(ValueRepresentation.String("test")));
        }
Exemplo n.º 3
0
 internal static Representation GetSingleRepresentation(object result)
 {
     if (result == null)
     {
         return(ValueRepresentation.OfNull());
     }
     else if (result is GraphDatabaseService)
     {
         return(new DatabaseRepresentation());
     }
     else if (result is Node)
     {
         return(new NodeRepresentation(( Node )result));
     }
     else if (result is Relationship)
     {
         return(new RelationshipRepresentation(( Relationship )result));
     }
     else if (result is double? || result is float?)
     {
         return(ValueRepresentation.number((( Number )result).doubleValue()));
     }
     else if (result is long?)
     {
         return(ValueRepresentation.number((( long? )result).Value));
     }
     else if (result is int?)
     {
         return(ValueRepresentation.number((( int? )result).Value));
     }
     else if (result is bool?)
     {
         return(ValueRepresentation.Bool((( bool? )result).Value));
     }
     else
     {
         return(ValueRepresentation.String(result.ToString()));
     }
 }
Exemplo n.º 4
0
 protected internal override Representation underlyingObjectToObject(string directionString)
 {
     return(ValueRepresentation.String(directionString));
 }
Exemplo n.º 5
0
 public virtual ValueRepresentation User()
 {
     return(ValueRepresentation.String(_user.name()));
 }
Exemplo n.º 6
0
        protected internal override void Serialize(MappingSerializer serializer)
        {
            if (_indexDefinition.NodeIndex)
            {
                serializer.PutList("labels", new ListRepresentation(RepresentationType.String, map(label => ValueRepresentation.String(label.name()), _indexDefinition.Labels)));
                if (!_indexDefinition.MultiTokenIndex)
                {
                    serializer.PutString("label", single(_indexDefinition.Labels).name());
                }
            }
            else
            {
                serializer.PutList("relationshipTypes", new ListRepresentation(RepresentationType.String, map(relType => ValueRepresentation.String(relType.name()), _indexDefinition.RelationshipTypes)));
                if (!_indexDefinition.MultiTokenIndex)
                {
                    serializer.PutString("relationshipType", single(_indexDefinition.RelationshipTypes).name());
                }
            }

            System.Func <string, Representation> converter = ValueRepresentation.@string;
            IEnumerable <Representation>         propertyKeyRepresentations = map(converter, _indexDefinition.PropertyKeys);

            serializer.PutList("property_keys", new ListRepresentation(RepresentationType.String, propertyKeyRepresentations));
            // Only print state and progress if progress is a valid value and not yet online
            if (_indexState == Org.Neo4j.Graphdb.schema.Schema_IndexState.Populating)
            {
                serializer.PutString("state", _indexState.name());
                serializer.PutString("population_progress", string.Format("{0,1:F0}%", _indexPopulationProgress.CompletedPercentage));
            }
        }
Exemplo n.º 7
0
 public ValueRepresentation ExtendedEntity()
 {
     return(ValueRepresentation.String(ExtendedEntity));
 }
Exemplo n.º 8
0
 public ValueRepresentation Description()
 {
     return(ValueRepresentation.String(_description));
 }
Exemplo n.º 9
0
 public ValueRepresentation MethodName()
 {
     return(ValueRepresentation.String(_name));
 }