CQRSMicroservices.Application.Deserializer.CreateCommand C# (CSharp) Метод

CreateCommand() публичный Метод

You could implement this with reflection or some other deserialize algorithm. For this sample, we explicitly implemented this.
public CreateCommand ( Newtonsoft.Json.Linq.JObject commandJson ) : Command
commandJson Newtonsoft.Json.Linq.JObject
Результат CQRSMicroservices.Framework.Command
    public Command CreateCommand(JObject commandJson)
    {
      var commandName = commandJson.Properties().First().Name;
      var commandBody = commandJson.Properties().First().Value.Value<JObject>();

      switch(commandName)
      {
        case "CQRSMicroservices.Articles.CreateArticleCommand":
          return new CreateArticleCommand
          {
            ArticleId = Guid.Parse(commandBody["ArticleId"].Value<string>()),
            Description = commandBody["Description"].Value<string>(),
            Price = decimal.Parse(commandBody["Price"].Value<string>(), System.Globalization.CultureInfo.InvariantCulture)
          };

        case "CQRSMicroservices.Articles.MakeArticleAvailableCommand":

          return new MakeArticleAvailableCommand
          {
            ArticleId = Guid.Parse(commandBody["ArticleId"].Value<string>()),
          };

        case "CQRSMicroservices.Articles.MakeArticleUnavailableCommand":
          return new MakeArticleUnavailableCommand
          {
            ArticleId = Guid.Parse(commandBody["ArticleId"].Value<string>()),
          };

        case "CQRSMicroservices.Articles.SellArticleCommand":
          return new SellArticleCommand
          {
            ArticleId = Guid.Parse(commandBody["ArticleId"].Value<string>()),
            CustomerId = Guid.Parse(commandBody["CustomerId"].Value<string>()),
          };

        case "CQRSMicroservices.Customers.CreateCustomerCommand":
          return new CreateCustomerCommand
          {
            CustomerId = Guid.Parse(commandBody["CustomerId"].Value<string>()),
            Name = commandBody["Name"].Value<string>()
          };

        default:
          throw new CommandNotFoundException(commandName);
      }
    }
    /// <summary>