internal static unsafe StatefulServicePartition FromNative(NativeTypes.FABRIC_STATEFUL_SERVICE_PARTITION_QUERY_RESULT_ITEM statefulPartitionResultItem) { NativeTypes.FABRIC_SERVICE_PARTITION_INFORMATION *nativePartitionInformation = (NativeTypes.FABRIC_SERVICE_PARTITION_INFORMATION *)statefulPartitionResultItem.PartitionInformation; NativeTypes.FABRIC_STATEFUL_SERVICE_PARTITION_QUERY_RESULT_ITEM_EX1 *statefulPartitionResultItemEx1 = (NativeTypes.FABRIC_STATEFUL_SERVICE_PARTITION_QUERY_RESULT_ITEM_EX1 *)statefulPartitionResultItem.Reserved; return(new StatefulServicePartition( ServicePartitionInformation.FromNative(*nativePartitionInformation), statefulPartitionResultItem.TargetReplicaSetSize, statefulPartitionResultItem.MinReplicaSetSize, (HealthState)statefulPartitionResultItem.HealthState, (ServicePartitionStatus)statefulPartitionResultItem.PartitionStatus, TimeSpan.FromSeconds(statefulPartitionResultItem.LastQuorumLossDurationInSeconds), Epoch.FromNative(statefulPartitionResultItemEx1->PrimaryEpoch))); }
internal static unsafe Partition CreateFromNative( NativeTypes.FABRIC_SERVICE_PARTITION_QUERY_RESULT_ITEM nativeResultItem) { if ((ServiceKind)nativeResultItem.Kind == ServiceKind.Stateless) { NativeTypes.FABRIC_STATELESS_SERVICE_PARTITION_QUERY_RESULT_ITEM nativeStatelessPartitionQueryResult = *(NativeTypes.FABRIC_STATELESS_SERVICE_PARTITION_QUERY_RESULT_ITEM *)nativeResultItem.Value; return(StatelessServicePartition.FromNative(nativeStatelessPartitionQueryResult)); } else if ((ServiceKind)nativeResultItem.Kind == ServiceKind.Stateful) { NativeTypes.FABRIC_STATEFUL_SERVICE_PARTITION_QUERY_RESULT_ITEM nativeStatefulServiceQueryResult = *(NativeTypes.FABRIC_STATEFUL_SERVICE_PARTITION_QUERY_RESULT_ITEM *)nativeResultItem.Value; return(StatefulServicePartition.FromNative(nativeStatefulServiceQueryResult)); } else { AppTrace.TraceSource.WriteNoise( "Partition.CreateFromNative", "Ignoring the result with unsupported ServiceKind value {0}", (int)nativeResultItem.Kind); return(null); } }