2008年7月22日

     摘要: 局域网内文件同步的玩具  阅读全文
posted @ 2008-07-22 17:45 micYng 阅读(403) | 评论 (5)编辑

2008年7月11日

     摘要: 用c#实现自动拨号  阅读全文
posted @ 2008-07-11 17:47 micYng 阅读(205) | 评论 (0)编辑

2008年7月10日

   1: class EnumLocalCollection
   2: {
   3:     private List<LocalCollectionInfo> _infos;
   4:  
   5:     public EnumLocalCollection()
   6:     {
   7:         _infos = new List<LocalCollectionInfo>();
   8:     }
   9:  
  10:     private string InvokeCmd()
  11:     {
  12:         Process p = new Process();
  13:         p.StartInfo.FileName = "cmd.exe";
  14:         p.StartInfo.UseShellExecute = false;
  15:         p.StartInfo.RedirectStandardInput = true;
  16:         p.StartInfo.RedirectStandardOutput = true;
  17:         p.StartInfo.RedirectStandardError = true;
  18:         p.StartInfo.CreateNoWindow = true;
  19:         p.Start();
  20:  
  21:         p.StandardInput.WriteLine("ipconfig");
  22:         p.StandardInput.WriteLine("exit");
  23:  
  24:         return p.StandardOutput.ReadToEnd();
  25:     }
  26:  
  27:     public bool Parse()
  28:     {
  29:         string input = InvokeCmd();
  30:  
  31:         var convert = new Func<MatchCollection, int, List<string>>(Converts);
  32:         List<string> names = convert.Invoke(Regex.Matches(input, @"(?:PPP|Ethernet) adapter (.*):"), 1);
  33:         List<string> ips = convert.Invoke(Regex.Matches(input, @"IPv??4?? Address.*:\s(\d{1,3}\.\d{1,3}\.\d{1,3}\.\d{1,3})"), 1);
  34:  
  35:         if (names.Count != ips.Count)
  36:             return false;
  37:  
  38:         for (int i = 0; i < names.Count; i++)
  39:         {
  40:             _infos.Add(new LocalCollectionInfo() { Name = names[i], IP = ips[i] });
  41:         }
  42:  
  43:         return true;
  44:     }
  45:  
  46:     public ReadOnlyCollection<LocalCollectionInfo> LocalCollectionInfos
  47:     {
  48:         get { return this._infos.AsReadOnly(); }
  49:     }
  50:  
  51:     private List<string> Converts(MatchCollection mcs, int group)
  52:     {
  53:         List<string> rts = new List<string>();
  54:         for (int i = 0; i < mcs.Count; i++)
  55:             rts.Add(mcs[i].Groups[group].Value);
  56:         return rts;
  57:     }
  58: }
  59:  
  60: class LocalCollectionInfo
  61: {
  62:     public string Name { get; set; }
  63:     public string IP { get; set; }
  64:  
  65:     public override string ToString()
  66:     {
  67:         return string.Format("{0}-{1}", Name, IP);
  68:     }
  69: }

用的时候这样用:

   1: EnumLocalCollection lc = new EnumLocalCollection();
   2: if (!lc.Parse())
   3: {
   4:     Console.WriteLine("error");
   5:     return;
   6: }
   7: ReadOnlyCollection<LocalCollectionInfo> infos = lc.LocalCollectionInfos;
   8: for (int i = 0; i < infos.Count; i++)
   9: {
  10:     Console.WriteLine(infos[i].ToString());
  11: }
posted @ 2008-07-10 18:15 micYng 阅读(104) | 评论 (0)编辑

2008年7月7日

     摘要:   阅读全文
posted @ 2008-07-07 15:58 micYng 阅读(135) | 评论 (0)编辑

2008年6月28日

If no encoder exists for the file format of the image, the Portable Network Graphics (PNG) encoder is used. When you use the Save method to save a graphic image as a Windows Metafile Format (WMF) or Enhanced Metafile Format (EMF) file, the resulting file is saved as a Portable Network Graphics (PNG) file. This behavior occurs because the GDI+ component of the .NET Framework does not have an encoder that you can use to save files as .wmf or .emf files.

唉,可怜偶滴一世清誉Sad

posted @ 2008-06-28 19:20 micYng 阅读(66) | 评论 (0)编辑

2008年6月25日

     摘要: 仅仅依据代码,结合msdn,谈经验,基础知识自行msdn or google,ok,let's go 先看一段最简单的 1: using System; 2: using System.C  阅读全文
posted @ 2008-06-25 19:52 micYng 阅读(1139) | 评论 (4)编辑

2008年6月19日

真™服了,把自己该搞定的技术问题转嫁到用户身上,vista明明提供了更加安全的机制,却被迫要关闭UAC,将IE安全设置改到更低,安装个烂控件之后,要重启n次........... 操蛋!Angry

招商的网银就很简单,中信你好好反思一下吧

实在忍无可忍了....

posted @ 2008-06-19 16:09 micYng 阅读(358) | 评论 (2)编辑

2008年5月29日

     摘要: 摘抄一段m$的kb The WinSock listen() call backlog parameter under Windows NT version 3.5 and 3.51 accepts  阅读全文
posted @ 2008-05-29 16:02 micYng 阅读(124) | 评论 (0)编辑

2007年12月18日

先来一句总结,所谓的IoC,所谓的Spring,所谓的Castle,所谓的....... 落叶归根还是到反射里去了(先不论java,至少在.net里是酱紫的),先看我刚刚抽丝剥茧的成果:

   1: protected virtual object CreateInstance(CreationContext context, object[] arguments, Type[] signature)
   2: {
   3:     object instance = null;
   4:  
   5:     Type implType = Model.Implementation;
   6:  
   7:     bool createProxy = Model.Interceptors.HasInterceptors;
   8:     bool createInstance = true;
   9:  
  10:     if (createProxy)
  11:     {
  12:         createInstance = Kernel.ProxyFactory.RequiresTargetInstance(Kernel, Model);
  13:     }
  14:  
  15:     if (createInstance)
  16:     {
  17:         try
  18:         {
  19:             if (implType.IsContextful)
  20:                 instance = Activator.CreateInstance(implType, arguments);
  21:             else
  22:             {
  23:                 ConstructorInfo cinfo = implType.GetConstructor(
  24:                     BindingFlags.Public | BindingFlags.Instance, null, signature, null);
  25:  
  26:                 instance = System.Runtime.Serialization.FormatterServices.GetUninitializedObject(implType);
  27:  
  28:                 cinfo.Invoke(instance, arguments);
  29:             }
  30:         }
  31:         catch (Exception ex)
  32:         {
  33:             throw new ComponentActivatorException(
  34:                 "ComponentActivator: could not instantiate " + Model.Implementation.FullName, ex);
  35:         }
  36:     }
  37:  
  38:     if (createProxy)
  39:     {
  40:         try
  41:         {
  42:             instance = Kernel.ProxyFactory.Create(Kernel, instance, Model, arguments);
  43:         }
  44:         catch (Exception ex)
  45:         {
  46:             throw new ComponentActivatorException("ComponentActivator: could not proxy " + Model.Implementation.FullName, ex);
  47:         }
  48:     }
  49:  
  50:     return instance;
  51: }

其中,有我最熟悉的2行代码:

   1: if (implType.IsContextful)
   2:     instance = Activator.CreateInstance(implType, arguments);

这不就是最原始的反射嘛Surprise只不过arguments这个参数,也是通过绑定服务接口以及组件类时,通过反射获取的,然后存储在某个IDictionary这样的哈希结构中,初始化的过程在Windsor.AddComponent方法调用时完成...

另外,贡献序列图一张
参考:

http://terrylee.cnblogs.com/archive/2006/04/28/castl_ioc_article.html

posted @ 2007-12-18 19:03 micYng 阅读(170) | 评论 (1)编辑

2007年12月17日

地址见 http://www.javaeye.com/topic/116585?page=1

一堆废话尚且不看,有谁用csc命令编译c++程序吗?忒牛逼啦
我不想引起语言争端......
posted @ 2007-12-17 18:39 micYng 阅读(299) | 评论 (7)编辑

导航

公告

垃圾Comment,Spam杀无赦!

查询及定制我的天气预报信息
<2008年8月>
272829303112
3456789
10111213141516
17181920212223
24252627282930
31123456

统计

与我联系

搜索

 

常用链接

留言簿(8)

我参与的团队

我的标签

随笔分类

随笔档案

文章分类

相册

收藏夹

.Net Enterprise Library

.Net Remoting

ASP.NET

Blog Friends:)

C# category

C# forum&blogs

C# Toolkit

CodeSmith Usages

cPP related

Design Pattern

Opensource project

Pervious Blog

Useful tip

积分与排名

最新评论

  • 1. re: 局域网内文件同步
  • 如果纯粹想用文件同步功能的话,可以搜索secondCopy这个软件,很好用。
    当然了自己写练习一下也不错! :)
  • --峻祁连
  • 2. re: Monitor vs Pulse
  • @lexus
    其实也没有特别的重构,只是类结构做了稍许调整,部分方法重新提取而已,便于分析流程 :)
  • --micYng
  • 3. re:Monitor vs Pulse
  • 血腥大地中pulse。*
  • --PH计电导率仪
  • 4. re: Monitor vs Pulse
  • Monitor.Wait 和 Monitor.Pulse 方法在效率上还是可以的。在有限的几种场景下,它可以模拟 Mutex 和 Event ,而且它大多数时候发生在用户空间,因为不用进入内核和上下文...
  • --Angel Lucifer
  • 5. re: Monitor vs Pulse
  • 把你重构的代码发出来看看哈,正在学习threadpool
  • --lexus

阅读排行榜

评论排行榜

60天内阅读排行