/// <summary> /// Initialize this provider to be able to gets the intialization value. /// </summary> private void Initialize() { if (!initialized) { initialized = true; if (elementType.BaseType == typeof(UpgradeHelpers.VB6.Activex.ComponentClassHelper) || elementType.BaseType == typeof(UpgradeHelpers.VB6.Activex.ComponentSingleUseClassHelper) || elementType.BaseType == typeof(UpgradeHelpers.VB6.Activex.GlbComponentSingleUseClassHelper)) { initializeMethod = InitialValueMethod.CSFactory; } else if (!elementType.Equals(typeof(String))) { //try for a constructor method if (constructorParams == null) { constructorParams = new object[] { } } ; if ((constructor = elementType.GetConstructor(Type.GetTypeArray(constructorParams))) == null) { if (elementType.IsValueType && (constructorParams == null || constructorParams.Length == 0)) { initializeMethod = (method = elementType.GetMethod("CreateInstance")) == null ? InitialValueMethod.ValueType : InitialValueMethod.CreateInstanceValueType; } } else { initializeMethod = InitialValueMethod.Constructor; } } } } }
/// <summary> /// Initialize this provider to be able to gets the intialization value. /// </summary> private void Initialize() { if (!_initialized) { _initialized = true; #if ACTIVEX_COMPONENTSERVER if (_elementType.BaseType.Name == "ComponentClassHelper" || _elementType.BaseType.Name == "ComponentSingleUseClassHelper" || _elementType.BaseType.Name == "GlbComponentSingleUseClassHelper") { _initializeMethod = InitialValueMethod.CsFactory; } else #endif if (_elementType == typeof(Object)) { _initializeMethod = InitialValueMethod.Null; } else if (!(_elementType == typeof(String))) { //try for a constructor method if (_constructorParams == null) { _constructorParams = new object[] { } } ; #if PORTABLE Type[] typeArray = new Type[_constructorParams.Length]; for (int i = 0; i < _constructorParams.Length; i++) { typeArray[i] = _constructorParams[i].GetType(); } #else Type[] typeArray = Type.GetTypeArray(_constructorParams); #endif if ((_constructor = _elementType.GetConstructor(typeArray)) == null) { if (_elementType.IsValueType && (_constructorParams == null || _constructorParams.Length == 0)) { _initializeMethod = (_method = _elementType.GetMethod("CreateInstance")) == null ? InitialValueMethod.ValueType : InitialValueMethod.CreateInstanceValueType; } } else { _initializeMethod = InitialValueMethod.Constructor; } } } } }