private static void CanExecuteRemove(object target, CanExecuteRoutedEventArgs e)
        {
            bool result = false;
            YYTDataProviderCommandManager ctl = target as YYTDataProviderCommandManager;

            if (ctl != null && ctl.Provider != null)
            {
                if (ctl.Provider.Data != null)
                {
                    YYT.Core.BusinessBase bb = e.Parameter as YYT.Core.BusinessBase;
                    IBindingList          list;
                    if (bb != null)
                    {
                        list = bb.Parent as IBindingList;
                    }
                    else
                    {
                        list = ctl.Provider.Data as IBindingList;
                    }
                    if (list != null)
                    {
                        result = list.AllowRemove;
                        if (result && !YYT.Security.AuthorizationRules.CanEditObject(ctl.Provider.Data.GetType()))
                        {
                            result = false;
                        }
                    }
                }
            }
            e.CanExecute = result;
        }
Ejemplo n.º 2
0
        /// <summary>
        /// Removes an item from the list if the object
        /// implements IBindingList and AllowRemove is true.
        /// </summary>
        /// <param name="item">
        /// The item to be removed from the list.
        /// </param>
        public void RemoveItem(object item)
        {
            // only do something if the object implements
            // IBindingList
            IBindingList list;

            YYT.Core.BusinessBase bb = item as YYT.Core.BusinessBase;
            if (bb != null)
            {
                list = bb.Parent as IBindingList;
            }
            else
            {
                list = this.Data as IBindingList;
            }
            if (list != null && list.AllowRemove)
            {
                list.Remove(item);
            }
        }
Ejemplo n.º 3
0
 /// <summary>
 /// By wrapping this property inside Using block
 /// you can set property values on
 /// <paramref name="businessObject">business object</paramref>
 /// without raising PropertyChanged events
 /// and checking user rights.
 /// </summary>
 /// <param name="businessObject">
 /// Object on with you would like to set property values
 /// </param>
 /// <returns>
 /// An instance of IDisposable object that allows
 /// bypassing of normal authorization checks during
 /// property setting.
 /// </returns>
 protected IDisposable BypassPropertyChecks(YYT.Core.BusinessBase businessObject)
 {
     return(businessObject.BypassPropertyChecks);
 }