Exemplo n.º 1
0
        /// <summary>
        /// Create wrapper for given jar file
        /// </summary>
        private void CreateAssembly(JarFile jf, string folder)
        {
            // Create java type wrappers
            var module = new NetModule(jf.Scope);

            var classTypeBuilders = jf.ClassNames.SelectMany(n => StandardTypeBuilder.Create(jf.LoadClass(n), target));

            var typeBuilders = classTypeBuilders.OrderBy(x => x.Priority).ToList();

            typeBuilders.ForEach(x => x.CreateType(null, module, target));

            // Implement and finalize types
            Implement(typeBuilders, target);

            var assemblyAttributes = new List <NetCustomAttribute>();

            if (!importAsStubs)
            {
                // Import code
                var attrType = new NetTypeDefinition(ClassFile.Empty, target, AttributeConstants.Dot42Scope)
                {
                    Name      = AttributeConstants.JavaCodeAttributeName,
                    Namespace = AttributeConstants.Dot42AttributeNamespace
                };
                string hash = JarReferenceHash.ComputeJarReferenceHash(jarFilePath);
                var    attr = new NetCustomAttribute(attrType, hash, Path.GetFileName(jarFilePath));
                assemblyAttributes.Add(attr);
            }

            // Save
            CodeGenerator.Generate(folder, module.Types, assemblyAttributes, target, this, target);
        }
Exemplo n.º 2
0
        public int?CompareByInheritance(StandardTypeBuilder other)
        {
            if (ReferenceEquals(other, this))
            {
                return(0);
            }

            var myBaseTypes = TypeDefinition.GetBaseTypes(true);

            if (myBaseTypes.Any(other.TypeDefinition.AreSame))
            {
                return(1);
            }
            var otherBaseTypes = other.TypeDefinition.GetBaseTypes(true);

            if (otherBaseTypes.Any(TypeDefinition.AreSame))
            {
                return(-1);
            }

            return(null);
        }
Exemplo n.º 3
0
        public int? CompareByInheritance(StandardTypeBuilder other)
        {
            if (ReferenceEquals(other, this))
                return 0;

            var myBaseTypes = TypeDefinition.GetBaseTypes(true);
            if (myBaseTypes.Any(other.TypeDefinition.AreSame))
                return 1;
            var otherBaseTypes = other.TypeDefinition.GetBaseTypes(true);
            if (otherBaseTypes.Any(TypeDefinition.AreSame))
                return -1;

            return null;
        }