Пример #1
0
        private readonly Method[] _sortedMethods;    // FIXME: [ NonSerialized ]

        internal ServiceClass(ServiceClassBuilder classBuilder)
        {
            Debug.Assert(classBuilder != null);

            _serviceName = classBuilder.Name;
            _description = classBuilder.Description;

            //
            // Set up methods and their names.
            //

            ICollection methodBuilders = classBuilder.Methods;

            _methods     = new Method[methodBuilders.Count];
            _methodNames = new string[methodBuilders.Count];
            int methodIndex = 0;

            foreach (MethodBuilder methodBuilder in methodBuilders)
            {
                Method method = new Method(methodBuilder, this);

                //
                // Check for duplicates.
                //

                if (Array.IndexOf(_methodNames, method.Name) >= 0)
                {
                    throw new DuplicateMethodException(string.Format("The method '{0}' cannot be exported as '{1}' because this name has already been used by another method on the '{2}' service.", method.Name, method.InternalName, _serviceName));
                }

                //
                // Add the method to the class and index it by its name.
                //

                _methods[methodIndex]       = method;
                _methodNames[methodIndex++] = method.Name;
            }

            //
            // Keep a sorted list of parameters and their names so we can
            // do fast look ups using binary search.
            //

            _sortedMethods = (Method[])_methods.Clone();
            InvariantStringArray.Sort(_methodNames, _sortedMethods);
        }
Пример #2
0
 internal MethodBuilder(ServiceClassBuilder serviceClass)
 {
     Debug.Assert(serviceClass != null);
     _serviceClass = serviceClass;
     _attributes   = ZeroAttributes;
 }