コード例 #1
0
ファイル: WellKnownFeatures.cs プロジェクト: riversky/roslyn
        // find feature packs dynamically, though ideally this would bind statically when/if this is moved up a layer.
        private static FeaturePack ComputePack()
        {
            // build a MEF composition using this assembly and the known VisualBasic/CSharp workspace assemblies.
            var assemblies = new List<Assembly>();
            var thisAssembly = typeof(WellKnownFeatures).Assembly;
            assemblies.Add(thisAssembly);

            var thisAssemblyName = thisAssembly.GetName();
            var assemblyShortName = thisAssemblyName.Name;
            var assemblyVersion = thisAssemblyName.Version;
            var publicKeyToken = thisAssemblyName.GetPublicKeyToken().Aggregate(string.Empty, (s, b) => s + b.ToString("x2"));

            LoadAssembly(assemblies,
                string.Format("Microsoft.CodeAnalysis.CSharp.Workspaces, Version={0}, Culture=neutral, PublicKeyToken={1}", assemblyVersion, publicKeyToken));

            LoadAssembly(assemblies,
                string.Format("Microsoft.CodeAnalysis.VisualBasic.Workspaces, Version={0}, Culture=neutral, PublicKeyToken={1}", assemblyVersion, publicKeyToken));

            var catalogs = assemblies.Select(a => new MEF.AssemblyCatalog(a));
            var pack = new MefExportPack(catalogs);

            return pack;
        }
コード例 #2
0
        // find feature packs dynamically, though ideally this would bind statically when/if this is moved up a layer.
        private static FeaturePack ComputePack()
        {
            // build a MEF composition using this assembly and the known VisualBasic/CSharp workspace assemblies.
            var assemblies   = new List <Assembly>();
            var thisAssembly = typeof(WellKnownFeatures).Assembly;

            assemblies.Add(thisAssembly);

            var thisAssemblyName  = thisAssembly.GetName();
            var assemblyShortName = thisAssemblyName.Name;
            var assemblyVersion   = thisAssemblyName.Version;
            var publicKeyToken    = thisAssemblyName.GetPublicKeyToken().Aggregate(string.Empty, (s, b) => s + b.ToString("x2"));

            LoadAssembly(assemblies,
                         string.Format("Microsoft.CodeAnalysis.CSharp.Workspaces, Version={0}, Culture=neutral, PublicKeyToken={1}", assemblyVersion, publicKeyToken));

            LoadAssembly(assemblies,
                         string.Format("Microsoft.CodeAnalysis.VisualBasic.Workspaces, Version={0}, Culture=neutral, PublicKeyToken={1}", assemblyVersion, publicKeyToken));

            var catalogs = assemblies.Select(a => new MEF.AssemblyCatalog(a));
            var pack     = new MefExportPack(catalogs);

            return(pack);
        }
コード例 #3
0
ファイル: SolutionTests.cs プロジェクト: riversky/roslyn
        private static FeaturePack GetTestWorkspaceFeatures()
        {
            if (testWorkspaceFeatures == null)
            {
                AssemblyCatalog assemblyCatalog = new AssemblyCatalog(typeof(SolutionTests).Assembly);
                MefExportPack mefExportPack = new MefExportPack(assemblyCatalog);
                testWorkspaceFeatures = WellKnownFeatures.Features.Combine(mefExportPack);
            }

            return testWorkspaceFeatures;
        }