Example #1
0
 public static Schema.KRPC.Services GetServices()
 {
     var services = new Schema.KRPC.Services ();
     foreach (var serviceSignature in Services.Instance.Signatures.Values) {
         var service = new Schema.KRPC.Service ();
         service.Name = serviceSignature.Name;
         foreach (var procedureSignature in serviceSignature.Procedures.Values) {
             var procedure = new Procedure ();
             procedure.Name = procedureSignature.Name;
             if (procedureSignature.HasReturnType)
             {
                 procedure.HasReturnType = true;
                 procedure.ReturnType = TypeUtils.GetTypeName (procedureSignature.ReturnType);
             }
             foreach (var parameterSignature in procedureSignature.Parameters) {
                 var parameter = new Parameter ();
                 parameter.Name = parameterSignature.Name;
                 parameter.Type = TypeUtils.GetTypeName (parameterSignature.Type);
                 if (parameterSignature.HasDefaultArgument)
                 {
                     parameter.HasDefaultArgument = true;
                     parameter.DefaultArgument = parameterSignature.DefaultArgument;
                 }
                 procedure.Parameters.Add (parameter);
             }
             foreach (var attribute in procedureSignature.Attributes) {
                 procedure.Attributes.Add (attribute);
             }
             if (procedureSignature.Documentation != "")
                 procedure.Documentation = procedureSignature.Documentation;
             service.Procedures.Add (procedure);
         }
         foreach (var clsSignature in serviceSignature.Classes.Values) {
             var cls = new Class ();
             cls.Name = clsSignature.Name;
             if (clsSignature.Documentation != "")
                 cls.Documentation = clsSignature.Documentation;
             service.Classes.Add (cls);
         }
         foreach (var enmSignature in serviceSignature.Enumerations.Values) {
             var enm = new Enumeration ();
             enm.Name = enmSignature.Name;
             if (enmSignature.Documentation != "")
                 enm.Documentation = enmSignature.Documentation;
             foreach (var enmValueSignature in enmSignature.Values) {
                 var enmValue = new EnumerationValue ();
                 enmValue.Name = enmValueSignature.Name;
                 enmValue.Value = enmValueSignature.Value;
                 if (enmValueSignature.Documentation != "")
                     enmValue.Documentation = enmValueSignature.Documentation;
                 enm.Values.Add (enmValue);
             }
             service.Enumerations.Add (enm);
         }
         if (serviceSignature.Documentation != "")
             service.Documentation = serviceSignature.Documentation;
         services.Services_.Add (service);
     }
     return services;
 }
Example #2
0
 public static Schema.KRPC.Service ToProtobufMessage (this Service.Messages.Service service)
 {
     var result = new Schema.KRPC.Service ();
     result.Name = service.Name;
     result.Procedures.Add (service.Procedures.Select (ToProtobufMessage));
     result.Classes.Add (service.Classes.Select (ToProtobufMessage));
     result.Enumerations.Add (service.Enumerations.Select (ToProtobufMessage));
     result.Documentation = service.Documentation;
     return result;
 }
Example #3
0
        public static Schema.KRPC.Service ToProtobufMessage(this Service.Messages.Service service)
        {
            var result = new Schema.KRPC.Service();

            result.Name = service.Name;
            result.Procedures.Add(service.Procedures.Select(ToProtobufMessage));
            result.Classes.Add(service.Classes.Select(ToProtobufMessage));
            result.Enumerations.Add(service.Enumerations.Select(ToProtobufMessage));
            result.Documentation = service.Documentation;
            return(result);
        }
Example #4
0
        public static Schema.KRPC.Services GetServices()
        {
            var services = new Schema.KRPC.Services();

            foreach (var serviceSignature in Services.Instance.Signatures.Values)
            {
                var service = new Schema.KRPC.Service();
                service.Name = serviceSignature.Name;
                foreach (var procedureSignature in serviceSignature.Procedures.Values)
                {
                    var procedure = new Procedure();
                    procedure.Name = procedureSignature.Name;
                    if (procedureSignature.HasReturnType)
                    {
                        procedure.HasReturnType = true;
                        procedure.ReturnType    = TypeUtils.GetTypeName(procedureSignature.ReturnType);
                    }
                    foreach (var parameterSignature in procedureSignature.Parameters)
                    {
                        var parameter = new Parameter();
                        parameter.Name = parameterSignature.Name;
                        parameter.Type = TypeUtils.GetTypeName(parameterSignature.Type);
                        if (parameterSignature.HasDefaultArgument)
                        {
                            parameter.HasDefaultArgument = true;
                            parameter.DefaultArgument    = parameterSignature.DefaultArgument;
                        }
                        procedure.Parameters.Add(parameter);
                    }
                    foreach (var attribute in procedureSignature.Attributes)
                    {
                        procedure.Attributes.Add(attribute);
                    }
                    if (procedureSignature.Documentation != "")
                    {
                        procedure.Documentation = procedureSignature.Documentation;
                    }
                    service.Procedures.Add(procedure);
                }
                foreach (var clsSignature in serviceSignature.Classes.Values)
                {
                    var cls = new Class();
                    cls.Name = clsSignature.Name;
                    if (clsSignature.Documentation != "")
                    {
                        cls.Documentation = clsSignature.Documentation;
                    }
                    service.Classes.Add(cls);
                }
                foreach (var enmSignature in serviceSignature.Enumerations.Values)
                {
                    var enm = new Enumeration();
                    enm.Name = enmSignature.Name;
                    if (enmSignature.Documentation != "")
                    {
                        enm.Documentation = enmSignature.Documentation;
                    }
                    foreach (var enmValueSignature in enmSignature.Values)
                    {
                        var enmValue = new EnumerationValue();
                        enmValue.Name  = enmValueSignature.Name;
                        enmValue.Value = enmValueSignature.Value;
                        if (enmValueSignature.Documentation != "")
                        {
                            enmValue.Documentation = enmValueSignature.Documentation;
                        }
                        enm.Values.Add(enmValue);
                    }
                    service.Enumerations.Add(enm);
                }
                if (serviceSignature.Documentation != "")
                {
                    service.Documentation = serviceSignature.Documentation;
                }
                services.Services_.Add(service);
            }
            return(services);
        }