Exemplo n.º 1
0
        private void ImportScriptAssembly(MetadataSource mdSource, string assemblyPath, bool coreAssembly)
        {
            string scriptName = null;

            AssemblyDefinition assembly;

            if (coreAssembly)
            {
                assembly = mdSource.CoreAssemblyMetadata;
            }
            else
            {
                assembly = mdSource.GetMetadata(assemblyPath);
            }

            string scriptNamespace = null;

            scriptName = MetadataHelpers.GetScriptAssemblyName(assembly, out string scriptIdentifier);

            if (string.IsNullOrEmpty(scriptName) == false)
            {
                ScriptReference dependency = new ScriptReference(scriptName, scriptIdentifier);

                symbols.AddDependency(dependency);
                scriptNamespace = dependency.Identifier;
            }

            foreach (TypeDefinition type in assembly.MainModule.Types)
            {
                try
                {
                    if (MetadataHelpers.IsCompilerGeneratedType(type))
                    {
                        continue;
                    }

                    ImportType(mdSource, type, coreAssembly, scriptNamespace);
                }
                catch (Exception e)
                {
                    Debug.Fail(e.ToString());
                }
            }
        }
Exemplo n.º 2
0
        private void ImportScriptAssembly(string applicationAssemblyName, MetadataSource mdSource, string assemblyPath, bool coreAssembly, bool applicationAssembly)
        {
            string scriptName = null;

            AssemblyDefinition assembly;

            if (coreAssembly)
            {
                assembly = mdSource.CoreAssemblyMetadata;
            }
            else
            {
                assembly = mdSource.GetMetadata(assemblyPath);
            }

            ScriptReference dependency = null;

            scriptName = MetadataHelpers.GetScriptAssemblyName(assembly, out string scriptIdentifier);

            if (string.IsNullOrEmpty(scriptName) == false)
            {
                dependency = ScriptReferenceProvider.Instance.GetReference(scriptName, scriptIdentifier);
                dependency.InternalesVisible = MetadataHelpers.InternalesVisibleTo(assembly).Contains(applicationAssemblyName);
                symbols.AddDependency(dependency);
            }

            foreach (TypeDefinition type in assembly.MainModule.Types)
            {
                try
                {
                    if (MetadataHelpers.IsCompilerGeneratedType(type))
                    {
                        continue;
                    }

                    ImportType(mdSource, type, inScriptCoreAssembly: coreAssembly, inApplicationAssembly: applicationAssembly, dependency: dependency);
                }
                catch (Exception e)
                {
                    Debug.Fail(e.ToString());
                }
            }
        }