首页 文章 精选 留言 我的

精选列表

搜索[代码生成],共10000篇文章
优秀的个人博客,低调大师

C#获取枚举描述代码

public class MusterEnum { /// 获取枚举的描述信息 /// </summary> /// <param name="e">传入枚举对象</param> /// <returns>得到对应描述信息</returns> public String GetEnumDesc(Enum e) { FieldInfo EnumInfo = e.GetType().GetField(e.ToString()); if (EnumInfo == null) { return ""; } DescriptionAttribute[] EnumAttributes = (DescriptionAttribute[])EnumInfo.GetCustomAttributes(typeof(DescriptionAttribute), false); if (EnumAttributes.Length > 0) { return EnumAttributes[0].Description; } return e.ToString(); } /// <summary> /// 将含有描述信息的枚举绑定到列表控件中 /// </summary> /// <param name="listControl"></param> /// <param name="enumType"></param> private Dictionary<string, string> BindDesEnumToListControl(System.Type enumType) { Dictionary<string, string> dic = new Dictionary<string, string>(); foreach (object enumValue in Enum.GetValues(enumType)) { Enum e = (Enum)enumValue; dic.Add(((int)enumValue).ToString(), GetEnumDesc(e)); } return dic; } } 还有一个是根据传入的枚举的数字索引直接获取 public static string GetEnumDesc<T>(Object obj) { obj = (T)obj; if (obj == null) throw new ArgumentNullException("参数不能为null"); if (!obj.GetType().IsEnum) throw new Exception("参数类型不正确"); FieldInfo fieldinfo = obj.GetType().GetField(obj.ToString()); string str = string.Empty; Object[] objs = fieldinfo.GetCustomAttributes(typeof(DescriptionAttribute), false); if (objs != null && objs.Length != 0) { DescriptionAttribute des = (DescriptionAttribute)objs[0]; str = des.Description; } return str; } 本文转自左正博客园博客,原文链接:http://www.cnblogs.com/soundcode/p/4846916.html ,如需转载请自行联系原作者

优秀的个人博客,低调大师

iOS开发之邮件发送代码

邮件发送功能是由MessageUI Framework提供的,这个框架是iPhone sdk中最简单的框。由一个类、一个视图控制器,一个protocol组成。 一、创建视图控制器: MFMailComposeViewController *mc = [[MFMailComposeViewController alloc] init]; mc.mailComposeDelegate = self ; 二、设置邮件主题: [mc setSubject:@"Hello, World!"]; 三、设置收件人,收件人有三种: 1、设置主收件人 [mc setToRecipients:[ NSArray arrayWithObjects:@ "zhuqi0@126.com" , "@dave@iphonedevbook.com" , nil ]; 2、设置cc [mc setCcRecipients:[NSArray arrayWithObject:@"zhuqil@163.com"]]; 3、设置bcc [mc setBccRecipients:[NSArray arrayWithObject:@"secret@gmail.com"]]; 四、设置邮件主体,有两种格式。 一种是纯文本 [mc setMessageBody:@"Watson!!!\n\nCome here, I need you!" isHTML:NO]; 一个是html格式 [mc setMessageBody:@ "<HTML><B>Hello, Joe!</B><BR/>What do you know?</HTML>" isHTML: YES ]; 五、添加附件 添加附件需要三个参数,一个是NSData类型的附件,一个是mimetype,一个附件的名称。 NSString *path = [[NSBundle mainBundle] pathForResource:@"blood_orange" ofType:@"png"]; NSData *data = [NSData dataWithContentsOfFile:path]; [mc addAttachmentData:data mimeType:@"image/png" fileName:@"blood_orange"]; 六、视图呈现 [self presentModalViewController:mc animated:YES]; [mc release]; 七、视图控制器的委托方法 邮件视图控制器的委托方法包含在MFMailComposeViewControllerDelegate中,无论用户是否发送或取消发送,不论系统是否能够发送邮件, 方法 mailComposeController:didFinishWithResult:error: gets called都会被调用。 - (void)mailComposeController:(MFMailComposeViewController*)controller didFinishWithResult:(MFMailComposeResult)result error:(NSError*)error { switch (result) { case MFMailComposeResultCancelled: NSLog(@"Mail send canceled..."); break; case MFMailComposeResultSaved: NSLog(@"Mail saved..."); break; case MFMailComposeResultSent: NSLog(@"Mail sent..."); break; case MFMailComposeResultFailed: NSLog(@"Mail send errored: %@...", [error localizedDescription]); break; default: break; } [self dismissModalViewControllerAnimated:YES]; } 本文转自麒麟博客园博客,原文链接:http://www.cnblogs.com/zhuqil/archive/2011/07/21/2112816.html,如需转载请自行联系原作者

优秀的个人博客,低调大师

Java反编译代码分析(一)

浅析如何读懂这种反编译过来的文件,不喜勿喷。 赋值 Node node; Node node1 = _$3.getChildNodes().item(0); node1; node1; JVM INSTR swap ; node; getChildNodes(); 0; item(); getChildNodes(); 0; item(); getNodeValue(); String s; s; 原始语句: Node node; Node node1 = currDocument.getChildNodes().item(0); node = node1; String s = node.getChildNodes().item(0).getChildNodes().item(0).getNodeValue(); //赋值语句 // JVM INSTR swap ; 不带参数创建对象 JVM INSTR new #244 <Class CrossTable>; JVM INSTR dup ; JVM INSTR swap ; CrossTable(); CrossTable crosstable; crosstable; CrossTable crosstable = new CrossTable(); 带参数创建对象 JVM INSTR new #262 <Class StringBuffer>; JVM INSTR dup ; JVM INSTR swap ; String.valueOf(s2); StringBuffer(); s.substring(j, i); append(); s6; append(); toString(); s2; s2 = (new StringBuffer(String.valueOf(s2))).append(s.substring(j, i)).append(s6).toString(); //s2 += s.substring(j, i) + s6; for循环 int k = 0; goto _L4 _L8: ... k++; _L4: if(k < as.length) goto _L8; else goto _L7 for(int k=0;k < as.length;k++) { ... } while循环 String s1 = ""; goto _L1 _L3: JVM INSTR new #262 <Class StringBuffer>; JVM INSTR dup ; JVM INSTR swap ; String.valueOf(s1); StringBuffer(); _$2(resultset, s, l); append(); toString(); s1; _L1: if(resultset.next()) goto _L3; else goto _L2 String s1 = ""; while(resultset.next()) { s1 = s1 + resultSetToString(resultset, s, l); } 我是天王盖地虎的分割线 本文转自我爱物联网博客园博客,原文链接:http://www.cnblogs.com/yydcdut/p/4314546.html,如需转载请自行联系原作者

资源下载

更多资源
Nacos

Nacos

Nacos /nɑ:kəʊs/ 是 Dynamic Naming and Configuration Service 的首字母简称,一个易于构建 AI Agent 应用的动态服务发现、配置管理和AI智能体管理平台。Nacos 致力于帮助您发现、配置和管理微服务及AI智能体应用。Nacos 提供了一组简单易用的特性集,帮助您快速实现动态服务发现、服务配置、服务元数据、流量管理。Nacos 帮助您更敏捷和容易地构建、交付和管理微服务平台。

Rocky Linux

Rocky Linux

Rocky Linux(中文名:洛基)是由Gregory Kurtzer于2020年12月发起的企业级Linux发行版,作为CentOS稳定版停止维护后与RHEL(Red Hat Enterprise Linux)完全兼容的开源替代方案,由社区拥有并管理,支持x86_64、aarch64等架构。其通过重新编译RHEL源代码提供长期稳定性,采用模块化包装和SELinux安全架构,默认包含GNOME桌面环境及XFS文件系统,支持十年生命周期更新。

Sublime Text

Sublime Text

Sublime Text具有漂亮的用户界面和强大的功能,例如代码缩略图,Python的插件,代码段等。还可自定义键绑定,菜单和工具栏。Sublime Text 的主要功能包括:拼写检查,书签,完整的 Python API , Goto 功能,即时项目切换,多选择,多窗口等等。Sublime Text 是一个跨平台的编辑器,同时支持Windows、Linux、Mac OS X等操作系统。

WebStorm

WebStorm

WebStorm 是jetbrains公司旗下一款JavaScript 开发工具。目前已经被广大中国JS开发者誉为“Web前端开发神器”、“最强大的HTML5编辑器”、“最智能的JavaScript IDE”等。与IntelliJ IDEA同源,继承了IntelliJ IDEA强大的JS部分的功能。

用户登录
用户注册