public ChoConfigurableObject() { _configurationElementAttribute = ChoType.GetAttribute(GetType(), typeof(ChoConfigurationSectionAttribute)) as ChoConfigurationSectionAttribute; //Discover and Hook the event handlers if (BeforeConfigurationObjectMemberLoaded == null) { EventHandlerEx.LoadHandlers <ChoPreviewConfigurationObjectMemberEventArgs>(ref BeforeConfigurationObjectMemberLoaded, ChoType.GetMethods(GetType(), typeof(ChoBeforeConfigurationObjectMemberLoadedHandlerAttribute)), this); } if (AfterConfigurationObjectMemberLoaded == null) { EventHandlerEx.LoadHandlers <ChoConfigurationObjectMemberEventArgs>(ref AfterConfigurationObjectMemberLoaded, ChoType.GetMethods(GetType(), typeof(ChoAfterConfigurationObjectMemberLoadedHandlerAttribute)), this); } if (ConfigurationObjectMemberLoadError == null) { EventHandlerEx.LoadHandlers <ChoConfigurationObjectMemberErrorEventArgs>(ref ConfigurationObjectMemberLoadError, ChoType.GetMethods(GetType(), typeof(ChoConfigurationObjectMemberLoadErrorHandlerAttribute)), this); } if (BeforeConfigurationObjectPersisted == null) { EventHandlerEx.LoadHandlers <ChoPreviewConfigurationObjectEventArgs>(ref BeforeConfigurationObjectPersisted, ChoType.GetMethods(GetType(), typeof(ChoBeforeConfigurationObjectPersistedHandlerAttribute)), this); } if (AfterConfigurationObjectPersisted == null) { EventHandlerEx.LoadHandlers <ChoConfigurationObjectEventArgs>(ref AfterConfigurationObjectPersisted, ChoType.GetMethods(GetType(), typeof(ChoAfterConfigurationObjectPersistedHandlerAttribute)), this); } if (BeforeConfigurationObjectMemberPersist == null) { EventHandlerEx.LoadHandlers <ChoPreviewConfigurationObjectMemberEventArgs>(ref BeforeConfigurationObjectMemberPersist, ChoType.GetMethods(GetType(), typeof(ChoBeforeConfigurationObjectMemberPersistHandlerAttribute)), this); } if (AfterConfigurationObjectMemberPersist == null) { EventHandlerEx.LoadHandlers <ChoConfigurationObjectMemberEventArgs>(ref AfterConfigurationObjectMemberPersist, ChoType.GetMethods(GetType(), typeof(ChoAfterConfigurationObjectMemberPersistHandlerAttribute)), this); } if (AfterConfigurationObjectLoadedInternal == null) { EventHandlerEx.LoadHandlers <ChoConfigurationObjectEventArgs>(ref AfterConfigurationObjectLoadedInternal, ChoType.GetMethods(GetType(), typeof(ChoAfterConfigurationObjectLoadedHandlerAttribute)), this); } if (ConfigurationObjectLoadError == null) { EventHandlerEx.LoadHandlers <ChoConfigurationObjectErrorEventArgs>(ref ConfigurationObjectLoadError, ChoType.GetMethods(GetType(), typeof(ChoConfigurationObjectLoadErrorHandlerAttribute)), this); } }
public ChoConfigurableObject() { _configurationElementAttribute = ChoType.GetAttribute(GetType(), typeof(ChoConfigurationSectionAttribute)) as ChoConfigurationSectionAttribute; if (_configurationElementAttribute == null) { throw new ChoFatalApplicationException("Missing configuration object attribute defined for '{0}' type.".FormatString(GetType().Name)); } //Discover and Hook the event handlers if (BeforeConfigurationObjectMemberLoaded == null) { EventHandlerEx.LoadHandlers <ChoPreviewConfigurationObjectMemberEventArgs>(ref BeforeConfigurationObjectMemberLoaded, ChoType.GetMethods(GetType(), typeof(ChoBeforeConfigurationObjectMemberLoadedHandlerAttribute)), this); } if (BeforeConfigurationObjectMemberSet == null) { EventHandlerEx.LoadHandlers <ChoPreviewConfigurationObjectMemberEventArgs>(ref BeforeConfigurationObjectMemberSet, ChoType.GetMethods(GetType(), typeof(ChoBeforeConfigurationObjectMemberSetHandlerAttribute)), this); } if (AfterConfigurationObjectMemberLoaded == null) { EventHandlerEx.LoadHandlers <ChoConfigurationObjectMemberEventArgs>(ref AfterConfigurationObjectMemberLoaded, ChoType.GetMethods(GetType(), typeof(ChoAfterConfigurationObjectMemberLoadedHandlerAttribute)), this); } if (AfterConfigurationObjectMemberSet == null) { EventHandlerEx.LoadHandlers <ChoConfigurationObjectMemberEventArgs>(ref AfterConfigurationObjectMemberSet, ChoType.GetMethods(GetType(), typeof(ChoAfterConfigurationObjectMemberSetHandlerAttribute)), this); } if (ConfigurationObjectMemberLoadError == null) { EventHandlerEx.LoadHandlers <ChoConfigurationObjectMemberErrorEventArgs>(ref ConfigurationObjectMemberLoadError, ChoType.GetMethods(GetType(), typeof(ChoConfigurationObjectMemberLoadErrorHandlerAttribute)), this); } if (ConfigurationObjectMemberSetError == null) { EventHandlerEx.LoadHandlers <ChoConfigurationObjectMemberErrorEventArgs>(ref ConfigurationObjectMemberSetError, ChoType.GetMethods(GetType(), typeof(ChoConfigurationObjectMemberSetErrorHandlerAttribute)), this); } if (BeforeConfigurationObjectPersisted == null) { EventHandlerEx.LoadHandlers <ChoPreviewConfigurationObjectEventArgs>(ref BeforeConfigurationObjectPersisted, ChoType.GetMethods(GetType(), typeof(ChoBeforeConfigurationObjectPersistedHandlerAttribute)), this); } if (AfterConfigurationObjectPersisted == null) { EventHandlerEx.LoadHandlers <ChoConfigurationObjectEventArgs>(ref AfterConfigurationObjectPersisted, ChoType.GetMethods(GetType(), typeof(ChoAfterConfigurationObjectPersistedHandlerAttribute)), this); } if (BeforeConfigurationObjectMemberPersist == null) { EventHandlerEx.LoadHandlers <ChoPreviewConfigurationObjectMemberEventArgs>(ref BeforeConfigurationObjectMemberPersist, ChoType.GetMethods(GetType(), typeof(ChoBeforeConfigurationObjectMemberPersistHandlerAttribute)), this); } if (AfterConfigurationObjectMemberPersist == null) { EventHandlerEx.LoadHandlers <ChoConfigurationObjectMemberEventArgs>(ref AfterConfigurationObjectMemberPersist, ChoType.GetMethods(GetType(), typeof(ChoAfterConfigurationObjectMemberPersistHandlerAttribute)), this); } if (BeforeConfigurationObjectLoadedInternal == null) { EventHandlerEx.LoadHandlers <ChoPreviewConfigurationObjectEventArgs>(ref BeforeConfigurationObjectLoadedInternal, ChoType.GetMethods(GetType(), typeof(ChoBeforeConfigurationObjectLoadedHandlerAttribute)), this); } if (AfterConfigurationObjectLoadedInternal == null) { EventHandlerEx.LoadHandlers <ChoConfigurationObjectEventArgs>(ref AfterConfigurationObjectLoadedInternal, ChoType.GetMethods(GetType(), typeof(ChoAfterConfigurationObjectLoadedHandlerAttribute)), this); } if (ConfigurationObjectLoadError == null) { EventHandlerEx.LoadHandlers <ChoConfigurationObjectErrorEventArgs>(ref ConfigurationObjectLoadError, ChoType.GetMethods(GetType(), typeof(ChoConfigurationObjectLoadErrorHandlerAttribute)), this); } //Type configObjType = GetType(); //ChoConfigurationSectionAttribute configurationElement = ChoType.GetAttribute(configObjType, typeof(ChoConfigurationSectionAttribute)) as ChoConfigurationSectionAttribute; //if (configurationElement == null || configurationElement.GetMe(configObjType) == null) // throw new ChoConfigurationException(String.Format(CultureInfo.InvariantCulture, Resources.ES1001, configObjType.Name)); //configurationElement.GetMe(configObjType).Construct(this); }
public ChoCommandLineArgObject() { _commandLineArgsObjectAttribute = ChoType.GetAttribute(GetType(), typeof(ChoCommandLineArgObjectAttribute)) as ChoCommandLineArgObjectAttribute; //Discover and Hook the event handlers if (BeforeCommandLineArgLoadedInternal == null) { EventHandlerEx.LoadHandlers <ChoPreviewCommandLineArgEventArgs>(ref BeforeCommandLineArgLoadedInternal, ChoType.GetMethods(GetType(), typeof(ChoBeforeCommandLineArgLoadedHandlerAttribute)), this); if (BeforeCommandLineArgLoadedInternal != null && BeforeCommandLineArgLoadedInternal.GetInvocationList().Length > 0) { BeforeCommandLineArgLoaded += (EventHandler <ChoPreviewCommandLineArgEventArgs>)BeforeCommandLineArgLoadedInternal.GetInvocationList()[BeforeCommandLineArgLoadedInternal.GetInvocationList().Length - 1]; } } if (AfterCommandLineArgLoadedInternal == null) { EventHandlerEx.LoadHandlers <ChoCommandLineArgEventArgs>(ref AfterCommandLineArgLoadedInternal, ChoType.GetMethods(GetType(), typeof(ChoAfterCommandLineArgLoadedHandlerAttribute)), this); if (AfterCommandLineArgLoadedInternal != null && AfterCommandLineArgLoadedInternal.GetInvocationList().Length > 0) { AfterCommandLineArgLoaded += (EventHandler <ChoCommandLineArgEventArgs>)AfterCommandLineArgLoadedInternal.GetInvocationList()[AfterCommandLineArgLoadedInternal.GetInvocationList().Length - 1]; } } if (CommandLineArgLoadErrorInternal == null) { EventHandlerEx.LoadHandlers <ChoCommandLineArgErrorEventArgs>(ref CommandLineArgLoadErrorInternal, ChoType.GetMethods(GetType(), typeof(ChoCommandLineArgLoadErrorHandlerAttribute)), this); if (CommandLineArgLoadErrorInternal != null && CommandLineArgLoadErrorInternal.GetInvocationList().Length > 0) { CommandLineArgLoadError += (EventHandler <ChoCommandLineArgErrorEventArgs>)CommandLineArgLoadErrorInternal.GetInvocationList()[CommandLineArgLoadErrorInternal.GetInvocationList().Length - 1]; } } if (BeforeCommandLineArgObjectLoadedInternal == null) { EventHandlerEx.LoadHandlers <ChoPreviewCommandLineArgObjectEventArgs>(ref BeforeCommandLineArgObjectLoadedInternal, ChoType.GetMethods(GetType(), typeof(ChoBeforeCommandLineArgObjectLoadedHandlerAttribute)), this); if (BeforeCommandLineArgObjectLoadedInternal != null && BeforeCommandLineArgObjectLoadedInternal.GetInvocationList().Length > 0) { BeforeCommandLineArgObjectLoaded += (EventHandler <ChoPreviewCommandLineArgObjectEventArgs>)BeforeCommandLineArgObjectLoadedInternal.GetInvocationList()[BeforeCommandLineArgObjectLoadedInternal.GetInvocationList().Length - 1]; } } if (AfterCommandLineArgObjectLoadedInternal == null) { EventHandlerEx.LoadHandlers <ChoCommandLineArgObjectEventArgs>(ref AfterCommandLineArgObjectLoadedInternal, ChoType.GetMethods(GetType(), typeof(ChoAfterCommandLineArgObjectLoadedHandlerAttribute)), this); if (AfterCommandLineArgObjectLoadedInternal != null && AfterCommandLineArgObjectLoadedInternal.GetInvocationList().Length > 0) { AfterCommandLineArgObjectLoaded += (EventHandler <ChoCommandLineArgObjectEventArgs>)AfterCommandLineArgObjectLoadedInternal.GetInvocationList()[AfterCommandLineArgObjectLoadedInternal.GetInvocationList().Length - 1]; } } if (CommandLineArgObjectLoadErrorInternal == null) { EventHandlerEx.LoadHandlers <ChoCommandLineArgObjectErrorEventArgs>(ref CommandLineArgObjectLoadErrorInternal, ChoType.GetMethods(GetType(), typeof(ChoCommandLineArgObjectLoadErrorHandlerAttribute)), this); if (CommandLineArgObjectLoadErrorInternal != null && CommandLineArgObjectLoadErrorInternal.GetInvocationList().Length > 0) { CommandLineArgObjectLoadError += (EventHandler <ChoCommandLineArgObjectErrorEventArgs>)CommandLineArgObjectLoadErrorInternal.GetInvocationList()[CommandLineArgObjectLoadErrorInternal.GetInvocationList().Length - 1]; } } if (CommandLineArgMemberNotFoundInternal == null) { EventHandlerEx.LoadHandlers <ChoCommandLineArgNotFoundEventArgs>(ref CommandLineArgMemberNotFoundInternal, ChoType.GetMethods(GetType(), typeof(ChoCommandLineArgMemberNotFoundHandlerAttribute)), this); if (CommandLineArgMemberNotFoundInternal != null && CommandLineArgMemberNotFoundInternal.GetInvocationList().Length > 0) { CommandLineArgMemberNotFound += (EventHandler <ChoCommandLineArgNotFoundEventArgs>)CommandLineArgMemberNotFoundInternal.GetInvocationList()[CommandLineArgMemberNotFoundInternal.GetInvocationList().Length - 1]; } } if (UnrecognizedCommandLineArgFoundInternal == null) { EventHandlerEx.LoadHandlers <ChoUnrecognizedCommandLineArgEventArg>(ref UnrecognizedCommandLineArgFoundInternal, ChoType.GetMethods(GetType(), typeof(ChoUnrecognizedCommandLineArgFoundHandlerAttribute)), this); if (UnrecognizedCommandLineArgFoundInternal != null && UnrecognizedCommandLineArgFoundInternal.GetInvocationList().Length > 0) { UnrecognizedCommandLineArgFound += (EventHandler <ChoUnrecognizedCommandLineArgEventArg>)UnrecognizedCommandLineArgFoundInternal.GetInvocationList()[UnrecognizedCommandLineArgFoundInternal.GetInvocationList().Length - 1]; } } }