Ejemplo n.º 1
0
        protected bool ShouldExportProperty(IProperty pe)
        {
            if (pe.IsIndexer)
            {
                return(!pe.IsExplicitInterfaceImplementation);
            }
            if (pe.IsExplicitInterfaceImplementation)
            {
                return(false);
            }
            var att = pe.GetMetadata <JPropertyAttribute>();

            if (att != null && !att.Export)
            {
                return(false);
            }
            if (JMeta.IsNativeField(pe))
            {
                return(false);
            }
            //{

            //    if (Sk.InlineFields(pe.GetDeclaringTypeDefinition()))
            //        return true;
            //    return false;
            //}
            return(true);
        }
Ejemplo n.º 2
0
        static JMemberExpression JName2(IProperty pe)
        {
            var name = pe.Name;
            var att  = pe.GetMetadata <JPropertyAttribute>();

            if (att != null && att.Name != null)
            {
                name = att.Name;
            }
            else if (JMeta.IsNativeField(pe))
            {
                name = name.ToJavaNaming();
            }

            return(J.Member(JCodeImporter.JsIdentifier(name)));
        }
Ejemplo n.º 3
0
        /// <summary>
        /// Indicates that object is IProperty that uses getter setter functions, and not native fields
        /// </summary>
        /// <param name="entity"></param>
        /// <returns></returns>
        bool IsEntityFunctionProperty(IEntity entity, ResolveResult scope)
        {
            var pe = entity as IProperty;

            if (pe != null)
            {
                var ce = pe.DeclaringType;
                if (ce != null && ce.Kind == TypeKind.Anonymous)
                {
                    var ce2 = scope.GetParentType();
                    if (ce2 != null && JMeta.UseNativeJsons(ce2))
                    {
                        return(false);
                    }
                }
                return(!JMeta.IsNativeField(pe) && !JMeta.UseNativeIndexer(pe)); // && !Sk.IsNativeProperty(pe);
            }
            return(false);
        }
Ejemplo n.º 4
0
 /// <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;
 }
Ejemplo n.º 5
0
        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);
        }