Пример #1
0
        private IEvent ConvertJsonToEvent(string eventJson)
        {
            dynamic @event        = JsonConvert.DeserializeObject(eventJson);
            string  eventTypeName = @event.Type;
            Type    eventType;

            if (!EventNameTypeMapping.TryGetEventType(eventTypeName, out eventType))
            {
                throw new Exception("unknow event type");
            }

            var convertEvent = JsonConvert.DeserializeObject(eventJson, eventType) as IEvent;

            return(convertEvent);
        }
        public EventSourcingGrain()
        {
            var assembly = this.GetType().Assembly;

            if (!registerAssembly.Contains(assembly.FullName))
            {
                lock (lockObj)
                {
                    if (!registerAssembly.Contains(assembly.FullName))
                    {
                        GrainInternalEventHandlerProvider.RegisterInternalEventHandler(assembly);
                        EventNameTypeMapping.RegisterEventType(assembly);
                        registerAssembly.Add(assembly.FullName);
                    }
                }
            }
        }