Saturday, 17 August 2013

Convert code-behind into Javascript

Convert code-behind into Javascript

First off, im not sure its even possible, even with Reflection but figured
I would ask.
First off lets say I have a method signature:
string format; object[] args;
//Check if Attribute is a standalone attribute or a Key-Value pairing
if( this.HasValue ) {
//Attribute is a Key-Value pair
//Check if the ValidateValue delegate contains an implementation
if( ValidateValue != null ) {
//Delegate contains an implementation
//execute the Delegate implementation
if( ValidateValue( this.Value ) ) {
//Implementation determined Value was of correct value
format = "{0}={1}"; args = new object[] { Name , Value };
} else
//Throw associated Exception for invalid Value determination
throw this.InvalidException;
} else {
//Delegate did not contain an implementation, unable to
validate Value
throw new NullReferenceException( "Method ValidateValue did
not have a function assigned to it!" );
}
} else {
//Attribute is a stand-alone Attribute
format = "{0}"; args = new object[] { Name };
}
//Return associated format for either form of Attribute.
return string.Format( format , args );
I know there are some intricate differences between JavaScript and .Nets
CLR but had done some reading on DLR and was wondering if it was possible
to combine Reflection with DLR to produce a JavaScript method at run time.
Ideally, they would have a static method signature but possibly assign a
lambda logic to a Delegate as well.
Again, not saying I am having a problem doing this, but more is it
possible and if so, what libraries would I use to get this pulled off.

No comments:

Post a Comment