Beispiel #1
0
        /// <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");
        }
Beispiel #3
0
        /// <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");
        }