Another C# question

Started by stanl, April 18, 2014, 09:40:17 AM

Previous topic - Next topic

stanl

It was so much fun learning about GenerateInMemory() for expanding WB's CLR functionality.... why not ask another dumb question, or more likely a moot point.

WB's CLR does not handle delegates. When Tony finally chimed in with code to get at a form's control backcolor/forecolor, the control itself was passed to the C# snippet. So this [in red] prevents one from passing say a button control to some C# you want to GenerateInMemory() and have the snippet monitor the click()?

Deana

Honestly I am not too familiar with dotNet delegates and how they would translate when called from a separate assembly...
Deana F.
Technical Support
Wilson WindowWare Inc.

stanl

Quote from: Deana on April 18, 2014, 01:23:35 PM
Honestly I am not too familiar with dotNet delegates and how they would translate when called from a separate assembly...

and, honestly... I'm not trying to poke holes... 

stanl

Ok... how about a Plan-B proposal.  Is this worth investigating?

I posted a CLR_RTF_Sample script, which worked with memory-generated C# code to set background color. The C# code took the control as a parameter. [TonyWare]

My interest was to extend the script to handle the button control being clicked.  Currently it is set in the script as


Form1.Controls.Add(Button1)


My Plan-B becomes: can one send form1 as an object to C# and have the button created in C# with an appropriate click event in the code?

Deana

Quote from: stanl on April 30, 2014, 01:31:41 PM
Ok... how about a Plan-B proposal.  Is this worth investigating?

I posted a CLR_RTF_Sample script, which worked with memory-generated C# code to set background color. The C# code took the control as a parameter. [TonyWare]

My interest was to extend the script to handle the button control being clicked.  Currently it is set in the script as


Form1.Controls.Add(Button1)


My Plan-B becomes: can one send form1 as an object to C# and have the button created in C# with an appropriate click event in the code?

Your guess is as good as mine...I suspect you might be able to pass the form object, but I would not recommend it, mostly because you would be working outside the boundaries of WinBatch. 

Golden hammer principle: The belief that there is a technology or tool that significantly improves productivity, reduces errors, shortens code, etc. without significant drawbacks.
The notion of a golden hammer, "a familiar technology or concept applied obsessively to many software problems", has been introduced into the information technology literature in 1998 as an anti-pattern: a programming practice to be avoided. Reference: http://en.wikipedia.org/wiki/Law_of_the_instrument and http://en.wikipedia.org/wiki/Anti-pattern.
Deana F.
Technical Support
Wilson WindowWare Inc.

td

Highly recommend the book  Design Patterns: Elements of Reusable Object-Oriented Software by Erich Gamma, Richard Helm, Ralph Johnson and John Vlissides to anyone wishing to dive into software design.  It's been around for 20 years but still a good study.
"No one who sees a peregrine falcon fly can ever forget the beauty and thrill of that flight."
  - Dr. Tom Cade

stanl

Quote from: td on May 01, 2014, 10:21:37 AM
Highly recommend the book  Design Patterns: Elements of Reusable Object-Oriented Software by Erich Gamma, Richard Helm, Ralph Johnson and John Vlissides to anyone wishing to dive into software design.  It's been around for 20 years but still a good study.

A yes or no to my question would have been sufficient.  I know how to read. My interest is more or less how far WB is willing to invest in .NET. Everything I do with respect to data analysis can be compiled from WB 2005. WB's link to the CLR gave me an opportunity to play with Powershell and learn a little more about asemblies. If WB plans to implement the CLR into Windows forms with delegates/events, +++

otherwise, wait and see....

td

Quote from: stanl on May 03, 2014, 06:22:11 AM
Quote from: td on May 01, 2014, 10:21:37 AM
Highly recommend the book  Design Patterns: Elements of Reusable Object-Oriented Software by Erich Gamma, Richard Helm, Ralph Johnson and John Vlissides to anyone wishing to dive into software design.  It's been around for 20 years but still a good study.

A yes or no to my question would have been sufficient.  I know how to read. My interest is more or less how far WB is willing to invest in .NET. Everything I do with respect to data analysis can be compiled from WB 2005. WB's link to the CLR gave me an opportunity to play with Powershell and learn a little more about asemblies. If WB plans to implement the CLR into Windows forms with delegates/events, +++

otherwise, wait and see....

My post was not intended to be a direct response to your question but to expand on the idea of design patterns and the appropriate use of technologies. I happen to have interest in the topic.  If you feel your thread has been hijacked, my apologies. But if you are not interested in a straying thread, you can always ignore it.     
"No one who sees a peregrine falcon fly can ever forget the beauty and thrill of that flight."
  - Dr. Tom Cade

stanl

Quote from: td on May 05, 2014, 06:59:26 AM
My post was not intended to be a direct response to your question but to expand on the idea of design patterns and the appropriate use of technologies.

Understood. I am doing my best with very little spare time to play with C# on LinQPad. Didn't mean to appear rude, just a little frustrated.  For example, what am I doing wrong [below]

Code (WINBATCH) Select

ObjectClrOption("use","System.Xml, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089")
oReader = ObjectClrNew('System.XML.XMLReader')


Deana

Quote from: stanl on May 06, 2014, 11:03:29 AM
Quote from: td on May 05, 2014, 06:59:26 AM
My post was not intended to be a direct response to your question but to expand on the idea of design patterns and the appropriate use of technologies.

Understood. I am doing my best with very little spare time to play with C# on LinQPad. Didn't mean to appear rude, just a little frustrated.  For example, what am I doing wrong [below]

Code (WINBATCH) Select

ObjectClrOption("use","System.Xml, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089")
oReader = ObjectClrNew('System.XML.XMLReader')



Remember dotNet is case sensitive. Use this instead:

Code (winbatch) Select
oReader = ObjectClrNew('System.Xml.XmlReader')
Deana F.
Technical Support
Wilson WindowWare Inc.

stanl

Quote from: Deana on May 06, 2014, 11:11:04 AM
Remember dotNet is case sensitive. Use this instead:

Code (winbatch) Select
oReader = ObjectClrNew('System.Xml.XmlReader')

WOW! and I was trying to play with some PS code (which works) and it specified


$reader = [System.XML.XMLReader]::Create([System.IO.StringReader] $xaml)


and all along I thought it was the Buckshot Amber (ranks #2 after Rogue Dead Guy)