internal static unsafe List <HealthEvent> FromNativeList(IntPtr nativeHealthEventsPtr) { List <HealthEvent> events = new List <HealthEvent>(); if (nativeHealthEventsPtr != IntPtr.Zero) { NativeTypes.FABRIC_HEALTH_EVENT_LIST *nativeEvents = (NativeTypes.FABRIC_HEALTH_EVENT_LIST *)nativeHealthEventsPtr; for (int i = 0; i < nativeEvents->Count; i++) { var nativeEvent = (NativeTypes.FABRIC_HEALTH_EVENT *)((ulong)nativeEvents->Items + (ulong)(i * Marshal.SizeOf(typeof(NativeTypes.FABRIC_HEALTH_EVENT)))); events.Add(HealthEvent.FromNative(*nativeEvent)); } } return(events); }
internal static unsafe EventHealthEvaluation FromNative(IntPtr nativeHealthEvaluationValuePtr) { ReleaseAssert.AssertIf(nativeHealthEvaluationValuePtr == IntPtr.Zero, string.Format(CultureInfo.CurrentCulture, StringResources.Error_NativeDataNull_Formatted, "nativeHealthEvaluationValue")); var nativeHealthEvaluation = *(NativeTypes.FABRIC_EVENT_HEALTH_EVALUATION *)nativeHealthEvaluationValuePtr; var managedHealthEvaluation = new EventHealthEvaluation(); managedHealthEvaluation.Description = NativeTypes.FromNativeString(nativeHealthEvaluation.Description); managedHealthEvaluation.AggregatedHealthState = (HealthState)nativeHealthEvaluation.AggregatedHealthState; ReleaseAssert.AssertIf(nativeHealthEvaluation.UnhealthyEvent == IntPtr.Zero, string.Format(CultureInfo.CurrentCulture, StringResources.Error_NativeDataNull_Formatted, "UnhealthyEvent")); var nativeHealthEvent = (NativeTypes.FABRIC_HEALTH_EVENT *)nativeHealthEvaluation.UnhealthyEvent; managedHealthEvaluation.UnhealthyEvent = HealthEvent.FromNative(*nativeHealthEvent); managedHealthEvaluation.ConsiderWarningAsError = NativeTypes.FromBOOLEAN(nativeHealthEvaluation.ConsiderWarningAsError); return(managedHealthEvaluation); }