internal static unsafe DeployedServicePackageHealthEvaluation FromNative(IntPtr nativeHealthEvaluationValuePtr) { ReleaseAssert.AssertIf(nativeHealthEvaluationValuePtr == IntPtr.Zero, string.Format(CultureInfo.CurrentCulture, StringResources.Error_NativeDataNull_Formatted, "nativeHealthEvaluationValue")); var nativeHealthEvaluation = *(NativeTypes.FABRIC_DEPLOYED_SERVICE_PACKAGE_HEALTH_EVALUATION *)nativeHealthEvaluationValuePtr; var managedHealthEvaluation = new DeployedServicePackageHealthEvaluation(); managedHealthEvaluation.Description = NativeTypes.FromNativeString(nativeHealthEvaluation.Description); managedHealthEvaluation.AggregatedHealthState = (HealthState)nativeHealthEvaluation.AggregatedHealthState; managedHealthEvaluation.UnhealthyEvaluations = HealthEvaluation.FromNativeList(nativeHealthEvaluation.UnhealthyEvaluations); managedHealthEvaluation.ApplicationName = NativeTypes.FromNativeUri(nativeHealthEvaluation.ApplicationName); managedHealthEvaluation.NodeName = NativeTypes.FromNativeString(nativeHealthEvaluation.NodeName); managedHealthEvaluation.ServiceManifestName = NativeTypes.FromNativeString(nativeHealthEvaluation.ServiceManifestName); if (nativeHealthEvaluation.Reserved != IntPtr.Zero) { var nativeResultItemEx1 = (NativeTypes.FABRIC_DEPLOYED_SERVICE_PACKAGE_HEALTH_EVALUATION_EX1 *)nativeHealthEvaluation.Reserved; managedHealthEvaluation.ServicePackageActivationId = NativeTypes.FromNativeString(nativeResultItemEx1->ServicePackageActivationId); } return(managedHealthEvaluation); }
internal static unsafe HealthEvaluation FromNativeValue(NativeTypes.FABRIC_HEALTH_EVALUATION nativeHealthEvaluation) { switch (nativeHealthEvaluation.Kind) { case NativeTypes.FABRIC_HEALTH_EVALUATION_KIND.FABRIC_HEALTH_EVALUATION_KIND_EVENT: return(EventHealthEvaluation.FromNative(nativeHealthEvaluation.Value)); case NativeTypes.FABRIC_HEALTH_EVALUATION_KIND.FABRIC_HEALTH_EVALUATION_KIND_PARTITIONS: return(PartitionsHealthEvaluation.FromNative(nativeHealthEvaluation.Value)); case NativeTypes.FABRIC_HEALTH_EVALUATION_KIND.FABRIC_HEALTH_EVALUATION_KIND_REPLICAS: return(ReplicasHealthEvaluation.FromNative(nativeHealthEvaluation.Value)); case NativeTypes.FABRIC_HEALTH_EVALUATION_KIND.FABRIC_HEALTH_EVALUATION_KIND_DEPLOYED_SERVICE_PACKAGES: return(DeployedServicePackagesHealthEvaluation.FromNative(nativeHealthEvaluation.Value)); case NativeTypes.FABRIC_HEALTH_EVALUATION_KIND.FABRIC_HEALTH_EVALUATION_KIND_DEPLOYED_APPLICATIONS: return(DeployedApplicationsHealthEvaluation.FromNative(nativeHealthEvaluation.Value)); case NativeTypes.FABRIC_HEALTH_EVALUATION_KIND.FABRIC_HEALTH_EVALUATION_KIND_SERVICES: return(ServicesHealthEvaluation.FromNative(nativeHealthEvaluation.Value)); case NativeTypes.FABRIC_HEALTH_EVALUATION_KIND.FABRIC_HEALTH_EVALUATION_KIND_NODES: return(NodesHealthEvaluation.FromNative(nativeHealthEvaluation.Value)); case NativeTypes.FABRIC_HEALTH_EVALUATION_KIND.FABRIC_HEALTH_EVALUATION_KIND_APPLICATIONS: return(ApplicationsHealthEvaluation.FromNative(nativeHealthEvaluation.Value)); case NativeTypes.FABRIC_HEALTH_EVALUATION_KIND.FABRIC_HEALTH_EVALUATION_KIND_UPGRADE_DOMAIN_NODES: return(UpgradeDomainNodesHealthEvaluation.FromNative(nativeHealthEvaluation.Value)); case NativeTypes.FABRIC_HEALTH_EVALUATION_KIND.FABRIC_HEALTH_EVALUATION_KIND_UPGRADE_DOMAIN_DEPLOYED_APPLICATIONS: return(UpgradeDomainDeployedApplicationsHealthEvaluation.FromNative(nativeHealthEvaluation.Value)); case NativeTypes.FABRIC_HEALTH_EVALUATION_KIND.FABRIC_HEALTH_EVALUATION_KIND_SYSTEM_APPLICATION: return(SystemApplicationHealthEvaluation.FromNative(nativeHealthEvaluation.Value)); case NativeTypes.FABRIC_HEALTH_EVALUATION_KIND.FABRIC_HEALTH_EVALUATION_KIND_PARTITION: return(PartitionHealthEvaluation.FromNative(nativeHealthEvaluation.Value)); case NativeTypes.FABRIC_HEALTH_EVALUATION_KIND.FABRIC_HEALTH_EVALUATION_KIND_REPLICA: return(ReplicaHealthEvaluation.FromNative(nativeHealthEvaluation.Value)); case NativeTypes.FABRIC_HEALTH_EVALUATION_KIND.FABRIC_HEALTH_EVALUATION_KIND_DEPLOYED_SERVICE_PACKAGE: return(DeployedServicePackageHealthEvaluation.FromNative(nativeHealthEvaluation.Value)); case NativeTypes.FABRIC_HEALTH_EVALUATION_KIND.FABRIC_HEALTH_EVALUATION_KIND_DEPLOYED_APPLICATION: return(DeployedApplicationHealthEvaluation.FromNative(nativeHealthEvaluation.Value)); case NativeTypes.FABRIC_HEALTH_EVALUATION_KIND.FABRIC_HEALTH_EVALUATION_KIND_SERVICE: return(ServiceHealthEvaluation.FromNative(nativeHealthEvaluation.Value)); case NativeTypes.FABRIC_HEALTH_EVALUATION_KIND.FABRIC_HEALTH_EVALUATION_KIND_NODE: return(NodeHealthEvaluation.FromNative(nativeHealthEvaluation.Value)); case NativeTypes.FABRIC_HEALTH_EVALUATION_KIND.FABRIC_HEALTH_EVALUATION_KIND_APPLICATION: return(ApplicationHealthEvaluation.FromNative(nativeHealthEvaluation.Value)); case NativeTypes.FABRIC_HEALTH_EVALUATION_KIND.FABRIC_HEALTH_EVALUATION_KIND_DELTA_NODES_CHECK: return(DeltaNodesCheckHealthEvaluation.FromNative(nativeHealthEvaluation.Value)); case NativeTypes.FABRIC_HEALTH_EVALUATION_KIND.FABRIC_HEALTH_EVALUATION_KIND_UPGRADE_DOMAIN_DELTA_NODES_CHECK: return(UpgradeDomainDeltaNodesCheckHealthEvaluation.FromNative(nativeHealthEvaluation.Value)); case NativeTypes.FABRIC_HEALTH_EVALUATION_KIND.FABRIC_HEALTH_EVALUATION_KIND_APPLICATION_TYPE_APPLICATIONS: return(ApplicationTypeApplicationsHealthEvaluation.FromNative(nativeHealthEvaluation.Value)); default: // The kind may be invalid because it was send by a newer version of the server. // Return null. It's the user's responsibility to check for null. // Another option is to throw an exception, such as: // throw new ArgumentException(string.Format(CultureInfo.CurrentCulture, StringResources.Error_NativeEnumInvalid_Formatted, nativeHealthEvaluation.Kind)); // Since this method is only intended for internal use, return null as an optimization. AppTrace.TraceSource.WriteError("HealthEvaluationKind.FromNative", "Unknown FABRIC_HEALTH_EVALUATION_KIND: {0}", nativeHealthEvaluation.Kind); return(null); } }