protected virtual void EmitMethods(Dictionary <string, List <MethodDeclaration> > methods, Dictionary <string, List <EntityDeclaration> > properties, Dictionary <OperatorType, List <OperatorDeclaration> > operators) { int pos = Emitter.Output.Length; var writerInfo = SaveWriter(); string globalTarget = H5Types.GetGlobalTarget(TypeInfo.Type.GetDefinition(), TypeInfo.TypeDeclaration); if (globalTarget == null) { EnsureComma(); Write(JS.Fields.METHODS); WriteColon(); BeginBlock(); } int checkPos = Emitter.Output.Length; var names = new List <string>(properties.Keys); foreach (var name in names) { var props = properties[name]; foreach (var prop in props) { if (prop is PropertyDeclaration) { Emitter.VisitPropertyDeclaration((PropertyDeclaration)prop); } else if (prop is CustomEventDeclaration) { Emitter.VisitCustomEventDeclaration((CustomEventDeclaration)prop); } else if (prop is IndexerDeclaration) { Emitter.VisitIndexerDeclaration((IndexerDeclaration)prop); } } } names = new List <string>(methods.Keys); foreach (var name in names) { EmitMethodsGroup(methods[name]); } if (operators != null) { var ops = new List <OperatorType>(operators.Keys); foreach (var op in ops) { EmitOperatorGroup(operators[op]); } } if (TypeInfo.ClassType == ClassType.Struct) { if (!StaticBlock) { EmitStructMethods(); } else { string structName = H5Types.ToJsName(TypeInfo.Type, Emitter); if (TypeInfo.Type.TypeArguments.Count > 0 && !Helpers.IsIgnoreGeneric(TypeInfo.Type, Emitter)) { structName = "(" + structName + ")"; } EnsureComma(); Write(JS.Funcs.GETDEFAULTVALUE + ": function () { return new " + structName + "(); }"); Emitter.Comma = true; } } else if (StaticBlock) { var ctor = TypeInfo.Type.GetConstructors().FirstOrDefault(c => c.Parameters.Count == 0 && Emitter.GetInline(c) != null); if (ctor != null) { var code = Emitter.GetInline(ctor); EnsureComma(); Write(JS.Funcs.GETDEFAULTVALUE + ": function () "); BeginBlock(); Write("return "); var argsInfo = new ArgumentsInfo(Emitter, ctor); new InlineArgumentsBlock(Emitter, argsInfo, code).Emit(); Write(";"); WriteNewLine(); EndBlock(); Emitter.Comma = true; } } if (globalTarget == null) { if (checkPos == Emitter.Output.Length) { Emitter.IsNewLine = writerInfo.IsNewLine; Emitter.ResetLevel(writerInfo.Level); Emitter.Comma = writerInfo.Comma; Emitter.Output.Length = pos; } else { WriteNewLine(); EndBlock(); } } }