Exemplo n.º 1
0
        /// <summary>
        /// Creates a statementLine using the given member data.
        /// </summary>
        /// <returns>Returns the generated CodeStatement.</returns>
        public CodeStatement CreateStatement()
        {
            CodeCatchClause codeCatchClause;

            if (Type != null && Catch != null)
            {
                codeCatchClause = new CodeCatchClause(LocalName, new CodeTypeReference(Type),
                                                      Catch.Select(s => s.CreateStatement()).ToArray());
            }
            else if (Type != null && Catch == null)
            {
                codeCatchClause = new CodeCatchClause(LocalName, new CodeTypeReference(Type));
            }
            else
            {
                codeCatchClause = new CodeCatchClause(LocalName);
            }


            return(Finally != null
                ? new CodeTryCatchFinallyStatement(Try.Select(s => s.CreateStatement()).ToArray(), new[] { codeCatchClause },
                                                   Finally.Select(s => s.CreateStatement()).ToArray())
                : new CodeTryCatchFinallyStatement(Try.Select(s => s.CreateStatement()).ToArray(),
                                                   new[] { codeCatchClause }));
        }