程序员 coding啥意思

I sat down with the Coding4Fun Developer Kit and immediately noticed the Preview Handler stuff. I got addicted to Preview Handlers back when Tim wrote one for PDFs. They are darned useful and it seems to me that any application that adds a new file type should add a preview handler for it. They are used in the Vista Explorer, in Outlook 2007 and in Windows Desktop Search. If you or your company makes an explorer replacement, you can also host a Preview Control and add Preview functionality to your own File Explorer application.

我坐在Coding4Fun开发人员套件中,立即注意到Preview Handler的内容。 提姆为PDF编写预览处理器时,我上瘾了。 它们非常有用,在我看来,任何添加新文件类型的应用程序都应为其添加预览处理程序。 它们在Vista资源管理器,Outlook 2007和Windows桌面搜索中使用。 如果您或您的公司替换了资源管理器,则还可以托管预览控件并将预览功能添加到您自己的文件资源管理器应用程序中。

I wanted to make a vCard Preview Handler so I could see what's inside a vCard on systems that don't have Outlook. Here's the process to create your own Preview Handler in no time (keeping in mind that the kit is BETA).

我想制作一个vCard预览处理程序,以便可以在没有Outlook的系统上看到vCard内部的内容。 这是立即创建您自己的预览处理程序的过程(请记住,该工具包是BETA )。

  • After installing the C4F Developer Kit, make new Class Library project and add a reference to the PreviewHandlerFramework.安装C4F开发人员工具包后,创建新的类库项目,并添加对PreviewHandlerFramework的引用。
  • Create a new class like below and add the [PreviewHandler] attribute with a name for your project, the extension or extensions (like .foo;.bar), and another Guid for the COM Stuff.

    创建一个如下所示的新类,并为[PreviewHandler]属性添加项目名称,一个或多个扩展名(例如.foo; .bar)和另一个用于COM Stuff的Guid。

    • You can get new GUIDs either via GuidGen.exe included with the Windows SDK or online at http://www.guidgen.com/ or in PowerShell via [Guid]::NewGuid().ToString().

      您可以通过Windows SDK附带的GuidGen.exe或通过http://www.guidgen.com/在线获得新的GUID,也可以通过[Guid] :: NewGuid()。ToString()在PowerShell中获得新的GUID。

  • Also, include a ProgId for your new class. I just used the namespace.classname. 另外,为您的新课程添加一个ProgId。 我只是使用了namespace.classname。
  • Notice that I derived from FileBasedPreviewHandler. You'll need to override CreatePreviewHandlerControl and return a new instance of your own Control that is derived from FileBasedPreviewHandlerControl. The boilerplate is below. It's inside Load() where you create whatever WinForms controls you need to and add them to the this.Controls collection.注意,我是从FileBasedPreviewHandler派生的。 您将需要重写CreatePreviewHandlerControl并返回派生自FileBasedPreviewHandlerControl的控件的新实例。 样板位于下方。 在Load()内部,您可以在其中创建所需的任何WinForms控件,并将它们添加到this.Controls集合中。
using C4F.DevKit.PreviewHandler.PreviewHandlerFramework;namespace C4F.DevKit.PreviewHandler.PreviewHandlers
{[PreviewHandler("Hanselman Silly vCard Preview Handler", ".vcf", "{42810C0B-FEA8-4dbf-A711-5634DFBA9F3B}")][ProgId("C4F.DevKit.PreviewHandler.PreviewHandlers.vCardPreviewHandler")][Guid("D193B258-AC07-4139-B334-C20F18F4FC7C")][ClassInterface(ClassInterfaceType.None)][ComVisible(true)]public sealed class vCardPreviewHandler : FileBasedPreviewHandler{protected override PreviewHandlerControl CreatePreviewHandlerControl(){return new vCardPreviewHandlerControl();}private sealed class vCardPreviewHandlerControl : FileBasedPreviewHandlerControl{public override void Load(FileInfo file){                 //ADD STUFF HERE}}}
}

vCards are funky things, and there's multiple versions of the format. The general format is like this:

电子名片很时髦,并且有多种格式。 通用格式如下:

BEGIN:VCARDVERSION:2.1N;LANGUAGE=en-us:Hanselman;ScottFN:Scott HanselmanORG:MicrosoftTITLE:Senior Program ManagerTEL;WORK;VOICE:+1 (503) 766-2048TEL;HOME;VOICE:+1 (503) 766-2048TEL;CELL;VOICE:+1 (503) 766-2048ADR;WORK;PREF:;;One Microsoft Way;Redmond;WA;11111;United States of AmericaLABEL;WORK;PREF;ENCODING=QUOTED-PRINTABLE:One Microsoft Way=0D=0A=Redmond, WA  11111ADR;HOME:;;5 Main Street;Main Town;OR,;12345;United States of AmericaLABEL;HOME;ENCODING=QUOTED-PRINTABLE:5 Main Street=0D=0A=Main Town, OR, 12345URL;WORK:http://www.hanselman.comEMAIL;PREF;INTERNET:firstname@lastname.com REV:20070810T050105ZEND:VCARD

BEGIN:VCARDVERSION:2.1N; LANGUAGE = en-us:Hanselman; ScottFN:Scott HanselmanORG:MicrosoftTITLE:Senior Program ManagerTEL; WORK; VOICE:+1(503)766-2048TEL; HOME; VOICE:+1(503)766- 2048TEL; CELL; VOICE:+1(503)766-2048ADR; WORK; PREF:;; One Microsoft Way; Redmond; WA; 11111; United States of AmericaLABEL; WORK; PREF; ENCODING = QUOTED-PRINTABLE:One Microsoft Way = 0D = 0A =雷德蒙德,WA 11111ADR; HOME:;; 5 Main Street; Main Town; OR,; 12345; United States of AmericaLABEL; HOME; ENCODING = QUOTED-PRINTABLE:5 Main Street = 0D = 0A = Main Town ,12345URL; WORK: http : //www.hanselman.com EMAIL; PREF; INTERNET:firstname@lastname.com REV:20070810T050105ZEND:VCARD

But there's a million extensions to this format and things can get very complex very fast. I set myself a goal of getting something passable working in a few hours, so I decided to preview the vCard in a DataGrid. That made Load() look like this:

但是,这种格式有100万种扩展,事情很快就会变得非常复杂。 我设定的目标是在几个小时内使某些东西能够通过,因此我决定在DataGrid中预览vCard。 这使得Load()看起来像这样:

public override void Load(FileInfo file)
{DataGridView grid = new DataGridView();grid.DataSource = ConvertVCardToDataTable(file);grid.ReadOnly = true;grid.Dock = DockStyle.Fill;grid.AutoSizeColumnsMode = DataGridViewAutoSizeColumnsMode.Fill;Controls.Add(grid);
}

Next, I took the FileInfo and spun through it, breaking up each line and sticking it into a static DataTable, the format most friendly to the DataGridView.

接下来,我获取FileInfo并将其旋转通过,将每一行分开,并将其粘贴到静态DataTable中,该格式对DataGridView最友好。

private static DataTable ConvertVCardToDataTable(FileInfo file)
{DataTable table = new DataTable();table.Locale = System.Threading.Thread.CurrentThread.CurrentCulture;table.TableName = file.Name;using (StreamReader sr = file.OpenText()){table.Columns.Add("Data");table.Columns.Add("Value");string line;while ((line = sr.ReadLine()) != null){if (line.Length > 3){string[] parts = ProcessVCardLine(line);if (parts != null && parts.Length == 2){table.Rows.Add(parts);}}}}return table;
}

ProcessVCardLine just returns a string array of "name,value" given a single vCard line. Again, I never said it was pretty, I just said it worked.

给定单个vCard行,ProcessVCardLine仅返回“名称,值”的字符串数组。 再说一次,我从未说过它很漂亮,我只是说它有效。

private static string[] ProcessVCardLine(string line)
{//This is by no means a complete or even passable parsing of the fairly complex vCard format.List<string> nameValue = new List<string>();if (line.StartsWith("BEGIN:VCARD")) return null;if (line.StartsWith("VERSION:")) return null;string[] parts = line.Split(':');if (parts.Length == 2){AddVCardLine(parts, ref nameValue, "TZ", "TimeZone");AddVCardLine(parts, ref nameValue, "NICKNAME", "Nickname");AddVCardLine(parts, ref nameValue, "N", "Name");AddVCardLine(parts, ref nameValue, "FN", "Friendly Name");AddVCardLine(parts, ref nameValue, "ORG", "Organization");AddVCardLine(parts, ref nameValue, "TITLE", "Title");AddVCardLine(parts, ref nameValue, "TEL", "Phone");AddVCardLine(parts, ref nameValue, "ADR", "Address");AddVCardLine(parts, ref nameValue, "URL", "Website");AddVCardLine(parts, ref nameValue, "EMAIL", "Email");AddVCardLine(parts, ref nameValue, "X-MS-IMADDRESS", "IM");}return nameValue.ToArray();
}private static void AddVCardLine(string[] parts, ref List<string> nameValue, string name, string friendlyName)
{if (parts[0].StartsWith(name) && parts[1] != null){nameValue.Add(friendlyName);nameValue.Add(parts[1].Replace(";", ",").Trim().Trim(','));}
}

Because this is a .NET assembly that will be called by an app expecting a COM dll, you'll need to put it in the GAC and run Regasm on it.

因为这是一个需要COM dll的应用程序将调用的.NET程序集,所以您需要将其放入GAC并在其上运行Regasm。

I made this easier during development by adding these two lines to the Post-build event command line. You may need to search your system to find where Gacutil.exe and Regasm.exe are on your system, or you can download the .NET Framework 2.0 SDK.

通过在开发后事件命令行中添加这两行,我在开发过程中更加轻松了。 您可能需要搜索系统以找到Gacutil.exe和Regasm.exe在系统上的位置,或者可以下载.NET Framework 2.0 SDK 。

"C:\Program Files\Microsoft SDKs\Windows\v6.0A\bin\Gacutil.exe" /i "$(TargetPath)"
"C:\Program Files\Microsoft SDKs\Windows\v6.0A\bin\Regasm.exe" /codebase "$(TargetPath)"

“ C:\ Program Files \ Microsoft SDKs \ Windows \ v6.0A \ bin \ Gacutil.exe” / i“ $(TargetPath)” “ C:\ Program Files \ Microsoft SDKs \ Windows \ v6.0A \ bin \ Regasm.exe” /代码库“ $(TargetPath)”

Once registered, the new vCard Preview Handlers is available all over Windows to any app that cares to use it.

注册后,新的vCard预览处理程序可在Windows上供所有希望使用它的应用程序使用。

I've looked at this code a couple of times, not just because it's poopy, but because I felt there must be at least a few clean ways I could have made the code cleaner/terser using some of the new C# 3.0 features like Anonymous Types, and yield. Any ideas?

我已经看了几次这个代码,不仅仅是因为它很笨拙,而且因为我觉得至少必须有一些干净的方法可以使用一些新的C#3.0功能(例如Anonymous)来使代码更简洁/更简洁。类型和产量。 有任何想法吗?

Here's the real tragedy. After I wrote this very sad little "just barely good enough" vCard parser, I discovered that the Coding4Fun DevKit already included a very complete vCard parsing implementation.

这是真正的悲剧。 在我写了一个非常悲伤的小“勉强够用”的vCard解析器之后,我发现Coding4Fun DevKit已经包含了一个非常完整的vCard解析实现。

Curse my metal body! The vCard sample is in the Contacts project within C4FDevKit and it's scrumptious. Well, live and learn. Anyway, I had fun and it took less than an hour to get a useful (to me) PreviewHandler working. The C4FDevKit includes samples and compiled PreviewHandlers for CSV, generic binary, Icons, XML files via IE, MSIs, PDFs, Resx and Resources, SNK (keys) and Zip Files. Sweet.

诅咒我的金属身体! vCard示例位于C4FDevKit的“联系人”项目中,非常棒。 好吧,生活和学习。 无论如何,我很开心,并且花了不到一个小时的时间来获得有用的(对我而言)PreviewHandler。 C4FDevKit包括用于CSV,通用二进制文件,图标,通过IE的XML文件,MSI,PDF,Resx和资源,SNK(密钥)和Zip文件的示例和已编译的PreviewHandlers。 甜。

You can more easily test your Preview Handlers using the PreviewHandlerHost control on a simple WinForms app, or even easier by using the already-written PreviewHandlerHost at Coding4Fun\C4FDevKit2008v1\Preview Handlers\Samples\VB\PreviewHandlerHostSample as seen in the screenshot above.

您可以在简单的WinForms应用程序上使用PreviewHandlerHost控件更轻松地测试您的预览处理程序,甚至可以通过使用已编写的位于Coding4Fun \ C4FDevKit2008v1 \ Preview Handlers \ Samples \ VB \ PreviewHandlerHostSample的PreviewHandlerHost来更轻松地测试预览处理程序。

翻译自: https://www.hanselman.com/blog/a-vcard-preview-handler-using-the-coding4fun-devkit

程序员 coding啥意思

程序员 coding啥意思_使用Coding4Fun DevKit的vCard预览处理程序相关推荐

  1. python程序员面试自我介绍_程序员面试经验总结

    主要包括以下内容: 一.程序员面试过程中,面试官想要从 " 自我介绍 " 获得什么信息? 二.如何去提炼简历中的精华?如何在沟通中体现你的软技能? 三.如何去解释简历中的瑕疵? 四 ...

  2. 程序员初试和复试_程序员的软微mem经验贴

    一背景 程序员一枚,在刷朋友圈时候看到有朋友发招生简章,突然来了兴致,决定试一把. 本科16年毕业刚刚符合报名资格,对现在状态比较满意,不愿意摆脱社会人身份,所以报名了非全日制.的人工智能方向(毕竟是 ...

  3. 软考程序员Java答题速成_软考程序员考试试题解答方法与技巧

    如果说程序员考试解上午题无技巧可言的话,那么解下午题就是70%的实力加30%的方法与技巧,若运用到极致的话,会是"四两拨千斤".下面就来看一下程序员下午题解题步骤和解题技巧,以供考 ...

  4. 程序员转实施工程师_只有程序员才能看得懂?程序员:算了,不看了,我得写代码了...

    程序员:还是看完我在写代码吧 1.程序猿最烦两件事,第一件事是别人要他给自己的代码写文档,第二件呢?是别人的程序没有留下文档. 2.程序猿的读书历程:x语言入门->x语言应用实践->x语言 ...

  5. 程序员初试和复试_程序员因肌肉发达面试被质疑能力,网友:这做程序员有啥关系呢?...

    如今的程序员,是互联网界的重要职业,不仅各种项目和系统需要程序员维护,还有很多前沿技术的进步也需要程序员来开发,因此程序员往往比较忙,而因此程序员被套上了各种职业病的标签.可是近日,有一位HR在招聘程 ...

  6. python程序员脱单攻略_作为一只程序员,如何脱单?

    哈哈,程序员追妹子.程序员要先认识妹子.你是不是不会修电脑的程序员,哈哈哈!下面小栈长为大家分享把妹小技巧,愿广大单身猿能在11月11日脱单哈!(VX公众号:速学Java) 1.关于没有话聊 我不知道 ...

  7. 程序员简历工作模式_简历的完整形式是什么?

    程序员简历工作模式 简历:简历 (CV: Curriculum Vitae) The CV is an abbreviation of Curriculum Vitae. It is a writte ...

  8. web开发程序员有几种_每个程序员都应该知道的10种流行的Web开发工具

    web开发程序员有几种 Are you planning to get into web development? Take a tool with you, it's scary out there ...

  9. 程序员离职代码交接_程序员离职大半个月,被老板命令回单位讲代码,员工:一次1万...

    正常情况下,如果我们已经被辞退大半个月了,那么与上一家公司也就没了任何关系,而根据<劳动合同法>的规定,离职人员应该按照双方的约定,办理工作交接,公司也应当依照法律的规定,在我们办理完工作 ...

最新文章

  1. php端口转发源码,Python实现TCP/IP协议下的端口转发及重定向示例
  2. 卡巴斯基安全浏览器_卡巴斯基 for windows 全方位安全软件2021注册表清除版
  3. 小阳买水果(前缀和,单调栈,思维)
  4. Centos 6.4搭建svnadmin服务器
  5. spring boot——MockMvc的用法 (SpringBoot 1.5.18)下测试通过
  6. flume消费kafka数据太慢_kafka补充01
  7. Day04:循环结构(while、do-while、for)
  8. java有哪些部分要学_java需要学习哪些知识
  9. matlab colormap详解 (2
  10. 第一章 Lua - AIR202 控制LED小灯
  11. 最新HTML完整结构
  12. 最小二乘法拟合圆心和半径 python实现
  13. linux下配置dnx地址,Linux上编译DNX失败
  14. isb 汇编_DSB,ISB,DMB指令 | 学步园
  15. 5分钟学废携程出品配置中心阿波罗的原理与搭建
  16. 基于geoserver的伪三维地图制作
  17. android 日历开发教程,android 开发教程之日历项目实践(三)
  18. MySQL——10038错误
  19. 可以作为艺术作品欣赏的CT三维重建技术。
  20. 引申5“生命起源VS电影机械公敌VS大数据、人工智能“

热门文章

  1. 刘晓燕《不就是语法和长难句吗》第一章个人笔记
  2. HTTP协议详解(转)
  3. 最新实用Python异步爬虫代理池(开源)
  4. kb2919442不适用计算机,无法更新kb2919442,kb2919355,显示此更新不适用于你的计算机,求助...
  5. 华为无线学习笔记--WLAN基础配置
  6. 数电三:编码器和译码器
  7. ZZULIOJ 1787 生化危机 (vector+DFS)
  8. ad软件 pcb如何走线过孔_PCB走线和过孔的过流能力
  9. java aes对称加密算法_Java实现AES对称加密算法
  10. php中下列哪些说法是正确的,关于PHP函数,下列定义方式正确的是