LogicTransactionObject AddLogObject(IBaseObject obj, LogAction action, BaseContext context, int?order)
        {
            if (obj == null)
            {
                throw new ArgumentNullException("obj");
            }
            if (String.IsNullOrEmpty(obj.Iid))
            {
                throw new ArgumentNullException("obj.Iid");
            }

            if (this.Objects == null)
            {
                this.Objects = new List <LogicTransactionObject>();
            }

            var result = this.Objects.FirstOrDefault(o => o.ObjectIid.Equals(obj.Iid, StringComparison.OrdinalIgnoreCase) && o.ActionChar.Equals(action.GetFirstLetter()));

            if (result == null)
            {
                this.Objects.Add(result = new LogicTransactionObject(action, obj, context)
                {
                    Params = new List <LogicTransactionObjectParam>()
                });
            }
            result.AddOrder = order ?? this.Objects.Count;
            return(result);
        }