기사는 2003년 11월에 올라 왔는데...

오늘 알았네요 --;;

 

VS 다음 버젼에서는 IDE 차원에서 Refactoring을 지원한다는군요.

 

The C# Whidbey IDE now includes refactoring support. Refactoring enables developers to automate many of the common tasks when restructuring code. For more information on refactoring, please visit http://www.refactoring.com/. Using the built-in refactoring support, developers can, for example, use the rename refactoring to automate the process of renaming a variable in source code.

The refactorings currently available in the Whidbey Technical Preview are:

  • Extract Method
  • Rename
  • Extract Interface
  • Encapsulate Field
  • Change Method Signature
  • Replace Arraylist

 

기사 원본입니다.

http://msdn.microsoft.com/vcsharp/default.aspx?pull=/library/en-us/dv_vstechart/html/whidbey_csharp_preview.asp

'programming > c#' 카테고리의 다른 글

csUnit 간단 사용법(VS에서의 UnitTest)  (0) 2004.02.01
.Net Unit Testing  (5) 2004.01.30
.Net Refactoring  (0) 2004.01.30

쩝... 계속 관련 자료 찾다가.. 우연히 Unit Testing 도구를 찾았네요.

이건 공짜~~

 

 

여깁니다.

http://www.csunit.org/index.php

 

다운 받고 있는데...

해 보고 잘 되면 설명도 올리던지 하죠.

 

 

 

그 홈페이지의 tutorials에 소스가 틀린  것도 있고... CUnit이 업데이트 됐는데, 내용이 update 안된 것들도 있긴 하지만... 음.. 잘 되네요...

 

오랫만에 다시 해 보니 재미있네요..

회사 컴 상태가 안좋아 화면 capture가 안되는 관계로... 노트북에 설치해서 화면 캡쳐까지 해서 사용법을 올리겠습니다.

'programming > c#' 카테고리의 다른 글

다음 릴리즈 될 Visual Stdio 코드 네임 'Whidbey'  (0) 2004.01.30
.Net Refactoring  (0) 2004.01.30
정규식 ( regular expression)  (3) 2004.01.26

C# 코딩하면서 편하게 Refactoring을 할 수 있는 방법이 없는지 인터넷의 세계를 항해하다 발견한 좋은 개인 Blog입니다.

 

한 1시간 돌아댕이면서 찾은게 이넘 찾은거 중 일부 밖에 안되네요...

 

참고하세요. 죄다 상용이네요...

 

----------------------------

 

.NET Refactoring (Looking for advice...)

I am looking into tools for doing .NET (specifically C#) refactoring within VS.NET.   I used the Eclipse product for my previous Java development and although it supports C#, it really doesn't.  

I have found these products in my search, and I am curious if anyone has tried these tools or has found other refactoring tools that work well.

Xtreme Simplicity
.NET Refactoring
DeKlarit  (not a true refactoring tool)
Rational XDE  (Stand alone tool)
Flywheel
Openieuw  (from Patrick Steele's blog)

If anyone has feedback or advice please post your comments!   Thanks!

posted on Wednesday, July 23, 2003 7:56 AM

 

------------------------------------------------

 

출처 : http://weblogs.asp.net/bhouse/archive/2003/07/23/10435.aspx

'programming > c#' 카테고리의 다른 글

.Net Unit Testing  (5) 2004.01.30
정규식 ( regular expression)  (3) 2004.01.26
배열관련 사항  (2) 2003.10.30

정규식에 대해서 대충 어떤 것인지는 알고 있었지만... 실제로 사용해 보기는 첨이었다.

다른 방법을 써도 되지만 그래도 함 공부하는 셈 치고...

 

MSDN에 나와 있는

######################################################################

'.NET Framework 정규식'에 대한 설명

정규식은 텍스트 처리를 위한 강력하고 효과적이며 융통성 있는 방법을 제공합니다. 정규식의 광범위한 패턴 일치 표기법을 사용하면 많은 양의 텍스트를 신속히 구문 분석하여 특정 문자 패턴을 찾을 수 있고, 텍스트 부분 문자열을 추출, 편집, 바꾸기 또는 삭제하거나 추출된 문자열을 컬렉션에 추가하여 보고서를 생성할 수 있습니다. HTML 처리, 로그 파일 구문 분석, HTTP 헤더 구문 분석 등 문자열을 다루는 여러 응용 프로그램에서 정규식은 반드시 필요한 도구입니다.

Microsoft .NET Framework 정규식은 Perl과 awk의 기능과 같은 다른 정규식 구현에서 가장 많이 사용되는 기능을 포함합니다. Perl 5 정규식과 호환되도록 디자인된 .NET Framework 정규식은 오른쪽에서 왼쪽으로 일치 검사, 실행 중 컴파일 등 다른 구현에서 아직 볼 수 없는 기능들을 포함합니다.

.NET Framework 정규식 클래스는 기본 클래스 라이브러리의 일부이며, ASP.NET 및 Visual Studio .NET과 같이 공용 언어 런타임을 목적으로 하는 언어 또는 도구와 함께 사용될 수 있습니다.

######################################################################

 

C#에서 정규식에 관련된 Namespace는 'System.Text.RegularExpressions' 이다.

 

 

아래 URL은 정규식을 정의할 때 사용되는 요소들에 대한 설명이다.

http://msdn.microsoft.com/library/default.asp?url=/library/en-us/cpgenref/html/cpconRegularExpressionsLanguageElements.asp

 

실제 정규식을 이용하는 예제는

http://msdn.microsoft.com/library/default.asp?url=/library/en-us/cpguide/html/cpconregularexpressionexamples.asp

 

 

실제 사용했던 Code

 

    System.Text.RegularExpressions.Regex r = new System.Text.RegularExpressions.Regex("^[0-9]*$");
   
    if(!(r.IsMatch(rows[0])))
     break;

 

아주 간단하죠.. 제대로 된건지 모르겠지만 테스트 해보니까 잘 작동하는 거라서..

숫자로만 이루어져 있지 않으면 끝내는 코드..

 

몇가지 예제입니다.

  • 전화번호 : 0\d{2,3}\-\d{2,4}\-\d{3,4}
  • 휴대폰번호 : 01[16789]\-\d{2,4}\-\d{3,4}
  • 주민등록번호: \d{6}\-\d{7}
  • domain : http\:\/\/[\w\-]+(\.\[\w\-]+)+
  •  

    예제 출처 : http://www.taeyo.net/lecture/NET_01/cassatt_05.asp

     

    더 많은 예제와 정보가 있는 사이트 : http://www.regexlib.com

    여기도 괜찮네요 : http://www.regular-expressions.info/

     

    정규식 만들때 사용할 수 있는 Visual한 Designer~

    http://www.sellsbrothers.com/tools/#regexd

     

    혹시 잘못된게 있거나 추가 정보가 있으면 덧글 부탁합니다.

    'programming > c#' 카테고리의 다른 글

    .Net Refactoring  (0) 2004.01.30
    배열관련 사항  (2) 2003.10.30
    엑셀 파일에서 데이터를 load할 때...  (0) 2003.10.30

    대부분 다 아시는 내용이겠지만, 이제막 c#을 공부하는 나로써 필요한 것들 ^^;;

     

    다차원 배열 생성 시 각 차원의 길이를 알아내는 방법

    int [,]a = {.............};

    a.getLength(0);  -> 1차원의 길이

    a.getLength(1);  -> 2차원의 길이

     

     

    'programming > c#' 카테고리의 다른 글

    정규식 ( regular expression)  (3) 2004.01.26
    엑셀 파일에서 데이터를 load할 때...  (0) 2003.10.30
    엑셀 파일 생성 코드  (0) 2003.10.30

    데브피아 게시물에서 본건데...

    oRange.Cells.Value2().toString();

    을 이용할 경우 엑셀의 date형식은 TimeSpan의 숫자 값으로만 가져 오도록 되기 때문에,

    엑셀에 보이는 형태로 값을 가져오려면, 아래와 같이 하면 된다.

    oRange.Cells.get_Value(Missing.Value).toString();


     

    'programming > c#' 카테고리의 다른 글

    배열관련 사항  (2) 2003.10.30
    엑셀 파일 생성 코드  (0) 2003.10.30
    프로젝트 배포  (0) 2003.10.20
    마이크로소프트 기술자료 - Q302084

    HOWTO: Automate Microsoft Excel from Microsoft Visual C# .NET

    The information in this article applies to:
    Microsoft Visual C# .NET (2002)
    Microsoft Excel 2000
    Microsoft Excel 2002

    SUMMARY
    This article demonstrates how to create an Automation client for Excel by using Visual C# .NET. 
    MORE INFORMATION
    Automation is a process that permits applications that are written in languages such as Visual C# .NET to programmatically control other applications. Automation to Excel permits you to perform actions such as creating a new workbook, adding data to the workbook, or creating charts. With Excel and other Microsoft Office applications, virtually all of the actions that you can perform manually through the user interface can also be performed programmatically by using Automation.

    Excel exposes this programmatic functionality through an object model. The object model is a collection of classes and methods that serve as counterparts to the logical components of Excel. For example, there is an Application object, a Workbook object, and a Worksheet object, each of which contain the functionality of those pieces of Excel. To access the object model from Visual C# .NET, you can set a project reference to the type library.

    This article demonstrates how to set the proper project reference to the Excel type library for Visual C# .NET and provides sample code to automate Excel. 
    Create an Automation Client for Microsoft Excel
    Start Microsoft Visual Studio .NET. On the File menu, click New and then click Project. Select Windows Application from the Visual C# Projects types. Form1 is created by default.
    Add a reference to the Microsoft Excel Object Library. To do this, follow these steps:
    On the Project menu, click Add Reference.
    On the COM tab, locate Microsoft Excel Object Library and click Select. 

    NOTE: The Excel Object Library contains a version number; the version for Microsoft Excel 2000 is 9.0 and the version for Microsoft Excel 2002 is 10.0.
    Click OK in the Add References dialog box to accept your selections. If you receive a prompt to generate wrappers for the libraries you selected, click Yes.
    On the View menu, select Toolbox to display the Toolbox and add a button to Form1.
    Double-click Button1. The code window for the form appears.
    In the code window, replace the following code
    private void button1_Click(object sender, System.EventArgs e)
    {
    }
    with: 
    private void button1_Click(object sender, System.EventArgs e)
    {
        Excel.Application oXL;
        Excel._Workbook oWB;
        Excel._Worksheet oSheet;
        Excel.Range oRng;

        try
        {
            //Start Excel and get Application object.
            oXL = new Excel.Application();
            oXL.Visible = true;

            //Get a new workbook.
            oWB = (Excel._Workbook)(oXL.Workbooks.Add( Missing.Value ));
            oSheet = (Excel._Worksheet)oWB.ActiveSheet;

            //Add table headers going cell by cell.
            oSheet.Cells[1, 1] = "First Name";
            oSheet.Cells[1, 2] = "Last Name";
            oSheet.Cells[1, 3] = "Full Name";
            oSheet.Cells[1, 4] = "Salary";

            //Format A1:D1 as bold, vertical alignment = center.
            oSheet.get_Range("A1", "D1").Font.Bold = true;
            oSheet.get_Range("A1", "D1").VerticalAlignment = 
                Excel.XlVAlign.xlVAlignCenter;
            
            // Create an array to multiple values at once.
            string[,] saNames = new string[5,2];
            
            saNames[ 0, 0] = "John";
            saNames[ 0, 1] = "Smith";
            saNames[ 1, 0] = "Tom";
            saNames[ 1, 1] = "Brown";
            saNames[ 2, 0] = "Sue";
            saNames[ 2, 1] = "Thomas";
            saNames[ 3, 0] = "Jane";
            saNames[ 3, 1] = "Jones";
            saNames[ 4, 0] = "Adam";
            saNames[ 4, 1] = "Johnson";

            //Fill A2:B6 with an array of values (First and Last Names).
            //EXCEL9 use:
            oSheet.get_Range("A2", "B6").Value2 = saNames;
            //EXCEL10 use:
            //oSheet.get_Range("A2", "B6").set_Value( Missing.Value, saNames );

            //Fill C2:C6 with a relative formula (=A2 & " " & B2).
            oRng = oSheet.get_Range("C2", "C6");
            oRng.Formula = "=A2 & \" \" & B2";

            //Fill D2:D6 with a formula(=RAND()*100000) and apply format.
            oRng = oSheet.get_Range("D2", "D6");
            oRng.Formula = "=RAND()*100000";
            oRng.NumberFormat = "$0.00";

            //AutoFit columns A:D.
            oRng = oSheet.get_Range("A1", "D1");
            oRng.EntireColumn.AutoFit();

            //Manipulate a variable number of columns for Quarterly Sales Data.
            DisplayQuarterlySales(oSheet);

            //Make sure Excel is visible and give the user control
            //of Microsoft Excel's lifetime.
            oXL.Visible = true;
            oXL.UserControl = true;
        }
        catch( Exception theException ) 
        {
            String errorMessage;
            errorMessage = "Error: ";
            errorMessage = String.Concat( errorMessage, theException.Message );
            errorMessage = String.Concat( errorMessage, " Line: " );
            errorMessage = String.Concat( errorMessage, theException.Source );

            MessageBox.Show( errorMessage, "Error" );
        }
    }

    private void DisplayQuarterlySales(Excel._Worksheet oWS)
    {
        Excel._Workbook oWB;
        Excel.Series oSeries;
        Excel.Range oResizeRange;
        Excel._Chart oChart;
        String sMsg;
        int iNumQtrs;

        //Determine how many quarters to display data for.
        for( iNumQtrs = 4; iNumQtrs >= 2; iNumQtrs--)
        {
            sMsg = "Enter sales data for ";
            sMsg = String.Concat( sMsg, iNumQtrs );
            sMsg = String.Concat( sMsg, " quarter(s)?");

            DialogResult iRet = MessageBox.Show( sMsg, "Quarterly Sales?", 
                MessageBoxButtons.YesNo );
            if (iRet == DialogResult.Yes)
                break;
        }

        sMsg = "Displaying data for ";
        sMsg = String.Concat( sMsg, iNumQtrs );
        sMsg = String.Concat( sMsg, " quarter(s)." );
        MessageBox.Show( sMsg, "Quarterly Sales" );

        //Starting at E1, fill headers for the number of columns selected.
        oResizeRange = oWS.get_Range("E1", "E1").get_Resize( Missing.Value, iNumQtrs);
        oResizeRange.Formula = "=\"Q\" & COLUMN()-4 & CHAR(10) & \"Sales\"";

        //Change the Orientation and WrapText properties for the headers.
        oResizeRange.Orientation = 38;
        oResizeRange.WrapText = true;

        //Fill the interior color of the headers.
        oResizeRange.Interior.ColorIndex = 36;

        //Fill the columns with a formula and apply a number format.
        oResizeRange = oWS.get_Range("E2", "E6").get_Resize( Missing.Value, iNumQtrs);
        oResizeRange.Formula = "=RAND()*100";
        oResizeRange.NumberFormat = "$0.00";

        //Apply borders to the Sales data and headers.
        oResizeRange = oWS.get_Range("E1", "E6").get_Resize( Missing.Value, iNumQtrs);
        oResizeRange.Borders.Weight = Excel.XlBorderWeight.xlThin;

        //Add a Totals formula for the sales data and apply a border.
        oResizeRange = oWS.get_Range("E8", "E8").get_Resize( Missing.Value, iNumQtrs);
        oResizeRange.Formula = "=SUM(E2:E6)";
        oResizeRange.Borders.get_Item( Excel.XlBordersIndex.xlEdgeBottom ).LineStyle 
            = Excel.XlLineStyle.xlDouble;
        oResizeRange.Borders.get_Item( Excel.XlBordersIndex.xlEdgeBottom ).Weight 
            = Excel.XlBorderWeight.xlThick;

        //Add a Chart for the selected data.
        oWB = (Excel._Workbook)oWS.Parent;
        oChart = (Excel._Chart)oWB.Charts.Add( Missing.Value, Missing.Value, 
            Missing.Value, Missing.Value );

        //Use the ChartWizard to create a new chart from the selected data.
        oResizeRange = oWS.get_Range("E2:E6", Missing.Value ).get_Resize( 
            Missing.Value, iNumQtrs);
        oChart.ChartWizard( oResizeRange, Excel.XlChartType.xl3DColumn, Missing.Value,
            Excel.XlRowCol.xlColumns, Missing.Value, Missing.Value, Missing.Value, 
            Missing.Value, Missing.Value, Missing.Value, Missing.Value );
        oSeries = (Excel.Series)oChart.SeriesCollection(1);
        oSeries.XValues = oWS.get_Range("A2", "A6");
        for( int iRet = 1; iRet <= iNumQtrs; iRet++)
        {
            oSeries = (Excel.Series)oChart.SeriesCollection(iRet);
            String seriesName;
            seriesName = "=\"Q";
            seriesName = String.Concat( seriesName, iRet );
            seriesName = String.Concat( seriesName, "\"" );
            oSeries.Name = seriesName;
        }                                                          
        
        oChart.Location( Excel.XlChartLocation.xlLocationAsObject, oWS.Name );

        //Move the chart so as not to cover your data.
        oResizeRange = (Excel.Range)oWS.Rows.get_Item(10, Missing.Value );
        oWS.Shapes.Item("Chart 1").Top = (float)(double)oResizeRange.Top;
        oResizeRange = (Excel.Range)oWS.Columns.get_Item(2, Missing.Value );
        oWS.Shapes.Item("Chart 1").Left = (float)(double)oResizeRange.Left;
    }
    NOTE: As written, this code uses the Excel 9.0 object library. When you added references to your project, if you selected the Excel 10.0 object library instead of the Excel 9.0 object library, search the code for comments that contain "//EXCEL10" and uncomment the line(s) of code to which the comment refers. Likewise, search the code for comments that contain "//EXCEL9" and comment the line(s) of code to which the comment refers.


    Scroll to the top of the code window. Add the following line to the end of the list of using directives:
    using System.Reflection;
    Test the Automation Client
    Press F5 to build and run the program.
    Click Button1 on the form. The program starts Excel and populates data on a new worksheet.
    When you are prompted to enter quarterly sales data, click Yes. A chart that is linked to quarterly data is added to the worksheet.

    (c) Microsoft Corporation 2001, All Rights Reserved. Contributions by Joel Alley, Microsoft Corporation.

    'programming > c#' 카테고리의 다른 글

    엑셀 파일에서 데이터를 load할 때...  (0) 2003.10.30
    프로젝트 배포  (0) 2003.10.20
    Excel 파일 읽어오는 방법  (0) 2003.10.20

    Deploying Applications

    The .NET Framework provides a number of basic features that make it easier to deploy a variety of applications. This section briefly describes those features and provides information about packaging and distributing applications with the .NET Framework.

    In This Section

    .NET Framework Deployment Features
    Provides a brief overview of the deployment features in the .NET Framework
    .NET Framework Deployment Basics
    Provides an overview of packaging and distributing .NET Framework applications.
    Deployment Scenarios
    Describes several possible deployment scenarios for .NET Framework applications.
    How the Runtime Locates Assemblies
    Describes how the common language runtime determines which assembly to use to fulfill a binding request.
    Redistributing the .NET Framework
    Describes where to obtain the .NET Framework redistributable package, Dotnetfx.exe, and how to use it to deploy the .NET Framework on user and server computers.

    Related Sections

    Deploying XML Web Services
    Describes how to deploy an XML Web service.
    Packaging and Deploying Resources
    Describes how to package and deploy resources.
    Deploying an Interop Application
    Describes how to deploy an interop application.
    Developing a Simple Windows Forms Control
    Describes key steps for authoring a custom Windows Forms control.
    Developing a Simple ASP.NET Server Control
    Describes key steps for authoring a custom server control.
    Deploying an Application for COM Access
    Describes how to deploy applications for use by COM clients.

    'programming > c#' 카테고리의 다른 글

    엑셀 파일에서 데이터를 load할 때...  (0) 2003.10.30
    엑셀 파일 생성 코드  (0) 2003.10.30
    Excel 파일 읽어오는 방법  (0) 2003.10.20

    참조 : http://www.c-sharpcorner.com

     

    How to Open and Read an Excel Spreadsheet into a ListView in .NET

    Submitted ByUser LevelDate of Submission
    Michael GoldIntermediate11/26/2001


    Figure 1 - Excel Spreadsheet read into a ListView

        Source Code:  ExcelReadMG.zip

    The Interoperability services make it very easy to work with COM Capable Applications such as Word and Excel.  You can also refer to my previous article on the topic: Real-time Stock Quotes in Excel using .NET for more information on accessing Excel via .NET.  This article was written in response to a question asking How do I open and excel file and read it using .NET? 

    The first step is to create a reference in your project to Excel 9.0 Objects Library.  This is done by right mouse clicking on the References folder in the Solution Explorer and choosing Add Reference. This brings up the Tab Dialog below.  Choose the COM Tab and pick Microsoft Excel 9.0 Objects Library.

    Figure 2 - Adding an Excel Reference

    This action puts an Interop.Excel.dll and Interop.Office.dll into your bin directory so you can manipulate excel.  

    Now we can declare our Excel Application Object and the compiler will recognize it:

    private Excel.Application ExcelObj = null;

    Excel is launched and an Application reference is obtained in the constructor of our form.  First an Excel Application object is constructed.  Then we check to make sure Excel was actually started. If it was, we have a valid application object and we can now use it to open a file:

    public Form1()
    {

    // Initialize the Windows Components

    InitializeComponent();

    ExcelObj = new Excel.Application();

    //  See if the Excel Application Object was successfully constructed
    if (ExcelObj == null)
     {
      MessageBox.Show("ERROR: EXCEL couldn't be started!");
      System.Windows.Forms.Application.Exit();
     }

    //  Make the Application Visible

      ExcelObj.Visible = true;

    }

    The code for opening the Excel file is shown below.  The code uses the OpenFileDialog component to get the path name for the Excel file.  The Excel file is opened using the WorkBooks collections' Open method.  This method takes 15 parameters with the following definition.  

    Function Open(Filename As String, [UpdateLinks], [ReadOnly], [Format], [Password], [WriteResPassword], [IgnoreReadOnlyRecommended], [Origin], [Delimiter], [Editable], [Notify], [Converter], [AddToMenuRecentlyUsed]) As Workbook

    We really are only interested in the FileName, but have added the other default parameters for your reference.  There is also an OpenText method in Workbooks for opening tab or comma delimited text files.

    private void menuItem2_Click(object sender, System.EventArgs e)
    {

     // prepare open file dialog to only search for excel files (had trouble setting this in design view)
      this.openFileDialog1.FileName = "*.xls";
      if (this.openFileDialog1.ShowDialog() == DialogResult.OK)
       {

      // ***********  Here is the call to Open a Workbook in Excel ****************
      // It uses most of the default values (except for the read-only which we set to true)
        Excel.Workbook theWorkbook = ExcelObj.Workbooks.Open(
              openFileDialog1.FileName, 0, true, 5,
              "", "", true, Excel.XlPlatform.xlWindows, "\t", false, false,
              0, true);

        // get the collection of sheets in the workbook
        Excel.Sheets sheets = theWorkbook.Worksheets;

       // get the first and only worksheet from the collection
       // of worksheets

        Excel.Worksheet worksheet = (Excel.Worksheet)sheets.get_Item(1);

       // loop through 10 rows of the spreadsheet and place each row in the list view
       for
    (int i = 1; i <= 10; i++)
        {
         Excel.Range range = worksheet.get_Range("A"+i.ToString(), "J" + i.ToString());
         System.Array myvalues = (System.Array)range.Cells.Value;
         string[] strArray = ConvertToStringArray(myvalues);
         listView1.Items.Add(new ListViewItem(strArray));
       }

      }

    }

    You also may want to note the ConvertToStringArray method which is used to convert a System.Array into a string array.  If someone knows an easier way to do this, please let me know and I'll alter the article.  The problem is that an Excel Array comes back as two dimensional even if you are selecting a range of a single row, so you need to change the 2-d array into something the listview can accept. Also the listview array is 0 based and the Excel range array is 1 based.

    string[] ConvertToStringArray(System.Array values)
    {

    // create a new string array
    string
    [] theArray = new string[values.Length];

    // loop through the 2-D System.Array and populate the 1-D String Array
     for (int i = 1; i <= values.Length; i++)
      {
       if (values.GetValue(1, i) == null)
        theArray[i-1] = "";
      else
       theArray[i-1] = (string)values.GetValue(1, i).ToString();
      }

      return theArray;
    }

    That's all there is to it!  Now you can read in all your old Excel Databases.  Perhaps you can even use ADO.NET to place them into a database! (Could be the topic for the next article.  ;-)

    'programming > c#' 카테고리의 다른 글

    엑셀 파일에서 데이터를 load할 때...  (0) 2003.10.30
    엑셀 파일 생성 코드  (0) 2003.10.30
    프로젝트 배포  (0) 2003.10.20

    + Recent posts