文章分类

站点统计

  • 分类总数: 13 个
  • 文章总数: 127 篇
  • 评论总数: 9 条
  • 附件总数: 49 个
  • 建站日期: 2008-08-18
  • 访问总数: 99065 人次
  • RSS订阅: 文章|评论


项目中使用第三方或开源代的代码,组件,中间件,框架的基本规则

Admin 于 2008-10-03 02:27:56 发表其它

1、总体原则

简单实用、易学、易用、易改

2、基本规则

  1. 项目很紧的情况下,如果不能提高开发效率的能不用就不用; 
    比如项目就几个月,而你却没用过的,如果可以满足客户需求,基本就不要用了 
  2. 必须是,常用的容易找到资料的,并相对容易学习; 
    包括社区、API帮助、演示例子等等; 
  3. 必须是有后续支持的、运行稳定、后续版本及时 
    举例如果是那种 .net 都出到 4.0 了而它还必须用 .net1.1 的是绝对不可选的 
  4. 学习时间总计,不得超过一个月(根据项目情况,有加有减); 
    学习成本过大,一定是不能选的,比如:在项目开发期间如果频繁出现因为此引起的技术问题 
  5. 不得因此造成开发成本过高不得超过1.5倍 
    如:你原来用 ASP.net 做一个同样的页面用 1 天,现在却需要 3 天就不好了,如果是1天办还是可以接受的 
  6. 项目上线后因此所引起的bug不得超过 20%; 
    如:如果因为xx第三方控件引起,bug 率过高,这多半是由于使用者学习的不透引起的 
  7. 必须保证项目内或公司内有2人以上比较精通、使用熟练度 90% 以上; 
    为了公司的发展,必须保证这点,否则如果人走了或生病了误事,起码对其了解程度在70%以上,包括属性,类,方法函数,程序流程,特性,常见问题(你用到的,没用到的不算)比如你用一个控件90%以上的属性和函数都要了解,并做过尝试; 
  8. 如果不是必须使用的,第一两个版本的不要用,测试的更不能用(除非冻结了API)
  9. 在设计文档上一定要明确指出那里用了、用的什么

3、对于开源的项目

  1. 必须保证公司内的人有实力维护(可以扩充,修改)本开源代码段或框架的人数,在2人以上,基本保证对类库或控件,项目文件的理解在90% 以上 (使用的部分,没关联到的不算); 
    如使用第3方的开源 GRID 包括 2.7 所提到的那些,还要了解函数方法类的内部处理流程(而不是每行代码都是干啥的、这样可以保证使用者是有能力,修改扩充的,如果有必要要整理,代码流程性文档)、而且一定要亲手做做实例,不能空想;

4、对于成品第三方组件,中间件,框架的

  1. 必须保证,此为大牌厂商,或应用比较广泛的

补充

在项目时间很充裕的情况下,本条例经审查可宽松对待;

被阅140次, 0票 发表评论

.NET Interface(wrapper) of AStyle[uncompleted]

Admin 于 2008-10-02 05:24:55 发表.Net

被阅106次, 0票AStyle 发表评论

Lucene.Net简单应用

Admin 于 2008-10-01 02:24:25 发表.Net

Lucene.Net是一个性能很好的信息检索库(或者叫搜索引擎内核)。Lucene.Net提供一套完整的API供应用程序实现全文索引与精确查询功能。这里只描述最基本的应用:

 1、建立索引

  1. //state the file location of the index 
  2. string indexFileLocation = @"C:\Index";  
  3. Lucene.Net.Store.Directory dir = 
  4.     Lucene.Net.Store.FSDirectory.GetDirectory(indexFileLocation, true); 
  5.  
  6. //create an analyzer to process the text 
  7. Lucene.Net.Analysis.Analyzer analyzer = new 
  8. Lucene.Net.Analysis.Standard.StandardAnalyzer();  
  9.  
  10. //create the index writer with the directory and analyzer defined. 
  11. Lucene.Net.Index.IndexWriter indexWriter = new 
  12. Lucene.Net.Index.IndexWriter(dir, analyzer,  
  13.            /*true to create a new index*/ true);  
  14.  
  15. //create a document, add in a single field 
  16. Lucene.Net.Documents.Document doc = new 
  17. Lucene.Net.Documents.Document(); 
  18.  
  19. Lucene.Net.Documents.Field fldContent =  
  20.   new Lucene.Net.Documents.Field("content",  
  21.   "The quick brown fox jumps over the lazy dog"
  22.   Lucene.Net.Documents.Field.Store.YES,  
  23.   Lucene.Net.Documents.Field.Index.TOKENIZED,  
  24.   Lucene.Net.Documents.Field.TermVector.YES); 
  25.  
  26. doc.Add(fldContent); 
  27.  
  28. //write the document to the index 
  29. indexWriter.AddDocument(doc); 
  30.  
  31. //optimize and close the writer 
  32. indexWriter.Optimize();  
  33. indexWriter.Close(); 

 这里用到了5个主要类:Directory、Analyzer、IndexWriter、Document和Field。通过Directory 实例记录需要存储的索引;Analyzer用于分析目标文本;结合Directory与Analyzer创建IndexWriter实例;结合 Document实例与Field实例保存文档要被IndexWriter存储的内容。然后调用IndexWriter的Optimize方法与 Close方法。
    1、Lucene.Net.Store.Directory  - Directory代表目标索引目录。Lucene.Net中包含了两种实现:FSDirectory与RAMDirectory,分别将索引结果存放于 文件系统与内存。开发人员也可以通过继承Directory来实现自己的存储方法。
    2、Lucene.Net.Analysis.Analyzer - Analyzer用于将文本分割成词语或词组,同时可去除多余的词语(比如英语里的and、a、the等等)。StandardAnalyzer实例化时 可传递要忽略的词语列表,如果传递的参数为空则使用Lucene.Net默认的设置。开发人员可通过继承Analyzer实现自己的文档索引方式。
    3、Lucene.Net.Index.IndexWriter - 用于配合Analyzer将分析结果保存到Directory。
    4、Lucene.Net.Docuemnts.Docuemnt - 用于代表一封EMail、或者一个网页、一篇文章等。
    5、Lucene.Net.Documents.Field - Docement包含一个用于描述文档的Field列表。每个Field包括一个name与相应的value,其中value包含了可用于查询的文本。 Field.Store用于告诉IndexWriter将field的value保存到索引以便检索时取出。此外,Field.Index用于告诉 IndexWriter如何索引当前field,比如Field.Index.TOKENIZED表示将文本拆 分,Field.Index.UNTOKENIZED则相反。

2、在索引中进行查找

  1. //state the file location of the index 
  2. string indexFileLocation = @"C:\Index"
  3. Lucene.Net.Store.Directory dir = 
  4.     Lucene.Net.Store.FSDirectory.GetDirectory(indexFileLocation, true); 
  5.  
  6. //create an index searcher that will perform the search 
  7. Lucene.Net.Search.IndexSearcher searcher = new 
  8. Lucene.Net.Search.IndexSearcher(dir); 
  9.  
  10. //build a query object 
  11. Lucene.Net.Index.Term searchTerm =  
  12.   new Lucene.Net.Index.Term("content""fox"); 
  13. Lucene.Net.Search.Query query = new Lucene.Net.Search.TermQuery(searchTerm); 
  14.  
  15. //execute the query 
  16. Lucene.Net.Search.Hits hits = searcher.Search(query); 
  17.  
  18. //iterate over the results. 
  19. for (int i = 0; i < hits.Length(); i++) 
  20.     Document doc = hits.Doc(i); 
  21.     string contentValue = doc.Get("content"); 
  22.  
  23.     Console.WriteLine(contentValue); 

 涉及的类有:Directory、IndexSearch、Query、Hits、Term。其中Query有多种实现:TermQuery, BooleanQuery, PhraseQuery, PrefixQuery, PhrasePrefixQuery, RangeQuery, FilteredQuery, 及 SpanQuery。Lucene.Net.Search.Hits用于表示查找的结果。

被阅138次, 0票Lucene.Net 发表评论

AngleScript,又一个开源C/C++脚本引擎

Admin 于 2008-10-01 00:09:56 发表C/C++

AngleScript脚本使用类似C/C++的语法,静态类型,面向对象,使用Handle而非指针,安全砂箱。
引擎支持实时编译,单步执行,详细的异常信息,可从控制台逐行输入解析,可编译成字节码供调用,模块化,支持多线程并可多线程调用引擎,可调试。
跨平台:可运行于Win32, Linux, MacOS X, XBox, XBox 360, PS2, PSP, PS3, Dreamcast, Nintendo DS和Windows Mobile
CPU无关:x86, amd64, sh4, mips, ppc, ppc64, arm都支持
源代码可用MSVC++, GNUC, MinGW和DJGPP编译。

被阅305次, 0票AngleScript 发表评论

使用了Mono.Cecil的一些项目

Admin 于 2008-09-30 11:37:02 发表.Net

开源项目

  • 编译器

  • 代码质量

    • Gendarme : Gendarme is a tool to find problems in programs.
    • Monoxide : Monoxide is an extensible assembly viewer.
  • 开发环境

    • SharpDevelop : 开源的.NET平台IDE,支持C#, VB.NET 及Boo等语言开发。
    • MonoDevelop : 基于GNOME IDE primarily designed for C# and other .NET languages.
    • MonoUML : CIL反向工程插件
    • Reflexil : 提供程序集修改功能的Reflector插件
  • AOP应用

    • AspectDNG : 静态织入器
    • SetPoint : 一个AOP引擎
    • Compose* : Compose* (or: ComposeStar) is a project that aims at enhancing the power of component- and object-based programming.
  • 程序集处理

    • Mono Linker : The linker is a tool one can use to only ship the minimal possible set of functions that a set of programs might require to run as opposed to the full libraries.
    • Mono Merge : 将多个程序集合并成单个程序集。
  • 数据库相关

    • db4o : 面向对象数据库,纯托管代码实现,支持.NET与Mono。
    • Euss : Evaluant Universal Storage Services (EUSS) is an extensible programming model and runtime components for building data aware solutions on the .Net platform.
  • 混淆器

    • Obfuscar : 一个简单的.NET程序混淆器
    • SharpObfuscator : It is a Software Protection tool, designed to help .NET developers efficiently protect their software.
  • 其它

    • mdb : Mono的托管代码调试器。

闭源项目

  • 编译器

    • Mainsoft CIL to Java bytecode compiler
  • 代码质量

  • Knowledge-Based Engineering 

    • Pacelab Suite: Knowledge-based engineering platform for multidisciplinary product modeling, design analysis, verification and optimization 
  • 代码混淆器

被阅218次, 0票Cecil Mono 发表评论

LyteBox -另一个LightBox效果库

Admin 于 2008-09-30 01:29:53 发表JavaScript

Lightbox的效果类似于WinXP操作系统的注销/关机对话框,除去屏幕中心位置的对话框,其他的区域都以淡出的效果逐渐变为银灰色以增加对比度, 此时除了对话框内的表单控件,没有其他区域可以获取焦点。 Lightbox的作用则相当于从前只在IE中被支持的"Modal Dialog";现在在FireFox也可用window.open(url, name, " modal=yes ");来实现同样的效果。使用"Modal Dialog"将限制用户的操作于弹出的对话框中,只有完成设定好的操作后方才关闭。在一些逻辑敏感的应用中强制吸引用户的注意力以防止用户的误操作导致 程序逻辑淆乱。
最流行的LightBox库是Lokesh Dhakar (http://www.huddletogether.com)的基于prototype.js、effects.js和scriptaculous.js的实现,LightBox2 Demo:http://www.cnbruce.com/test/lightbox/ 。而LyteBox(http://dolem.com/lytebox/)只需在网页中引用lytebox.js脚本文件就足够了。Lytebox不仅 能支持图像展示,还比Lightbox2多了“自动播放图像”的功能,当然最主要的是Lytebox支持弹出网页的效果。

被阅146次, 0票LyteBox LightBox 发表评论

IronPython 2.0 beta 5 已经发布

Admin 于 2008-09-30 00:02:48 发表.Net

IronPython 2.0 beta 5 已经发布,下载地址:http://www.codeplex.com/IronPython/Release/ProjectReleases.aspx?ReleaseId=15625。IronPython 2.0 Beta 5是2.0系列的最后一个beta版本,下个版本就是RC版了。也就是说到了下个版本所有API都将固化了。现在也是到学习IronPython 2的时间了。从beta 4发布就有了msi 安装文件,并且带来了python的标准库 ,标准库的许可是以Python Software Foundation license 发布,这也就意味着移值cpython应用会很容易了。

值得注意的是带来了DLR hosting spec 的稳定版本,你可以从这里下载 DLR hosting spec的word 版本 http://compilerlab.members.winisp.net/dlr-spec-hosting.doc

这个版本还有一个最明显的变化的是命名空间作了个重大的修改,把所有的DLR 类型从System移到了Microsoft,原因是http://lists.ironpython.com/pipermail/users-ironpython.com/2008-August/thread.html#8036 许多人把IronPython嵌入到C# (.NET 3.5)项目中。

另外一点是DLR 宿主API不有一个针对Python的默认配置,现在应该用IronPython.Hosting.Python去创建脚本引擎,这样在应用程序中宿主 IronPython就更容易了。IronPython.Hosting.Python有几个辅助方法,以创建一个ScriptRuntime或 ScriptEngine ,并为ScriptRuntime和ScriptEngine增加了一些Python-specific 扩展方法。

  1. using IronPython.Hosting; 
  2.  
  3. ScriptEngine engine = Python.CreateEngine(); 
  4.  
  5. ScriptScope sys = engine.GetSysModule(); 
  6. var platform = sys.GetVariable("platform"); 
  7. Console.WriteLine(platform); 
  8.  
  9. ScriptScope builtins = engine.GetBuiltinModule(); 
  10. var pow = builtins.GetVariable<doubledouble,double>>("pow"); 
  11. Console.WriteLine(pow(2,3)); 
  12.  
  13. ScriptScope clr = engine.GetClrModule(); 
  14. var getPythonType = clr.GetVariable
  15. Console.WriteLine(PythonType.Get__name__(getPythonType(typeof(string)))); 

see also:http://blogs.msdn.com/srivatsn/archive/2008/09/16/hosting-ironpython-made-easier.aspx

被阅208次, 0票IronPython 发表评论

使用Vernam(维尔南/弗纳姆)算法实现文件加密解密[C#]

Admin 于 2008-09-29 04:54:13 发表.Net

本文介绍如何通过Gilbert Sandford Vernam的算法实现一个简洁而又稳定的文件加密解密类。通过此类加密的数据是绝对无法在没有密钥的情况下被破解的。它的基本原理是,需要有一个需要加 密的明文和一个随机生成的解密钥匙文件。然后使用这两个文件组合起来生成密文:(明文) 组合 (密钥) = 加密后的密文。
使用Vernam加密算法,经其处理的密钥可以拥有与待加密文件大小相同的密钥长度,而且输出文件的大小相比待加密文件无任何改变(精确到字节)。换言 之,密钥文件越大,加密强度越高!举个例子,如果想加密一个5M的文件,那么密钥长度将高达40,000,000位,输出文件大小则仍为5M。前面的数字 意味着即使是梦幻配置的个人电脑,想要在“有生之年”靠穷取法破解出密码,也是不可能完成的任务!待加密文件类型不限,密钥文件也可以是任何数据:应用程 序、交换文件,或者音乐文件,甚至是您宠物的靓照,等等...

Vernam密码算法:
    1、 现代密码体制的萌芽是Vernam加密方法。
    2、Vernam密码是美国电话电报公司的Gilbert Vernam在1917年为电报通信设计的一种非常方便的密码,它在近代计算机和通信系统设计中得到了广泛应用。
    3、Vernam密码的明文、密钥和密文均用二元数字序列表示。这是一种使用异或方法进行加密解密的方法。
    4、要编制Vernam密码,只需先把明文和密钥表示成二元序列,再把它们按位模2相加,就可得到密文。
    5、而解密只需把密文和密钥的二元序列按位模2相加便可得到明文。
    6、开始时使用一个定长的密钥序列,这样产生的密文能形成有规律的反复,易被破译;后来采用的密钥与明文同长,且密钥序列只用一次,称为“一次一密体制”。

Vernam类:

  1. using System; 
  2. using System.IO; 
  3.  
  4. public class Vernam 
  5.     /// <summary> 
  6.     /// Encrypts a file by the Vernam-algorithm 
  7.     /// </summary> 
  8.     /// <param name="originalFile"> 
  9.     /// Name of the file to be encrypted. Data is read from this file. 
  10.     /// </param> 
  11.     /// <param name="encryptedFile"> 
  12.     /// Name of the encrypted file. The encrypted data gets written to that file. 
  13.     /// </param> 
  14.     /// <param name="keyFile"> 
  15.     /// Name of the key file. The one time key gets written to that file. 
  16.     /// </param> 
  17.     public void EncryptFile(string originalFile, string encryptedFile, string keyFile) 
  18.     { 
  19.         // Read in the bytes from the original file: 
  20.         byte[] originalBytes; 
  21.         using (FileStream fs = new FileStream(originalFile, FileMode.Open)) 
  22.         { 
  23.             originalBytes = new byte[fs.Length]; 
  24.             fs.Read(originalBytes, 0, originalBytes.Length); 
  25.         } 
  26.  
  27.         // Create the one time key for encryption. This is done 
  28.         // by generating random bytes that are of the same lenght  
  29.         // as the original bytes: 
  30.         byte[] keyBytes = new byte[originalBytes.Length]; 
  31.         Random random = new Random(); 
  32.         random.NextBytes(keyBytes); 
  33.  
  34.         // Write the key to the file: 
  35.         using (FileStream fs = new FileStream(keyFile, FileMode.Create)) 
  36.         { 
  37.             fs.Write(keyBytes, 0, keyBytes.Length); 
  38.         } 
  39.  
  40.         // Encrypt the data with the Vernam-algorithm: 
  41.         byte[] encryptedBytes = new byte[originalBytes.Length]; 
  42.         DoVernam(originalBytes, keyBytes, ref encryptedBytes); 
  43.  
  44.         // Write the encrypted file: 
  45.         using (FileStream fs = new FileStream(encryptedFile, FileMode.Create)) 
  46.         { 
  47.             fs.Write(encryptedBytes, 0, encryptedBytes.Length); 
  48.         } 
  49.     } 
  50.     //--------------------------------------------------------------------- 
  51.     /// <summary> 
  52.     /// Decrypts a file by Vernam-algorithm 
  53.     /// </summary> 
  54.     /// <param name="encryptedFile"> 
  55.     /// Name of the encrypted file 
  56.     /// </param> 
  57.     /// <param name="keyFile"> 
  58.     /// Name of the key file. The content of this file has to be the same 
  59.     /// as the content generated while encrypting 
  60.     /// </param> 
  61.     /// <param name="decryptedFile"> 
  62.     /// Name of the decrypted file. The decrypted data gets written to this  
  63.     /// file 
  64.     /// </param> 
  65.     public void DecryptFile(string encryptedFile, string keyFile, string decryptedFile) 
  66.     { 
  67.         // Read in the encrypted bytes: 
  68.         byte[] encryptedBytes; 
  69.         using (FileStream fs = new FileStream(encryptedFile, FileMode.Open)) 
  70.         { 
  71.             encryptedBytes = new byte[fs.Length]; 
  72.             fs.Read(encryptedBytes, 0, encryptedBytes.Length); 
  73.         } 
  74.  
  75.         // Read in the key: 
  76.         byte[] keyBytes; 
  77.         using (FileStream fs = new FileStream(keyFile, FileMode.Open)) 
  78.         { 
  79.             keyBytes = new byte[fs.Length]; 
  80.             fs.Read(keyBytes, 0, keyBytes.Length); 
  81.         } 
  82.  
  83.         // Decrypt the data with the Vernam-algorithm: 
  84.         byte[] decryptedBytes = new byte[encryptedBytes.Length]; 
  85.         DoVernam(encryptedBytes, keyBytes, ref decryptedBytes); 
  86.  
  87.         // Write the decrypted file: 
  88.         using (FileStream fs = new FileStream(decryptedFile, FileMode.Create)) 
  89.         { 
  90.             fs.Write(decryptedBytes, 0, decryptedBytes.Length); 
  91.         } 
  92.     } 
  93.     //--------------------------------------------------------------------- 
  94.     /// <summary> 
  95.     /// Computes the Vernam-encryption/decryption 
  96.     /// </summary> 
  97.     /// <param name="inBytes"></param> 
  98.     /// <param name="keyBytes"></param> 
  99.     /// <param name="outBytes"></param> 
  100.     private void DoVernam(byte[] inBytes, byte[] keyBytes, ref byte[] outBytes) 
  101.     { 
  102.         // Check arguments: 
  103.         if ((inBytes.Length != keyBytes.Length) || 
  104.             (keyBytes.Length != outBytes.Length)) 
  105.             throw new ArgumentException("Byte-array are not of same length"); 
  106.  
  107.         // Encrypt/decrypt by XOR: 
  108.         for (int i = 0; i < inBytes.Length; i++) 
  109.             outBytes[i] = (byte)(inBytes[i] ^ keyBytes[i]); 
  110.     } 

使用范例:

  1. class Program 
  2.     static void Main(string[] args) 
  3.     { 
  4.         Vernam vernam = new Vernam(); 
  5.  
  6.         // Test with an image: 
  7.         vernam.EncryptFile("Image.gif""Image_encrypted.gif""Key01.dat"); 
  8.         vernam.DecryptFile("Image_encrypted.gif""Key01.dat""Image_decrypted.gif"); 
  9.  
  10.         // Test with text file: 
  11.         vernam.EncryptFile("Text.txt""Text_encrypted.txt""Key02.dat"); 
  12.         vernam.DecryptFile("Text_encrypted.txt""Key02.dat""Text_decrypted.txt"); 
  13.  
  14.         // Test with pdf file: 
  15.         vernam.EncryptFile("Text.pdf""Text_encrypted.pdf""Key03.dat"); 
  16.         vernam.DecryptFile("Text_encrypted.pdf""Key03.dat""Text_decrypted.pdf"); 
  17.     } 

 

4 / 16 / 127 | « 1 2 3 4 5 6 7 » |
Powered by MiniBoke v2.0.0.8 Build 0828

Copyright © 2008 开源吧!. All rights reserved.

粤ICP备07500939号