Пример #1
0
            public object __exit__(CodeContext context, object exc_type, object exc_value, object exc_tb)
            {
                DynamicOperations ops = context.LanguageContext.Operations;

                if (exc_type == null && exc_value == null && exc_tb == null)
                {
                    object commitfn;
                    if (ops.TryGetMember(this, "commit", out commitfn))
                    {
                        ops.Invoke(commitfn);
                    }
                    else
                    {
                        commit();
                    }
                }
                else
                {
                    object rollbackfn;
                    if (ops.TryGetMember(this, "rollback", out rollbackfn))
                    {
                        ops.Invoke(rollbackfn);
                    }
                    else
                    {
                        rollback();
                    }
                }

                return(false);
            }
Пример #2
0
 /// <summary>
 /// Invokes the provided object with the given parameters and returns the result.
 ///
 /// The prefered way of calling objects is to convert the object to a strongly typed delegate
 /// using the ConvertTo methods and then invoking that delegate.
 /// </summary>
 public dynamic Invoke(object obj, params object[] parameters)
 {
     return(_ops.Invoke(obj, parameters));
 }
Пример #3
0
 /// <summary>
 /// Calls the provided object with the given parameters and returns the result.
 ///
 /// The prefered way of calling objects is to convert the object to a strongly typed delegate
 /// using the ConvertTo methods and then invoking that delegate.
 /// </summary>
 public object Call(object obj, params object[] parameters)
 {
     return(_ops.Invoke(obj, parameters));
 }