コード例 #1
0
ファイル: MemberParser.cs プロジェクト: st9200/soal-oslo
        private void Process_Operation(dynamic node)
        {
            Operation operation = new Operation();

            // Map source location and node to object
            operation.AddMetaInfo(new SourceLocationInfo(node, context));
            context.AddObject(node, operation);

            // Interface
            try
            {
                NameContext.Current.CheckName(node.Name, typeof(Operation));
                operation.Interface = (Interface)NameContext.Current.Scope;
            }
            catch (NameCollisionException exception)
            {
                Error_NameExists(operation, exception);
            }

            // Name (obligatory)
            operation.Name = node.Name;

            // ReturnType (obligatory)
            try
            {
                operation.ReturnType = this.Process_ReturnTypeReference(node.ReturnType);
            }
            catch (NameNotFoundException exception)
            {
                Error_NameNotFound(operation, exception);
            }
            catch (NameCollisionException exception)
            {
                Error_NameCollision(operation, exception);
            }

            // Enter scope
            using (new NameContextScope(operation))
            {
                // Parameters (optional)
                if (node.Parameters != null)
                {
                    foreach (dynamic param in node.Parameters)
                    {
                        this.Process_OperationParameter(param);
                    }
                }

                // Exceptions (optional)
                if (node.Exceptions != null)
                {
                    foreach (dynamic exc in node.Exceptions)
                    {
                        SourceLocationInfo location = new SourceLocationInfo(exc, context);
                        try
                        {
                            ExceptionType exceptionType = this.Process_NamespacedTypeReference(exc, typeof(ExceptionType));
                            if (operation.Exceptions.Contains(exceptionType))
                            {
                                Error_NameRedundant(location, typeof(ExceptionType), exceptionType.FullName);
                            }
                            else
                            {
                                operation.Exceptions.Add(exceptionType);
                            }
                        }
                        catch (NameNotFoundException exception)
                        {
                            Error_NameNotFound(location, exception);
                        }
                        catch (NameCollisionException exception)
                        {
                            Error_NameCollision(location, exception);
                        }
                    }
                }
            }
        }