/// <summary>
        /// Convert from a <see cref="System.String"/> value to an
        /// <see cref="RegistryKey"/> instance.
        /// </summary>
        /// <param name="context">
        /// A <see cref="System.ComponentModel.ITypeDescriptorContext"/>
        /// that provides a format context.
        /// </param>
        /// <param name="culture">
        /// The <see cref="System.Globalization.CultureInfo"/> to use
        /// as the current culture.
        /// </param>
        /// <param name="value">
        /// The value that is to be converted.
        /// </param>
        /// <returns>
        /// A <see cref="System.String"/> array if successful.
        /// </returns>
        public override object ConvertFrom(ITypeDescriptorContext context, CultureInfo culture, object value)
        {
            AssertUtils.ArgumentNotNull(value, "value");

            if (value is string)
            {
                string keyName = (string)value;
                AssertUtils.ArgumentHasText(keyName, "value");

                string[]    keys = StringUtils.Split(keyName, "\\", false, true);
                RegistryKey key  = GetRootKey(keys[0]);
                for (int i = 1; i < keys.Length; i++)
                {
                    // open all sub-keys but the last one as read-only
                    key = key.OpenSubKey(keys[i], (i == keys.Length - 1));
                    if (key == null)
                    {
                        throw new ArgumentException("Registry key [" + GetPartialKeyName(keys, i) + "] does not exist.");
                    }
                }

                return(key);
            }
            return(base.ConvertFrom(context, culture, value));
        }
        /// <summary>
        /// Obtains a <see cref="MongoDatabase"/> connection for the given <see cref="MongoServer"/>instance, database name and credentials
        /// </summary>
        /// <param name="mongo">the <see cref="MongoServer"/> instance, must not be null.</param>
        /// <param name="databaseName">the database name, must not be null or empty.</param>
        /// <param name="credentials">the credentials to use, must not be null.</param>
        public static MongoDatabase GetDatabase(MongoServer mongo, string databaseName, MongoCredentials credentials, WriteConcern writeConcern)
        {
            AssertUtils.ArgumentNotNull(mongo, "mongo");
            AssertUtils.ArgumentHasText(databaseName, "databaseName");

            return(DoGetDatabase(mongo, databaseName, credentials, writeConcern, true));
        }
        /// <summary>
        /// Creates the message converter given its name in the application context.
        /// </summary>
        /// <param name="messageConverterObjectName">Name of the message converter object.</param>
        /// <returns>
        /// A IMessageConverter instance configured via the application context
        /// </returns>
        public IMessageConverter CreateMessageConverter(string messageConverterObjectName)
        {
            AssertUtils.ArgumentHasText(messageConverterObjectName, "MessgaeFormatterObjectName");
            IDictionary converters = LogicalThreadContext.GetData(CONVERTER_DICTIONARY_SLOTNAME) as IDictionary;

            if (converters == null)
            {
                converters = new Hashtable();
                LogicalThreadContext.SetData(CONVERTER_DICTIONARY_SLOTNAME, converters);
            }
            if (!converters.Contains(messageConverterObjectName))
            {
                IMessageConverter mc =
                    (IMessageConverter)
                    applicationContext.GetObject(messageConverterObjectName, typeof(IMessageConverter));
                if (applicationContext.ObjectFactory.GetObjectDefinition(messageConverterObjectName).IsSingleton)
                {
                    log.Warn("MessageConverter with name = [" + messageConverterObjectName + "] should be declared with singleton=false.  Using Clone() to create independent instance for thread local storage");
                    converters.Add(messageConverterObjectName, mc.Clone());
                }
                else
                {
                    converters.Add(messageConverterObjectName, mc);
                }
            }
            return(converters[messageConverterObjectName] as IMessageConverter);
        }
        /// <summary>
        /// Registers resource handler and maps it to the specified protocol name.
        /// </summary>
        /// <remarks>
        /// <p>
        /// If the mapping already exists, the existing mapping will be
        /// silently overwritten with the new mapping.
        /// </p>
        /// </remarks>
        /// <param name="protocolName">
        /// The protocol to add (or override).
        /// </param>
        /// <param name="handlerType">
        /// The concrete implementation of the
        /// <see cref="Oragon.Spring.Core.IO.IResource"/> interface that will handle
        /// the specified protocol.
        /// </param>
        /// <exception cref="System.ArgumentNullException">
        /// If the supplied <paramref name="protocolName"/> is
        /// <see langword="null"/> or contains only whitespace character(s); or
        /// if the supplied <paramref name="handlerType"/> is
        /// <see langword="null"/>.
        /// </exception>
        /// <exception cref="System.ArgumentException">
        /// If the supplied <paramref name="handlerType"/> is not a
        /// <see cref="Type"/> that derives from the
        /// <see cref="Oragon.Spring.Core.IO.IResource"/> interface; or (having passed
        /// this first check), the supplied <paramref name="handlerType"/>
        /// does not expose a constructor that takes a single
        /// <see cref="System.String"/> parameter.
        /// </exception>
        public static void RegisterResourceHandler(string protocolName, Type handlerType)
        {
            #region Sanity Checks

            AssertUtils.ArgumentHasText(protocolName, "protocolName");
            AssertUtils.ArgumentNotNull(handlerType, "handlerType");
            if (!typeof(IResource).IsAssignableFrom(handlerType))
            {
                throw new ArgumentException(
                          string.Format("[{0}] does not implement [{1}] interface (it must).", handlerType.FullName, typeof(IResource).FullName));
            }

            #endregion

            lock (syncRoot)
            {
                //SecurityCritical.ExecutePrivileged( new SecurityPermission(SecurityPermissionFlag.Infrastructure), delegate
                //{
                // register generic uri parser for this scheme
                if (!UriParser.IsKnownScheme(protocolName))
                {
                    UriParser.Register(new TolerantUriParser(), protocolName, 0);
                }
                //});
                IDynamicConstructor ctor = GetResourceConstructor(handlerType);
                resourceHandlers[protocolName] = ctor;
            }
        }
示例#5
0
        /// <summary>
        /// Creates a new instance of the
        /// <see cref="Spring.Objects.PropertyValue"/> class.
        /// </summary>
        /// <param name="name">The name of the property.</param>
        /// <param name="val">
        /// The value of the property (possibly before type conversion).
        /// </param>
        /// <exception cref="System.ArgumentNullException">
        /// If the supplied <paramref name="name"/> is <see langword="null"/> or
        /// contains only whitespace character(s).
        /// </exception>
        public PropertyValue(string name, object val)
        {
            AssertUtils.ArgumentHasText(name, "name");

            propertyName  = name;
            propertyValue = val;
        }
示例#6
0
        /// <summary>
        /// Resolves the supplied <paramref name="alias"/> to a <see cref="System.Type"/>.
        /// </summary>
        /// <param name="alias">
        /// The alias to resolve.
        /// </param>
        /// <returns>
        /// The <see cref="System.Type"/> the supplied <paramref name="alias"/> was
        /// associated with, or <see lang="null"/> if no <see cref="System.Type"/>
        /// was previously registered for the supplied <paramref name="alias"/>.
        /// </returns>
        /// <exception cref="System.ArgumentNullException">
        /// If the supplied <paramref name="alias"/> is <see langword="null"/> or
        /// contains only whitespace character(s).
        /// </exception>
        public static Type ResolveType(string alias)
        {
            AssertUtils.ArgumentHasText(alias, "alias");
            Type type;

            types.TryGetValue(alias, out type);
            return(type);
        }
示例#7
0
        /// <summary>
        /// Creates a new instance of the
        /// <see cref="Spring.Objects.PropertyValue"/> class.
        /// </summary>
        /// <param name="name">The name of the property.</param>
        /// <param name="val">
        /// The value of the property (possibly before type conversion).
        /// </param>
        /// <param name="expression">Pre-parsed property name.</param>
        /// <exception cref="System.ArgumentNullException">
        /// If the supplied <paramref name="name"/> or <paramref name="name"/>
        /// is <see langword="null"/>, or if the name contains only whitespace characters.
        /// </exception>
        public PropertyValue(string name, object val, IExpression expression)
        {
            AssertUtils.ArgumentHasText(name, "name");

            propertyName       = name;
            propertyExpression = expression;
            propertyValue      = val;
        }
        /// <summary>
        /// Registers resource handler and maps it to the specified protocol name.
        /// </summary>
        /// <remarks>
        /// <p>
        /// If the mapping already exists, the existing mapping will be
        /// silently overwritten with the new mapping.
        /// </p>
        /// </remarks>
        /// <param name="protocolName">
        /// The protocol to add (or override).
        /// </param>
        /// <param name="handlerTypeName">
        /// The type name of the concrete implementation of the
        /// <see cref="Oragon.Spring.Core.IO.IResource"/> interface that will handle
        /// the specified protocol.
        /// </param>
        /// <exception cref="System.ArgumentNullException">
        /// If the supplied <paramref name="protocolName"/> is
        /// <see langword="null"/> or contains only whitespace character(s); or
        /// if the supplied <paramref name="handlerTypeName"/> is
        /// <see langword="null"/>.
        /// </exception>
        /// <exception cref="System.ArgumentException">
        /// If the supplied <paramref name="handlerTypeName"/> is not a
        /// <see cref="Type"/> that derives from the
        /// <see cref="Oragon.Spring.Core.IO.IResource"/> interface; or (having passed
        /// this first check), the supplied <paramref name="handlerTypeName"/>
        /// does not expose a constructor that takes a single
        /// <see cref="System.String"/> parameter.
        /// </exception>
        public static void RegisterResourceHandler(string protocolName, string handlerTypeName)
        {
            AssertUtils.ArgumentHasText(protocolName, "protocolName");
            AssertUtils.ArgumentHasText(handlerTypeName, "handlerTypeName");

            Type handlerType = TypeResolutionUtils.ResolveType(handlerTypeName);

            RegisterResourceHandler(protocolName, handlerType);
        }
示例#9
0
        /// <summary>
        /// Registers an alias for the supplied <see cref="System.Type"/>.
        /// </summary>
        /// <param name="alias">
        /// The alias for the supplied <see cref="System.Type"/>.
        /// </param>
        /// <param name="type">
        /// The <see cref="System.Type"/> to register the supplied <paramref name="alias"/> under.
        /// </param>
        /// <exception cref="System.ArgumentNullException">
        /// If the supplied <paramref name="type"/> is <see langword="null"/>; or if
        /// the supplied <paramref name="alias"/> is <see langword="null"/> or
        /// contains only whitespace character(s).
        /// </exception>
        public static void RegisterType(string alias, Type type)
        {
            AssertUtils.ArgumentHasText(alias, "alias");
            AssertUtils.ArgumentNotNull(type, "type");

            lock (syncRoot)
            {
                types[alias] = type;
            }
        }
示例#10
0
        /// <summary>
        /// Initializes a new instance of the <see cref="ErrorMessageAction"/> class.
        /// </summary>
        /// <param name="messageId">Error message resource identifier.</param>
        /// <param name="providers">Names of the error providers this message should be added to.</param>
        public ErrorMessageAction(string messageId, params string[] providers)
        {
            AssertUtils.ArgumentHasText(messageId, "messageId");
            if (providers == null || providers.Length == 0)
            {
                throw new ArgumentException("At least one error provider has to be specified.", "providers");
            }

            this.messageId = messageId;
            this.providers = providers;
        }
        /// <summary>
        /// Registers a <see cref="IResultFactory"/> for the specified <paramref name="resultMode"/>.
        /// </summary>
        /// <param name="resultMode">the resultMode. Must not be null.</param>
        /// <param name="resultFactory">the factory respponsible for handling <paramref name="resultMode"/> results. Must not be null.</param>
        /// <returns>the factory previously registered for the specified <paramref name="resultMode"/>, if any.</returns>
        /// <remarks>
        /// See <see cref="ResultFactoryRegistry"/> overview for more information.
        /// </remarks>
        public static IResultFactory RegisterResultMode(string resultMode, IResultFactory resultFactory)
        {
            AssertUtils.ArgumentHasText(resultMode, "resultMode");
            AssertUtils.ArgumentNotNull(resultFactory, "resultFactory");

            lock (s_registeredFactories.SyncRoot)
            {
                IResultFactory prevFactory = (IResultFactory)s_registeredFactories[resultMode];
                s_registeredFactories[resultMode] = resultFactory;
                return(prevFactory);
            }
        }
示例#12
0
        private SimpleMongoDatabaseFactory(MongoServer mongo, string databaseName, MongoCredentials credentials,
                                           bool mongoInstanceCreated)
        {
            AssertUtils.ArgumentNotNull(mongo, "mongo");
            AssertUtils.ArgumentHasText(databaseName, "databaseName");
            AssertUtils.IsTrue(!Regex.IsMatch(databaseName, @"[^A-Za-z0-9-_]+"),
                               "Database name must only contain letters, numbers, underscores and dashes!");

            _mongo                = mongo;
            _databaseName         = databaseName;
            _mongoInstanceCreated = mongoInstanceCreated;
            _credentials          = credentials;
        }
示例#13
0
        /// <summary>
        /// Registers an alias for the specified <see cref="System.Type"/>.
        /// </summary>
        /// <remarks>
        /// <p>
        /// This overload does eager resolution of the <see cref="System.Type"/>
        /// referred to by the <paramref name="typeName"/> parameter. It will throw a
        /// <see cref="System.TypeLoadException"/> if the <see cref="System.Type"/> referred
        /// to by the <paramref name="typeName"/> parameter cannot be resolved.
        /// </p>
        /// </remarks>
        /// <param name="alias">
        /// A string that will be used as an alias for the specified
        /// <see cref="System.Type"/>.
        /// </param>
        /// <param name="typeName">
        /// The (possibly partially assembly qualified) name of the
        /// <see cref="System.Type"/> to register the alias for.
        /// </param>
        /// <exception cref="System.ArgumentNullException">
        /// If either of the supplied parameters is <see langword="null"/> or
        /// contains only whitespace character(s).
        /// </exception>
        /// <exception cref="System.TypeLoadException">
        /// If the <see cref="System.Type"/> referred to by the supplied
        /// <paramref name="typeName"/> cannot be loaded.
        /// </exception>
        public static void RegisterType(string alias, string typeName)
        {
            AssertUtils.ArgumentHasText(alias, "alias");
            AssertUtils.ArgumentHasText(typeName, "typeName");

            Type type = TypeResolutionUtils.ResolveType(typeName);

            if (type.IsGenericTypeDefinition)
            {
                alias += ("`" + type.GetGenericArguments().Length);
            }

            RegisterType(alias, type);
        }
        private void InitializeEndpoint()
        {
            lock (_initializationMonitor) {
                if (_initialized)
                {
                    return;
                }

                AssertUtils.ArgumentHasText(_inputChannelName, "inputChannelName is required");

                AssertUtils.IsTrue(_objectFactory.ContainsObject(_inputChannelName), "no such input channel '" + _inputChannelName + "' for endpoint '" + _objectName + "'");

                IMessageChannel channel = (IMessageChannel)_objectFactory.GetObject(_inputChannelName, typeof(IMessageChannel));
                if (channel is ISubscribableChannel)
                {
                    if (_pollerMetadata != null)
                    {
                        throw new ArgumentException("A poller should not be specified for endpoint '" + _objectName
                                                    + "', since '" + _inputChannelName + "' is a SubscribableChannel (not pollable).");
                    }
                    _endpoint = new EventDrivenConsumer((ISubscribableChannel)channel, _handler);
                }
                else if (channel is IPollableChannel)
                {
                    PollingConsumer pollingConsumer = new PollingConsumer((IPollableChannel)channel, _handler);
                    if (_pollerMetadata == null)
                    {
                        _pollerMetadata = IntegrationContextUtils.GetDefaultPollerMetadata(_objectFactory);
                        AssertUtils.ArgumentNotNull(_pollerMetadata, "No poller has been defined for endpoint '" + _objectName + "', and no default poller is available within the context.");
                    }
                    pollingConsumer.Trigger               = _pollerMetadata.Trigger;
                    pollingConsumer.MaxMessagesPerPoll    = _pollerMetadata.MaxMessagesPerPoll;
                    pollingConsumer.ReceiveTimeout        = _pollerMetadata.ReceiveTimeout;
                    pollingConsumer.TaskExecutor          = _pollerMetadata.TaskExecutor;
                    pollingConsumer.TransactionManager    = _pollerMetadata.TransactionManager;
                    pollingConsumer.TransactionDefinition = _pollerMetadata.TransactionDefinition;
                    pollingConsumer.AdviceChain           = _pollerMetadata.AdviceChain;
                    _endpoint = pollingConsumer;
                }
                else
                {
                    throw new ArgumentException("unsupported channel type: [" + channel.GetType() + "]");
                }
                _endpoint.AutoStartup   = _autoStartup;
                _endpoint.ObjectName    = _objectName;
                _endpoint.ObjectFactory = _objectFactory;
                _endpoint.AfterPropertiesSet();
                _initialized = true;
            }
        }
        private void SetPropertyValue(ObjectDefinitionBuilder builder, XmlElement element, string attrName, string propertyName)
        {
            AssertUtils.ArgumentNotNull(builder, "builder");
            AssertUtils.ArgumentNotNull(element, "element");
            AssertUtils.ArgumentHasText(attrName, "attrName");
            AssertUtils.ArgumentHasText(propertyName, "propertyName");

            string attr = element.GetAttribute(attrName);

            if (StringUtils.HasText(attr))
            {
                builder.AddPropertyValue(propertyName, attr);
            }
        }
示例#16
0
        /// <summary>
        /// Creates a new instance of the <see cref="Spring.Web.Support.Result"/> class.
        /// </summary>
        /// <remarks>
        /// <p>
        /// See both the class documentation (<see cref="Spring.Web.Support.Result"/>)
        /// and the reference documentation for the Spring.Web library for a
        /// discussion and examples of what values the supplied <paramref name="result"/>
        /// can have.
        /// </p>
        /// </remarks>
        /// <param name="result">The result descriptor.</param>
        /// <exception cref="System.ArgumentNullException">
        /// If the supplied <paramref name="result"/> is <see langword="null"/> or
        /// contains only whitespace character(s).
        /// </exception>
        /// <exception cref="ArgumentOutOfRangeException">if the result mode is unknown.</exception>
        public Result(string result)
        {
            AssertUtils.ArgumentHasText(result, "result");

            result = ExtractAndSetResultMode(result);

            int indexOfQueryStringDelimiter = result.IndexOf('?');

            if (indexOfQueryStringDelimiter > 0)
            {
                ParseParameters(result.Substring(indexOfQueryStringDelimiter + 1));
                result = result.Substring(0, indexOfQueryStringDelimiter);
            }
            targetPage = result.Trim();
        }
示例#17
0
        /// <summary>
        /// Gets the controls type from a given filename
        /// </summary>
        public static Type GetControlType(string controlName)
        {
            AssertUtils.ArgumentHasText(controlName, "controlName");
            if (s_log.IsDebugEnabled)
            {
                s_log.Debug("getting control type for " + controlName);
            }

//            HttpContext ctx = HttpContext.Current;
//            if (ctx == null)
//            {
//                throw new ObjectCreationException( "Unable to get control type. HttpContext is not defined." );
//            }

            string rootedVPath = WebUtils.CombineVirtualPaths(VirtualEnvironment.CurrentExecutionFilePath, controlName);

            if (s_log.IsDebugEnabled)
            {
                s_log.Debug("control vpath is " + rootedVPath);
            }

            Type controlType;

            try
            {
//#if NET_2_0
//                controlType = BuildManager.GetCompiledType( rootedVPath ); // requires rooted virtual path!
//#else
//              controlType = (Type) miGetCompiledUserControlType.Invoke(null, new object[] { rootedVPath, null, ctx });
//#endif
                controlType = VirtualEnvironment.GetCompiledType(rootedVPath);
            }
            catch (HttpException httpEx)
            {
                // for better error-handling suppress 404 HttpExceptions here
                if (httpEx.GetHttpCode() == 404)
                {
                    throw new FileNotFoundException(string.Format("Control '{0}' does not exist", rootedVPath));
                }
                throw;
            }

            if (s_log.IsDebugEnabled)
            {
                s_log.Debug(string.Format("got control type '{0}' for vpath '{1}'", controlType.FullName, rootedVPath));
            }
            return(controlType);
        }
示例#18
0
        /// <summary>
        /// Sets error message that should be displayed in the case
        /// of a non-fatal binding error.
        /// </summary>
        /// <param name="messageId">
        /// Resource ID of the error message.
        /// </param>
        /// <param name="errorProviders">
        /// List of error providers message should be added to.
        /// </param>
        public void SetErrorMessage(string messageId, params string[] errorProviders)
        {
            AssertUtils.ArgumentHasText(messageId, "messageId");
            if (errorProviders == null || errorProviders.Length == 0)
            {
                throw new ArgumentException("At least one error provider has to be specified.", "providers");
            }

            this.errorMessage = new BindingErrorMessage(this.BINDING_ID, messageId, null);
            Set providers = new HashedSet();

            providers.Add(ALL_BINDINGERRORS_PROVIDER);
            providers.AddAll(errorProviders);
            errorProviders = new string[providers.Count];
            providers.CopyTo(errorProviders, 0);
            this.errorProviders = errorProviders;
        }
        /// <summary>
        /// Creates the message queue given its name in the application context.
        /// </summary>
        /// <param name="messageQueueObjectName">Name of the message queue object.</param>
        /// <returns>
        /// A MessageQueue instance configured via the application context
        /// </returns>
        public MessageQueue CreateMessageQueue(string messageQueueObjectName)
        {
            AssertUtils.ArgumentHasText(messageQueueObjectName, "DefaultMessageQueueObjectName");
            IDictionary queues = LogicalThreadContext.GetData(QUEUE_DICTIONARY_SLOTNAME) as IDictionary;

            if (queues == null)
            {
                queues = new Hashtable();
                LogicalThreadContext.SetData(QUEUE_DICTIONARY_SLOTNAME, queues);
            }
            if (!queues.Contains(messageQueueObjectName))
            {
                MessageQueue mq = applicationContext.GetObject(messageQueueObjectName) as MessageQueue;
                queues.Add(messageQueueObjectName, mq);
            }
            return(queues[messageQueueObjectName] as MessageQueue);
        }
示例#20
0
        /// <summary>
        ///     Registers lambda expression under the specified <paramref name="functionName" />.
        /// </summary>
        /// <param name="functionName">Function name to register expression as.</param>
        /// <param name="lambdaExpression">Lambda expression to register.</param>
        /// <param name="variables">Variables dictionary that the function will be registered in.</param>
        public static void RegisterFunction(string functionName, string lambdaExpression, IDictionary variables)
        {
            AssertUtils.ArgumentHasText(functionName, "functionName");
            AssertUtils.ArgumentHasText(lambdaExpression, "lambdaExpression");

            var lexer = new ExpressionLexer(new StringReader(lambdaExpression));
            ExpressionParser parser = new SolenoidExpressionParser(lexer);

            try
            {
                parser.lambda();
            }
            catch (TokenStreamRecognitionException ex)
            {
                throw new SyntaxErrorException(ex.recog.Message, ex.recog.Line, ex.recog.Column, lambdaExpression);
            }
            variables[functionName] = parser.getAST();
        }
示例#21
0
        public virtual void AfterPropertiesSet()
        {
            AssertUtils.ArgumentNotNull(cache, "Cache Property must be set");
            name = (!StringUtils.HasText(name) ? objectName : name);
            AssertUtils.ArgumentHasText(name, "Name (or ObjectName) property must be set");

            // first get cache
            region = cache.GetRegion(name);
            if (region != null)
            {
                log.Info("Retrieved region [" + name + "] from cache");
            }
            // fall back to cache creation if one is not found
            else
            {
                region = LookupFallback(cache, name);
            }
        }
示例#22
0
        /// <summary>
        /// Registers <see cref="TypeConverter"/> for the specified type.
        /// </summary>
        /// <remarks>
        /// This is a convinience method that accepts the names of both
        /// type to register converter for and the converter itself,
        /// resolves them using <see cref="TypeRegistry"/>, creates an
        /// instance of type converter and calls overloaded
        /// <see cref="RegisterConverter(Type,TypeConverter)"/> method.
        /// </remarks>
        /// <param name="typeName">Type name of the type to register the converter for (can be a type alias).</param>
        /// <param name="converterTypeName">Type name of the type converter to register (can be a type alias).</param>
        /// <exception cref="ArgumentNullException">If either of arguments is <c>null</c> or empty string.</exception>
        /// <exception cref="TypeLoadException">
        /// If either of arguments fails to resolve to a valid <see cref="Type"/>.
        /// </exception>
        /// <exception cref="ArgumentException">
        /// If type converter does not derive from <see cref="TypeConverter"/> or if it cannot be instantiated.
        /// </exception>
        public static void RegisterConverter(string typeName, string converterTypeName)
        {
            AssertUtils.ArgumentHasText(typeName, "typeName");
            AssertUtils.ArgumentHasText(converterTypeName, "converterTypeName");

            try
            {
                Type type          = TypeResolutionUtils.ResolveType(typeName);
                Type converterType = TypeResolutionUtils.ResolveType(converterTypeName);
                if (!typeof(TypeConverter).IsAssignableFrom(converterType))
                {
                    throw new ArgumentException(
                              "Type specified as a 'converterTypeName' does not inherit from System.ComponentModel.TypeConverter");
                }
                RegisterConverter(type, (TypeConverter)ObjectUtils.InstantiateType(converterType));
            }
            catch (FatalReflectionException e)
            {
                throw new ArgumentException("Failed to create an instance of the specified type converter.", e);
            }
        }
示例#23
0
        /// <summary>
        /// Returns the <see cref="System.Type"/> of the ASPX page
        /// referred to by the supplied <paramref name="pageUrl"/>.
        /// </summary>
        /// <remarks>
        /// <p>
        /// As indicated by the exception that can be thrown by this method,
        /// the ASPX page referred to by the supplied <paramref name="pageUrl"/>
        /// does have to be instantiated in order to determine its
        /// see cref="System.Type"/>
        /// </p>
        /// </remarks>
        /// <param name="pageUrl">
        /// The filename of the ASPX page.
        /// </param>
        /// <returns>
        /// The <see cref="System.Type"/> of the ASPX page
        /// referred to by the supplied <paramref name="pageUrl"/>.
        /// </returns>
        /// <exception cref="System.ArgumentNullException">
        /// If the supplied <paramref name="pageUrl"/> is <see langword="null"/> or
        /// contains only whitespace character(s).
        /// </exception>
        /// <exception cref="Spring.Objects.Factory.ObjectCreationException">
        /// If this method is not called in the scope of an active web session
        /// (i.e. the implementation this method depends on this code executing
        /// in the environs of a running web server such as IIS); or if the
        /// page could not be instantiated (for whatever reason, such as the
        /// ASPX <paramref name="pageUrl"/> not actually existing).
        /// </exception>
        public static Type GetPageType(string pageUrl)
        {
            AssertUtils.ArgumentHasText(pageUrl, "pageUrl");

//            HttpContext ctx = HttpContext.Current;
//            if (ctx == null)
//            {
//                throw new ObjectCreationException( "Unable to get page type. HttpContext is not defined." );
//            }

            try
            {
                Type pageType = GetCompiledPageType(pageUrl);
                return(pageType);
            }
            catch (Exception ex)
            {
                string msg = String.Format("Unable to get page type for url [{0}]", pageUrl);
                s_log.Error(msg, ex);
                throw new ObjectCreationException(msg, ex);
            }
        }
 /// <summary>
 /// Add argument value for the given name in the constructor argument list.
 /// </summary>
 /// <param name="name">The name in the constructor argument list.</param>
 /// <param name="value">The argument value.</param>
 /// <exception cref="ArgumentException">
 /// If the supplied <paramref name="name"/> is <see langword="null"/>
 /// or is composed wholly of whitespace.
 /// </exception>
 public virtual void AddNamedArgumentValue(string name, object value)
 {
     AssertUtils.ArgumentHasText(name, "name");
     NamedArgumentValues[GetCanonicalNamedArgument(name)] = new ValueHolder(value);
 }
示例#25
0
 /// <summary>
 /// Creates a new instance of the <see cref="RegularExpressionValidator"/> class.
 /// </summary>
 /// <param name="test">The expression to validate.</param>
 /// <param name="when">The expression that determines if this validator should be evaluated.</param>
 /// <param name="expression">The regular expression to match against.</param>
 public RegularExpressionValidator(string test, string when, string expression)
     : base(test, when)
 {
     AssertUtils.ArgumentHasText(test, "test");
     this.expression = expression;
 }
 /// <summary>
 /// Creates a new instance of the
 /// <see cref="Spring.Core.IO.AbstractResource"/> class.
 /// </summary>
 /// <remarks>
 /// <p>
 /// This is an <see langword="abstract"/> class, and as such exposes no
 /// public constructors.
 /// </p>
 /// </remarks>
 /// <param name="resourceName">
 /// A string representation of the resource.
 /// </param>
 /// <exception cref="System.ArgumentNullException">
 /// If the supplied <paramref name="resourceName"/> is
 /// <see langword="null"/> or contains only whitespace character(s).
 /// </exception>
 protected AbstractResource(string resourceName)
 {
     AssertUtils.ArgumentHasText(resourceName, "resourceName");
     this.protocol     = ConfigurableResourceLoader.GetProtocol(resourceName);
     this.resourceName = resourceName;
 }
示例#27
0
 /// <summary>
 /// Creates a new instance of the <b>UrlValidator</b> class.
 /// </summary>
 /// <param name="test">The expression to validate.</param>
 /// <param name="when">The expression that determines if this validator should be evaluated.</param>
 public UrlValidator(string test, string when)
     : base(test, when)
 {
     AssertUtils.ArgumentHasText(test, "test");
 }
 /// <summary>
 /// Add argument value for the given name in the constructor argument list.
 /// </summary>
 /// <param name="name">The name in the constructor argument list.</param>
 /// <param name="value">The argument value.</param>
 /// <exception cref="ArgumentException">
 /// If the supplied <paramref name="name"/> is <see langword="null"/>
 /// or is composed wholly of whitespace.
 /// </exception>
 public void AddNamedArgumentValue(string name, object value)
 {
     AssertUtils.ArgumentHasText(name, "name");
     GetAndInitializeNamedArgumentValuesIfNeeded()[GetCanonicalNamedArgument(name)] = new ValueHolder(value);
 }
		/// <summary>
		/// Creates a new instance of the
		/// <see cref="Spring.Objects.Factory.Support.LookupMethodOverride"/> class.
		/// </summary>
		/// <remarks>
		/// <p>
		/// Methods eligible for lookup override must not have arguments.
		/// </p>
		/// </remarks>
		/// <param name="methodName">
		/// The name of the method that is to be overridden.
		/// </param>
		/// <param name="objectName">
		/// The name of the object in the current IoC context that the
		/// dependency injected method must return.
		/// </param>
		/// <exception cref="System.ArgumentNullException">
		/// If either of the supplied arguments is <see langword="null"/> or
		/// contains only whitespace character(s).
		/// </exception>
		public LookupMethodOverride(string methodName, string objectName)
			: base(methodName)
		{
			AssertUtils.ArgumentHasText(objectName, "objectName");
			this.objectName = objectName;
		}
示例#30
0
 /// <summary>
 /// Invoked by an <see cref="Spring.Objects.Factory.IObjectFactory"/>
 /// after it has set all object properties supplied
 /// (and satisfied the
 /// <see cref="Spring.Objects.Factory.IObjectFactoryAware"/>
 /// and <see cref="Spring.Context.IApplicationContextAware"/>
 /// interfaces).
 /// </summary>
 /// <remarks>
 /// <p>
 /// Ensures that the <see cref="TargetObjectName"/> property has been
 /// set to a valid value (i.e. is not <see langword="null"/> or a string
 /// that consists solely of whitespace).
 /// </p>
 /// </remarks>
 /// <exception cref="System.Exception">
 /// In the event of misconfiguration (such as failure to set an essential
 /// property) or if initialization fails.
 /// </exception>
 /// <seealso cref="Spring.Objects.Factory.IInitializingObject.AfterPropertiesSet"/>
 public virtual void AfterPropertiesSet()
 {
     AssertUtils.ArgumentHasText(
         TargetObjectName, "TargetObjectName",
         "The 'TargetObjectName' property must have a value.");
 }