1. #1
    Ext User
    Join Date
    Mar 2007
    Posts
    74
    Vote Rating
    0
    Teflon is on a distinguished road

      0  

    Talking [2.0] Write Ext code in C# with ExtJS/ASP.NET/Script#

    [2.0] Write Ext code in C# with ExtJS/ASP.NET/Script#


    I really love Ext but coding in javascript just gives me the chills. So I went out and found a way to use my favorite js library (Ext) and my favorite programming language (C#) at the same time. By using a project called Script# I am able to write C# code and have it converted into javascript, similar to GWT. Building on that, Script# also allows you to code against external APIs, but you need to create the types, methods, properties, etc. for everything in the javascript library. So what I did was write a little console app that parses all of the ExtJS source files extracting out the script comments and writing C# files for each class. The end result is a programmable C# API to access all of the Ext objects and I threw in a couple new things to make life a little easier.

    Since the entire API is generated, I haven't been able to check every piece of code to make sure nothing is missing, but from what I can tell all of it should be there. The only thing that doesn't work and I have to spend some time to figure out is the methods on Function objects such as createDelegate, defer, etc. Script# includes a createDelegate method but not a defer method. Another feature I want to get done is to create types for each classes constructor config objects so you can get intellisense on the config parameter.

    Here is a demo page I put online, this was written entirely in c# code.
    It's just the Products in the Northwind DB (Note: This app still uses Ext 1.1.1, I'll update it one day)
    http://ext.ordereze.net/scriptsharp/products.aspx

    Here's a link to download the complete demo project
    http://extsharp.googlecode.com
    - The only requirement to run this project locally is to download and install Script# from here and VS2005 of course

    And here's the source code for the javascript parser that creates the Ext API
    http://extsharp.googlecode.com

    UPDATE - 9/14/07
    A few things to be aware of when working with this api
    • Since C#/Script# does not allow for classes to be named the same as namespaces, I had to rename a few classes. They are Ext, Toolbar, DomHelper, UpdateManager, SplitBar. These classes have been renamed to {name}Class where {name} is the name of the original class (i.e. Ext becomes ExtClass in Script#).
    • In addition to that, the first thing you need to do before you use any Ext code is run the statement below. This method just tells the browser that the class Ext.ExtClass points to the Ext class
      Code:
      ScriptSharpAdapter.init();
    • I kept running into a problem where Script# wouldn't compile the code and the reason always was that I was accessing classes using the fully qualified name. (i.e. new Ext.form.TextField()) all you need to do to fix this is to add a using statement for the namespace (using Ext.form;) and then changed the code to be (new TextField())

    UPDATE - 9/16/07
    I've put all source code and downloads on the GoogleCode project website
    http://extsharp.googlecode.com
    I'll be making updates to the svn repository over there
    The change log can be viewed there as well
    http://extsharp.googlecode.com/svn/trunk/CHANGELOG.txt

    UPDATE - 10/3/07
    This API has been converted to work with the ExtJS 2.0 alpha release. I want to create some samples using it before packaging it up for a release though. Expect an update within the next few days.

    UPDATE - 12/5/07
    Updated ExtSharp to parse ExtJS v2.0 Final. Zipped up the parser and the samples.

    Intellisense


    Method Signatures with param info


    Method Overloads for varying params


    Method Overloads for unlimited param functions
    I currently have max 15 overloads, but more can be created by just changing a number in the converter project


    Compile-time error checking


    Events list with usage info


    Delegates for all events


    Intellisense for config options

  2. #2
    Sencha User harley.333's Avatar
    Join Date
    Mar 2007
    Posts
    286
    Vote Rating
    4
    harley.333 is on a distinguished road

      0  

    Thumbs up


    Awesome - please keep up posted on your progress!

  3. #3
    Ext JS Premium Member
    Join Date
    Mar 2007
    Location
    NL
    Posts
    607
    Vote Rating
    1
    mdissel is on a distinguished road

      0  

    Default


    Really great initiative!! If you need any help, just let us know! and keep us posted on updates....

    Thanks

    Marco

  4. #4
    Ext User yaip's Avatar
    Join Date
    Sep 2007
    Posts
    6
    Vote Rating
    0
    yaip is on a distinguished road

      0  

    Default What about VB

    What about VB


    Script# seems to be for C# developer only. Anything for VB guys?

  5. #5
    Ext User
    Join Date
    Mar 2007
    Posts
    74
    Vote Rating
    0
    Teflon is on a distinguished road

      0  

    Default


    Yeah Script# is only C#, there isn't anything for VB as far as I know.

  6. #6
    Ext JS - Development Team J.C. Bize's Avatar
    Join Date
    May 2007
    Location
    Bay Area, CA
    Posts
    179
    Vote Rating
    0
    J.C. Bize is on a distinguished road

      0  

    Default


    Looks really promising, looking forward to your progress

  7. #7
    Ext JS Premium Member
    Join Date
    Mar 2007
    Location
    NL
    Posts
    607
    Vote Rating
    1
    mdissel is on a distinguished road

      0  

    Default


    I started to play with this and got it compiled... It seems you're using a older version of script# (0.4.2 is latest version), but after changing the references all works fine..

    It seems that the SP "GetProductsPagedAndSorted" is missing in the database..

    (it seems that resharper doesn't handle the checkbox "do not reference mscorlib.dll" ...

    Thanks

    Marco

  8. #8
    Ext User
    Join Date
    Mar 2007
    Posts
    74
    Vote Rating
    0
    Teflon is on a distinguished road

      0  

    Default


    1. I upgraded to Script# v0.4.2 and fixed the references in the zip file above

    2. I verified that the sproc "GetProductsPagedAndSorted" is in the db. Here it is if you don't want to download the whole thing again:
    PHP Code:
    CREATE PROCEDURE dbo.GetProductsPagedAndSorted 
    (
        @
    sortExpression nvarchar(100),
        @
    startRowIndex int,
        @
    maximumRows int
    )
    AS

    -- 
    Make sure a @sortExpression is specified
    IF LEN(@sortExpression) = 0
        SET 
    @sortExpression 'ProductID'

    -- Issue query
    DECLARE @sql nvarchar(4000)
    SET @sql 'SELECT ProductID, ProductName, SupplierID, CategoryID, QuantityPerUnit, UnitPrice, UnitsInStock, UnitsOnOrder, ReorderLevel, Discontinued, CategoryName, SupplierName
                FROM (SELECT ProductID, ProductName, p.SupplierID, p.CategoryID, QuantityPerUnit, UnitPrice, UnitsInStock, UnitsOnOrder, ReorderLevel, Discontinued,
                      c.CategoryName, s.CompanyName AS SupplierName, 
                       ROW_NUMBER() OVER (ORDER BY ' 
    + @sortExpression ') AS RowRank
                FROM Products AS p
                        INNER JOIN Categories AS c ON
                            c.CategoryID = p.CategoryID
                        INNER JOIN Suppliers AS s ON
                            s.SupplierID = p.SupplierID) AS ProductsWithRowNumbers
                WHERE     RowRank > ' 
    CONVERT(nvarchar(10), @startRowIndex) + 
                    
    ' AND RowRank <= (' CONVERT(nvarchar(10), @startRowIndex) + ' + ' 
                    
    CONVERT(nvarchar(10), @maximumRows) + ')'

    -- Execute the SQL query
    EXEC sp_executesql 
    @sql 
    3. Yes, Resharper doesn't play nice with Script#. I've learned to ignore the "Anbiguous reference" error.

    Thanks so much for your comments. I'm glad I'm not the only person who has an interest in this.

  9. #9
    Sencha User harley.333's Avatar
    Join Date
    Mar 2007
    Posts
    286
    Vote Rating
    4
    harley.333 is on a distinguished road

      0  

    Talking


    I remember seeing Script# about a month ago and thinking it was pretty fantastic. But the very next day, I saw a blog about Microsoft's DLR (Dynamic Language Runtime). Which promises to make techniques like Script# a thing of the past.

    But honestly Teflon, I'm very happy you took the initiative, and I'm going to give your code a try. I find JavaScript just as easy to write as C# or VB.Net, but having a compiler check for typos and type safety makes my job that much easier.

    Again, thanks a ton!

  10. #10
    Ext User rodiniz's Avatar
    Join Date
    Mar 2007
    Location
    Rio de Janeiro, Brazil
    Posts
    276
    Vote Rating
    0
    rodiniz is on a distinguished road

      0  

    Default


    Nice job.. I thought about doing this, but its a lot of C# code to write
    Well done.

film izle

hd film izle

film sitesi

takipci kazanma sitesi

takipci kazanma sitesi

güzel olan herşey

takipci alma sitesi

komik eğlenceli videolar