Esempio n. 1
0
        /// <summary>
        ///
        /// </summary>
        /// <param name="operaCommand"></param>
        /// <param name="jsonSerializer"></param>
        /// <returns></returns>
        public static CommandStreamMessage ConvertTo(IOperateCommand operaCommand, Serialization.IJsonSerializer jsonSerializer)
        {
            var type    = operaCommand.Command.GetType();
            var message = new CommandStreamMessage()
            {
                AppDomain       = operaCommand.AppDomain,
                CreateDate      = operaCommand.CreateDate,
                Creator         = operaCommand.Creator,
                CommandContent  = jsonSerializer.SerializeObject(operaCommand.Command),
                CommandName     = type.Name,
                CommandType     = Regex.Replace(type.AssemblyQualifiedName, "version=(.*?),", "", RegexOptions.IgnoreCase),
                HashCode        = operaCommand.HashCode,
                Increment       = operaCommand.Increment,
                AggregateId     = operaCommand.AggregateId,
                AggregateIdType = Regex.Replace(operaCommand.AggregateIdType.AssemblyQualifiedName, "version=(.*?),", "", RegexOptions.IgnoreCase),
                Version         = operaCommand.Version,
            };

            return(message);
        }
Esempio n. 2
0
        /// <summary>
        ///
        /// </summary>
        /// <param name="operaEvent"></param>
        /// <param name="jsonSerializer"></param>
        /// <returns></returns>
        public static EventStreamMessage ConvertTo(IOperateEvent operaEvent, Serialization.IJsonSerializer jsonSerializer)
        {
            var type    = operaEvent.Event.GetType();
            var message = new EventStreamMessage()
            {
                AggregateType   = operaEvent.AggregateType.FullName,
                AppDomain       = operaEvent.AppDomain,
                CreateDate      = operaEvent.CreateDate,
                Creator         = operaEvent.Creator,
                EventContent    = jsonSerializer.SerializeObject(operaEvent.Event),
                EventName       = type.Name,
                EventType       = Regex.Replace(type.AssemblyQualifiedName, "version=(.*?),", "", RegexOptions.IgnoreCase),
                HashCode        = operaEvent.HashCode,
                Increment       = operaEvent.Increment,
                AggregateId     = operaEvent.AggregateId,
                AggregateIdType = Regex.Replace(operaEvent.AggregateIdType.AssemblyQualifiedName, "version=(.*?),", "", RegexOptions.IgnoreCase),
                Version         = operaEvent.Version,
            };

            return(message);
        }