Forums

Is C# class unseen?

General discussion about Cobra. Releases and general news will also be posted here.
Feel free to ask questions or just say "Hello".

Is C# class unseen?

Postby arisawa » Tue Sep 30, 2008 3:26 am

(Machine translation)
Hi
When I mix a source file of cobra with source file of C# and compile it,
is a class of C# an unseen class from cobra class?

e.g. partial class.
arisawa
 
Posts: 51

Re: Is C# class unseen?

Postby Charles » Tue Sep 30, 2008 7:55 am

Correct, Cobra cannot see C#, but you can make Cobra see it like this:
Code: Select all
// MySharpClass.cs
class MySharpClass {
    public string Foo(int i) {
        // ...
    }
}

class MySharpClass
is fake

def foo(i as int) as String
pass

# ...

Now Cobra "knows" what's in "MySharpClass". I haven't yet tried combining "fake" and "partial". Let me know how it goes!
Charles
 
Posts: 2515
Location: Los Angeles, CA

Re: Is C# class unseen?

Postby arisawa » Wed Oct 01, 2008 1:33 am

if my method is not clumsy...

A fake class seems to pursue all the main bodies in the C# class.
Therefore, "fake" and "partial" are not compatible ?
arisawa
 
Posts: 51

Re: Is C# class unseen?

Postby Charles » Wed Oct 01, 2008 9:44 am

Yes, I tried "fake" and "partial" together this morning and they aren't compatible.

Can you get by with a non-partial class? Also, what kind of code would you write in C#? Can it be written in Cobra?
Charles
 
Posts: 2515
Location: Los Angeles, CA

Re: Is C# class unseen?

Postby arisawa » Wed Oct 01, 2008 12:44 pm

Thank you, I am not troubled right now.
It is corner-cutting to want to do me. :)

Visual Studio(or Mono Develop) designer generated Form class is partial.
I think so easy, form design.
If that class apply in my cobra project.
arisawa
 
Posts: 51

Re: Is C# class unseen?

Postby Charles » Wed Oct 01, 2008 6:17 pm

To connect the C# to the Cobra, some ideas come to mind:

-- Perhaps the Visual Studio or Mono project could produce a DLL instead of an EXE. Then a Cobra program could reference it and use it. Make the C# methods virtual. Then in Cobra make a subclass and override that method. When creating the form, instantiate the Cobra class, not the C# class.

-- Make a DLL with Cobra that contains your application logic. Have your C# program reference the Cobra-based DLL. Have your C# forms instantiate the Cobra helper classes and invoke methods on them as needed. This might get awkward if you need to pass in numerous references to controls.

-- Write a Cobra plugin for one of the IDEs. :-)
Charles
 
Posts: 2515
Location: Los Angeles, CA

Re: Is C# class unseen?

Postby arisawa » Thu Oct 02, 2008 12:18 pm

Thank you.
Two first ideas served as a good reference. :D
The one of the remainder is the most amazing, but it look like to be McKinley for me.

Squeeze an else idea. :idea:

1) Do you know Glade3?
Glade3 does a design output XML.
I tried it many times, but did not get along well.
(This may be a thing by my failure.The connection of the signature did not go well.)

2) Useing WPF which new Windows has.
But this idea became out of control. :?
arisawa
 
Posts: 51

Re: Is C# class unseen?

Postby Charles » Thu Oct 02, 2008 12:35 pm

I've seen Glade. So a possibility is to read Glade files or to build something like it for Cobra and .NET.

Another possibility is to code the GUI yourself without using a designer. This approach is described in Programming Microsoft Windows Forms.

Also, see WinForms How To and ObjectExplorer-WinForms.cobra.
Charles
 
Posts: 2515
Location: Los Angeles, CA


Return to Discussion

Who is online

Users browsing this forum: No registered users and 83 guests

cron