internal static unsafe DeltaNodesCheckHealthEvaluation FromNative(IntPtr nativeDeltaNodesCheckHealthEvaluationPtr)
        {
            ReleaseAssert.AssertIf(nativeDeltaNodesCheckHealthEvaluationPtr == IntPtr.Zero, string.Format(CultureInfo.CurrentCulture, StringResources.Error_NativeDataNull_Formatted, "DeltaNodesCheckHealthEvaluation"));
            var nativeDeltaNodesCheckHealthEvaluation = *(NativeTypes.FABRIC_DELTA_NODES_CHECK_HEALTH_EVALUATION *)nativeDeltaNodesCheckHealthEvaluationPtr;

            var managedDeltaNodesCheckHealthEvaluation = new DeltaNodesCheckHealthEvaluation();

            managedDeltaNodesCheckHealthEvaluation.Description                   = NativeTypes.FromNativeString(nativeDeltaNodesCheckHealthEvaluation.Description);
            managedDeltaNodesCheckHealthEvaluation.AggregatedHealthState         = (HealthState)nativeDeltaNodesCheckHealthEvaluation.AggregatedHealthState;
            managedDeltaNodesCheckHealthEvaluation.BaselineErrorCount            = (long)nativeDeltaNodesCheckHealthEvaluation.BaselineErrorCount;
            managedDeltaNodesCheckHealthEvaluation.BaselineTotalCount            = (long)nativeDeltaNodesCheckHealthEvaluation.BaselineTotalCount;
            managedDeltaNodesCheckHealthEvaluation.TotalCount                    = (long)nativeDeltaNodesCheckHealthEvaluation.TotalCount;
            managedDeltaNodesCheckHealthEvaluation.MaxPercentDeltaUnhealthyNodes = nativeDeltaNodesCheckHealthEvaluation.MaxPercentDeltaUnhealthyNodes;
            managedDeltaNodesCheckHealthEvaluation.UnhealthyEvaluations          = HealthEvaluation.FromNativeList(nativeDeltaNodesCheckHealthEvaluation.UnhealthyEvaluations);

            return(managedDeltaNodesCheckHealthEvaluation);
        }
Exemple #2
0
        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);
            }
        }