示例#1
0
        public static Messages.Services GetServices()
        {
            var services = new Messages.Services();

            foreach (var serviceSignature in Services.Instance.Signatures.Values)
            {
                var service = new Messages.Service(serviceSignature.Name);
                foreach (var procedureSignature in serviceSignature.Procedures.Values)
                {
                    var procedure = new Procedure(procedureSignature.Name);
                    if (procedureSignature.HasReturnType)
                    {
                        procedure.ReturnType = TypeUtils.GetTypeName(procedureSignature.ReturnType);
                    }
                    foreach (var parameterSignature in procedureSignature.Parameters)
                    {
                        var parameter = new Parameter(parameterSignature.Name, TypeUtils.GetTypeName(parameterSignature.Type));
                        if (parameterSignature.HasDefaultValue)
                        {
                            parameter.DefaultValue = parameterSignature.DefaultValue;
                        }
                        procedure.Parameters.Add(parameter);
                    }
                    foreach (var attribute in procedureSignature.Attributes)
                    {
                        procedure.Attributes.Add(attribute);
                    }
                    if (procedureSignature.Documentation.Length > 0)
                    {
                        procedure.Documentation = procedureSignature.Documentation;
                    }
                    service.Procedures.Add(procedure);
                }
                foreach (var clsSignature in serviceSignature.Classes.Values)
                {
                    var cls = new Class(clsSignature.Name);
                    if (clsSignature.Documentation.Length > 0)
                    {
                        cls.Documentation = clsSignature.Documentation;
                    }
                    service.Classes.Add(cls);
                }
                foreach (var enmSignature in serviceSignature.Enumerations.Values)
                {
                    var enm = new Enumeration(enmSignature.Name);
                    if (enmSignature.Documentation.Length > 0)
                    {
                        enm.Documentation = enmSignature.Documentation;
                    }
                    foreach (var enmValueSignature in enmSignature.Values)
                    {
                        var enmValue = new EnumerationValue(enmValueSignature.Name, enmValueSignature.Value);
                        if (enmValueSignature.Documentation.Length > 0)
                        {
                            enmValue.Documentation = enmValueSignature.Documentation;
                        }
                        enm.Values.Add(enmValue);
                    }
                    service.Enumerations.Add(enm);
                }
                if (serviceSignature.Documentation.Length > 0)
                {
                    service.Documentation = serviceSignature.Documentation;
                }
                services.ServicesList.Add(service);
            }
            return(services);
        }
示例#2
0
文件: KRPC.cs 项目: pipi1226/krpc
        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);
        }