Ejemplo n.º 1
0
        internal static unsafe DeployedStatefulServiceReplica FromNative(NativeTypes.FABRIC_DEPLOYED_STATEFUL_SERVICE_REPLICA_QUERY_RESULT_ITEM nativeObj)
        {
            var    serviceManifestName        = string.Empty;
            string servicePackageActivationId = null;
            long   hostProcessId       = 0;
            var    reconfigInformation = new ReconfigurationInformation();

            if (nativeObj.Reserved != IntPtr.Zero)
            {
                var extended = (NativeTypes.FABRIC_DEPLOYED_STATEFUL_SERVICE_REPLICA_QUERY_RESULT_ITEM_EX1 *)nativeObj.Reserved;
                serviceManifestName = NativeTypes.FromNativeString(extended->ServiceManifestName);

                if (extended->Reserved != IntPtr.Zero)
                {
                    var nativeResultItemEx2 =
                        (NativeTypes.FABRIC_DEPLOYED_STATEFUL_SERVICE_REPLICA_QUERY_RESULT_ITEM_EX2 *)extended->Reserved;

                    servicePackageActivationId = NativeTypes.FromNativeString(nativeResultItemEx2->ServicePackageActivationId);

                    if (nativeResultItemEx2->Reserved != IntPtr.Zero)
                    {
                        var extended3 = (NativeTypes.FABRIC_DEPLOYED_STATEFUL_SERVICE_REPLICA_QUERY_RESULT_ITEM_EX3 *)nativeResultItemEx2->Reserved;
                        hostProcessId = extended3->HostProcessId;

                        var reconfigurationInformation = (NativeTypes.FABRIC_RECONFIGURATION_INFORMATION_QUERY_RESULT *)extended3->ReconfigurationInformation;
                        reconfigInformation = new ReconfigurationInformation(
                            (ReplicaRole)reconfigurationInformation->PreviousConfigurationRole,
                            (ReconfigurationPhase)reconfigurationInformation->ReconfigurationPhase,
                            (ReconfigurationType)reconfigurationInformation->ReconfigurationType,
                            NativeTypes.FromNativeFILETIME(reconfigurationInformation->ReconfigurationStartTimeUtc));
                    }
                }
            }

            return(new DeployedStatefulServiceReplica
            {
                ServiceName = new Uri(NativeTypes.FromNativeString(nativeObj.ServiceName)),
                ServiceTypeName = NativeTypes.FromNativeString(nativeObj.ServiceTypeName),
                CodePackageName = NativeTypes.FromNativeString(nativeObj.CodePackageName),
                ServiceManifestName = serviceManifestName,
                ServicePackageActivationId = servicePackageActivationId,
                Partitionid = nativeObj.PartitionId,
                ReplicaStatus = (ServiceReplicaStatus)nativeObj.ReplicaStatus,
                Address = NativeTypes.FromNativeString(nativeObj.Address),
                ReplicaId = nativeObj.ReplicaId,
                ReplicaRole = (ReplicaRole)nativeObj.ReplicaRole,
                ServiceManifestVersion_ = NativeTypes.FromNativeString(nativeObj.ServiceManifestVersion),
                HostProcessId = hostProcessId,
                ReconfigurationInformation = reconfigInformation,
            });
        }
Ejemplo n.º 2
0
        /// <summary>
        /// Serializes the object to JSON.
        /// </summary>
        /// <param name="writer">The <see cref="T: Newtonsoft.Json.JsonWriter" /> to write to.</param>
        /// <param name="obj">The object to serialize to JSON.</param>
        internal static void Serialize(JsonWriter writer, ReconfigurationInformation obj)
        {
            // Required properties are always serialized, optional properties are serialized when not null.
            writer.WriteStartObject();
            writer.WriteProperty(obj.PreviousConfigurationRole, "PreviousConfigurationRole", ReplicaRoleConverter.Serialize);
            writer.WriteProperty(obj.ReconfigurationPhase, "ReconfigurationPhase", ReconfigurationPhaseConverter.Serialize);
            writer.WriteProperty(obj.ReconfigurationType, "ReconfigurationType", ReconfigurationTypeConverter.Serialize);
            if (obj.ReconfigurationStartTimeUtc != null)
            {
                writer.WriteProperty(obj.ReconfigurationStartTimeUtc, "ReconfigurationStartTimeUtc", JsonWriterExtensions.WriteDateTimeValue);
            }

            writer.WriteEndObject();
        }