質問

I'm moving a solution from .Net 2 to 4.5 and upgrading to Script# 0.8.

The release notes for Script# 0.8 say:

GlobalMethodsAttribute is gone (no implicit generation of methods on to the global script object, you must instead do it explicitly by assigning a delegate to the member on the global object)

How do you reference the 'global object'? for most of the projects I was able to work around this, but I have a couple where every other method is tagged with:

[Global]

UPDATE

I found this in my AssemblyInfo.cs

[assembly: ScriptTemplate(@"
/*! {name}.js {version}
 * {description}
 */

""use strict"";

require([{requires}], function({dependencies}) {
  var $global = this;
  {script}
});

")]

Anything I specify here gets inserted into the compiled javascript - is this the place to define globals?

役に立ちましたか?

解決

To set something on the global object, use Script.SetField using Script.Global as the instance object. Writing from memory, but do believe those are the API of interest.

You can update the script template if you want to add some directly authored JavaScript instead of generated script.

ライセンス: CC-BY-SA帰属
所属していません StackOverflow
scroll top