Exemple #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);
        }
        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);
        }
        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;
        }