viewpoint-particle

Author Topic: Another C# question  (Read 6680 times)

stanl

  • Pundit
  • *****
  • Posts: 951
Another C# question
« on: April 18, 2014, 09:40:17 am »
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

  • Wilson WindowWare Tech Support
  • Pundit
  • *****
  • Posts: 1183
  • WinBatch® can do it.
    • WinBatch Tech Support Database
Re: Another C# question
« Reply #1 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...
Deana F.
Technical Support
Wilson WindowWare Inc.

stanl

  • Pundit
  • *****
  • Posts: 951
Re: Another C# question
« Reply #2 on: April 19, 2014, 09:20:31 am »
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

  • Pundit
  • *****
  • Posts: 951
Re: Another C# question
« Reply #3 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

Code: [Select]
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

  • Wilson WindowWare Tech Support
  • Pundit
  • *****
  • Posts: 1183
  • WinBatch® can do it.
    • WinBatch Tech Support Database
Re: Another C# question
« Reply #4 on: May 01, 2014, 08:40:41 am »
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

Code: [Select]
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

  • Tech Support
  • *****
  • Posts: 3103
    • WinBatch
Re: Another C# question
« Reply #5 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.
"No one who sees a peregrine falcon fly can ever forget the beauty and thrill of that flight."
  - Dr. Tom Cade

stanl

  • Pundit
  • *****
  • Posts: 951
Re: Another C# question
« Reply #6 on: May 03, 2014, 06:22:11 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

  • Tech Support
  • *****
  • Posts: 3103
    • WinBatch
Re: Another C# question
« Reply #7 on: May 05, 2014, 06:59:26 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

  • Pundit
  • *****
  • Posts: 951
Re: Another C# question
« Reply #8 on: May 06, 2014, 11:03:29 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
 
ObjectClrOption("use","System.Xml, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089")
oReader = ObjectClrNew('System.XML.XMLReader')
 
 

Deana

  • Wilson WindowWare Tech Support
  • Pundit
  • *****
  • Posts: 1183
  • WinBatch® can do it.
    • WinBatch Tech Support Database
Re: Another C# question
« Reply #9 on: May 06, 2014, 11:11:04 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
 
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
oReader = ObjectClrNew('System.Xml.XmlReader')
Deana F.
Technical Support
Wilson WindowWare Inc.

stanl

  • Pundit
  • *****
  • Posts: 951
Re: Another C# question
« Reply #10 on: May 06, 2014, 12:39:39 pm »
Remember dotNet is case sensitive. Use this instead:

Code: Winbatch
oReader = ObjectClrNew('System.Xml.XmlReader')

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

Code: [Select]
$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)