예제 #1
0
파일: Global.cs 프로젝트: xxjeng/nuxleus
        protected void Application_Start(object sender, EventArgs e)
        {
            if (_xameleonConfiguration.DebugMode == "yes") _DEBUG = true;

            if (_xameleonConfiguration.UseMemcached == "yes")
            {
                _useMemCached = true;
                _memcachedClient = new Client(new MemcachedClient(), AspNetMemcachedConfiguration.GetConfig());
            }

            string baseUri = (string)_xameleonConfiguration.PreCompiledXslt.BaseUri;
            if (baseUri != String.Empty)
                baseUri = (string)_xameleonConfiguration.PreCompiledXslt.BaseUri;
            else
                baseUri = "~";

            _xsltTransformationManager = new XsltTransformationManager(_processor, _transform, _resolver, _serializer);
            _xsltTransformationManager.HashAlgorithm = _hashAlgorithm;
            _resolver.Credentials = CredentialCache.DefaultCredentials;
            _namedXsltHashtable = _xsltTransformationManager.NamedXsltHashtable;

            string hashkey = (string)_xameleonConfiguration.BaseSettings.ObjectHashKey;
            Application["hashkey"] = hashkey;

            foreach (PreCompiledXslt xslt in _xameleonConfiguration.PreCompiledXslt)
            {
                string localBaseUri = (string)_xameleonConfiguration.PreCompiledXslt.BaseUri;
                if (localBaseUri == String.Empty)
                    localBaseUri = baseUri;
                Uri xsltUri = new Uri(HttpContext.Current.Server.MapPath(localBaseUri + xslt.Uri));
                _xsltTransformationManager.Compiler.BaseUri = xsltUri;
                _xsltTransformationManager.AddTransformer(xslt.Name, xsltUri, _resolver, xslt.InitialMode, xslt.InitialTemplate);
                _namedXsltHashtable.Add(xslt.Name, xsltUri);
                if (xslt.UseAsBaseXslt == "yes")
                {
                    _baseXsltContext = new BaseXsltContext(xsltUri, XsltTransformationManager.GenerateNamedETagKey(xslt.Name, xsltUri), xslt.Name);
                }
            }

            _xsltTransformationManager.SetBaseXsltContext(_baseXsltContext);

            foreach (XsltParam xsltParam in _xameleonConfiguration.GlobalXsltParam)
            {
                _globalXsltParams[xsltParam.Name] = (string)xsltParam.Select;
            }

            if (_memcachedClient != null)
                Application["as_memcached"] = _memcachedClient;
            Application["as_usememcached"] = _useMemCached;
            Application["as_xslTransformationManager"] = _xsltTransformationManager;
            Application["as_namedXsltHashtable"] = _namedXsltHashtable;
            Application["as_globalXsltParams"] = _globalXsltParams;
            Application["as_debug"] = _DEBUG;

        }
예제 #2
0
        protected void Application_Start(object sender, EventArgs e)
        {

            if (_xameleonConfiguration.UseMemcached == "yes")
            {
                _useMemCached = true;
                _memcachedClient = new MemcachedClient();
                _pool = SockIOPool.GetInstance();
                List<string> serverList = new List<string>();
                foreach (MemcachedServer server in _memcachedConfiguration.MemcachedServerCollection)
                {
                    serverList.Add(server.IP + ":" + server.Port);
                }
                _pool.SetServers(serverList.ToArray());

                if (_memcachedConfiguration.UseCompression != null && _memcachedConfiguration.UseCompression == "yes")
                    _memcachedClient.EnableCompression = true;
                else
                    _memcachedClient.EnableCompression = false;

                MemcachedPoolConfig poolConfig = (MemcachedPoolConfig)_memcachedConfiguration.PoolConfig;
                _pool.InitConnections = (int)poolConfig.InitConnections;
                _pool.MinConnections = (int)poolConfig.MinConnections;
                _pool.MaxConnections = (int)poolConfig.MaxConnections;
                _pool.SocketConnectTimeout = (int)poolConfig.SocketConnectTimeout;
                _pool.SocketTimeout = (int)poolConfig.SocketConnect;
                _pool.MaintenanceSleep = (int)poolConfig.MaintenanceSleep;
                _pool.Failover = (bool)poolConfig.Failover;
                _pool.Nagle = (bool)poolConfig.Nagle;
                _pool.Initialize();
            }

            string baseUri = (string)_xameleonConfiguration.PreCompiledXslt.BaseUri;
            if (baseUri != String.Empty)
                baseUri = (string)_xameleonConfiguration.PreCompiledXslt.BaseUri;
            else
                baseUri = "~";

            _xsltTransformationManager = new XsltTransformationManager(_processor, _transform, _resolver, _serializer);
            _xsltTransformationManager.HashAlgorithm = _hashAlgorithm;
            _resolver.Credentials = CredentialCache.DefaultCredentials;
            _namedXsltHashtable = _xsltTransformationManager.NamedXsltHashtable;

            string hashkey = (string)_xameleonConfiguration.BaseSettings.ObjectHashKey;
            Application["hashkey"] = hashkey;

            foreach (PreCompiledXslt xslt in _xameleonConfiguration.PreCompiledXslt)
            {
                string localBaseUri = (string)_xameleonConfiguration.PreCompiledXslt.BaseUri;
                if (localBaseUri == String.Empty)
                    localBaseUri = baseUri;
                Uri xsltUri = new Uri(HttpContext.Current.Server.MapPath(localBaseUri + xslt.Uri));
                _xsltTransformationManager.Compiler.BaseUri = xsltUri;
                _xsltTransformationManager.AddTransformer(xslt.Name, xsltUri, _resolver, xslt.InitialMode, xslt.InitialTemplate);
                _namedXsltHashtable.Add(xslt.Name, xsltUri);
                if (xslt.UseAsBaseXslt == "yes")
                {
                    _baseXsltContext = new BaseXsltContext(xsltUri, XsltTransformationManager.GenerateNamedETagKey(xslt.Name, xsltUri), xslt.Name);
                }
            }

            _xsltTransformationManager.SetBaseXsltContext(_baseXsltContext);

            foreach (XsltParam xsltParam in _xameleonConfiguration.GlobalXsltParam)
            {
                _globalXsltParams[xsltParam.Name] = (string)xsltParam.Select;
            }

            if (_memcachedClient != null)
                Application["appStart_memcached"] = _memcachedClient;
            Application["appStart_usememcached"] = _useMemCached;
            Application["appStart_xslTransformationManager"] = _xsltTransformationManager;
            Application["appStart_namedXsltHashtable"] = _namedXsltHashtable;
            Application["appStart_globalXsltParams"] = _globalXsltParams;

        }