public IBeanRuntime <Object> RegisterBean <Object>(Type type) { CheckNotDisposed(); ParamChecker.AssertParamNotNull(type, "type"); return(new BeanRuntime <Object>(this, type, true)); }
public virtual void AfterPropertiesSet() { ParamChecker.AssertNotNull(AccessorTypeProvider, "AccessorTypeProvider"); }
public virtual void AfterPropertiesSet() { ParamChecker.AssertParamNotNull(SyncContext, "SyncContext"); }
public virtual void AfterPropertiesSet() { ParamChecker.AssertNotNull(ParentWindow, "ParentWindow"); }
public virtual FieldInstance ImplementField(FieldInstance field) { ParamChecker.AssertParamNotNull(field, "field"); return(ImplementField(field, null)); }
public void AfterPropertiesSet() { ParamChecker.AssertNotNull(PrefetchHelper, "PrefetchHelper"); }
public virtual void AfterPropertiesSet() { ParamChecker.AssertNotNull(XmlController, "XmlController"); ParamChecker.AssertNotNull(XmlDictionary, "XmlDictionary"); ParamChecker.AssertNotNull(XmlPostProcessorRegistry, "XmlPostProcessorRegistry"); }
public virtual void AfterPropertiesSet() { ParamChecker.AssertNotNull(ObjectFuture, "ObjectFuture"); }
public virtual void AfterPropertiesSet() { ParamChecker.AssertNotNull(DataChangeListener, "DataChangeListener"); }
public void AfterPropertiesSet() { ParamChecker.AssertNotNull(BeanContext, "BeanContext"); ParamChecker.AssertNotNull(ContextHandle, "ContextHandle"); }
public override void AfterPropertiesSet() { base.AfterPropertiesSet(); ParamChecker.AssertNotNull(TestEntityService, "TestEntityService"); }
public void AfterPropertiesSet() { ParamChecker.AssertNotNull(ExtendableRegistry, "ExtendableRegistry"); ParamChecker.AssertNotNull(ProxyFactory, "ProxyFactory"); ParamChecker.AssertNotNull(ProviderType, "ProviderType"); ParamChecker.AssertNotNull(ExtendableType, "ExtendableType"); MethodInfo[] addRemoveMethods; if (ArgumentTypes != null) { addRemoveMethods = ExtendableRegistry.GetAddRemoveMethods(ExtendableType, ArgumentTypes); } else { addRemoveMethods = ExtendableRegistry.GetAddRemoveMethods(ExtendableType); } MethodInfo addMethod = addRemoveMethods[0]; MethodInfo removeMethod = addRemoveMethods[1]; ParameterInfo[] parameterTypes = addMethod.GetParameters(); Type extensionType = parameterTypes[0].ParameterType; if (parameterTypes.Length == 1) { extendableContainer = Activator.CreateInstance(typeof(DefaultExtendableContainer <>).MakeGenericType(extensionType), "message"); Type[] extTypeArray = new Type[] { extensionType }; Type fastClass = extendableContainer.GetType(); MethodInfo registerMethod = fastClass.GetMethod("Register", extTypeArray); MethodInfo unregisterMethod = fastClass.GetMethod("Unregister", extTypeArray); MethodInfo getAllMethod = fastClass.GetMethod("GetExtensions", EmptyList.EmptyArray <Type>()); MethodInfo[] methodsOfProviderType = ProviderType.GetMethods(); methodMap.Add(addMethod, registerMethod); methodMap.Add(removeMethod, unregisterMethod); for (int a = methodsOfProviderType.Length; a-- > 0;) { MethodInfo methodOfProviderType = methodsOfProviderType[a]; if (methodOfProviderType.GetParameters().Length == 0) { methodMap.Add(methodOfProviderType, getAllMethod); } } } else if (parameterTypes.Length == 2) { Type keyType = parameterTypes[1].ParameterType; if (typeof(Type).Equals(keyType)) { extendableContainer = Activator.CreateInstance(typeof(ClassExtendableContainer <>).MakeGenericType(extensionType), "message", "keyMessage"); } else { extendableContainer = Activator.CreateInstance(typeof(MapExtendableContainer <,>).MakeGenericType(keyType, extensionType), "message", "keyMessage"); } Type[] extKeyTypeArray = new Type[] { extensionType, keyType }; Type fastClass = extendableContainer.GetType(); MethodInfo registerMethod = fastClass.GetMethod("Register", extKeyTypeArray); MethodInfo unregisterMethod = fastClass.GetMethod("Unregister", extKeyTypeArray); MethodInfo getOneMethod = fastClass.GetMethod("GetExtension", new Type[] { keyType }); MethodInfo getAllMethod = fastClass.GetMethod("GetExtensions", EmptyList.EmptyArray <Type>()); MethodInfo[] methodsOfProviderType = ProviderType.GetMethods(); methodMap.Add(addMethod, registerMethod); methodMap.Add(removeMethod, unregisterMethod); for (int a = methodsOfProviderType.Length; a-- > 0;) { MethodInfo methodOfProviderType = methodsOfProviderType[a]; if (methodOfProviderType.GetParameters().Length == 1) { methodMap.Add(methodOfProviderType, getOneMethod); providerTypeGetOne = methodOfProviderType; } else if (methodOfProviderType.GetParameters().Length == 0) { methodMap.Add(methodOfProviderType, getAllMethod); } } } else { throw new ExtendableException("ExtendableType '" + ExtendableType.FullName + "' not supported: It must contain exactly 2 methods with each either 1 or 2 arguments"); } }
public IBeanRuntime <V> RegisterExternalBean <V>(V externalBean) { CheckNotDisposed(); ParamChecker.AssertParamNotNull(externalBean, "externalBean"); return(new BeanRuntime <V>(this, externalBean, false)); }
public IBeanRuntime <V> RegisterWithLifecycle <V>(V obj) { CheckNotDisposed(); ParamChecker.AssertParamNotNull(obj, "obj"); return(new BeanRuntime <V>(this, obj, true)); }
public virtual void AfterPropertiesSet() { ParamChecker.AssertNotNull(FilterDescriptorConverter, "FilterDescriptorConverter"); }
public AbstractMemberConfig(String name) { ParamChecker.AssertParamNotNullOrEmpty(name, "name"); this.name = name; }
public void AfterPropertiesSet() { ParamChecker.AssertNotNull(Method, "method"); }
public IBeanConfiguration RegisterExternalBean(Object externalBean) { ParamChecker.AssertParamNotNull(externalBean, "externalBean"); return(RegisterExternalBean(GenerateBeanName(externalBean.GetType()), externalBean)); }
public virtual void AfterPropertiesSet() { ParamChecker.AssertNotNull(BeanContext, "BeanContext"); ParamChecker.AssertNotNull(ProxyFactory, "ProxyFactory"); }
public IBeanConfiguration RegisterWithLifecycle(Object obj) { ParamChecker.AssertParamNotNull(obj, "externalBean"); return(RegisterWithLifecycle(GenerateBeanName(obj.GetType()), obj)); }
public virtual void AfterPropertiesSet() { ParamChecker.AssertNotNull(ProgressListener, "ProgressListener"); }
public void RegisterDisposable(IDisposable disposable) { ParamChecker.AssertParamNotNull(disposable, "disposable"); RegisterWithLifecycle(new DisposableHook(disposable)); }
public virtual void AfterPropertiesSet(IBeanContextFactory beanContextFactory) { ParamChecker.AssertNotNull(RevertChangesHelper, "RevertChangesHelper"); ParamChecker.AssertNotNull(SharedData, "SharedData"); ParamChecker.AssertNotNull(SharedDataHandOnExtendable, "SharedDataHandOnExtendable"); //TODO: inject Uri as bean #if SILVERLIGHT Uri uri = HtmlPage.Document.DocumentUri; #else Uri uri = null; if (uri == null) { throw new NotSupportedException("This code has to be compatible with .NET first"); } #endif ISet <String> allBeanNames = new HashSet <String>(); if (BeansToConsume != null) { allBeanNames.UnionWith(BeansToConsume.Keys); } IDictionary <String, IModelContainer> data = null; if (Token != null) { data = SharedData.Read(Token); } if (data == null) { // Clear token to suppress handsOn in afterStarted() Token = null; data = new Dictionary <String, IModelContainer>(); } IModelMultiContainer <Uri> uriList = (IModelMultiContainer <Uri>)DictionaryExtension.ValueOrDefault(data, SourceUriBeanName); if (uriList != null) { //Url-list is avaliable uriList.Values.Add(uri); } allBeanNames.UnionWith(data.Keys); if (!allBeanNames.Contains(SourceUriBeanName)) { //Url-list is not avaliable beanContextFactory.RegisterBean <ModelMultiContainer <Uri> >(SourceUriBeanName).PropertyValue("Value", uri); } IdentityHashSet <Object> allProvidedBusinessObjects = new IdentityHashSet <Object>(); foreach (String nameInOwnContext in allBeanNames) { //Proecess the input IModelContainer dataContainer = DictionaryExtension.ValueOrDefault(data, nameInOwnContext); if (dataContainer != null) { if (dataContainer is IModelMultiContainer) { IEnumerable businessObjects = ((IModelMultiContainer)dataContainer).ValuesData; if (businessObjects != null) { allProvidedBusinessObjects.AddAll(businessObjects.Cast <object>()); } } else if (dataContainer is IModelSingleContainer) { Object businessObject = ((IModelSingleContainer)dataContainer).ValueData; if (businessObject != null) { allProvidedBusinessObjects.Add(businessObject); } } //By copying only the data, listeners are unregistered //beanContextFactory.registerBean(name, dataContainer.GetType()).propertyValue("Data", dataContainer.Data); beanContextFactory.RegisterExternalBean(nameInOwnContext, dataContainer); continue; } if (!BeansToConsume.ContainsKey(nameInOwnContext)) { continue; } //Process default-beans String aliasToDefaultBean = BeansToConsume[nameInOwnContext]; if (aliasToDefaultBean == null) { //Mandatory parameter was not present in data throw new Exception("The new Screen has not all mandatory information: \"" + nameInOwnContext + "\" is missing."); } if (!nameInOwnContext.Equals(aliasToDefaultBean)) { beanContextFactory.RegisterAlias(nameInOwnContext, aliasToDefaultBean); } } if (allProvidedBusinessObjects.Count > 0) { IRevertChangesSavepoint savepoint = RevertChangesHelper.CreateSavepoint(allProvidedBusinessObjects); beanContextFactory.RegisterExternalBean(savepoint).Autowireable <IRevertChangesSavepoint>(); } }
public void RegisterDisposable(IDisposableBean disposableBean) { ParamChecker.AssertParamNotNull(disposableBean, "disposableBean"); RegisterWithLifecycle(new DisposableBeanHook(disposableBean)); }
public override void AfterPropertiesSet() { base.AfterPropertiesSet(); ParamChecker.AssertNotNull(RevertChangesHelper, "ChangeHelper"); }
public virtual void AfterPropertiesSet() { ParamChecker.AssertNotNull(ImplementAbstractObjectFactory, "ImplementAbstractObjectFactory"); }
protected PropertyInfoEntry GetPropertyEntry(Type type, SmartCopyMap <Type, PropertyInfoEntry> map, bool isOldIocMode, bool isIocMode) { ParamChecker.AssertParamNotNull(type, "type"); PropertyInfoEntry propertyEntry = map.Get(type); if (propertyEntry != null) { return(propertyEntry); } Object writeLock = map.GetWriteLock(); lock (writeLock) { propertyEntry = map.Get(type); if (propertyEntry != null) { // Concurrent thread might have been faster return(propertyEntry); } HashMap <String, HashMap <Type, HashMap <String, MethodInfo> > > sortedMethods = new HashMap <String, HashMap <Type, HashMap <String, MethodInfo> > >(); MethodInfo[] methods = ReflectUtil.GetDeclaredMethodsInHierarchy(type); foreach (MethodInfo method in methods) { if (method.DeclaringType.Equals(typeof(Object))) { continue; } if (method.IsStatic) { continue; } try { String propName = GetPropertyNameFor(method); if (propName.Length == 0) { continue; } HashMap <Type, HashMap <String, MethodInfo> > sortedMethod = sortedMethods.Get(propName); if (sortedMethod == null) { sortedMethod = HashMap <Type, HashMap <String, MethodInfo> > .Create(1); sortedMethods.Put(propName, sortedMethod); } ParameterInfo[] parameterInfos = method.GetParameters(); Type propertyType; String prefix; if (parameterInfos.Length == 1) { propertyType = parameterInfos[0].ParameterType; prefix = "set"; } else if (parameterInfos.Length == 0) { propertyType = method.ReturnType; prefix = "get"; } else { throw new Exception("Method is not an accessor: " + method); } HashMap <String, MethodInfo> methodPerType = sortedMethod.Get(propertyType); if (methodPerType == null) { methodPerType = HashMap <String, MethodInfo> .Create(2); sortedMethod.Put(propertyType, methodPerType); } methodPerType.Put(prefix, method); } catch (Exception e) { throw RuntimeExceptionUtil.Mask(e, "Error occured while processing " + method); } } HashMap <String, HashMap <String, MethodInfo> > filteredMethods = FilterOverriddenMethods(sortedMethods, type); HashMap <String, IPropertyInfo> propertyMap = new HashMap <String, IPropertyInfo>(0.5f); foreach (MapEntry <String, HashMap <String, MethodInfo> > propertyData in filteredMethods) { String propertyName = propertyData.Key; HashMap <String, MethodInfo> propertyMethods = propertyData.Value; MethodInfo getter = propertyMethods.Get("get"); MethodInfo setter = propertyMethods.Get("set"); if (isIocMode) { if (setter == null || (!setter.IsPublic && !AnnotationUtil.IsAnnotationPresent <AutowiredAttribute>(setter, false) && !AnnotationUtil.IsAnnotationPresent <PropertyAttribute>(setter, false))) { continue; } } MethodPropertyInfo propertyInfo = new MethodPropertyInfo(type, propertyName, getter, setter); propertyMap.Put(propertyInfo.Name, propertyInfo); } Type[] interfaces = type.GetInterfaces(); List <Type> typesToSearch = new List <Type>(interfaces); typesToSearch.Add(type); foreach (Type typeToSearch in typesToSearch) { PropertyInfo[] properties = typeToSearch.GetProperties(BindingFlags.FlattenHierarchy | BindingFlags.Static | BindingFlags.Instance | BindingFlags.Public); foreach (PropertyInfo property in properties) { if (property.GetGetMethod() != null && property.GetGetMethod().GetParameters().Length != 0) { continue; } if (property.GetSetMethod() != null && property.GetSetMethod().GetParameters().Length != 1) { continue; } MethodInfo getter = null; MethodInfo setter = null; MethodPropertyInfo propertyInfo = (MethodPropertyInfo)propertyMap.Get(property.Name); if (propertyInfo != null) { getter = propertyInfo.Getter; setter = propertyInfo.Setter; } if (getter == null) { getter = property.GetGetMethod(); } if (setter == null) { setter = property.GetSetMethod(); } if (isIocMode && setter == null) { continue; } propertyInfo = new MethodPropertyInfo(type, property.Name, getter, setter); propertyInfo.PutAnnotations(property); propertyMap.Put(propertyInfo.Name, propertyInfo); } } FieldInfo[] fields = ReflectUtil.GetDeclaredFieldsInHierarchy(type); foreach (FieldInfo field in fields) { if (field.IsStatic) { continue; } if (isOldIocMode) { if (!AnnotationUtil.IsAnnotationPresent <AutowiredAttribute>(field, false) && !AnnotationUtil.IsAnnotationPresent <PropertyAttribute>(field, false)) { continue; } } String propertyName = GetPropertyNameFor(field); IPropertyInfo existingProperty = propertyMap.Get(propertyName); if (existingProperty != null && existingProperty.IsWritable) { // Ignore field injection if the already resolved (method-)property is writable continue; } IPropertyInfo propertyInfo = new FieldPropertyInfo(type, propertyName, field); propertyMap.Put(propertyInfo.Name, propertyInfo); } propertyEntry = new PropertyInfoEntry(propertyMap); map.Put(type, propertyEntry); return(propertyEntry); } }
public virtual void AfterPropertiesSet() { ParamChecker.AssertNotNull(SecurityServiceWCF, "SecurityServiceWCF"); }
public virtual void AfterPropertiesSet() { ParamChecker.AssertNotNull(BeanContext, "BeanContext"); ParamChecker.AssertNotNull(CreateModuleType, "CreateModuleType"); }
public virtual void AfterPropertiesSet() { ParamChecker.AssertNotNull(Cache, "Cache"); ParamChecker.AssertNotNull(EntityMetaDataProvider, "EntityMetaDataProvider"); }