private static ApplicationContext CreateApplicationContext(Dictionary<string, object> cookies)
        {
            var result = new ApplicationContext();
            var contextKeys = typeof(ApplicationContext).GetProperties().Where(x => x.CanWrite);
            var context = HttpContext.Current;

            foreach (PropertyInfo propertyInfo in contextKeys)
            {
                string propertyKey = (context.Request.Cookies[propertyInfo.Name] != null) ? context.Request.Cookies[propertyInfo.Name].Value : String.Empty;
               
                if (!string.IsNullOrEmpty(propertyKey))
                {
                    // in this case whe use TypeDescriptor COnvertion because the GUID cannot be natively translated from string.
                    //http://stackoverflow.com/questions/393731/generic-conversion-function-doesnt-seem-to-work-with-guids
                    object value = TypeDescriptor.GetConverter(propertyInfo.PropertyType).ConvertFromInvariantString(propertyKey);
                    result.GetType().GetProperty(propertyInfo.Name).SetValue(result, value, null);
                }
            }

            return result;
        }