internal static unsafe UpgradeDomainDeltaNodesCheckHealthEvaluation FromNative(IntPtr nativeUpgradeDomainDeltaNodesCheckHealthEvaluationPtr)
        {
            ReleaseAssert.AssertIf(nativeUpgradeDomainDeltaNodesCheckHealthEvaluationPtr == IntPtr.Zero, string.Format(CultureInfo.CurrentCulture, StringResources.Error_NativeDataNull_Formatted, "UpgradeDomainDeltaNodesCheckHealthEvaluation"));
            var nativeUpgradeDomainDeltaNodesCheckHealthEvaluation = *(NativeTypes.FABRIC_UPGRADE_DOMAIN_DELTA_NODES_CHECK_HEALTH_EVALUATION *)nativeUpgradeDomainDeltaNodesCheckHealthEvaluationPtr;

            var managedUpgradeDomainDeltaNodesCheckHealthEvaluation = new UpgradeDomainDeltaNodesCheckHealthEvaluation();

            managedUpgradeDomainDeltaNodesCheckHealthEvaluation.Description           = NativeTypes.FromNativeString(nativeUpgradeDomainDeltaNodesCheckHealthEvaluation.Description);
            managedUpgradeDomainDeltaNodesCheckHealthEvaluation.AggregatedHealthState = (HealthState)nativeUpgradeDomainDeltaNodesCheckHealthEvaluation.AggregatedHealthState;
            managedUpgradeDomainDeltaNodesCheckHealthEvaluation.UpgradeDomainName     = NativeTypes.FromNativeString(nativeUpgradeDomainDeltaNodesCheckHealthEvaluation.UpgradeDomainName);
            managedUpgradeDomainDeltaNodesCheckHealthEvaluation.BaselineErrorCount    = (long)nativeUpgradeDomainDeltaNodesCheckHealthEvaluation.BaselineErrorCount;
            managedUpgradeDomainDeltaNodesCheckHealthEvaluation.BaselineTotalCount    = (long)nativeUpgradeDomainDeltaNodesCheckHealthEvaluation.BaselineTotalCount;
            managedUpgradeDomainDeltaNodesCheckHealthEvaluation.TotalCount            = (long)nativeUpgradeDomainDeltaNodesCheckHealthEvaluation.TotalCount;
            managedUpgradeDomainDeltaNodesCheckHealthEvaluation.MaxPercentUpgradeDomainDeltaUnhealthyNodes = nativeUpgradeDomainDeltaNodesCheckHealthEvaluation.MaxPercentUpgradeDomainDeltaUnhealthyNodes;
            managedUpgradeDomainDeltaNodesCheckHealthEvaluation.UnhealthyEvaluations = HealthEvaluation.FromNativeList(nativeUpgradeDomainDeltaNodesCheckHealthEvaluation.UnhealthyEvaluations);

            return(managedUpgradeDomainDeltaNodesCheckHealthEvaluation);
        }
Пример #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);
            }
        }