/// <inheritdoc/> public object SetObjectData(object obj, SerializationInfo info, StreamingContext context, ISurrogateSelector selector) { var id = GrainId.Create(info.GetString("type"), info.GetString("key")); var iface = GrainInterfaceType.Create(info.GetString("interface")); return(_activator.CreateReference(id, iface)); }
public object DeserializeGrainReference(Type t, IDeserializationContext context) { var reader = context.StreamReader; GrainId id = reader.ReadGrainId(); GrainInterfaceType interfaceType = reader.ReadGrainInterfaceType(); return(_activator.CreateReference(id, interfaceType)); }
/// <summary> /// Converts the provided value into a <see cref="GrainReference"/>. /// </summary> public GrainReference FromKeyString(string referenceString) { var splits = referenceString.Split('_'); var type = new GrainType(Convert.FromBase64String(splits[0])); var key = new IdSpan(Convert.FromBase64String(splits[1])); var id = new GrainId(type, key); return(_activator.CreateReference(id, default)); }
public ActivationData( ActivationAddress addr, PlacementStrategy placedUsing, IActivationCollector collector, TimeSpan ageLimit, IOptions <SiloMessagingOptions> messagingOptions, TimeSpan maxWarningRequestProcessingTime, TimeSpan maxRequestProcessingTime, ILoggerFactory loggerFactory, IServiceProvider applicationServices, IGrainRuntime grainRuntime, GrainReferenceActivator referenceActivator, GrainTypeComponents sharedComponents, ActivationMessageScheduler messageScheduler) { if (null == addr) { throw new ArgumentNullException(nameof(addr)); } if (null == placedUsing) { throw new ArgumentNullException(nameof(placedUsing)); } if (null == collector) { throw new ArgumentNullException(nameof(collector)); } _receiveMessageInScheduler = state => this.ReceiveMessageInScheduler(state); _shared = sharedComponents; _messageScheduler = messageScheduler; logger = loggerFactory.CreateLogger <ActivationData>(); this.lifecycle = new GrainLifecycle(loggerFactory.CreateLogger <LifecycleSubject>()); this.maxRequestProcessingTime = maxRequestProcessingTime; this.maxWarningRequestProcessingTime = maxWarningRequestProcessingTime; this.messagingOptions = messagingOptions.Value; ResetKeepAliveRequest(); Address = addr; State = ActivationState.Create; PlacedUsing = placedUsing; if (!this.GrainId.IsSystemTarget()) { this.collector = collector; } CollectionAgeLimit = ageLimit; this.GrainReference = referenceActivator.CreateReference(addr.Grain, default); this.serviceScope = applicationServices.CreateScope(); this.Runtime = grainRuntime; }
/// <summary> /// Converts the provided grain reference key <see cref="string"/> into a <see cref="GrainReference"/>. /// </summary> /// <param name="referenceString"> /// The string representation of a grain reference. /// </param> /// <returns>The grain reference.</returns> public GrainReference FromKeyString(string referenceString) { var i = referenceString.IndexOf('_'); if (i < 0) { throw new ArgumentException(nameof(referenceString)); } var type = new GrainType(Convert.FromBase64String(referenceString.Substring(0, i))); var key = new IdSpan(Convert.FromBase64String(referenceString.Substring(i + 1))); var id = new GrainId(type, key); return(_activator.CreateReference(id, default)); }