예제 #1
0
        public IEnumerable <EcsFile> ConvertTargetFiles(IEnumerable <EcsFile> allFiles, string ProjectName, string EntryPoint)
        {
            var projectFiles = EmbeddedFileLoader.GetFilesAndUpdate(typeof(TargetPC).Assembly, "Target.PC.Target_VS", ProjectName, EntryPoint);
            var halFiles     = EmbeddedFileLoader.GetFiles(typeof(TargetPC).Assembly, "Target.PC.Hal");

            return(projectFiles.Concat(halFiles).Concat(allFiles));
        }
예제 #2
0
        public static TypeDefinition CopyType(TypeDefinition t)
        {
            var nt = new TypeDefinition(t.Namespace, t.Name, t.Attributes, t.BaseType);

            foreach (var a in t.CustomAttributes)
            {
                // move this out of here??
                if (a.AttributeType.Name == "CustomSourceFile")
                {
                    var filename      = (string)a.ConstructorArguments[0].Value;
                    var sourceContent = filename == ""? "": EmbeddedFileLoader.GetResourceFile(filename, t.Module);
                    var nas           = new CustomAttribute(t.Module.ImportReference(typeof(CustomSource)).Resolve().Methods[0], a.GetBlob());
                    nas.ConstructorArguments.Add(new CustomAttributeArgument(t.Module.ImportReference(typeof(string)), sourceContent));
                    nt.CustomAttributes.Add(nas);
                }
                else if (a.AttributeType.Name == "CustomHeaderFile")
                {
                    var filename      = (string)a.ConstructorArguments[0].Value;
                    var sourceContent = filename == "" ? "" : EmbeddedFileLoader.GetResourceFile(filename, t.Module);
                    var nas           = new CustomAttribute(t.Module.ImportReference(typeof(CustomHeader)).Resolve().Methods[0], a.GetBlob());
                    nas.ConstructorArguments.Add(new CustomAttributeArgument(t.Module.ImportReference(typeof(string)), sourceContent));
                    nt.CustomAttributes.Add(nas);
                }

                else
                {
                    var na = new CustomAttribute(a.Constructor, a.GetBlob());
                    foreach (var ca in a.ConstructorArguments)
                    {
                        var nca = new CustomAttributeArgument(ca.Type, ca.Value);
                        na.ConstructorArguments.Add(nca);
                    }

                    nt.CustomAttributes.Add(na);
                }
            }

            foreach (var i in t.Interfaces)
            {
                nt.Interfaces.Add(new InterfaceImplementation(i.InterfaceType));
            }

            foreach (var f in t.Fields)
            {
                var nf = new FieldDefinition(f.Name, f.Attributes, f.FieldType);

                nt.Fields.Add(nf);
            }

            foreach (var m in t.Methods)
            {
                //var nm = m;
                //nm.DeclaringType = nt;
                var nm = new MethodDefinition(m.Name, m.Attributes, m.ReturnType);
                foreach (var p in m.Parameters)
                {
                    nm.Parameters.Add(new ParameterDefinition(p.Name, p.Attributes, p.ParameterType));
                }

                foreach (var a in m.CustomAttributes)
                {
                    var na = new CustomAttribute(a.Constructor, a.GetBlob());
                    nm.CustomAttributes.Add(na);
                }

                if (m.HasBody)
                {
                    CopyMethodBody(m, nm);
                }

                nt.Methods.Add(nm);
            }

            if (t.IsPointer)
            {
            }

            return(nt);
        }