예제 #1
0
        /// <summary>
        /// Gets the object from Json properties.
        /// </summary>
        /// <param name="reader">The <see cref="T: Newtonsoft.Json.JsonReader" /> to read from.</param>
        /// <returns>The object Value.</returns>
        internal static FabricEvent GetFromJsonProperties(JsonReader reader)
        {
            FabricEvent obj;
            var         propName = reader.ReadPropertyName();

            if (!propName.Equals("Kind", StringComparison.Ordinal))
            {
                throw new JsonReaderException($"Incorrect discriminator property name {propName}, Expected discriminator property name is Kind.");
            }

            var propValue = reader.ReadValueAsString();

            if (propValue.Equals("ApplicationEvent", StringComparison.Ordinal))
            {
                obj = ApplicationEventConverter.GetFromJsonProperties(reader);
            }
            else if (propValue.Equals("ClusterEvent", StringComparison.Ordinal))
            {
                obj = ClusterEventConverter.GetFromJsonProperties(reader);
            }
            else if (propValue.Equals("ContainerInstanceEvent", StringComparison.Ordinal))
            {
                obj = ContainerInstanceEventConverter.GetFromJsonProperties(reader);
            }
            else if (propValue.Equals("NodeEvent", StringComparison.Ordinal))
            {
                obj = NodeEventConverter.GetFromJsonProperties(reader);
            }
            else if (propValue.Equals("PartitionAnalysisEvent", StringComparison.Ordinal))
            {
                obj = PartitionAnalysisEventConverter.GetFromJsonProperties(reader);
            }
            else if (propValue.Equals("PartitionEvent", StringComparison.Ordinal))
            {
                obj = PartitionEventConverter.GetFromJsonProperties(reader);
            }
            else if (propValue.Equals("ReplicaEvent", StringComparison.Ordinal))
            {
                obj = ReplicaEventConverter.GetFromJsonProperties(reader);
            }
            else if (propValue.Equals("ServiceEvent", StringComparison.Ordinal))
            {
                obj = ServiceEventConverter.GetFromJsonProperties(reader);
            }
            else if (propValue.Equals("ApplicationCreated", StringComparison.Ordinal))
            {
                obj = ApplicationCreatedEventConverter.GetFromJsonProperties(reader);
            }
            else if (propValue.Equals("ApplicationDeleted", StringComparison.Ordinal))
            {
                obj = ApplicationDeletedEventConverter.GetFromJsonProperties(reader);
            }
            else if (propValue.Equals("ApplicationHealthReportCreated", StringComparison.Ordinal))
            {
                obj = ApplicationHealthReportCreatedEventConverter.GetFromJsonProperties(reader);
            }
            else if (propValue.Equals("ApplicationHealthReportExpired", StringComparison.Ordinal))
            {
                obj = ApplicationHealthReportExpiredEventConverter.GetFromJsonProperties(reader);
            }
            else if (propValue.Equals("ApplicationUpgradeComplete", StringComparison.Ordinal))
            {
                obj = ApplicationUpgradeCompleteEventConverter.GetFromJsonProperties(reader);
            }
            else if (propValue.Equals("ApplicationUpgradeDomainComplete", StringComparison.Ordinal))
            {
                obj = ApplicationUpgradeDomainCompleteEventConverter.GetFromJsonProperties(reader);
            }
            else if (propValue.Equals("ApplicationUpgradeRollbackComplete", StringComparison.Ordinal))
            {
                obj = ApplicationUpgradeRollbackCompleteEventConverter.GetFromJsonProperties(reader);
            }
            else if (propValue.Equals("ApplicationUpgradeRollbackStart", StringComparison.Ordinal))
            {
                obj = ApplicationUpgradeRollbackStartEventConverter.GetFromJsonProperties(reader);
            }
            else if (propValue.Equals("ApplicationUpgradeStart", StringComparison.Ordinal))
            {
                obj = ApplicationUpgradeStartEventConverter.GetFromJsonProperties(reader);
            }
            else if (propValue.Equals("DeployedApplicationHealthReportCreated", StringComparison.Ordinal))
            {
                obj = DeployedApplicationHealthReportCreatedEventConverter.GetFromJsonProperties(reader);
            }
            else if (propValue.Equals("DeployedApplicationHealthReportExpired", StringComparison.Ordinal))
            {
                obj = DeployedApplicationHealthReportExpiredEventConverter.GetFromJsonProperties(reader);
            }
            else if (propValue.Equals("ProcessDeactivated", StringComparison.Ordinal))
            {
                obj = ProcessDeactivatedEventConverter.GetFromJsonProperties(reader);
            }
            else if (propValue.Equals("ContainerDeactivated", StringComparison.Ordinal))
            {
                obj = ContainerDeactivatedEventConverter.GetFromJsonProperties(reader);
            }
            else if (propValue.Equals("NodeAborted", StringComparison.Ordinal))
            {
                obj = NodeAbortedEventConverter.GetFromJsonProperties(reader);
            }
            else if (propValue.Equals("NodeAborting", StringComparison.Ordinal))
            {
                obj = NodeAbortingEventConverter.GetFromJsonProperties(reader);
            }
            else if (propValue.Equals("NodeAdded", StringComparison.Ordinal))
            {
                obj = NodeAddedEventConverter.GetFromJsonProperties(reader);
            }
            else if (propValue.Equals("NodeClose", StringComparison.Ordinal))
            {
                obj = NodeCloseEventConverter.GetFromJsonProperties(reader);
            }
            else if (propValue.Equals("NodeClosing", StringComparison.Ordinal))
            {
                obj = NodeClosingEventConverter.GetFromJsonProperties(reader);
            }
            else if (propValue.Equals("NodeDeactivateComplete", StringComparison.Ordinal))
            {
                obj = NodeDeactivateCompleteEventConverter.GetFromJsonProperties(reader);
            }
            else if (propValue.Equals("NodeDeactivateStart", StringComparison.Ordinal))
            {
                obj = NodeDeactivateStartEventConverter.GetFromJsonProperties(reader);
            }
            else if (propValue.Equals("NodeDown", StringComparison.Ordinal))
            {
                obj = NodeDownEventConverter.GetFromJsonProperties(reader);
            }
            else if (propValue.Equals("NodeHealthReportCreated", StringComparison.Ordinal))
            {
                obj = NodeHealthReportCreatedEventConverter.GetFromJsonProperties(reader);
            }
            else if (propValue.Equals("NodeHealthReportExpired", StringComparison.Ordinal))
            {
                obj = NodeHealthReportExpiredEventConverter.GetFromJsonProperties(reader);
            }
            else if (propValue.Equals("NodeOpenedSuccess", StringComparison.Ordinal))
            {
                obj = NodeOpenedSuccessEventConverter.GetFromJsonProperties(reader);
            }
            else if (propValue.Equals("NodeOpenFailed", StringComparison.Ordinal))
            {
                obj = NodeOpenFailedEventConverter.GetFromJsonProperties(reader);
            }
            else if (propValue.Equals("NodeOpening", StringComparison.Ordinal))
            {
                obj = NodeOpeningEventConverter.GetFromJsonProperties(reader);
            }
            else if (propValue.Equals("NodeRemoved", StringComparison.Ordinal))
            {
                obj = NodeRemovedEventConverter.GetFromJsonProperties(reader);
            }
            else if (propValue.Equals("NodeUp", StringComparison.Ordinal))
            {
                obj = NodeUpEventConverter.GetFromJsonProperties(reader);
            }
            else if (propValue.Equals("PartitionHealthReportCreated", StringComparison.Ordinal))
            {
                obj = PartitionHealthReportCreatedEventConverter.GetFromJsonProperties(reader);
            }
            else if (propValue.Equals("PartitionHealthReportExpired", StringComparison.Ordinal))
            {
                obj = PartitionHealthReportExpiredEventConverter.GetFromJsonProperties(reader);
            }
            else if (propValue.Equals("PartitionReconfigurationCompleted", StringComparison.Ordinal))
            {
                obj = PartitionReconfigurationCompletedEventConverter.GetFromJsonProperties(reader);
            }
            else if (propValue.Equals("PartitionPrimaryMoveAnalysis", StringComparison.Ordinal))
            {
                obj = PartitionPrimaryMoveAnalysisEventConverter.GetFromJsonProperties(reader);
            }
            else if (propValue.Equals("ServiceCreated", StringComparison.Ordinal))
            {
                obj = ServiceCreatedEventConverter.GetFromJsonProperties(reader);
            }
            else if (propValue.Equals("ServiceDeleted", StringComparison.Ordinal))
            {
                obj = ServiceDeletedEventConverter.GetFromJsonProperties(reader);
            }
            else if (propValue.Equals("ServiceHealthReportCreated", StringComparison.Ordinal))
            {
                obj = ServiceHealthReportCreatedEventConverter.GetFromJsonProperties(reader);
            }
            else if (propValue.Equals("ServiceHealthReportExpired", StringComparison.Ordinal))
            {
                obj = ServiceHealthReportExpiredEventConverter.GetFromJsonProperties(reader);
            }
            else if (propValue.Equals("DeployedServiceHealthReportCreated", StringComparison.Ordinal))
            {
                obj = DeployedServiceHealthReportCreatedEventConverter.GetFromJsonProperties(reader);
            }
            else if (propValue.Equals("DeployedServiceHealthReportExpired", StringComparison.Ordinal))
            {
                obj = DeployedServiceHealthReportExpiredEventConverter.GetFromJsonProperties(reader);
            }
            else if (propValue.Equals("StatefulReplicaHealthReportCreated", StringComparison.Ordinal))
            {
                obj = StatefulReplicaHealthReportCreatedEventConverter.GetFromJsonProperties(reader);
            }
            else if (propValue.Equals("StatefulReplicaHealthReportExpired", StringComparison.Ordinal))
            {
                obj = StatefulReplicaHealthReportExpiredEventConverter.GetFromJsonProperties(reader);
            }
            else if (propValue.Equals("StatelessReplicaHealthReportCreated", StringComparison.Ordinal))
            {
                obj = StatelessReplicaHealthReportCreatedEventConverter.GetFromJsonProperties(reader);
            }
            else if (propValue.Equals("StatelessReplicaHealthReportExpired", StringComparison.Ordinal))
            {
                obj = StatelessReplicaHealthReportExpiredEventConverter.GetFromJsonProperties(reader);
            }
            else if (propValue.Equals("ClusterHealthReportCreated", StringComparison.Ordinal))
            {
                obj = ClusterHealthReportCreatedEventConverter.GetFromJsonProperties(reader);
            }
            else if (propValue.Equals("ClusterHealthReportExpired", StringComparison.Ordinal))
            {
                obj = ClusterHealthReportExpiredEventConverter.GetFromJsonProperties(reader);
            }
            else if (propValue.Equals("ClusterUpgradeComplete", StringComparison.Ordinal))
            {
                obj = ClusterUpgradeCompleteEventConverter.GetFromJsonProperties(reader);
            }
            else if (propValue.Equals("ClusterUpgradeDomainComplete", StringComparison.Ordinal))
            {
                obj = ClusterUpgradeDomainCompleteEventConverter.GetFromJsonProperties(reader);
            }
            else if (propValue.Equals("ClusterUpgradeRollbackComplete", StringComparison.Ordinal))
            {
                obj = ClusterUpgradeRollbackCompleteEventConverter.GetFromJsonProperties(reader);
            }
            else if (propValue.Equals("ClusterUpgradeRollbackStart", StringComparison.Ordinal))
            {
                obj = ClusterUpgradeRollbackStartEventConverter.GetFromJsonProperties(reader);
            }
            else if (propValue.Equals("ClusterUpgradeStart", StringComparison.Ordinal))
            {
                obj = ClusterUpgradeStartEventConverter.GetFromJsonProperties(reader);
            }
            else if (propValue.Equals("ChaosStopped", StringComparison.Ordinal))
            {
                obj = ChaosStoppedEventConverter.GetFromJsonProperties(reader);
            }
            else if (propValue.Equals("ChaosStarted", StringComparison.Ordinal))
            {
                obj = ChaosStartedEventConverter.GetFromJsonProperties(reader);
            }
            else if (propValue.Equals("ChaosRestartNodeFaultCompleted", StringComparison.Ordinal))
            {
                obj = ChaosRestartNodeFaultCompletedEventConverter.GetFromJsonProperties(reader);
            }
            else if (propValue.Equals("ChaosRestartCodePackageFaultScheduled", StringComparison.Ordinal))
            {
                obj = ChaosRestartCodePackageFaultScheduledEventConverter.GetFromJsonProperties(reader);
            }
            else if (propValue.Equals("ChaosRestartCodePackageFaultCompleted", StringComparison.Ordinal))
            {
                obj = ChaosRestartCodePackageFaultCompletedEventConverter.GetFromJsonProperties(reader);
            }
            else if (propValue.Equals("ChaosRemoveReplicaFaultScheduled", StringComparison.Ordinal))
            {
                obj = ChaosRemoveReplicaFaultScheduledEventConverter.GetFromJsonProperties(reader);
            }
            else if (propValue.Equals("ChaosRemoveReplicaFaultCompleted", StringComparison.Ordinal))
            {
                obj = ChaosRemoveReplicaFaultCompletedEventConverter.GetFromJsonProperties(reader);
            }
            else if (propValue.Equals("ChaosMoveSecondaryFaultScheduled", StringComparison.Ordinal))
            {
                obj = ChaosMoveSecondaryFaultScheduledEventConverter.GetFromJsonProperties(reader);
            }
            else if (propValue.Equals("ChaosMovePrimaryFaultScheduled", StringComparison.Ordinal))
            {
                obj = ChaosMovePrimaryFaultScheduledEventConverter.GetFromJsonProperties(reader);
            }
            else if (propValue.Equals("ChaosRestartReplicaFaultScheduled", StringComparison.Ordinal))
            {
                obj = ChaosRestartReplicaFaultScheduledEventConverter.GetFromJsonProperties(reader);
            }
            else if (propValue.Equals("ChaosRestartNodeFaultScheduled", StringComparison.Ordinal))
            {
                obj = ChaosRestartNodeFaultScheduledEventConverter.GetFromJsonProperties(reader);
            }
            else
            {
                throw new InvalidOperationException("Unknown Kind.");
            }

            return(obj);
        }
예제 #2
0
        /// <summary>
        /// Gets the object from Json properties.
        /// </summary>
        /// <param name="reader">The <see cref="T: Newtonsoft.Json.JsonReader" /> to read from.</param>
        /// <returns>The object Value.</returns>
        internal static ApplicationEvent GetFromJsonProperties(JsonReader reader)
        {
            var eventInstanceId     = default(Guid?);
            var timeStamp           = default(DateTime?);
            var hasCorrelatedEvents = default(bool?);
            var applicationId       = default(string);

            do
            {
                var propName = reader.ReadPropertyName();
                if (propName.Equals("Kind", StringComparison.Ordinal))
                {
                    var propValue = reader.ReadValueAsString();

                    if (propValue.Equals("ApplicationCreated", StringComparison.Ordinal))
                    {
                        return(ApplicationCreatedEventConverter.GetFromJsonProperties(reader));
                    }
                    else if (propValue.Equals("ApplicationDeleted", StringComparison.Ordinal))
                    {
                        return(ApplicationDeletedEventConverter.GetFromJsonProperties(reader));
                    }
                    else if (propValue.Equals("ApplicationHealthReportCreated", StringComparison.Ordinal))
                    {
                        return(ApplicationHealthReportCreatedEventConverter.GetFromJsonProperties(reader));
                    }
                    else if (propValue.Equals("ApplicationHealthReportExpired", StringComparison.Ordinal))
                    {
                        return(ApplicationHealthReportExpiredEventConverter.GetFromJsonProperties(reader));
                    }
                    else if (propValue.Equals("ApplicationUpgradeComplete", StringComparison.Ordinal))
                    {
                        return(ApplicationUpgradeCompleteEventConverter.GetFromJsonProperties(reader));
                    }
                    else if (propValue.Equals("ApplicationUpgradeDomainComplete", StringComparison.Ordinal))
                    {
                        return(ApplicationUpgradeDomainCompleteEventConverter.GetFromJsonProperties(reader));
                    }
                    else if (propValue.Equals("ApplicationUpgradeRollbackComplete", StringComparison.Ordinal))
                    {
                        return(ApplicationUpgradeRollbackCompleteEventConverter.GetFromJsonProperties(reader));
                    }
                    else if (propValue.Equals("ApplicationUpgradeRollbackStart", StringComparison.Ordinal))
                    {
                        return(ApplicationUpgradeRollbackStartEventConverter.GetFromJsonProperties(reader));
                    }
                    else if (propValue.Equals("ApplicationUpgradeStart", StringComparison.Ordinal))
                    {
                        return(ApplicationUpgradeStartEventConverter.GetFromJsonProperties(reader));
                    }
                    else if (propValue.Equals("DeployedApplicationHealthReportCreated", StringComparison.Ordinal))
                    {
                        return(DeployedApplicationHealthReportCreatedEventConverter.GetFromJsonProperties(reader));
                    }
                    else if (propValue.Equals("DeployedApplicationHealthReportExpired", StringComparison.Ordinal))
                    {
                        return(DeployedApplicationHealthReportExpiredEventConverter.GetFromJsonProperties(reader));
                    }
                    else if (propValue.Equals("ProcessDeactivated", StringComparison.Ordinal))
                    {
                        return(ProcessDeactivatedEventConverter.GetFromJsonProperties(reader));
                    }
                    else if (propValue.Equals("ContainerDeactivated", StringComparison.Ordinal))
                    {
                        return(ContainerDeactivatedEventConverter.GetFromJsonProperties(reader));
                    }
                    else if (propValue.Equals("DeployedServiceHealthReportCreated", StringComparison.Ordinal))
                    {
                        return(DeployedServiceHealthReportCreatedEventConverter.GetFromJsonProperties(reader));
                    }
                    else if (propValue.Equals("DeployedServiceHealthReportExpired", StringComparison.Ordinal))
                    {
                        return(DeployedServiceHealthReportExpiredEventConverter.GetFromJsonProperties(reader));
                    }
                    else if (propValue.Equals("ChaosRestartCodePackageFaultScheduled", StringComparison.Ordinal))
                    {
                        return(ChaosRestartCodePackageFaultScheduledEventConverter.GetFromJsonProperties(reader));
                    }
                    else if (propValue.Equals("ChaosRestartCodePackageFaultCompleted", StringComparison.Ordinal))
                    {
                        return(ChaosRestartCodePackageFaultCompletedEventConverter.GetFromJsonProperties(reader));
                    }
                    else if (propValue.Equals("ApplicationEvent", StringComparison.Ordinal))
                    {
                        // kind specified as same type, deserialize using properties.
                    }
                    else
                    {
                        throw new InvalidOperationException("Unknown Discriminator.");
                    }
                }
                else
                {
                    if (string.Compare("EventInstanceId", propName, StringComparison.Ordinal) == 0)
                    {
                        eventInstanceId = reader.ReadValueAsGuid();
                    }
                    else if (string.Compare("TimeStamp", propName, StringComparison.Ordinal) == 0)
                    {
                        timeStamp = reader.ReadValueAsDateTime();
                    }
                    else if (string.Compare("HasCorrelatedEvents", propName, StringComparison.Ordinal) == 0)
                    {
                        hasCorrelatedEvents = reader.ReadValueAsBool();
                    }
                    else if (string.Compare("ApplicationId", propName, StringComparison.Ordinal) == 0)
                    {
                        applicationId = reader.ReadValueAsString();
                    }
                    else
                    {
                        reader.SkipPropertyValue();
                    }
                }
            }while (reader.TokenType != JsonToken.EndObject);

            return(new ApplicationEvent(
                       kind: Common.FabricEventKind.ApplicationEvent,
                       eventInstanceId: eventInstanceId,
                       timeStamp: timeStamp,
                       hasCorrelatedEvents: hasCorrelatedEvents,
                       applicationId: applicationId));
        }