首页 \ 问答 \ 在Scala中,是否有简单的方法将案例类转换为元组?(In Scala, is there an easy way to convert a case class into a tuple?)

在Scala中,是否有简单的方法将案例类转换为元组?(In Scala, is there an easy way to convert a case class into a tuple?)

有没有一个简单的方法来将案例类转换为元组?

当然,我可以轻松地编写样板代码来做到这一点,但我的意思是没有样板。

我真正的追求是一种轻松地按照字典顺序排序的方法。 我可以通过导入scala.math.Ordering.Implicits._来实现元组的目标,瞧,我的元组为它们定义了一个Ordering。 但是在scala.math.Ordering中的含义一般不适用于案例类。


Is there an easy way to convert a case class into a tuple?

I can, of course, easily write boilerplate code to do this, but I mean without the boilerplate.

What I'm really after is a way to easily make a case class lexicographically Ordered. I can achieve the goal for tuples by importing scala.math.Ordering.Implicits._, and voila, my tuples have an Ordering defined for them. But the implicits in scala.math.Ordering don't work for case classes in general.


原文:https://stackoverflow.com/questions/8087958
更新时间:2023-05-29 07:05

最满意答案

查看HttpCookie对象的Expires属性 - 更多内容在此处 。 我相信你将来会像在msdn网站上的例子那样设置cookie到期日期。 因为您在过去设置了日期时间,所以Cookie会自动过期,您永远无法阅读它。


Look at the Expires property of HttpCookie object - more on this here. I believe you shoud set cookie expiration date in future like in the example on msdn site. Because you set date time in the past the cookie automatically expires and you are never able to read it.

相关问答

更多
  • 明确的答案在您链接到您的原始问题forums.asp.net后。 这些答案直接来自产品团队成员自己。 Cookieless表单认证/无Cookie会话是不推荐的技术。 ASP.NET团队近年来没有做什么(MVC,WebAPI,SignalR,Friendly URLs)支持它。 事情可能会因意外事故而发生作用,但这不应该被误解为官方支持的情况。 所有已提交的关于无cookie形式auth / cookieless会话的错误都会自动解决,并且不会由产品团队修复。 The definitive answer w ...
  • 查看HttpCookie对象的Expires属性 - 更多内容在此处 。 我相信你将来会像在msdn网站上的例子那样设置cookie到期日期。 因为您在过去设置了日期时间,所以Cookie会自动过期,您永远无法阅读它。 Look at the Expires property of HttpCookie object - more on this here. I believe you shoud set cookie expiration date in future like in the exampl ...
  • 这是一个例子: public class HomeController : Controller { public ActionResult CreateCookie() { var cookie = new HttpCookie("cookie_name", "some value"); Response.AppendCookie(cookie); return View(); } public ActionResult R ...
  • 尝试使用Response.SetCookie() ,因为Response.Cookies.Add()可以导致添加多个cookie,而SetCookie将更新现有的cookie。 Try using Response.SetCookie(), because Response.Cookies.Add() can cause multiple cookies to be added, whereas SetCookie will update an existing cookie.
  • 关于这一行: if (filterContext.HttpContext.Items["Theam"] != null) HttpContext.Items是一个请求级别的设置。 这意味着您需要在每个HTTP请求上重新加载它。 如果你没有在运行这段代码之前的请求生命周期中的某个地方设置HttpContext.Items["Theam"] ,它将始终为空。 我不确定这是你的问题,但它可以解释为什么你的代码的其余部分在手动设置变量时工作。 Regarding this line: if (filterCont ...
  • 有很多开源项目实现了身份验证,授权和实现,记住我,cookie管理。 它们不同于简单到复杂的门户系统,如Orchard cms。 一开始,探索微软音乐教程是很好的,其中一部分解释了认证和授权http://www.asp.net/mvc/tutorials/mvc-music-store/mvc-music-store-part-7 ,这是它的来源http://mvcmusicstore.codeplex.com/ , 除了论坛引擎是一个总是使用授权和身份验证的Web应用程序,您可以下载一个mvc论坛http ...
  • 感谢@DavidTansey的输入。 实现了以下代码并能够模拟Response.Cookies。 然而,这不是我期待的上下文包装,但至少我能够继续前进。 单元测试文件: public class HttpContextMock:HttpContextBase {private HttpResponseBase response; public override HttpResponseBase Response { get { if ( ...
  • 我为我的场景找到了解决方案。 我在两个应用程序的机器密钥中添加了compatibilityMode =“Framework45”,它们都运行良好。 注意:如果您的某个应用程序使用的是旧版本的.NET框架,则必须明确配置.NET 4.5应用程序以使用早期的计算机兼容性模式,否则它们将无法加密/解密表单身份验证票证。 只是为了提醒你我的情景: WebForms ASP.NET 4.5
  • 我认为你很少有“InActive”用户。 我只是将它们存储在Cache中并在每个请求中检查它。 如果用户恰好是InActive,则将其注销。 在内存中比依赖cookie信息更好。 I would assume you have very few "InActive" users. I would just store them in Cache and check it on every request. If the user happens to be InActive then log them ou ...

相关文章

更多

最新问答

更多
  • 如何使用自由职业者帐户登录我的php网站?(How can I login into my php website using freelancer account? [closed])
  • 如何打破按钮上的生命周期循环(How to break do-while loop on button)
  • C#使用EF访问MVC上的部分类的自定义属性(C# access custom attributes of a partial class on MVC with EF)
  • 如何获得facebook app的publish_stream权限?(How to get publish_stream permissions for facebook app?)
  • 如何并排放置两个元件?(How to position two elements side by side?)
  • 在MySQL和/或多列中使用多个表用于Rails应用程序(Using multiple tables in MySQL and/or multiple columns for a Rails application)
  • 如何隐藏谷歌地图上的登录按钮?(How to hide the Sign in button from Google maps?)
  • Mysql左连接旋转90°表(Mysql Left join rotate 90° table)
  • 带有ImageMagick和许多图像的GIF动画(GIF animation with ImageMagick and many images)
  • 电脑高中毕业学习去哪里培训
  • 电脑系统专业就业状况如何啊?
  • IEnumerable linq表达式(IEnumerable linq expressions)
  • 如何在Spring测试中连接依赖关系(How to wire dependencies in Spring tests)
  • Solr可以在没有Lucene的情况下运行吗?(Can Solr run without Lucene?)
  • 如何保证Task在当前线程上同步运行?(How to guarantee that a Task runs synchronously on the current thread?)
  • 在保持每列的类的同时向数据框添加行(Adding row to data frame while maintaining the class of each column)
  • 的?(The ? marks in emacs/haskell and ghc mode)
  • 一个线程可以调用SuspendThread传递自己的线程ID吗?(Can a thread call SuspendThread passing its own thread ID?)
  • 延迟socket.io响应,并“警告 - websocket连接无效”(Delayed socket.io response, and “warn - websocket connection invalid”)
  • 悬停时的图像转换(Image transition on hover)
  • IIS 7.5仅显示homecontroller(IIS 7.5 only shows homecontroller)
  • 没有JavaScript的复选框“关闭”值(Checkbox 'off' value without JavaScript)
  • java分布式框架有哪些
  • Python:填写表单并点击按钮确认[关闭](Python: fill out a form and confirm with a button click [closed])
  • PHP将文件链接到根文件目录(PHP Linking Files to Root File Directory)
  • 我如何删除ListView中的项目?(How I can remove a item in my ListView?)
  • 您是否必须为TFS(云)中的每个BUG创建一个TASK以跟踪时间?(Do you have to create a TASK for every BUG in TFS (Cloud) to track time?)
  • typoscript TMENU ATagParams小写(typoscript TMENU ATagParams lowercase)
  • 武陟会计培训类的学校哪个好点?
  • 从链接中删除文本修饰(Remove text decoration from links)