Beispiel #1
0
 public static ActivationAddress ToActivationAddress(this GrainAddress addr)
 {
     return(ActivationAddress.GetAddress(
                SiloAddress.FromParsableString(addr.SiloAddress),
                LegacyGrainId.FromParsableString(addr.GrainId),
                ActivationId.GetActivationId(UniqueKey.Parse(addr.ActivationId.AsSpan()))));
 }
        public override object ReadJson(JsonReader reader, Type objectType, object existingValue, JsonSerializer serializer)
        {
            JObject jo      = JObject.Load(reader);
            GrainId grainId = LegacyGrainId.FromParsableString(jo["GrainId"].ToObject <string>());

            return(grainId);
        }
Beispiel #3
0
        private GrainId RoundTripGrainIdToParsable(GrainId input)
        {
            string  str    = ((LegacyGrainId)input).ToParsableString();
            GrainId output = LegacyGrainId.FromParsableString(str);

            return(output);
        }
Beispiel #4
0
        public void ID_Interning_GrainID()
        {
            Guid    guid = new Guid();
            GrainId gid1 = LegacyGrainId.FromParsableString(guid.ToString("B"));
            GrainId gid2 = LegacyGrainId.FromParsableString(guid.ToString("N"));

            Assert.Equal(gid1, gid2); // Should be equal GrainId's

            // Round-trip through Serializer
            GrainId gid3 = (GrainId)this.environment.SerializationManager.RoundTripSerializationForTesting(gid1);

            Assert.Equal(gid1, gid3); // Should be equal GrainId's
            Assert.Equal(gid2, gid3); // Should be equal GrainId's
        }
Beispiel #5
0
        public void ID_Interning_GrainID()
        {
            Guid    guid = new Guid();
            GrainId gid1 = LegacyGrainId.FromParsableString(guid.ToString("B"));
            GrainId gid2 = LegacyGrainId.FromParsableString(guid.ToString("N"));

            Assert.Equal(gid1, gid2); // Should be equal GrainId's

            // Round-trip through Serializer
            GrainId gid3 = this.environment.Serializer.Deserialize <GrainId>(environment.Serializer.SerializeToArray(gid1));

            Assert.Equal(gid1, gid3); // Should be equal GrainId's
            Assert.Equal(gid2, gid3); // Should be equal GrainId's
        }
 /// <summary>
 /// Creates a new grain and a grain reference pair.
 /// </summary>
 /// <param name="grainId">The grain ID.</param>
 /// <param name="version">The initial version of the state.</param>
 /// <returns>A grain reference and a state pair.</returns>
 internal Tuple <GrainReference, GrainState <TestState1> > GetTestReferenceAndState(string grainId, string version)
 {
     return(Tuple.Create((GrainReference)this.grainFactory.GetGrain(LegacyGrainId.FromParsableString(LegacyGrainId.GetGrainId(RandomUtilities.NormalGrainTypeCode, grainId).ToParsableString())), new GrainState <TestState1> {
         State = new TestState1(), ETag = version
     }));
 }