示例#1
0
 /// <summary>
 /// Add action to Catch block
 /// </summary>
 /// <param name="action">Action to add</param>
 public void AddCatch(IScriptAction action)
 {
     if (Catch== null)
         Catch = new Block();
     Catch.Add(action);
 }
示例#2
0
        /// Handle exception
        protected object OnError(Exception ex, Block catchBlock)
        {
            VerboseMessage("Exception: {0}.", Utils.TransformStr(ex.Message, TransformRules.TrimInternal));
            if (catchBlock == null)
                Utils.Rethrow(ex);
            Exception excSave = Context.CurrentException;
            try
            {

                ScriptExceptionWithStackTrace cs = ex as ScriptExceptionWithStackTrace;
                Context.CurrentException = (cs == null) ? ex : cs.InnerException;
                if (catchBlock != null && catchBlock.Items.Count == 0)
                    VerboseMessage("Supressing exception");
                else
                {

                    return Context.Execute(catchBlock);
                }
            }
            finally
            {
                Context.CurrentException = excSave;
                if (ex is ScriptTerminateException)
                    Utils.Rethrow(ex);
            }
            return null;
        }
示例#3
0
 /// <summary>
 /// Add action to Try block
 /// </summary>
 /// <param name="action">Action to add</param>
 public void AddTry(IScriptAction action)
 {
     if (Try == null)
         Try = new Block();
     Try.Add(action);
 }
示例#4
0
 /// <summary>
 /// Add action to Finally block
 /// </summary>
 /// <param name="action">Action to add</param>
 public void AddFinally(IScriptAction action)
 {
     if (Finally== null)
         Finally = new Block();
     Finally.Add(action);
 }
示例#5
0
文件: If.cs 项目: xsharper/xsharper
        /// <summary>
        /// Read child element of the current node
        /// </summary>
        /// <param name="context">XML context</param>
        /// <param name="reader">XML reader</param>
        /// <param name="setToProperty">Property to which the object must be assigned, or null for automatic resolution</param>
        protected override void ReadChildElement(IXsContext context, System.Xml.XmlReader reader, System.Reflection.PropertyInfo setToProperty)
        {
            if (string.Compare(reader.LocalName, "else", StringComparison.OrdinalIgnoreCase) == 0)
            {
                if (Else!=null)
                    throw new ParsingException("Only one else block is allowed per if statement!");

                // To allow special <if> <else /> </if> syntax
                if (reader.IsEmptyElement)
                {
                    Else = new Block();
                    reader.Skip();
                    return;
                }
            }

            base.ReadChildElement(context, reader, setToProperty);
        }
示例#6
0
文件: If.cs 项目: xsharper/xsharper
 /// Add an action to Else block
 public void AddElse(IScriptAction action)
 {
     if (Else == null)
         Else = new Block();
     Else.Add(action);
 }