Ejemplo n.º 1
0
        private void ApplyAuthorizationRules(Control control)
        {
            foreach (Binding binding in control.DataBindings)
            {
                // get the BindingSource if appropriate
                if (binding.DataSource is BindingSource)
                {
                    BindingSource bs =
                        (BindingSource)binding.DataSource;
                    // get the object property name
                    string propertyName =
                        binding.BindingMemberInfo.BindingField;
                    // get the BusinessObject if appropriate
                    if (bs.DataSource is BusinessBase)
                    {
                        BusinessBase ds =
                            (BusinessBase)bs.DataSource;

                        ApplyReadRules(
                            control, binding,
                            ds.CanReadProperty(propertyName));
                        ApplyWriteRules(
                            control, binding,
                            ds.CanWriteProperty(propertyName));
                    }
                    else if (bs.DataSource is IReadOnlyObject)
                    {
                        IReadOnlyObject ds =
                            (IReadOnlyObject)bs.DataSource;

                        ApplyReadRules(
                            control, binding,
                            ds.CanReadProperty(propertyName));
                    }
                }
            }
        }