EventConverter

Namespace: Stripe.net
We found 10 examples in language CSharp for this search. You will see 36 fragments of code.
        [HttpPost]
        public EventDTO Create(EventDTO dto)
        {
            var _event = new Facade().GetEventManager().Create(new EventConverter().ConvertDTO(dto));
            return new EventConverter().ConvertModel(_event);
        }

        [HttpGet]
        public IEnumerable<EventDTO> ReadAll()
        {
            return new EventConverter().ConvertListToDTO(new Facade().GetEventManager().ReadAll());
        }

        [HttpGet]
        public EventDTO ReadById(int id)
        {
            return new EventConverter().ConvertModel(new Facade().GetEventManager().ReadByID(id));
        }

        [HttpPut]
        public EventDTO Update(int id, EventDTO dto)
        {
            dto.Id = id;
            var _event = new Facade().GetEventManager().Update(new EventConverter().ConvertDTO(dto));
            return new EventConverter().ConvertModel(_event);
        }

        [HttpGet]
        public IEnumerable<EventDTO> ReadByMonth(DateTime month)
        {
            return new EventConverter().ConvertListToDTO(new Facade().GetEventManager().ReadByMonth(month));
        }

        [TestMethod]
        public void sut_implements_IEventConverter()
        {
            typeof(EventConverter).Should().Implement<IEventConverter>();
        }

        [TestMethod, AutoData]
        public void ConvertToEvent_sets_id_correctly(
            string id,
            string processId,
            string initiator,
            string predecessorId,
            MessageData1 data,
            EventConverter sut)
        {
            var message = new Message(id, processId, initiator, predecessorId, data);
            EventData actual = sut.ConvertToEvent(message);
            actual.MessageId.Should().Be(id);
        }

        [TestMethod, AutoData]
        public void TryConvertToMessage_sets_id_correctly(
            Message message, EventConverter sut)
        {
            EventData eventData = sut.ConvertToEvent(message);
            Message actual = sut.TryConvertToMessage(eventData);
            actual.Id.Should().Be(message.Id);
        }

        [TestMethod, AutoData]
        public void TryConvertToMessage_sets_tracing_properties_correctly(
            Message message, EventConverter sut)
        {
            EventData eventData = sut.ConvertToEvent(message);

            Message actual = sut.TryConvertToMessage(eventData);

            actual.ProcessId.Should().Be(message.ProcessId);
            actual.Initiator.Should().Be(message.Initiator);
            actual.PredecessorId.Should().Be(message.PredecessorId);
        }

        [TestMethod, AutoData]
        public void given_no_type_property_then_TryConvertToMessage_returns_null(
            Message message, EventConverter sut)
        {
            EventData eventData = sut.ConvertToEvent(message);
            eventData.Properties.Remove("Type");

            Message actual = sut.TryConvertToMessage(eventData);

            actual.Should().BeNull();
        }

        [TestMethod]
        [InlineAutoData(true)]
        [InlineAutoData(1)]
        public void given_non_string_type_property_then_TryConvertToMessage_returns_null(
            object value, Message message, EventConverter sut)
        {
            EventData eventData = sut.ConvertToEvent(message);
            eventData.Properties["Type"] = value;

            Message actual = sut.TryConvertToMessage(eventData);

            actual.Should().BeNull();
        }

namespace truename.Effects;

public delegate GameEvent EventConverter(Game game, GameEvent @event);
public class ReplacementEffect : ContinuousEffect
{
  public GameCondition AppliesTo { get; private set; } = (game, @event) => false;
  public EventConverter CreateReplacement { get; private set; }

  public ReplacementEffect(GameCondition applies, EventConverter @event)
    : this(applies, applies, @event) { }

  public ReplacementEffect(GameCondition applies, GameCondition isExpired, EventConverter @event)
    : base(isExpired)
  {
    this.AppliesTo = applies;
    this.CreateReplacement = @event;
  }
}


        /// <summary>Registers a converter that lasts until the disposable is disposed</summary>
        /// <remarks>Warning: Mapping the same event to itself will cause an infinite recursive subscription</remarks>
        public static IDisposable Convert<TEventIn, TEventOut>(Func<TEventIn, TEventOut> eventConverter)
        {
            return eventAggregator.Convert<TEventIn, TEventOut>(eventConverter);
        }

        /// <summary>Registers a converter that lasts until the disposable is disposed</summary>
        /// <remarks>Warning: Mapping the same event to itself will cause an infinite recursive subscription</remarks>
        public static IDisposable Convert<TEventIn, TEventOut>(Func<TEventIn, TEventOut> eventConverter, Func<TEventIn, bool> predicate)
        {
            return eventAggregator.Convert<TEventIn, TEventOut>(eventConverter, predicate);
        }


        [Fact]
        public void Ctor()
        {
           var converter = new EventConverter(_typeResolver);
        }

        [Fact]
        public void Ctor_typeResolver_null()
        {
            var ex = Assert.Throws<ArgumentNullException>(() => new EventConverter(null));
            ex.ParamName.Should().Be("typeResolver");
        }

        [Fact]
        public void Upgrade_unknown_event()
        {
            var converter = new EventConverter(_typeResolver);
            converter.Upgrade(CreateEvent());
        }

        [Fact]
        public void Upgrade_theEvent_null()
        {
            var converter = new EventConverter(_typeResolver);
            var ex = Assert.Throws<ArgumentNullException>(() => converter.Upgrade(null));
            ex.ParamName.Should().Be("theEvent");
        }

        [Fact]
        public void AddConverter_ByType()
        {
            var anEvent = CreateEvent();
            var converter = new EventConverter(_typeResolver);
            converter.AddConverter(typeof(AnEvent), _childConverter);

            converter.Upgrade(anEvent);

            _childConverter.AssertWasCalled(x => x.Upgrade(anEvent));
        }

        [Fact]
        public void AddConverter_ByType_eventType_null()
        {
            var converter = new EventConverter(_typeResolver);
            var ex = Assert.Throws<ArgumentNullException>(() => converter.AddConverter((Type) null, _childConverter));
            ex.ParamName.Should().Be("eventType");
        }

    public static List<Common.DTO.EventDto> GetAllEvents()
    {
      try
      {
        return Converters.EventConverter.ToDtoEventList(DAL.EventDal.SelectEvents());
      }
      catch (Exception e)
      {
        throw e;
      }
    }

    public static List<Common.DTO.BaseCodeDto> GetEventType()
    {
      try
      {
        return Converters.EventConverter.ToDtoEventTypeList(DAL.EventDal.SelectEventType());
      }
      catch (Exception e)
      {
        throw e;
      }
    }

    //public static List<Common.DTO.BaseCodeDto> GetEventType()
    //{
    //  return Converters.EventConverter.ToDtoEventTypeList();
    //}
    public static Common.DTO.EventDto SelectEvents(int code)
    {
      try
      {
        return Converters.EventConverter.ToDtoEvent(DAL.EventDal.SalectEvent(code));
      }
      catch (Exception e)
      {
        throw e;
      }
    }
    public static Common.DTO.EventDto SelectEventByUID(int u_id)
    {
      try
      {
        return Converters.EventConverter.ToDtoEvent(DAL.EventDal.SalectEventByUserId(u_id));
      }
      catch (Exception e)
      {
        throw e;
      }
    }

    public static int updateCategoryiesList(List<BaseCodeDto> CategoryiesList)
    {
      try
      {
        return DAL.EventDal.UpdateCategoryiesList(Converters.EventConverter.ToDalCategoryiesList(CategoryiesList));
      }
      catch (Exception e)
      {

        throw e;
      }
    }
    public static int UpdateEvent(EventDto event1)
    {
      try
      {
        return DAL.EventDal.UpdateEvent(Converters.EventConverter.ToDalEventEdit(event1));
      }
      catch (Exception e)
      {

        throw e;
      }
    }


        [Test]
        public void Ctor()
        {
            Assert.DoesNotThrow(() => new EventConverter(_typeResolver));
        }

        [Test]
        public void Ctor_typeResolver_null()
        {
            var ex = Assert.Throws<ArgumentNullException>(() => new EventConverter(null));
            ex.ParamName.Should().Be("typeResolver");
        }

        [Test]
        public void Upgrade_unknown_event()
        {
            var converter = new EventConverter(_typeResolver);
            Assert.DoesNotThrow(() => converter.Upgrade(CreateEvent()));
        }

        [Test]
        public void Upgrade_theEvent_null()
        {
            var converter = new EventConverter(_typeResolver);
            var ex = Assert.Throws<ArgumentNullException>(() => converter.Upgrade(null));
            ex.ParamName.Should().Be("theEvent");
        }

        [Test]
        public void AddConverter_ByType()
        {
            var anEvent = CreateEvent();
            var converter = new EventConverter(_typeResolver);
            converter.AddConverter(typeof(AnEvent), _childConverter);

            converter.Upgrade(anEvent);

            _childConverter.AssertWasCalled(x => x.Upgrade(anEvent));
        }

        [Test]
        public void AddConverter_ByType_eventType_null()
        {
            var converter = new EventConverter(_typeResolver);
            var ex = Assert.Throws<ArgumentNullException>(() => converter.AddConverter((Type) null, _childConverter));
            ex.ParamName.Should().Be("eventType");
        }


        [Test]
        [Parallelizable]
        [TestCaseSource(typeof(TestEventSource), nameof(TestEventSource.CannedEvents))]
        public void ShouldNotFailOnEvents(JournalEvent e)
        {
            eventConverter.OnNext(e);

            eventConverter.GetPlayerSystem(DateTime.UtcNow);
            eventConverter.GetPlayerShipType(DateTime.UtcNow);
            eventConverter.GetPlayerShipId(DateTime.UtcNow);
            eventConverter.GetPlayerIsInCrew(DateTime.UtcNow);
        }


        /// <summary>Registers a converter that lasts until the disposable is disposed</summary>
        /// <remarks>Warning: Mapping the same event to itself will cause an infinite recursive subscription</remarks>
        public IDisposable Convert<TEventIn, TEventOut>(Func<TEventIn, TEventOut> eventConverter)
        {
            return this.GetEventInternal<TEventOut>().AddOther(this.GetEvent<TEventIn>().Select(eventConverter));
        }

        /// <summary>Registers a converter that lasts until the disposable is disposed</summary>
        /// <remarks>Warning: Mapping the same event to itself will cause an infinite recursive subscription</remarks>
        public IDisposable Convert<TEventIn, TEventOut>(Func<TEventIn, TEventOut> eventConverter, Func<TEventIn, bool> predicate)
        {
            return this.GetEventInternal<TEventOut>().AddOther(this.GetEvent<TEventIn>().Where(predicate).Select(eventConverter));
        }


		public override PropertyDescriptorCollection GetProperties(ITypeDescriptorContext context, object component, Attribute[] attributes)
		{
			EventInfoConverter eventConverter = component as EventInfoConverter;
			if (eventConverter != null)
			{
				return eventConverter.GetProperties();
			}
			else
			{
				return PropertyDescriptorUtils.GetInstanceEvents(component);
			}
		}

Stripe.Infrastructure.EventConverter : JsonConverter

Constructors :

public EventConverter()

Methods :

public Boolean get_CanWrite()
public Void WriteJson(JsonWriter writer = , Object value = , JsonSerializer serializer = )
public Object ReadJson(JsonReader reader = , Type objectType = , Object existingValue = , JsonSerializer serializer = )
public Boolean CanConvert(Type objectType = )
public Boolean get_CanRead()
public Type GetType()
public String ToString()
public Boolean Equals(Object obj = )
public Int32 GetHashCode()