/// <summary> /// Formats the specified data token. /// </summary> /// <param name="dataToken">The data token.</param> /// <returns>The token in serialized form.</returns> protected override string Format(PrimitiveToken dataToken) { var dict = new Dictionary<string, string> { {"name", dataToken.Name}, {"id", dataToken.Id.ToString()}}; return CreateNode(typeCache[dataToken.TypeId], dict, ((XmlString)dataToken.SerialData).Data); }
private void PrimitiveHandler(PrimitiveToken token) { Type type = typeIds[(int)token.TypeId]; try { object value = ((IPrimitiveSerializer)serializerMapping[type]).Parse(token.SerialData); if (token.Id != null) id2obj[(int)token.Id] = value; SetValue(token.Name, value); } catch (Exception e) { if (e is InvalidCastException || e is KeyNotFoundException) { throw new PersistenceException(String.Format( "Invalid primitive serializer configuration for type \"{0}\".", type.AssemblyQualifiedName), e); } else { throw new PersistenceException(String.Format( "Unexpected exception while trying to parse object of type \"{0}\".", type.AssemblyQualifiedName), e); } } }