首页 \ 问答 \ 时间重复效果(Repeat effect with timing)

时间重复效果(Repeat effect with timing)

我有这个代码

$(document).ready(function () {
    $('.HighlightedTr').delay(1000).effect("highlight", {}, 1000);        
});`

工作得很好,但有一次......有可能延迟一遍吗? 喜欢每秒或每5秒?

TXS


I have this code

$(document).ready(function () {
    $('.HighlightedTr').delay(1000).effect("highlight", {}, 1000);        
});`

Works good but once.. Is it possible to repeat this with some delay? like every seconds or every 5 seconds?

Txs


原文:https://stackoverflow.com/questions/6690647
更新时间:2024-01-10 12:01

最满意答案

OleDB非常适合解析CSV数据,您不必使用反射。 以下是使用OleDB类进行映射的主要思路:

  1. 用户定义一个映射(使用委托,流畅的界面或其他东西),它进入Mapper类的Dictionary。
  2. Parser创建一个DataTable并从mapper中插入列
  3. Parser以正确的类型从CSV文件创建OleDbConnection,Adapter,Command和填充dataTable。
  4. 解析器从DataTable中提取IDataRecords,并且您的Mapper需要从IDataRecord映射到对象。 有关记录到对象映射的指导,我建议阅读ORM映射器的来源,如Dapper.NET,Massive,PetaPoco。

OleDb CSV解析:将csv加载到oleDB中并强制所有推断的数据类型为字符串

UPDATE

由于只有一个字符串,不言而喻,使用最简单,最简单的方法更好。 所以,对于问题:

实现泛型类 - 如果不需要进一步提升解析(不再需要字符串,将来不再有约束/特性),我会选择一个带有对象,字符串和映射信息的静态类。 它现在和你的几乎一样。 这里有一些修改版本(可能无法编译,但应该反映一般的想法):

public static class CSVParser
{
    public static void FillPOCO(object poco, string csvData, CSVMapping mapping)
    {
        PropertyInfo[] relevantProperties = poco.GetType().GetProperties().Where(x => mapping.Mapping.Keys.Contains(x)).ToArray();
        string[] dataStrings = csvData.Split(',');
        foreach (PropertyInfo property in relevantProperties)
            SetPropertyValue(poco, property, dataStrings[mapping.Mapping[property.Name]]);
    }

    private static void SetPropertyValue(object poco, PropertyInfo property, string value)
    {
        // .. here goes code to change type to the necessary one ..
        property.SetValue(poco, value);
    }
}

关于字符串到类型的值转换 - 有Convert.ChangeType方法处理大多数情况。 布尔变量存在特殊问题(当它被赋予“0”而不是“假”时)。

至于数据填充 - 尽管反射被认为是缓慢的,对于单个对象而且很少使用它应该足够,因为它简单易行。 处理poco种群问题的常用方法是:运行时转换方法创建(使用反射初始化然后像任何其他方法一样编译和调用) - 通常使用DynamicMethod,Expression Trees和类似方法实现 - 这里有很多话题在这里; 动态对象的使用(自C#4.0以来可用) - 在哪里分配/获取变量,你不需要声明它; 使用市场上的可用库(通常来自ORM系统,因为它们严重依赖于数据到对象的转换)。

就个人而言,我会测量反射是否适合我的表现需求,并且会向前推进问题。


OleDB is great at parsing CSV data and you don't have to use reflection for it. Here's the main idea for mapping with OleDB classes:

  1. User defines a mapping (using delegate, fluent interface or something) and it gets into the Dictionary in your Mapper class.
  2. Parser creates a DataTable and inserts columns from mapper
  3. Parser creates OleDbConnection, Adapter, Command and fills dataTable from CSV file in correct types.
  4. Parser extracts IDataRecords from DataTable and your Mapper needs to map from IDataRecord to objects. For guidance on record-to-object mapping I'd recommend reading sources of ORM mappers like Dapper.NET, Massive, PetaPoco.

OleDb CSV parsing: Load csv into oleDB and force all inferred datatypes to string

UPDATE

Since there's only one string, it goes without saying that using easiest and simplest approach is better. So, for the questions:

Implement generic class - if there's no need to further advance parsing (no more string, no more constraints/features in the future), I'd go for a static class that takes object, string and mapping information. It'd have almost the same look as yours does right now. Here's somewhat modified version (may not compile, but should reflect the general idea):

public static class CSVParser
{
    public static void FillPOCO(object poco, string csvData, CSVMapping mapping)
    {
        PropertyInfo[] relevantProperties = poco.GetType().GetProperties().Where(x => mapping.Mapping.Keys.Contains(x)).ToArray();
        string[] dataStrings = csvData.Split(',');
        foreach (PropertyInfo property in relevantProperties)
            SetPropertyValue(poco, property, dataStrings[mapping.Mapping[property.Name]]);
    }

    private static void SetPropertyValue(object poco, PropertyInfo property, string value)
    {
        // .. here goes code to change type to the necessary one ..
        property.SetValue(poco, value);
    }
}

Regarding the string to typed value conversion - there's Convert.ChangeType method that handles most of the cases. There's particular problem with boolean variables (when it's given "0" instead of "false") though.

As for data population - though reflection is said to be slow, for single objects and seldom usages it should suffice since it's easy and simple. Usual methods for dealing with problem of poco population are: run-time conversion method creation (that uses reflection to be initialized and then is compiled and called like any other method) - usually implemented using DynamicMethod, Expression Trees and similar - there's plenty of topic here on so; usage of dynamic objects (available since C# 4.0) - where to assign/get variable you don't need to declare it; use available libraries on the market (usually from the ORM systems, since they rely heavily on data-to-object conversion).

Personally, I'd measure if reflection is suitable for my performance needs and would progress forward pass the problem.

相关问答

更多
  • OleDB非常适合解析CSV数据,您不必使用反射。 以下是使用OleDB类进行映射的主要思路: 用户定义一个映射(使用委托,流畅的界面或其他东西),它进入Mapper类的Dictionary。 Parser创建一个DataTable并从mapper中插入列 Parser以正确的类型从CSV文件创建OleDbConnection,Adapter,Command和填充dataTable。 解析器从DataTable中提取IDataRecords,并且您的Mapper需要从IDataRecord映射到对象。 有关 ...
  • 作为参考,optparse(http://docs.python.org/library/optparse.html)版本看起来像这样。 import optparse parser = optparse.OptionParser() parser.add_option("-i","--input",dest="filename") (options,args) = parser.parse_args() thefile = options.filename reader = csv.reader(th ...
  • 这与Dapper无关。 还要考虑其他人发布给你的问题的评论。 下面只是建议如何避免解密两次get块。 private string _password; private bool _isDecrypted = false; public string Password { get { if(_isDecrypted == false) { _password = Decrypt(_password); _isDe ...
  • 我找到了一个在codeproject上提供给我的答案:使用带有操作的字典将允许我通过clientID跟踪项目以及它所属的属性 public Dictionary> setters = new Dictionary>(); 我的clientID是一个Guid.PropertyName所以现在我可以轻松匹配Machine(Guid).Property I found an answer ...
  • 从.NET 4.5开始,他们意识到需要将DbGeography作为核心.NET Framework的一部分,并将其从EntityFramework.dll中移出,并将其移出到System.Data.Entity.dll中 ,这是他们现在提供的ORM Agnostic API,以便EF任何其他ORM都可以构建它。 As of .NET 4.5 they realized the need to have DbGeography as part of the core .NET Framework and mo ...
  • 问题是你的PhoneNumber.TryParse()调用被转换成一个发送到服务器的表达式,它不理解。 此外,没有办法告诉SQL您的结构,因此您将无法根据解析的值执行服务器端查询。 一种选择是捕获字符串值并将PhoneNumber.TryParse()位移动到其他位置。 例如: public class Customer { public string HomePhoneString; private bool _HomePhoneParsed; private PhoneNumber? _H ...
  • 如果您提供了Customer的2个上下文和重叠属性,那将会有所帮助。 出于本答复的目的,我使用上下文:'Sales'和'Marketing',共享属性是'Preferred Name' 我最初基于“重叠字段”这一短语的想法是,您需要重新访问您的模型,因为您不应该有2个模型负责特定值,否则您会有并发/竞争条件。 尝试并思考您的客户如何解决过去的笔和纸的情况。 谁拥有'客户'文件? 销售和营销每个都有自己的版本,还是营销依赖销售副本(反之亦然)? 此外,DDD最强大的一个方面是它会强制您的持久性问题进入您所属的 ...
  • 在Beta1中,CLR类到EDM类型的映射有点不可原谅。 听起来好像这里的问题是发现多个“Entry”类与所需的“Entry”实体不匹配。 我们应该忽略这些,但在Beta1中我们没有,你得到一个例外。 我们已经为下一个测试版开发了这个,所以相反,EF继续寻找匹配的类,在你的情况下会找到你的Entry类,一切都会好的。 在Beta2发布之前,您可能需要将Entry类的名称更改为更独特的名称。 希望这可以帮助 亚历克斯 实体框架团队的项目经理。 In Beta1 the mapping for CLR clas ...
  • 您可以在实体设计器中更改它。 Enity Data Model(EDM)包含3个主要部分: 概念模型。 您想要保存哪些对象。 存储模型。 你有什么数据库结构。 映射。 如何将对象映射到数据库。 POCO实际上是在概念模型中“定义”的。 在模型设计器中打开Edmx文件。 在那里找到用户实体并更改属性的名称。 You can change it in Entity Designer. Enity Data Model (EDM) contains 3 main parts: Conceptual model. ...
  • 查看ASP.NET MVC in Action一书。 。 它有一整章专门讨论这个主题。 他们建议并展示如何使用AutoMapper将域实体映射到ViewModels。 我这里也有一个例子。 在BootStrapper中: Mapper.CreateMap() .ForMember(dst => dst.TypeName, opt => opt.MapFrom(src => src.BuildingType.Name)); ...

相关文章

更多

最新问答

更多
  • 您如何使用git diff文件,并将其应用于同一存储库的副本的本地分支?(How do you take a git diff file, and apply it to a local branch that is a copy of the same repository?)
  • 将长浮点值剪切为2个小数点并复制到字符数组(Cut Long Float Value to 2 decimal points and copy to Character Array)
  • OctoberCMS侧边栏不呈现(OctoberCMS Sidebar not rendering)
  • 页面加载后对象是否有资格进行垃圾回收?(Are objects eligible for garbage collection after the page loads?)
  • codeigniter中的语言不能按预期工作(language in codeigniter doesn' t work as expected)
  • 在计算机拍照在哪里进入
  • 使用cin.get()从c ++中的输入流中丢弃不需要的字符(Using cin.get() to discard unwanted characters from the input stream in c++)
  • No for循环将在for循环中运行。(No for loop will run inside for loop. Testing for primes)
  • 单页应用程序:页面重新加载(Single Page Application: page reload)
  • 在循环中选择具有相似模式的列名称(Selecting Column Name With Similar Pattern in a Loop)
  • System.StackOverflow错误(System.StackOverflow error)
  • KnockoutJS未在嵌套模板上应用beforeRemove和afterAdd(KnockoutJS not applying beforeRemove and afterAdd on nested templates)
  • 散列包括方法和/或嵌套属性(Hash include methods and/or nested attributes)
  • android - 如何避免使用Samsung RFS文件系统延迟/冻结?(android - how to avoid lag/freezes with Samsung RFS filesystem?)
  • TensorFlow:基于索引列表创建新张量(TensorFlow: Create a new tensor based on list of indices)
  • 企业安全培训的各项内容
  • 错误:RPC失败;(error: RPC failed; curl transfer closed with outstanding read data remaining)
  • C#类名中允许哪些字符?(What characters are allowed in C# class name?)
  • NumPy:将int64值存储在np.array中并使用dtype float64并将其转换回整数是否安全?(NumPy: Is it safe to store an int64 value in an np.array with dtype float64 and later convert it back to integer?)
  • 注销后如何隐藏导航portlet?(How to hide navigation portlet after logout?)
  • 将多个行和可变行移动到列(moving multiple and variable rows to columns)
  • 提交表单时忽略基础href,而不使用Javascript(ignore base href when submitting form, without using Javascript)
  • 对setOnInfoWindowClickListener的意图(Intent on setOnInfoWindowClickListener)
  • Angular $资源不会改变方法(Angular $resource doesn't change method)
  • 在Angular 5中不是一个函数(is not a function in Angular 5)
  • 如何配置Composite C1以将.m和桌面作为同一站点提供服务(How to configure Composite C1 to serve .m and desktop as the same site)
  • 不适用:悬停在悬停时:在元素之前[复制](Don't apply :hover when hovering on :before element [duplicate])
  • 常见的python rpc和cli接口(Common python rpc and cli interface)
  • Mysql DB单个字段匹配多个其他字段(Mysql DB single field matching to multiple other fields)
  • 产品页面上的Magento Up出售对齐问题(Magento Up sell alignment issue on the products page)