protected IEnumerable <IMember> GetExportedDeclaredAndGeneratedFields(ITypeDefinition ce, bool isStatic) { foreach (var pe in ce.GetFields(t => t.IsStatic == isStatic, GetMemberOptions.IgnoreInheritedMembers)) { if (!JMeta.IsJsExported(pe)) { continue; } yield return(pe); } foreach (var pe in ce.GetEvents(t => t.IsStatic == isStatic, GetMemberOptions.IgnoreInheritedMembers)) { if (!JMeta.IsJsExported(pe)) { continue; } yield return(pe); } foreach (var fe in GeneratePropertyFields(ce, isStatic)) { yield return(fe); } }
/// <summary> /// Generates backing fields for automatic properties, and fake fields for properties who are defined as fields /// </summary> /// <param name="ce"></param> /// <returns></returns> protected IEnumerable <IField> GeneratePropertyFields(ITypeDefinition ce, bool isStatic) { //var list = new List<IField>(); foreach (var pe in ce.GetProperties(t => t.IsStatic == isStatic, GetMemberOptions.IgnoreInheritedMembers)) { if (!JMeta.IsJsExported(pe)) { continue; } if (JMeta.IsNativeField(pe)) { yield return(GenerateFakeField(pe)); } else if (pe.IsAutomaticProperty(Compiler.Project)) { yield return(GenerateBackingField(pe)); } } //return list; }
public virtual List <JEntityDeclaration> _VisitEnum(ITypeDefinition ce) { var unit = new JUnit { Statements = new List <JStatement>() }; ExportTypeNamespace(ce); var att = ce.GetMetadata <JEnumAttribute>(); bool valuesAsNames; JMeta.UseJsonEnums(ce, out valuesAsNames); //var valuesAsNames = att != null && att.ValuesAsNames; var constants = ce.GetConstants().ToList(); if (!valuesAsNames && constants.Where(t => t.ConstantValue == null).FirstOrDefault() != null) { var value = 0L; foreach (var c in constants) { if (c.ConstantValue == null) { c.SetConstantValue(value); } else { value = Convert.ToInt64(c.ConstantValue); } value++; } } constants.RemoveAll(t => !JMeta.IsJsExported(t)); var json = new JJsonObjectExpression { NamesValues = new List <JJsonNameValue>() }; json.NamesValues.AddRange(constants.Select(t => Export(t, valuesAsNames))); var st = ce.JAccess().Assign(json).Statement(); unit.Statements.Add(st); throw new NotSupportedException(); }
protected List <IMethod> GetAccessorsToExport(IProperty pe) { var list = new List <IMethod>(); if (pe.IsAutomaticProperty(Compiler.Project) && !JMeta.IsNativeField(pe)) { list.Add(pe.Getter); list.Add(pe.Setter); } else { if (pe.Getter != null) { list.Add(pe.Getter); } if (pe.Setter != null) { list.Add(pe.Setter); } } list.RemoveAll(t => !JMeta.IsJsExported(t)); return(list); }
//JsTypeImporter_ExtJs ExtJsExport; private bool ShouldExportType(ITypeDefinition ce) { return(JMeta.IsJsExported(ce)); }
bool ShouldExportMethodBody(IMethod me) { return(JMeta.IsJsExported(me) && me.GetMethodDeclaration() != null && !me.IsAnonymousMethod()); }