System.ComponentModel.MemberDescriptor.GetSite C# (CSharp) Méthode

GetSite() protected static méthode

Gets a component site for the given component.

protected static GetSite ( object component ) : ISite
component object
Résultat ISite
        protected static ISite GetSite(object component)
        {
            if (!(component is IComponent))
            {
                return null;
            }

            return ((IComponent)component).Site;
        }

Usage Example

Exemple #1
0
 public override void SetValue(object component, object value)
 {
     if (component != null)
     {
         ISite site = MemberDescriptor.GetSite(component);
         IComponentChangeService service = null;
         object oldValue         = null;
         object invocationTarget = this.GetInvocationTarget(this.componentClass, component);
         if (!this.IsReadOnly)
         {
             if (site != null)
             {
                 service = (IComponentChangeService)site.GetService(typeof(IComponentChangeService));
             }
             if (service != null)
             {
                 oldValue = SecurityUtils.MethodInfoInvoke(this.GetMethodValue, invocationTarget, null);
                 try
                 {
                     service.OnComponentChanging(component, this);
                 }
                 catch (CheckoutException exception)
                 {
                     if (exception != CheckoutException.Canceled)
                     {
                         throw exception;
                     }
                     return;
                 }
             }
             try
             {
                 SecurityUtils.MethodInfoInvoke(this.SetMethodValue, invocationTarget, new object[] { value });
                 this.OnValueChanged(invocationTarget, EventArgs.Empty);
             }
             catch (Exception exception2)
             {
                 value = oldValue;
                 if ((exception2 is TargetInvocationException) && (exception2.InnerException != null))
                 {
                     throw exception2.InnerException;
                 }
                 throw exception2;
             }
             finally
             {
                 if (service != null)
                 {
                     service.OnComponentChanged(component, this, oldValue, value);
                 }
             }
         }
     }
 }
All Usage Examples Of System.ComponentModel.MemberDescriptor::GetSite