1. jsmooth 를 설치합니다. http://jsmooth.sourceforge.net/



2. 이클립스에서 프로젝트를 실행-jar로 내보내기 합니다.



설정은 적당히 합니다

3. jsmooth 실행~



프로그램 종류를 고릅니다.. 윈도우 프로그램이면 windowed를 고릅니다. 콘솔이면 위에꺼



실행파일 위치를 지정합니다.. 아이콘과 시작 디렉토리를 지정할 수 있습니다.. 생략도 됨..



use an embedded jar를 체크 하고 좀전에 내보내기한 jar를 선택합니다. 그리고 시작 함수가 있는 클래스를 골라줍니다.

안 골라주면 실행해도 바로 꺼지게 됩니다..



최소, 최고 JVM 버전을 작성할 수도 있습니다.. 전 그냥 패스..

다 됐으면 project-> compile을 합니다. 그럼 좀전 지정한 곳에 실행파일이 만들어 집니다

그럼 jar파일이 없어도 실행되게 되죠~
Posted by orange code
이번엔 다른 디컴파일러를 쓰는 방법입니다..  저는 이쪽의 결과가 더 좋은것 같네요..

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