Author Topic: Anyone mess with Orcas yet?  (Read 4659 times)

0 Members and 1 Guest are viewing this topic.

It's Alive!

  • Retired
  • Needs a day job
  • Posts: 8691
  • AKA Daniel
Anyone mess with Orcas yet?
« on: August 31, 2007, 01:18:48 PM »
I wrote my first C# lambda expression today and it worked.. :|
For those who are interested, the C# 3.0 specification has been published
http://msdn2.microsoft.com/en-us/vcsharp/default.aspx

seems they added a ton of stuff to the language and to .NET 3.5 , more stuff to learn

Code: [Select]
using System;
using System.Collections.Generic;
using Autodesk.AutoCAD.DatabaseServices;
using Autodesk.AutoCAD.EditorInput;
using Autodesk.AutoCAD.Runtime;
using AcadApp = Autodesk.AutoCAD.ApplicationServices.Application;
namespace cSharpTest
{
    public class SoSharp
    {
        [LispFunction("test1")]
        public static void DoTest1(ResultBuffer Args)
        {
            Editor ed = AcadApp.DocumentManager.MdiActiveDocument.Editor;
            List<TypedValue> list = new List<TypedValue>(Args.AsArray());
            list.ForEach ( p => ed.WriteMessage(p.ToString()));
        }
    }
}


« Last Edit: August 31, 2007, 01:23:10 PM by Danielm103 »

It's Alive!

  • Retired
  • Needs a day job
  • Posts: 8691
  • AKA Daniel
Re: Anyone mess with Orcas yet?
« Reply #1 on: August 31, 2007, 02:55:27 PM »
here is a fun one

Code: [Select]
//(test2 64)
        [LispFunction("test2")]
        public static void DoTest2(ResultBuffer Args)
        {
            Editor ed = AcadApp.DocumentManager.MdiActiveDocument.Editor;
            List<TypedValue> list = new List<TypedValue>(Args.AsArray());

            Func<UInt64, UInt64> Factorial = null;
            Factorial = (n) => n <= 1 ? 1 : n * Factorial(n - 1);

            ed.WriteMessage("{0}", Factorial(Convert.ToUInt64(list[0].Value)).ToString());
        }

9223372036854775808

LE

  • Guest
Re: Anyone mess with Orcas yet?
« Reply #2 on: August 31, 2007, 10:47:17 PM »
44616E69656C;

Can this beta be use with AutoCAD 2007 ?

Kerry

  • Mesozoic relic
  • Seagull
  • Posts: 11654
  • class keyThumper<T>:ILazy<T>
Re: Anyone mess with Orcas yet?
« Reply #3 on: August 31, 2007, 11:19:35 PM »

I've had it installed for a while, but haven't made the time to play yet Daniel ... looks like you're having fun !
kdub, kdub_nz in other timelines.
Perfection is not optional.
Everything will work just as you expect it to, unless your expectations are incorrect.
Discipline: None at all.

It's Alive!

  • Retired
  • Needs a day job
  • Posts: 8691
  • AKA Daniel
Re: Anyone mess with Orcas yet?
« Reply #4 on: August 31, 2007, 11:27:09 PM »
44616E69656C;

Can this beta be use with AutoCAD 2007 ?

Yes, that’s what version I was testing on. Since it’s still beta, I just stuck it on my laptop but I haven’t had any problems.

It's Alive!

  • Retired
  • Needs a day job
  • Posts: 8691
  • AKA Daniel
Re: Anyone mess with Orcas yet?
« Reply #5 on: August 31, 2007, 11:32:43 PM »

I've had it installed for a while, but haven't made the time to play yet Daniel ... looks like you're having fun !


Yes, I think it’s pretty cool so far, I just hope they don’t make the language so feature full that it becomes bloatware.

It's Alive!

  • Retired
  • Needs a day job
  • Posts: 8691
  • AKA Daniel
Re: Anyone mess with Orcas yet?
« Reply #6 on: September 01, 2007, 01:18:25 PM »
You can now target a specific framework in your project. In this function I targeted the 2.0 framework

Code: [Select]
static void Main(string[] args)
    {
      var TypedValueList = new List<KeyValuePair<int, int>>();
      for (int i = 0; i < 10; i++)
      {
        for (int x = 0; x < 10; x++)
        {
          TypedValueList.Add(new KeyValuePair<int, int>(x, i));
        }
      }
      var eList = TypedValueList.FindAll
        (pairs => pairs.Key == 0 && pairs.Value > 5).GetEnumerator();

      while (eList.MoveNext())
      {
        Console.WriteLine("\n{0}", eList.Current);
      }
      Console.ReadKey();
    }
And reflector picked up this
Code: [Select]
private static void Main(string[] args)
{
    List<KeyValuePair<int, int>> TypedValueList = new List<KeyValuePair<int, int>>();
    for (int i = 0; i < 10; i++)
    {
        for (int x = 0; x < 10; x++)
        {
            TypedValueList.Add(new KeyValuePair<int, int>(x, i));
        }
    }
    List<KeyValuePair<int, int>>.Enumerator eList = TypedValueList.FindAll(delegate (KeyValuePair<int, int> pairs) {
        return (pairs.Key == 0) && (pairs.Value > 5);
    }).GetEnumerator();
    while (eList.MoveNext())
    {
        Console.WriteLine("\n{0}", eList.Current);
    }
    Console.ReadKey();
}


So it seems that some of the new language features are backwards compatible with older frameworks

It's Alive!

  • Retired
  • Needs a day job
  • Posts: 8691
  • AKA Daniel
Re: Anyone mess with Orcas yet?
« Reply #7 on: September 01, 2007, 02:01:21 PM »
This is the same as above but I am using LinQ to query an in-memory collection using an extension method with a lambda expression.  :lol:

Code: [Select]
static void Main(string[] args)
    {
      var TypedValueList = new List<KeyValuePair<int, int>>();
      for (int i = 0; i < 10; i++)
      {
        for (int x = 0; x < 10; x++)
        {
          TypedValueList.Add(new KeyValuePair<int, int>(x, i));
        }
      }

      Func<KeyValuePair<int, int>, bool>
        Filter = pairs => pairs.Key == 0 && pairs.Value > 5;

      var eList = TypedValueList.Where(Filter).GetEnumerator();

      while (eList.MoveNext())
      {
        Console.WriteLine("\n{0}", eList.Current);
      }
      Console.ReadKey();
    }
« Last Edit: September 01, 2007, 08:44:42 PM by Danielm103 »

Kerry

  • Mesozoic relic
  • Seagull
  • Posts: 11654
  • class keyThumper<T>:ILazy<T>
Re: Anyone mess with Orcas yet?
« Reply #8 on: September 02, 2007, 01:14:48 AM »
LinQ ..
That reminds me of something I bookmarked recently

http://www.albahari.com/linqpad.html


and while I'm at it ...
' Reflexil is an assembly editor and runs as a plug-in for Lutz Roeder's Reflector. '
http://sourceforge.net/project/showfiles.php?group_id=200895

edit: Fixed lazy Sunday spelling ..
« Last Edit: September 02, 2007, 01:19:22 AM by Kerry Brown »
kdub, kdub_nz in other timelines.
Perfection is not optional.
Everything will work just as you expect it to, unless your expectations are incorrect.
Discipline: None at all.

sinc

  • Guest
Re: Anyone mess with Orcas yet?
« Reply #9 on: September 04, 2007, 05:14:28 PM »
Yes, I think it’s pretty cool so far, I just hope they don’t make the language so feature full that it becomes bloatware.

Now that's an optimist.  After all this time, still hoping to see non-bloatware out of Microsoft...   :-D

Kerry

  • Mesozoic relic
  • Seagull
  • Posts: 11654
  • class keyThumper<T>:ILazy<T>
Re: Anyone mess with Orcas yet?
« Reply #10 on: September 05, 2007, 05:21:31 AM »
This may be worth bookmarking ..
Jomo Fisher -- C#, LINQ and Whatnot

http://blogs.msdn.com/jomo_fisher/archive/2007/07/23/the-least-you-need-to-know-about-c-3-0.aspx

FrontPage:

http://blogs.msdn.com/jomo_fisher/default.aspx

added/edit: links changed

« Last Edit: September 06, 2007, 06:10:08 AM by Kerry Brown »
kdub, kdub_nz in other timelines.
Perfection is not optional.
Everything will work just as you expect it to, unless your expectations are incorrect.
Discipline: None at all.