public override bool Equals(object o)
        {
            if (o == null || !this.GetType().Equals(o.GetType()))
            {
                return(false);
            }

            if (Object.ReferenceEquals(this, o))
            {
                return(true);
            }

            ThriftMethodMetadata that = (ThriftMethodMetadata)o;

            return(this.QualifiedName.Equals(that.QualifiedName) && this.ReturnType.Equals(that.ReturnType) &&
                   Enumerable.SequenceEqual(this.Parameters, that.Parameters) && this.Method.Equals(that.Method) &&
                   Enumerable.Equals(this.Exceptions, that.Exceptions) && this.IsOneWay.Equals(that.IsOneWay));
        }
Example #2
0
        //private readonly IEnumerable<String> documentation;

        public ThriftServiceMetadata(Type serviceClass, ThriftCatalog catalog)
        {
            this.Name = ParseServiceName(serviceClass);

            var builder = ImmutableDictionary.CreateBuilder <String, ThriftMethodMetadata>();

            foreach (var method in serviceClass.FindAttributedMethods(typeof(ThriftMethodAttribute)))
            {
                ThriftMethodMetadata methodMetadata = new ThriftMethodMetadata(this.Name, method, catalog);
                if (builder.ContainsKey(methodMetadata.QualifiedName))
                {
                    throw new ThriftyException($"duplicate thrift method : {method.DeclaringType.FullName}.{method.Name} .");
                }
                builder[methodMetadata.QualifiedName] = methodMetadata;
            }
            this.Methods = builder.ToImmutable();

            //A multimap from order to method name. Sorted by key (order), with nulls (i.e. no order) last.
            //Within each key, values(ThriftMethodMetadata) are sorted by method name.

            this.DeclaredMethods = builder
                                   .OrderBy(kp => kp.Value.Order).ThenBy(kp => kp.Key)
                                   .ToArray()
                                   .ToImmutableDictionary(kp => kp.Key, kp => kp.Value);

            List <ThriftServiceMetadata> parentServices = new List <ThriftServiceMetadata>();

            foreach (var parent in serviceClass.GetTypeInfo().GetInterfaces())
            {
                var attributes = parent.GetEffectiveClassAnnotations <ThriftServiceAttribute>();
                if (attributes.Any())
                {
                    parentServices.Add(new ThriftServiceMetadata(parent, catalog));
                }
            }
            this.ParentServices = parentServices.ToImmutableList();
        }