Пример #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>
 /// Gets the member name from the object obj.  Returns true if the member is successfully retrieved and
 /// stores the value in the value out param.
 /// </summary>
 public bool TryGetMember(object obj, string name, out object value)
 {
     return(_ops.TryGetMember(obj, name, out value));
 }