public override void WriteJson(JsonWriter writer, object value, JsonSerializer serializer) { if (value != null && value is ComponentListener) { ComponentListener componentListener = (ComponentListener)value; if (!componentListener.IsDefault) { if (this.Owner is StateManagedItem) { componentListener.Owner = ((StateManagedItem)this.Owner).Owner; } else if (this.Owner is Control) { componentListener.Owner = (Control)this.Owner; } componentListener.SetArgumentList(this.Owner.GetType().GetProperty(this.PropertyName)); writer.WriteRawValue(new ClientConfig().Serialize(componentListener)); return; } } writer.WriteRawValue("{}"); }
public override object ConvertFrom(ITypeDescriptorContext context, CultureInfo culture, object value) { if (((string)value).IsNotEmpty()) { ComponentListener listener = new ComponentListener(); listener.Handler = (string)value; return(listener); } else { return(new ComponentListener()); } }
public override object ConvertFrom(ITypeDescriptorContext context, CultureInfo culture, object value) { if (((string)value).IsNotEmpty()) { ComponentListener listener = new ComponentListener(); listener.Handler = (string)value; return listener; } else { return new ComponentListener(); } }
public override void LoadViewState(object state) { object[] states = state as object[]; ResourceManager rm = this.ResourceManager; if (rm != null && !rm.ManageEventsViewState) { base.LoadViewState(state); } 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("Can't find the property '{0}'".FormatWith(listenerName)); } ComponentListener componentListener = (ComponentListener)property.GetValue(this, null); if (componentListener != null) { componentListener.LoadViewState(listenerState); } } } } else { base.LoadViewState(state); } }
public ListenerTriplet(string name, ComponentListener listener, ConfigOptionAttribute attribute) { this.name = name; this.listener = listener; this.attribute = attribute; }