internal IntPtr ToNative(PinCollection pin) { var nativeHealthInformation = new NativeTypes.FABRIC_HEALTH_INFORMATION(); nativeHealthInformation.Property = pin.AddObject(this.Property); nativeHealthInformation.SourceId = pin.AddObject(this.SourceId); nativeHealthInformation.State = (NativeTypes.FABRIC_HEALTH_STATE) this.HealthState; nativeHealthInformation.Description = pin.AddObject(this.Description); if (this.TimeToLive == TimeSpan.MaxValue) { nativeHealthInformation.TimeToLiveSeconds = NativeTypes.FABRIC_HEALTH_REPORT_INFINITE_TTL; } else { nativeHealthInformation.TimeToLiveSeconds = (uint)Math.Ceiling(this.TimeToLive.TotalSeconds); } nativeHealthInformation.RemoveWhenExpired = NativeTypes.ToBOOLEAN(this.RemoveWhenExpired); nativeHealthInformation.SequenceNumber = this.SequenceNumber; return(pin.AddBlittable(nativeHealthInformation)); }
internal static unsafe HealthInformation FromNative(NativeTypes.FABRIC_HEALTH_INFORMATION nativeHealthInformation) { var healthInformation = new HealthInformation( NativeTypes.FromNativeString(nativeHealthInformation.SourceId), NativeTypes.FromNativeString(nativeHealthInformation.Property), (HealthState)nativeHealthInformation.State); healthInformation.Description = NativeTypes.FromNativeString(nativeHealthInformation.Description); if (nativeHealthInformation.TimeToLiveSeconds == NativeTypes.FABRIC_HEALTH_REPORT_INFINITE_TTL) { healthInformation.TimeToLive = TimeSpan.MaxValue; } else { healthInformation.TimeToLive = TimeSpan.FromSeconds(nativeHealthInformation.TimeToLiveSeconds); } healthInformation.SequenceNumber = nativeHealthInformation.SequenceNumber; healthInformation.RemoveWhenExpired = NativeTypes.FromBOOLEAN(nativeHealthInformation.RemoveWhenExpired); return(healthInformation); }