/// <summary> /// Creates a service. /// </summary> public ServiceInfo(string name, IEnumerable <IServiceMemberInfo> members = null, IEnumerable <ServiceAttributeInfo> attributes = null, string summary = null, IEnumerable <string> remarks = null, NamedTextPosition position = null) { if (name == null) { throw new ArgumentNullException(nameof(name)); } Name = name; Members = members.ToReadOnlyList(); Attributes = attributes.ToReadOnlyList(); Summary = summary ?? ""; Remarks = remarks.ToReadOnlyList(); Position = position; ServiceDefinitionUtility.ValidateName(Name, Position); foreach (var member in Members) { if (!(member is ServiceMethodInfo) && !(member is ServiceDtoInfo) && !(member is ServiceEnumInfo) && !(member is ServiceErrorSetInfo)) { throw new ServiceDefinitionException($"Unsupported member type '{member.GetType()}'."); } } ServiceDefinitionUtility.ValidateNoDuplicateNames(Members, "service member"); m_membersByName = new ReadOnlyDictionary <string, IServiceMemberInfo>(Members.ToDictionary(x => x.Name, x => x)); foreach (var field in Methods.SelectMany(x => x.RequestFields.Concat(x.ResponseFields)).Concat(Dtos.SelectMany(x => x.Fields))) { GetFieldType(field); } }
/// <summary> /// Creates an attribute. /// </summary> public ServiceAttributeInfo(string name, IEnumerable <ServiceAttributeParameterInfo> parameters = null, NamedTextPosition position = null) { if (name == null) { throw new ArgumentNullException(nameof(name)); } Name = name; Parameters = parameters.ToReadOnlyList(); Position = position; ServiceDefinitionUtility.ValidateName(Name, Position); ServiceDefinitionUtility.ValidateNoDuplicateNames(Parameters, "attribute parameter"); }
/// <summary> /// Creates an enum value. /// </summary> public ServiceEnumValueInfo(string name, IEnumerable <ServiceAttributeInfo> attributes = null, string summary = null, NamedTextPosition position = null) { if (name == null) { throw new ArgumentNullException(nameof(name)); } Name = name; Attributes = attributes.ToReadOnlyList(); Summary = summary ?? ""; Position = position; ServiceDefinitionUtility.ValidateName(Name, Position); }
/// <summary> /// Creates a DTO. /// </summary> public ServiceDtoInfo(string name, IEnumerable <ServiceFieldInfo> fields = null, IEnumerable <ServiceAttributeInfo> attributes = null, string summary = null, IEnumerable <string> remarks = null, NamedTextPosition position = null) { if (name == null) { throw new ArgumentNullException(nameof(name)); } Name = name; Fields = fields.ToReadOnlyList(); Attributes = attributes.ToReadOnlyList(); Summary = summary ?? ""; Remarks = remarks.ToReadOnlyList(); Position = position; ServiceDefinitionUtility.ValidateName(Name, Position); ServiceDefinitionUtility.ValidateNoDuplicateNames(Fields, "field"); }
/// <summary> /// Creates an attribute parameter. /// </summary> public ServiceAttributeParameterInfo(string name, string value, NamedTextPosition position = null) { if (name == null) { throw new ArgumentNullException(nameof(name)); } if (value == null) { throw new ArgumentNullException(nameof(value)); } Name = name; Value = value; Position = position; ServiceDefinitionUtility.ValidateName(Name, Position); }