Пример #1
0
        /// <summary>
        /// Creates a new instance of <see cref="GraphNode"/> using a serialization information.
        /// </summary>
        protected GraphNode(SerializationInfo info, StreamingContext context)
        {
            var objectTree = new JObject();

            foreach (var field in info)
            {
                if (field.Value is JToken)
                {
                    objectTree.Add(field.Name, (JToken)field.Value);
                    continue;
                }
                if (field.Value is IEnumerable <object> )
                {
                    var values = (IEnumerable <object>)field.Value;
                    objectTree.Add(field.Name, new JArray(values.ToArray()));
                    continue;
                }
                objectTree.Add(field.Name, new JValue(field.Value));
            }
            if (objectTree["@type"] != null)
            {
                throw new NotSupportedException(
                          "Deserializing a graph node from JSON is not supported with GraphSON2 or GraphSON3.");
            }
            else
            {
                _node = GraphSON1Node.CreateParsedNode(objectTree);
            }
        }
Пример #2
0
 internal GraphNode(JObject objectTree)
 {
     if (objectTree["@type"] != null)
     {
         throw new NotSupportedException(
                   "Deserializing a graph node from JSON is not supported with GraphSON2 or GraphSON3.");
     }
     else
     {
         _node = GraphSON1Node.CreateParsedNode(objectTree);
     }
 }