이번엔 다른 디컴파일러를 쓰는 방법입니다..  저는 이쪽의 결과가 더 좋은것 같네요..

1. 마찬가지로 Help -> Install New Software... 를 누릅니다

Add 버튼을 눌러 Location에 http://java.decompiler.free.fr/jd-eclipse/update 을 적고 OK를 누릅니다.

Java Decompiler Eclipse Plug-in를 설치하고 이클립스를 재시작합니다.




2. Window -> Preferences

General -> Editors -> File Associations 에서

*.class를 선택하고 밑에서 편집기를 Class File Editor를 선택하여 Default 로 지정합니다.



따로 받아야 하는 파일은 없습니다.

3. 보고 싶은 클래스에 우클릭하여 Open Declaration을 선택하거나 단축키인 F3을 눌러서

소스를 봅니다~
Posted by orange code
1. Help -> Install New Software... 를 누릅니다

Add 버튼을 눌러 Location에 http://jadclipse.sf.net/update 을 적고 OK를 누릅니다.

밑 플러그인 목록에 JDT Decompiler Features를 체크 하여 설치합니다.

이클립스를 재시작합니다.



2. Window -> Preferences

General -> Editors -> File Associations 에서

*.class를 선택하고 밑에서 편집기를 Decompiled Class File Viewer를 선택하여 Default 로 지정합니다.



Java -> Decompilers 에서

Decompiler를 Jad를 선택합니다.



3. http://www.varaneckas.com/jad 에서 jad를 다운받습니다.


압축을 풀어 이클립스 실행파일이 있는 폴더에 복사합니다.



4. 이제 편집기에서 소스가 궁금한 클래스명을 선택하고 F3을 누르면..

디컴파일된 소스가 보이게 됩니다.. 클래스에 따라서.. 결과가 제대로 나오지 않을 수도있습니다.. 

참고로 실제 소스와 완전히 같지 않기 때문에 디버깅시에 전혀 엉뚱한 라인을 가리킵니다..ㄱ-


Posted by orange code
컴퓨터 프로그래밍2010. 6. 6. 22:43
public static class RandomSelector
{
    static Random random = new Random();
    public static T Random<T>(this IEnumerable<T> enumerable)
    {
        int c = enumerable.Count();
        int i = random.Next(c);
        return enumerable.Skip(i).First();
    }
}

프로젝트에 새 파일이나 기존소스에 추가해줍니다.

사용방법
int[] a = { 1, 2, 3, 4, 5, 6, 7, 8, 9, 10 };
int b = a.Random();

List<int> a = new List<int>();
....
....
int b = a.Random();

Posted by orange code
컴퓨터 프로그래밍2010. 4. 12. 21:18

 C#나 다른 대부분 객체지향언어는 객체가 생성될 때 초기화나 다른 일들을 할 수 있게 생성자를 작성할 수 있게 해줍니다. 그래서 클래스를 쓰는 입장에서는 새 객체를 만들기만 해도 그 객체의 접근가능한 변수나 속성들이 유효한 값을 갖고 있다고 생각할 수 있습니다. 하지만 정적 변수나 속성의 경우 선언과 동시에 하는 초기화도 제한이 있고, 객체를 만들기 전에 접근할 수 있기 때문에 원하는 값으로 미리 초기화하는 방법이 필요합니다. 정적 함수로 초기화 함수를 작성하여 클래스 사용전에 호출하는 방법도 있지만, 그 함수 호출을 빼먹을 위험성도 있습니다. 그래서 이 때 필요한게 static constructor인데요.. 사실 이미 자바에도 있는 내용입니다.. 문법까지 같은지는 기억은 안나지만.. 
 이 문법은

static 클래스명()
{
}
이렇고 접근제한자를 쓸 수 없고, 파라미터를 받을 수도 없습니다..

using System;
using System.Collections.Generic;

static class Program
{
    static Program()
    {
        IntList = new List<int>();
        IntList.Add(1);
        IntList.Add(3);
        IntList.Add(5);
    }
    public static List<int> IntList { get; private set; }

    static void Main()
    {
        foreach (int i in IntList)
        {
            Console.WriteLine(i);
        }
    }
}
Posted by orange code
Posted by orange code
http://social.msdn.microsoft.com/Forums/en-US/linqprojectgeneral/thread/925b245d-5529-4a64-8cd4-4bc83ee6fe7a/
 public static class PredicateBuilder
{
    public static Expression<Func<T, bool>> Make<T>() { return null; }
    public static Expression<Func<T, bool>> Make<T>(this Expression<Func<T, bool>> predicate)
    {
        return predicate;
    }
    public static Expression<Func<T, bool>> MakePredicate<T>(this IQueryable<T> source)
    {
        return null;
    }
    public static Expression<Func<T, bool>> Or<T>(this Expression<Func<T, bool>> expr, Expression<Func<T, bool>> or)
    {
        if (expr == null) return or;
        var invokedExpr = Expression.Invoke(or, expr.Parameters.Cast<Expression>());
        return Expression.Lambda<Func<T, bool>>(Expression.Or(expr.Body, invokedExpr), expr.Parameters);
    }
    public static Expression<Func<T, bool>> And<T>(this Expression<Func<T, bool>> expr, Expression<Func<T, bool>> and)
    {
        if (expr == null) return and;
        var invokedExpr = Expression.Invoke(and, expr.Parameters.Cast<Expression>());
        return Expression.Lambda<Func<T, bool>>(Expression.And(expr.Body, invokedExpr), expr.Parameters);
    }
}
Posted by orange code
컴퓨터 프로그래밍2009. 12. 28. 23:18
private static T ReadStruct<T>(byte[] buffer) where T : struct
{
    int size = Marshal.SizeOf(typeof(T));
    if (size > buffer.Length)
        throw new Exception();
    IntPtr ptr = Marshal.AllocHGlobal(size);
    Marshal.Copy(buffer, 0, ptr, size);
    T obj = (T)Marshal.PtrToStructure(ptr, typeof(T));
    Marshal.FreeHGlobal(ptr);
    return obj;


ex)
struct A
{
    public int x, y;
}

A a = ReadStruct<A>(buffer);
Posted by orange code
1. 실버라잇에서 접근하는 WCF서비스를 만들때는 반드시 'silverlight 사용 wcf 서비스'로 만든다.

2. 서비스 클래스를 작성한다.

3. web.config에서 <system.serviceModel> 안의 <endpoint address="" binding="basicHttpBinding" contract="DownloadService" /> 부분에서 binding부분이 다르게 되있다면 basicHttpBinding으로 수정한다.
<serviceHostingEnvironment aspNetCompatibilityEnabled="true" /> 가 없으면 추가한다.

4. 실버라잇 프로젝트에서  서비스 레퍼런스 추가하며 앞에 제작한 WCF서비스를 등록한다.

5. 실버라잇 클래스에서 서비스를 이요한다.
EndpointAddress address = new EndpointAddress(new Uri(Application.Current.Host.Source, "../Service.svc"));
client = new ServiceClient(new BasicHttpBinding(), address);
위처럼 client를 가져온후.. client 를 살펴보면, 앞에 작성한 함수들이 비동기버전으로 만들어져 있다.

Posted by orange code

관리자모드로  C:\Windows\Microsoft.NET\Framework\v3.0\Windows Communication Foundation 로 가서
ServiceModelReg.exe /r /y 를 실행해주면 됩니다.

웹사이트의 처리기매핑 정보가 모두 초기화되니 주의해야합니다..
Posted by orange code
컴퓨터 프로그래밍2009. 12. 18. 04:39


중간 단계 따윈 없이 바로 제작 과정 들어갑니다..

일단 WMP 의 주요 인터페이스는 이렇습니다.
IWMPCore -> 미플 총괄
IWMPControls -> 재생/정지
IWMPPlaylist -> 재생목록
IWMPMedia -> 곡하나
그외에
IWMPPlaylistCollection, IWMPPlaylistArray등이 있는데 특히 이 두개는 이번 플러그인 제작에 쓰였습니다.

제작할 플러그인은 다음곡들을 예약하는 기능이고 이름은 BookMe로 정했습니다.

BookMe 재생목록 만들기&가져오는 함수
일단 플러그인 내에서 이 BookMe 목록은 중요한데요 이 목록을 가져오는 함수인데
m_spCore->get_playlistCollection(&spPlaylistCollection); // 전체 재생목록
spPlaylistCollection->getByName(L"BookMe", &spPlaylistArray); // 이름이 BookMe인것들
spPlaylistArray->get_count(&playlistCount); // 일치하는 재생목록 갯수
if (playlistCount > 0)
    spPlaylistArray->item(0, &spPlaylist); // 처음 재생목록으로 선택
else
    spPlaylistCollection->newPlaylist(L"BookMe", &spPlaylist); // 새로 만듦

이 코드로 미플 재생시 BookMe 재생목록이 바로바로 생기게 되죠..
사용자는 다음에 듣고 싶은곡을 이 재생목록에 추가할테고요...
이제 남은건 현재 재생곡이 끝났을 때, 이 목록에 남은 곡이 있다면 그 곡을 재생하고 BookMe목록에서 지우는겁니다..

플러그인 프로젝트 생성시에 event항목을 체크하면 IWMPEvents를 상속받게 되어서, WMP의 다양한 이벤트에 대해 처리할 수 가 있게 됩니다.. 그중에는 PlayStateChange 함수에서  wmppsPlaying, wmppsMediaEnded 로 재생시작/정지를 알 수 있죠.. wmppsMediaEnded 이벤트가 발생하면 BookMe목록에서 하나 가져와서 재생하면 되는거죠, 근데 중요한것은 IWMPCore나 IWMPControls의 노래변경기능은 현재 재생중인 목록에서 가져온 미디어 객체만 허용하기 때문에, BookMe에서 가져온 객체를 가지고, 현재 재생중인 목록의 미디어들과 비교하면서 파일이 같은 미디어를 찾아서 재생시켜줘야 된다는 것입니다..
또 하나 플러그인을 제작하면서 힘들었던건... wmppsMediaEnded 이벤트 발생시 곡을 멈추고 원하는 곡을 재생하면, wmp가 선택한 노래로 바로 바뀌어 버리는것이었습니다.. 그래서 결국 타이머를 이용한 시간차로 해결했죠.. 자세한건 소스를....
그리고 중요한건 윈도우7에선 관리자모드로 visual studio를 켜야, 컴파일후 플러그인 등록이 됩니다~ 안그럼 에러뜸

Posted by orange code