Пример #1
0
        public Com.DigitalAsset.Ledger.Api.V1.Command ToProtoCommand()
        {
            Com.DigitalAsset.Ledger.Api.V1.Command command = new Com.DigitalAsset.Ledger.Api.V1.Command();

            if (this is CreateCommand)
            {
                command.Create = ((CreateCommand)this).ToProto();
            }
            else if (this is ExerciseCommand)
            {
                command.Exercise = ((ExerciseCommand)this).ToProto();
            }
            else if (this is CreateAndExerciseCommand)
            {
                command.CreateAndExercise = ((CreateAndExerciseCommand)this).ToProto();
            }
            else if (this is ExerciseByKeyCommand)
            {
                command.ExerciseByKey = ((ExerciseByKeyCommand)this).ToProto();
            }
            else
            {
                throw new CommandUnknown(this);
            }

            return(command);
        }
Пример #2
0
        public static Command FromProtoCommand(Com.DigitalAsset.Ledger.Api.V1.Command command)
        {
            switch (command.CommandCase)
            {
            case Com.DigitalAsset.Ledger.Api.V1.Command.CommandOneofCase.Create:
                return(CreateCommand.FromProto(command.Create));

            case Com.DigitalAsset.Ledger.Api.V1.Command.CommandOneofCase.Exercise:
                return(ExerciseCommand.FromProto(command.Exercise));

            case Com.DigitalAsset.Ledger.Api.V1.Command.CommandOneofCase.CreateAndExercise:
                return(CreateAndExerciseCommand.FromProto(command.CreateAndExercise));

            case Com.DigitalAsset.Ledger.Api.V1.Command.CommandOneofCase.ExerciseByKey:
                return(ExerciseByKeyCommand.FromProto(command.ExerciseByKey));

            case Com.DigitalAsset.Ledger.Api.V1.Command.CommandOneofCase.None:
            default:
                throw new ProtoCommandUnknown(command);
            }
        }
Пример #3
0
 public ProtoCommandUnknown(Com.DigitalAsset.Ledger.Api.V1.Command command)
     : base($"Command unknown {command}")
 {
 }