本文整理汇总了C#中Mono.CSharp.JavaScript.JsEmitContext.MakeJsNamespaceName方法的典型用法代码示例。如果您正苦于以下问题:C# JsEmitContext.MakeJsNamespaceName方法的具体用法?C# JsEmitContext.MakeJsNamespaceName怎么用?C# JsEmitContext.MakeJsNamespaceName使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类Mono.CSharp.JavaScript.JsEmitContext
的用法示例。
在下文中一共展示了JsEmitContext.MakeJsNamespaceName方法的2个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。
示例1: EmitContainerJs
public override void EmitContainerJs (JsEmitContext jec)
{
VerifyClsCompliance ();
var name = jec.MakeJsNamespaceName (this.NS.Name);
bool is_global_ns = String.IsNullOrEmpty (name);
if (!is_global_ns) {
jec.Buf.Write ("\tvar ", name, ";\n",
"\t(function (", name, ") {\n", Location);
jec.Buf.Indent ();
jec.MarkNamespaceDefined (NS.Name);
}
base.EmitContainerJs (jec);
if (!is_global_ns) {
jec.Buf.Unindent ();
jec.Buf.Write ("\t})(", name, " || (", name, " = {});\n");
}
}
示例2: EmitJs
public override void EmitJs (JsEmitContext jec)
{
if (!jec.CheckCanEmit (Location))
return;
if (!has_static_constructor && HasStaticFieldInitializer) {
var c = DefineDefaultConstructor (true);
c.Define ();
}
if (!(this.Parent is NamespaceContainer)) {
jec.Report.Error (7075, Location, "JavaScript code generation for nested types not supported.");
return;
}
Constructor constructor = null;
foreach (var member in Members) {
var c = member as Constructor;
if (c != null) {
if ((c.ModFlags & Modifiers.STATIC) != 0) {
continue;
}
if (constructor != null) {
jec.Report.Error (7077, c.Location, "JavaScript generation not supported for overloaded constructors");
return;
}
constructor = c;
}
}
var nsc = (NamespaceContainer)this.Parent;
jec.Buf.Write ("\tvar ", this.MemberName.Name, " = (function () {\n", Location);
jec.Buf.Indent ();
base.EmitJs (jec);
jec.Buf.Write ("\treturn ", this.MemberName.Name, ";\n");
jec.Buf.Unindent();
jec.Buf.Write ("\t})();\n");
var nsname = jec.MakeJsNamespaceName(nsc.NS.Name);
jec.Buf.Write ("\t", nsname, ".", this.MemberName.Name, " = ", this.MemberName.Name, ";\n");
}