Ejemplo n.º 1
0
        private Type ValidateAndGetType(ProtocolElement element, string typeName, Type assignableType, string elementPropertyName)
        {
            Type type;

            try
            {
                type = Type.GetType(typeName, true);
            }
            catch (Exception exception)
            {
                PropertyInformation information = null;
                string filename = string.Empty;
                int    line     = 0;
                if ((element != null) && (element.ElementInformation != null))
                {
                    information = element.ElementInformation.Properties[elementPropertyName];
                    if (information != null)
                    {
                        filename = information.Source;
                        line     = information.LineNumber;
                    }
                }
                throw new ConfigurationErrorsException(exception.Message, exception, filename, line);
            }
            ConfigUtil.CheckAssignableType(assignableType, type, element, elementPropertyName);
            return(type);
        }
Ejemplo n.º 2
0
        internal static Type LoadTypeWithChecks(string typeName, Type requiredBaseType, Type requiredBaseType2, ConfigurationElement elem, string propertyName)
        {
            Type type = ConfigUtil.GetType(typeName, propertyName, elem);

            if (requiredBaseType2 == null)
            {
                ConfigUtil.CheckAssignableType(requiredBaseType, type, elem, propertyName);
                return(type);
            }
            ConfigUtil.CheckAssignableType(requiredBaseType, requiredBaseType2, type, elem, propertyName);
            return(type);
        }
        private ISessionIDManager InitSessionIDManager(SessionStateSection config)
        {
            ISessionIDManager manager;
            string            sessionIDManagerType = config.SessionIDManagerType;

            if (string.IsNullOrEmpty(sessionIDManagerType))
            {
                manager = new SessionIDManager();
                this._usingAspnetSessionIdManager = true;
            }
            else
            {
                Type type = ConfigUtil.GetType(sessionIDManagerType, "sessionIDManagerType", config);
                ConfigUtil.CheckAssignableType(typeof(ISessionIDManager), type, config, "sessionIDManagerType");
                manager = (ISessionIDManager)HttpRuntime.CreatePublicInstance(type);
            }
            manager.Initialize();
            return(manager);
        }
        private IPartitionResolver InitPartitionResolver(SessionStateSection config)
        {
            string partitionResolverType = config.PartitionResolverType;

            if (string.IsNullOrEmpty(partitionResolverType))
            {
                return(null);
            }
            if ((config.Mode != SessionStateMode.StateServer) && (config.Mode != SessionStateMode.SQLServer))
            {
                throw new ConfigurationErrorsException(System.Web.SR.GetString("Cant_use_partition_resolve"), config.ElementInformation.Properties["partitionResolverType"].Source, config.ElementInformation.Properties["partitionResolverType"].LineNumber);
            }
            Type type = ConfigUtil.GetType(partitionResolverType, "partitionResolverType", config);

            ConfigUtil.CheckAssignableType(typeof(IPartitionResolver), type, config, "partitionResolverType");
            IPartitionResolver resolver = (IPartitionResolver)HttpRuntime.CreatePublicInstance(type);

            resolver.Initialize();
            return(resolver);
        }