using System; using System.Collections.Generic; using System.ComponentModel; using System.Drawing; using System.Data; using System.Linq; using System.Text; using System.Runtime.CompilerServices; using System.Threading.Tasks; using System.Windows.Forms; namespace WindowsFormsApplication6 { public partial class UCtlCompA : UserControl, INotifyPropertyChanged { public UCtlCompA() { InitializeComponent(); this.textBox2.DataBindings.Add("Text", this, "SumName", false, DataSourceUpdateMode.OnPropertyChanged); } private void txtTitle_TextChanged(object sender, EventArgs e) { ProdName = txtTitle.Text; SumName = ProdName + " / " + UserName; } private void textBox1_TextChanged(object sender, EventArgs e) { UserName = textBox1.Text; SumName = ProdName + " / " + UserName; } private void NotifyPropertyChanged([CallerMemberName] String propertyName = "") { if (PropertyChanged != null) { PropertyChanged(this, new PropertyChangedEventArgs(propertyName)); } } public string ProdName { get { return this._prodname; } set { if (value != this._prodname) { this._prodname = value; NotifyPropertyChanged(); } } } public string UserName { get { return this._username; } set { if (value != this._username) { this._username = value; NotifyPropertyChanged(); } } } public string SumName { get { return this._sumname; } set { if (value != this._sumname) { this._sumname = value; NotifyPropertyChanged(); } } } public event PropertyChangedEventHandler PropertyChanged; private string _prodname = string.Empty; private string _username = string.Empty; private string _sumname = string.Empty; } }
2014년 3월 21일 금요일
INotifyPropertyChanged Test
라벨:
.NET Framework
2014년 3월 18일 화요일
.Net Framework SourceCode 살펴보기
어찌보면 MS는 대단한 대인배인 듯 하다.
물론 .net Reflactor 같은 것을 이용하면 되겠지만
남이 하는 거와 그냥 내 걸 볼 수 있게 아예 사이트를 만들어 놓는 건 좀 다른 듯 하다.
아무튼 .Net Framework의 소스를 쭉 살펴볼 수 있는 공식 사이트...
http://referencesource.microsoft.com/
물론 .net Reflactor 같은 것을 이용하면 되겠지만
남이 하는 거와 그냥 내 걸 볼 수 있게 아예 사이트를 만들어 놓는 건 좀 다른 듯 하다.
아무튼 .Net Framework의 소스를 쭉 살펴볼 수 있는 공식 사이트...
http://referencesource.microsoft.com/
라벨:
.NET Framework
2014년 3월 13일 목요일
Performance Profiler by RealProxy
http://vunvulearadu.blogspot.kr/2014/02/aop-using-realproxy-custom.html
위에서 제시된 코드를 기반으로(사실 똑같다)
내 손으로 다시 쳐서 구현해본 코드이다.
PostSharp보다 좀 불편해보이는 방식이긴 한데
Pre-Processing되는 PostSharp의 경우
간혹 불안정하게 동작하는 경우가 있고
이를 해결할 방법이 뾰족하게 없으나
이렇게 직접 코드를 작성하는 경우는
결국 안정성은 본인의 몫이기 때문에 잘만 한다면
PostSharp보다 나을도 있겠다 싶다.
물론 상용Tool인 PostSharp은 좋은 제품인 건 맞다.
위에서 제시된 코드를 기반으로(사실 똑같다)
내 손으로 다시 쳐서 구현해본 코드이다.
PostSharp보다 좀 불편해보이는 방식이긴 한데
Pre-Processing되는 PostSharp의 경우
간혹 불안정하게 동작하는 경우가 있고
이를 해결할 방법이 뾰족하게 없으나
이렇게 직접 코드를 작성하는 경우는
결국 안정성은 본인의 몫이기 때문에 잘만 한다면
PostSharp보다 나을도 있겠다 싶다.
물론 상용Tool인 PostSharp은 좋은 제품인 건 맞다.
using System; using System.Collections.Generic; using System.Linq; using System.Text; using System.Threading.Tasks; using System.Diagnostics; using System.Reflection; using System.Runtime.Remoting.Proxies; using System.Runtime.Remoting.Messaging; namespace AOPWithRealProxy { class Program { static void Main(string[] args) { PerfProfilingDynamicProxy<itest> testProfiling = new PerfProfilingDynamicProxy<itest>(new Test()); ITest test = (ITest)testProfiling.GetTransparentProxy(); test.TestMethod(); Console.ReadLine(); } } public class PerfProfilingDynamicProxy: RealProxy { public PerfProfilingDynamicProxy(T decorated) : base(typeof(T)) { _decorated = decorated; } public override IMessage Invoke(IMessage msg) { IMethodCallMessage methodcall = (IMethodCallMessage)msg; MethodInfo methodInfo = methodcall.MethodBase as MethodInfo; PerfProfilingAttribute profilingAttribute = (PerfProfilingAttribute)methodInfo.GetCustomAttributes(typeof(PerfProfilingAttribute)).FirstOrDefault(); if(profilingAttribute == null) { return NormalInvoke(methodInfo, methodcall); } else { return ProfiledInvoke(methodInfo, methodcall, profilingAttribute.Message); } } private IMessage NormalInvoke(MethodInfo methodInfo, IMethodCallMessage methodCall) { try { var result = methodInfo.Invoke(_decorated, methodCall.InArgs); return new ReturnMessage(result, null, 0, methodCall.LogicalCallContext, methodCall); } catch(Exception err) { return new ReturnMessage(err, methodCall); } } private IMessage ProfiledInvoke(MethodInfo methodInfo, IMethodCallMessage methodCall, string attrMessage) { Stopwatch sw = null; try { sw = Stopwatch.StartNew(); var result = methodInfo.Invoke(_decorated, methodCall.InArgs); sw.Stop(); Console.WriteLine(sw.ElapsedMilliseconds); long tick = sw.ElapsedTicks; return new ReturnMessage(result, new object[] { tick }, 1, methodCall.LogicalCallContext, methodCall); } catch(Exception err) { return new ReturnMessage(err, methodCall); } finally { if(sw != null && sw.IsRunning) { sw.Stop(); } } } private readonly T _decorated; } public class PerfProfilingAttribute : Attribute { public PerfProfilingAttribute(string message) { Message = message; } public PerfProfilingAttribute() { Message = string.Empty; } public string Message { get; set; } } public interface ITest { [PerfProfiling] DateTime TestMethod(); } public class Test : ITest { public DateTime TestMethod() { double sumv = 0.0; for(int i = 0; i < 100000; i++) { Random rnd = new Random(575); sumv += rnd.NextDouble(); } return DateTime.Now; } } }
라벨:
.NET Framework
2014년 3월 12일 수요일
2014년 3월 11일 화요일
Distributed Caching
http://msdn.microsoft.com/en-us/magazine/dd942840.aspx
실제 훌륭한 .Net용 Distributed Cache 솔루션을 가지고 있는
NCache사 사장 (사장이 이런 내용의 글을 쓰다니...,
우리가 알고 있는 그런 "관리의 사장"은 아닌 듯)
이 작성한 글이다.
딱 느낌이 많이 해본 솜씨...
실제로 이 부분을 작업하면서 항상 부딪쳤던 문제들인데
잘 정리해둔 것 같다.
특히 Caching Relational Data 부분은 미리 알았더라면
많은 수고를 들 수 있었던 부분이 아닌가 싶다.
실제 훌륭한 .Net용 Distributed Cache 솔루션을 가지고 있는
NCache사 사장 (사장이 이런 내용의 글을 쓰다니...,
우리가 알고 있는 그런 "관리의 사장"은 아닌 듯)
이 작성한 글이다.
딱 느낌이 많이 해본 솜씨...
실제로 이 부분을 작업하면서 항상 부딪쳤던 문제들인데
잘 정리해둔 것 같다.
특히 Caching Relational Data 부분은 미리 알았더라면
많은 수고를 들 수 있었던 부분이 아닌가 싶다.
라벨:
.NET Framework
피드 구독하기:
글 (Atom)