/// <summary>
        /// Deserializes to versioned message.
        /// </summary>
        /// <param name="serialized">The serialized.</param>
        /// <param name="dtoVersion">The dto version.</param>
        /// <param name="serializerType">Type of the serializer.</param>
        /// <returns>The <see cref="VersionedMessage"/>.</returns>
        public static VersionedMessage DeserializeToVersionedMessage(
            this string serialized,
            DtoVersion dtoVersion,
            SerializerType serializerType = SerializerType.ProtocolBuffers)
        {
            var rtn = serialized.Deserialize <VersionedMessage>(serializerType);

            rtn.Version = dtoVersion;
            return(rtn);
        }
예제 #2
0
        public DtoVersion GetAllVersionInfo()
        {
            var versionDto = new DtoVersion();
            var dbversions = _uow.VersionRepository.GetById(1);

            versionDto.DatabaseVersion = dbversions.DatabaseVersion;
            var versionMapping = new VersionMapping().Get();

            versionDto.TargetDbVersion = versionMapping[SettingStrings.GlobalVersion];
            return(versionDto);
        }
        /// <summary>
        /// Serializes to versioned message.
        /// </summary>
        /// <typeparam name="TEntity">The type of the entity.</typeparam>
        /// <param name="entity">The entity.</param>
        /// <param name="dtoVersion">The dto version.</param>
        /// <param name="serializerType">Type of the serializer.</param>
        /// <returns>The <see cref="VersionedMessage"/>.</returns>
        public static VersionedMessage SerializeToVersionedMessage <TEntity>(
            this TEntity entity,
            DtoVersion dtoVersion,
            SerializerType serializerType = SerializerType.ProtocolBuffers)
            where TEntity : class
        {
            var data = entity.SerializeToString(serializerType);

            return(new VersionedMessage
            {
                Data = data,
                Version = dtoVersion,
            });
        }