Script#: Determine if imported type is null
I'm writing code that calls an external JavaScript library Foo but only if Foo is defined.  The equivalent JavaScript code should looks something like this:

    if (typeof(Foo) != "undefined") {
      Foo.bar();
    }

I've tried the following in Script#:
<ul>
<li><strong>if (!Script.IsNullOrDefined(Foo)):</strong> My project requires aacorlib and cannot use sscorlib, where IsNullOrDefined is defined.</li>
<li><strong>if (typeof(Foo).ToString() != "undefined"):</strong> Results in Foo.toString() !== 'undefined' which will fail because Foo is undefined.</li>
<li><strong>if ((string)Type.InvokeMethod(null, "typeof", "Foo") != "undefined"):</strong> Compile error "The name of a global method must be a valid identifier", referring to "typeof".</li>
<li><strong>if (Type.IsClass(typeof(Foo))):</strong>Fails at runtime with "Foo undefined" error.</li>
<li><strong>if (typeof(Foo) != null):</strong>Emits "if(Foo!= null)" which throws "Foo undefined" error.</li>
</ul>

What should the Script# code look like to generate this JavaScript code?

Script#: Determine if imported type is null
===

I'm writing code that calls an external JavaScript library Foo but only if Foo is defined.  The equivalent JavaScript code should looks something like this:

    if (typeof(Foo) != "undefined") {
      Foo.bar();
    }

I've tried the following in Script#:
<ul>
<li><strong>if (!Script.IsNullOrDefined(Foo)):</strong> My project requires aacorlib and cannot use sscorlib, where IsNullOrDefined is defined.</li>
<li><strong>if (typeof(Foo).ToString() != "undefined"):</strong> Results in Foo.toString() !== 'undefined' which will fail because Foo is undefined.</li>
<li><strong>if ((string)Type.InvokeMethod(null, "typeof", "Foo") != "undefined"):</strong> Compile error "The name of a global method must be a valid identifier", referring to "typeof".</li>
<li><strong>if (Type.IsClass(typeof(Foo))):</strong>Fails at runtime with "Foo undefined" error.</li>
<li><strong>if (typeof(Foo) != null):</strong>Emits "if(Foo!= null)" which throws "Foo undefined" error.</li>
</ul>

What should the Script# code look like to generate this JavaScript code?
