// The special constructor is used to deserialize values. protected GrainReference(SerializationInfo info, StreamingContext context) { // Reset the property value using the GetValue method. var grainIdStr = info.GetString("GrainId"); GrainId = GrainId.FromParsableString(grainIdStr); if (IsSystemTarget) { var siloAddressStr = info.GetString("SystemTargetSilo"); SystemTargetSilo = SiloAddress.FromParsableString(siloAddressStr); } if (IsObserverReference) { var observerIdStr = info.GetString(OBSERVER_ID_STR); observerId = GuidId.FromParsableString(observerIdStr); } var genericArg = info.GetString("GenericArguments"); if (String.IsNullOrEmpty(genericArg)) { genericArg = null; } genericArguments = genericArg; var serializerContext = context.Context as ISerializerContext; this.runtime = serializerContext?.ServiceProvider.GetService(typeof(IGrainReferenceRuntime)) as IGrainReferenceRuntime; }
// The special constructor is used to deserialize values. protected GrainReference(SerializationInfo info, StreamingContext context) { this.responseCallbackDelegate = this.ResponseCallback; // Reset the property value using the GetValue method. var grainIdStr = info.GetString("GrainId"); GrainId = GrainId.FromParsableString(grainIdStr); if (IsSystemTarget) { var siloAddressStr = info.GetString("SystemTargetSilo"); SystemTargetSilo = SiloAddress.FromParsableString(siloAddressStr); } if (IsObserverReference) { var observerIdStr = info.GetString(OBSERVER_ID_STR); observerId = GuidId.FromParsableString(observerIdStr); } var genericArg = info.GetString("GenericArguments"); if (String.IsNullOrEmpty(genericArg)) { genericArg = null; } genericArguments = genericArg; #if !NETSTANDARD_TODO this.OnDeserialized(context); #endif }
/// <summary> /// Gets the <see cref="SiloAddress"/> of the system target. /// </summary> public SiloAddress GetSiloAddress() { var key = this.GrainId.Key.ToStringUtf8(); if (key.IndexOf(SegmentSeparator) is int index && index >= 0) { key = key.Substring(0, index); } return(SiloAddress.FromParsableString(key)); }
public static GrainReference FromKeyString(string key) { if (string.IsNullOrWhiteSpace(key)) { throw new ArgumentNullException("key", "GrainReference.FromKeyString cannot parse null key"); } string trimmed = key.Trim(); string grainIdStr; int grainIdIndex = (GRAIN_REFERENCE_STR + "=").Length; int genericIndex = trimmed.IndexOf(GENERIC_ARGUMENTS_STR + "=", StringComparison.Ordinal); int observerIndex = trimmed.IndexOf(OBSERVER_ID_STR + "=", StringComparison.Ordinal); int systemTargetIndex = trimmed.IndexOf(SYSTEM_TARGET_STR + "=", StringComparison.Ordinal); if (genericIndex >= 0) { grainIdStr = trimmed.Substring(grainIdIndex, genericIndex); string genericStr = trimmed.Substring(genericIndex + (GENERIC_ARGUMENTS_STR + "=").Length); if (String.IsNullOrEmpty(genericStr)) { genericStr = null; } return(FromGrainId(GrainId.FromParsableString(grainIdStr), genericStr)); } else if (observerIndex >= 0) { grainIdStr = trimmed.Substring(grainIdIndex, observerIndex); string observerIdStr = trimmed.Substring(observerIndex + (OBSERVER_ID_STR + "=").Length); GuidId observerId = GuidId.FromParsableString(observerIdStr); return(NewObserverGrainReference(GrainId.FromParsableString(grainIdStr), observerId)); } else if (systemTargetIndex >= 0) { grainIdStr = trimmed.Substring(grainIdIndex, systemTargetIndex); string systemTargetStr = trimmed.Substring(systemTargetIndex + (SYSTEM_TARGET_STR + "=").Length); SiloAddress siloAddress = SiloAddress.FromParsableString(systemTargetStr); return(FromGrainId(GrainId.FromParsableString(grainIdStr), null, siloAddress)); } else { grainIdStr = trimmed.Substring(grainIdIndex); return(FromGrainId(GrainId.FromParsableString(grainIdStr))); } //return FromGrainId(GrainId.FromParsableString(grainIdStr), generic); }
public MembershipEntry ToEntry() { return(new MembershipEntry { FaultZone = FaultZone, HostName = HostName, IAmAliveTime = LogFormatter.ParseDate(IAmAliveTime), ProxyPort = ProxyPort, RoleName = RoleName, SiloAddress = SiloAddressClass.FromParsableString(SiloAddress), SiloName = SiloName, Status = (SiloStatus)Status, StartTime = LogFormatter.ParseDate(StartTime), SuspectTimes = SuspectTimes.Select(x => x.ToTuple()).ToList(), UpdateZone = UpdateZone }); }
// The special constructor is used to deserialize values. protected GrainReference(SerializationInfo info, StreamingContext context) { // Reset the property value using the GetValue method. var grainIdStr = info.GetString("GrainId"); GrainId = GrainId.FromParsableString(grainIdStr); if (GrainId.IsSystemTarget) { var siloAddressStr = info.GetString("SystemTargetSilo"); SystemTargetSilo = SiloAddress.FromParsableString(siloAddressStr); } var genericArg = info.GetString("GenericArguments"); if (String.IsNullOrEmpty(genericArg)) { genericArg = null; } genericArguments = genericArg; }
internal static GrainReference FromKeyString(string key, IGrainReferenceRuntime runtime) { if (string.IsNullOrWhiteSpace(key)) { throw new ArgumentNullException(nameof(key), "GrainReference.FromKeyString cannot parse null key"); } ReadOnlySpan <char> trimmed = key.AsSpan().Trim(); ReadOnlySpan <char> grainIdStr; int grainIdIndex = (GRAIN_REFERENCE_STR + "=").Length; int genericIndex = trimmed.IndexOf(GENERIC_ARGUMENTS_STR_WITH_EQUAL_SIGN.AsSpan(), StringComparison.Ordinal); int observerIndex = trimmed.IndexOf(OBSERVER_ID_STR_WITH_EQUAL_SIGN.AsSpan(), StringComparison.Ordinal); int systemTargetIndex = trimmed.IndexOf(SYSTEM_TARGET_STR_WITH_EQUAL_SIGN.AsSpan(), StringComparison.Ordinal); if (genericIndex >= 0) { grainIdStr = trimmed.Slice(grainIdIndex, genericIndex - grainIdIndex).Trim(); ReadOnlySpan <char> genericStr = trimmed.Slice(genericIndex + GENERIC_ARGUMENTS_STR_WITH_EQUAL_SIGN.Length); return(FromGrainId(GrainId.FromParsableString(grainIdStr), runtime, genericStr.ToString())); } else if (observerIndex >= 0) { grainIdStr = trimmed.Slice(grainIdIndex, observerIndex - grainIdIndex).Trim(); ReadOnlySpan <char> observerIdStr = trimmed.Slice(observerIndex + OBSERVER_ID_STR_WITH_EQUAL_SIGN.Length); GuidId observerId = GuidId.FromParsableString(observerIdStr.ToString()); return(NewObserverGrainReference(GrainId.FromParsableString(grainIdStr), observerId, runtime)); } else if (systemTargetIndex >= 0) { grainIdStr = trimmed.Slice(grainIdIndex, systemTargetIndex - grainIdIndex).Trim(); ReadOnlySpan <char> systemTargetStr = trimmed.Slice(systemTargetIndex + SYSTEM_TARGET_STR_WITH_EQUAL_SIGN.Length); SiloAddress siloAddress = SiloAddress.FromParsableString(systemTargetStr.ToString()); return(FromGrainId(GrainId.FromParsableString(grainIdStr), runtime, null, siloAddress)); } else { grainIdStr = trimmed.Slice(grainIdIndex); return(FromGrainId(GrainId.FromParsableString(grainIdStr), runtime)); } }
public Uri ToGatewayUri() { var siloAddress = SiloAddressClass.FromParsableString(SiloAddress); return(SiloAddressClass.New(new IPEndPoint(siloAddress.Endpoint.Address, ProxyPort), siloAddress.Generation).ToGatewayUri()); }