public void SerializerOptionsCantBeNull_Fails() { var options = new ActorProxyOptions(); Action action = () => options.JsonSerializerOptions = null; action.Should().Throw <ArgumentNullException>(); }
/// <summary> /// Initialize when ActorProxy is created for non-Remoting calls. /// </summary> internal void Initialize( ActorNonRemotingClient client, ActorId actorId, string actorType, ActorProxyOptions options) { this.actorNonRemotingClient = client; this.ActorId = actorId; this.ActorType = actorType; this.JsonSerializerOptions = options?.JsonSerializerOptions ?? this.JsonSerializerOptions; }
public void Create_WithCustomSerializerArgument_Succeeds() { var options = new ActorProxyOptions() { JsonSerializerOptions = new JsonSerializerOptions() }; var actorId = new ActorId("abc"); var proxy = (ActorProxy)ActorProxy.Create(actorId, typeof(ITestActor), "TestActor", options); Assert.Same(options.JsonSerializerOptions, proxy.JsonSerializerOptions); }
/// <summary> /// Initialize when ActorProxy is created for Remoting. /// </summary> internal void Initialize( ActorRemotingClient client, ActorId actorId, string actorType, ActorProxyOptions options) { this.actorRemotingClient = client; this.ActorId = actorId; this.ActorType = actorType; this.ActorMessageBodyFactory = client.GetRemotingMessageBodyFactory(); this.JsonSerializerOptions = options?.JsonSerializerOptions ?? this.JsonSerializerOptions; }
/// <summary> /// Initialize when ActorProxy is created for Remoting. /// </summary> internal void Initialize( ActorRemotingClient client, ActorId actorId, string actorType, ActorProxyOptions options) { this.actorRemotingClient = client; this.ActorId = actorId; this.ActorType = actorType; this.ActorMessageBodyFactory = client.GetRemotingMessageBodyFactory(); this.JsonSerializerOptions = options?.JsonSerializerOptions ?? new JsonSerializerOptions(JsonSerializerDefaults.Web); this.DaprApiToken = options?.DaprApiToken; }
/// <summary> /// Creates a proxy to the actor object that implements an actor interface. /// </summary> /// <param name="actorId">The actor ID of the proxy actor object. Methods called on this proxy will result in requests /// being sent to the actor with this ID.</param> /// <param name="actorInterfaceType"> /// The actor interface type implemented by the remote actor object. /// The returned proxy object will implement this interface. /// </param> /// <param name="actorType">Type of actor implementation.</param> /// <param name="options">The optional <see cref="ActorProxyOptions" /> to use when creating the actor proxy.</param> /// <returns>Proxy to the actor object.</returns> public static object Create(ActorId actorId, Type actorInterfaceType, string actorType, ActorProxyOptions options = null) { if (!typeof(IActor).IsAssignableFrom(actorInterfaceType)) { throw new ArgumentException("The interface must implement IActor.", nameof(actorInterfaceType)); } return(DefaultProxyFactory.CreateActorProxy(actorId, actorInterfaceType, actorType, options)); }
/// <summary> /// Creates a proxy to the actor object that implements an actor interface. /// </summary> /// <typeparam name="TActorInterface"> /// The actor interface implemented by the remote actor object. /// The returned proxy object will implement this interface. /// </typeparam> /// <param name="actorId">The actor ID of the proxy actor object. Methods called on this proxy will result in requests /// being sent to the actor with this ID.</param> /// <param name="actorType">Type of actor implementation.</param> /// <param name="options">The optional <see cref="ActorProxyOptions" /> to use when creating the actor proxy.</param> /// <returns>Proxy to the actor object.</returns> public static TActorInterface Create <TActorInterface>(ActorId actorId, string actorType, ActorProxyOptions options = null) where TActorInterface : IActor { return(DefaultProxyFactory.CreateActorProxy <TActorInterface>(actorId, actorType, options)); }
/// <summary> /// Creates an Actor Proxy for making calls without Remoting. /// </summary> /// <param name="actorId">Actor Id.</param> /// <param name="actorType">Type of actor.</param> /// <param name="options">The optional <see cref="ActorProxyOptions" /> to use when creating the actor proxy.</param> /// <returns>Actor proxy to interact with remote actor object.</returns> public static ActorProxy Create(ActorId actorId, string actorType, ActorProxyOptions options = null) { return(DefaultProxyFactory.Create(actorId, actorType, options)); }
public void DefaultConstructor_Succeeds() { var options = new ActorProxyOptions(); Assert.NotNull(options); }