示例#1
0
 public override object ConvertFrom(ITypeDescriptorContext context, CultureInfo culture, object value)
 {
     if (!string.IsNullOrEmpty((string)value))
     {
         ComponentListener listener = new ComponentListener();
         listener.Handler = (string)value;
         return(listener);
     }
     else
     {
         return(new ComponentListener());
     }
 }
示例#2
0
        public override void WriteJson(JsonWriter writer, object value)
        {
            if (value != null && value is ComponentListener)
            {
                ComponentListener componentListener = (ComponentListener)value;

                if (!componentListener.IsDefault)
                {
                    writer.WriteRawValue(new ClientConfig().Serialize(componentListener));
                    return;
                }
            }
            writer.WriteRawValue("{}");
        }
示例#3
0
        private void InitEventsOwner()
        {
            PropertyInfo componentListeners = this.GetType().GetProperty(Observable.ListenersKey);

            if (componentListeners != null)
            {
                ComponentListeners     listeners  = componentListeners.GetValue(this, null) as ComponentListeners;
                List <ListenerTriplet> properties = listeners.Listeners;

                foreach (ListenerTriplet property in properties)
                {
                    ComponentListener listener = property.Listener;
                    if (listener != null)
                    {
                        listener.Owner = this;
                    }
                }
            }

            PropertyInfo ajaxEvents = this.GetType().GetProperty(Observable.AjaxEventsKey);

            if (ajaxEvents != null)
            {
                ComponentAjaxEvents     events     = ajaxEvents.GetValue(this, null) as ComponentAjaxEvents;
                List <AjaxEventTriplet> properties = events.AjaxEvents;

                foreach (AjaxEventTriplet property in properties)
                {
                    ComponentAjaxEvent ajaxEvent = property.AjaxEvent;
                    if (ajaxEvent != null)
                    {
                        ajaxEvent.Owner             = this;
                        ajaxEvent.ExtraParams.Owner = this;
                        foreach (Parameter param in ajaxEvent.ExtraParams)
                        {
                            param.Owner = this;
                        }
                    }

                    if (!ajaxEvent.IsDefault)
                    {
                        this.ForceIDRendering = true;
                    }
                }
            }
        }
示例#4
0
        public override void LoadViewState(object state)
        {
            object[] states = state as object[];

            if (states != null)
            {
                foreach (Pair pair in states)
                {
                    string listenerName  = (string)pair.First;
                    object listenerState = pair.Second;

                    if (listenerName == "base")
                    {
                        base.LoadViewState(listenerState);
                    }
                    else
                    {
                        PropertyInfo property = this.GetType().GetProperty(listenerName);

                        if (property == null)
                        {
                            throw new InvalidOperationException(string.Format("Can't find the property '{0}'", listenerName));
                        }

                        ComponentListener componentListener = (ComponentListener)property.GetValue(this, null);
                        if (componentListener != null)
                        {
                            componentListener.LoadViewState(listenerState);
                        }
                    }
                }
            }
            else
            {
                base.LoadViewState(state);
            }
        }
示例#5
0
 public ListenerTriplet(string name, ComponentListener listener, ClientConfigAttribute attribute)
 {
     this.name      = name;
     this.listener  = listener;
     this.attribute = attribute;
 }