当前位置: 首页>>代码示例>>C#>>正文


C# Project.GetSourceSet方法代码示例

本文整理汇总了C#中Project.GetSourceSet方法的典型用法代码示例。如果您正苦于以下问题:C# Project.GetSourceSet方法的具体用法?C# Project.GetSourceSet怎么用?C# Project.GetSourceSet使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在Project的用法示例。


在下文中一共展示了Project.GetSourceSet方法的14个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。

示例1: GetSourceSetReturnsTheSameInstanceIfCalledTwice

        public void GetSourceSetReturnsTheSameInstanceIfCalledTwice()
        {
            var project = new Project("test", new Module("testmod", new Suite(new TestFileSystemDirectory("module"))));
            var set1 = project.GetSourceSet("cs");
            var set2 = project.GetSourceSet("cs");

            set1.Should().BeSameAs(set2);
        }
开发者ID:vigoo,项目名称:bari,代码行数:8,代码来源:ProjectTest.cs

示例2: CreatedSourceSetAddedToSourceSetsProperty

        public void CreatedSourceSetAddedToSourceSetsProperty()
        {
            var project = new Project("test", new Module("testmod", new Suite(new TestFileSystemDirectory("module"))));
            var set1 = project.GetSourceSet("cs");
            var set2 = project.GetSourceSet("cs");

            project.SourceSets.Should().HaveCount(1);
            project.SourceSets.Should().HaveElementAt(0, set1);
        }
开发者ID:vigoo,项目名称:bari,代码行数:9,代码来源:ProjectTest.cs

示例3: GetSourceSetCreatesSetIfMissing

        public void GetSourceSetCreatesSetIfMissing()
        {
            var project = new Project("test", new Module("testmod", new Suite(new TestFileSystemDirectory("module"))));
            var set1 = project.GetSourceSet("cs");

            set1.Should().NotBeNull();
            set1.Type.Should().Be(new SourceSetType("cs"));
        }
开发者ID:vigoo,项目名称:bari,代码行数:8,代码来源:ProjectTest.cs

示例4: DiscoverProjectSources

 /// <summary>
 /// Goes through all the subdirectories of a project and interprets them as source sets
 /// </summary>
 /// <param name="project">The project to be extended with source sets</param>
 /// <param name="projectDir">The project's directory</param>
 private void DiscoverProjectSources(Project project, IFileSystemDirectory projectDir)
 {
     foreach (var sourceSetName in projectDir.ChildDirectories)
     {
         var sourceSet = project.GetSourceSet(sourceSetName);
         AddAllFiles(sourceSet, projectDir.GetChildDirectory(sourceSetName));
     }
 }
开发者ID:zvrana,项目名称:bari,代码行数:13,代码来源:ModuleProjectDiscovery.cs

示例5: HasNonEmptySourceSetMethodWorks

        public void HasNonEmptySourceSetMethodWorks()
        {
            var project = new Project("test", new Module("testmod", new Suite(new TestFileSystemDirectory("module"))));
            var set1 = project.GetSourceSet("cs");

            project.HasNonEmptySourceSet("cs").Should().BeFalse();
            project.HasNonEmptySourceSet("vb").Should().BeFalse();

            set1.Add(new SuiteRelativePath("testfile"));

            project.HasNonEmptySourceSet("cs").Should().BeTrue();
            project.HasNonEmptySourceSet("vb").Should().BeFalse();
        }
开发者ID:vigoo,项目名称:bari,代码行数:13,代码来源:ProjectTest.cs

示例6: Run

        /// <summary>
        /// Executes the given build script on the given project, returning the set of
        /// target files the script generated.
        /// 
        /// <para>
        /// The script's global scope has the following predefined variables set:
        /// - <c>project</c> refers to the project being built
        /// - <c>sourceSet</c> is the project's source set associated with the build script
        /// - <c>targetRoot</c> is the root target directory where all the files are generated
        /// - <c>targetDir</c> is where the project's output should be built
        /// </para>
        /// <para>
        /// A special global function <c>get_tool</c> is available which accepts a reference URI and
        /// a file name. 
        /// The same protocols are supported as for references in the suite definition. The 
        /// function's return value is the absolute path of the given file, where the tool
        /// has been deployed.
        /// </para>
        /// </summary>
        /// <param name="project">The input project to build</param>
        /// <param name="buildScript">The build script to execute</param>
        /// <returns>Returns the set of files generated by the script. They have to be
        /// indicated in the script's <c>results</c> variable, relative to <c>targetDir</c>.</returns>
        public ISet<TargetRelativePath> Run(Project project, IBuildScript buildScript)
        {
            var engine = CreateEngine();
            
            var runtime = engine.Runtime;
            try
            {
                var scope = runtime.CreateScope();

                scope.SetVariable("project", project);
                scope.SetVariable("sourceSet",
                                  project.GetSourceSet(buildScript.SourceSetName)
                                         .Files.Select(srp => (string) srp)
                                         .ToList());
                AddGetToolToScope(scope, project);

                var targetDir = TargetRoot.GetChildDirectory(project.Module.Name, createIfMissing: true);
                var localTargetDir = targetDir as LocalFileSystemDirectory;
                var localTargetRoot = TargetRoot as LocalFileSystemDirectory;
                if (localTargetDir != null && localTargetRoot != null)
                {
                    scope.SetVariable("targetRoot", localTargetRoot.AbsolutePath);
                    scope.SetVariable("targetDir", localTargetDir.AbsolutePath);

                    var pco = (PythonCompilerOptions)engine.GetCompilerOptions();
                    pco.Module |= ModuleOptions.Optimized;
                    
                    var script = engine.CreateScriptSourceFromString(buildScript.Source, SourceCodeKind.File);
                    script.Compile(pco);
                    script.Execute(scope);

                    return new HashSet<TargetRelativePath>(
                        scope.GetVariable<IList<object>>("results")
                             .Cast<string>()
                             .Select(t => GetTargetRelativePath(targetDir, t)));
                }
                else
                {
                    throw new NotSupportedException("Only local file system is supported for python scripts!");
                }
            }
            finally
            {
                runtime.Shutdown();
            }
        }
开发者ID:zvrana,项目名称:bari,代码行数:69,代码来源:ProjectBuildScriptRunner.cs

示例7: GetSourceSets

 /// <summary>
 /// Gets the source sets to include 
 /// </summary>
 /// <param name="project">The project to get its source sets</param>
 /// <returns>Returns an enumeration of source sets, all belonging to the given project</returns>
 protected override IEnumerable<ISourceSet> GetSourceSets(Project project)
 {
     return new[] {project.GetSourceSet("resources")};
 }
开发者ID:zvrana,项目名称:bari,代码行数:9,代码来源:EmbeddedResourcesSection.cs

示例8: WriteAppConfig

        private void WriteAppConfig(XmlWriter writer, Project project)
        {
            // Must be called within an open PropertyGroup

            if (project.HasNonEmptySourceSet("appconfig"))
            {
                var sourceSet = project.GetSourceSet("appconfig");
                var configs = sourceSet.Files.ToList();

                if (configs.Count > 1)
                    throw new TooManyAppConfigsException(project);

                var appConfigPath = configs.FirstOrDefault();
                if (appConfigPath != null)
                {
                    writer.WriteElementString("AppConfig", ToProjectRelativePath(project, appConfigPath, "cs"));
                }
            }
        }
开发者ID:vigoo,项目名称:bari,代码行数:19,代码来源:PropertiesSection.cs

示例9: WriteManifest

        private void WriteManifest(XmlWriter writer, Project project)
        {
            // Must be called within an open PropertyGroup

            if (project.HasNonEmptySourceSet("manifest"))
            {
                var sourceSet = project.GetSourceSet("manifest");
                var manifests = sourceSet.Files.ToList();

                if (manifests.Count > 1)
                    throw new TooManyManifestsException(project);

                var manifestPath = manifests.FirstOrDefault();
                if (manifestPath != null)
                {
                    writer.WriteElementString("ApplicationManifest", ToProjectRelativePath(project, manifestPath, "cs"));
                }
            }
        }
开发者ID:vigoo,项目名称:bari,代码行数:19,代码来源:PropertiesSection.cs

示例10: Run

        /// <summary>
        /// Executes the given build script on the given project, returning the set of
        /// target files the script generated.
        /// 
        /// <para>
        /// The script's global scope has the following predefined variables set:
        /// - <c>project</c> refers to the project being built
        /// - <c>sourceSet</c> is the project's source set associated with the build script
        /// - <c>targetRoot</c> is the root target directory where all the files are generated
        /// - <c>targetDir</c> is where the project's output should be built
        /// </para>
        /// <para>
        /// A special global function <c>get_tool</c> is available which accepts a reference URI and
        /// a file name. 
        /// The same protocols are supported as for references in the suite definition. The 
        /// function's return value is the absolute path of the given file, where the tool
        /// has been deployed.
        /// </para>
        /// </summary>
        /// <param name="project">The input project to build</param>
        /// <param name="buildScript">The build script to execute</param>
        /// <returns>Returns the set of files generated by the script. They have to be
        /// indicated in the script's <c>results</c> variable, relative to <c>targetDir</c>.</returns>
        public ISet<TargetRelativePath> Run(Project project, IBuildScript buildScript)
        {
            var engine = CreateEngine();

            var runtime = engine.Runtime;
            try
            {
                var scope = runtime.CreateScope();

                scope.SetVariable("is_mono", parameters.UseMono);
                scope.SetVariable("project", project);
                scope.SetVariable("sourceSet",
                                  project.GetSourceSet(buildScript.SourceSetName)
                                         .Files.Select(srp => (string) srp)
                                         .ToList());
                AddGetToolToScope(scope, project);

                var targetDir = TargetRoot.GetChildDirectory(project.Module.Name, createIfMissing: true);
                var localTargetDir = targetDir as LocalFileSystemDirectory;
                var localTargetRoot = TargetRoot as LocalFileSystemDirectory;
                if (localTargetDir != null && localTargetRoot != null)
                {
                    scope.SetVariable("targetRoot", localTargetRoot.AbsolutePath);
                    scope.SetVariable("targetDir", localTargetDir.AbsolutePath);

                    var pco = (PythonCompilerOptions)engine.GetCompilerOptions();
                    pco.Module |= ModuleOptions.Optimized;

                    try
                    {
                        var script = engine.CreateScriptSourceFromString(buildScript.Source, SourceCodeKind.File);
                        script.Compile(pco);
                        script.Execute(scope);

                        return new HashSet<TargetRelativePath>(
                            scope.GetVariable<IList<object>>("results")
                                .Cast<string>()
                                .Select(t => GetTargetRelativePath(targetDir, t)));
                    }
                    catch (Exception ex)
                    {
                        var eo = engine.GetService<ExceptionOperations>();

                        string msg, typeName;
                        eo.GetExceptionMessage(ex, out msg, out typeName);

                        foreach (var line in msg.Split(new[] { '\n', '\r' }, StringSplitOptions.RemoveEmptyEntries))
                        {
                            output.Error(line);
                        }

                        output.Error("Call stack:");
                        foreach (var frame in eo.GetStackFrames(ex))
                        {
                            var line = frame.GetFileLineNumber();
                            var method = frame.GetMethodName();

                            output.Error(String.Format("Line {0} in {1}", line, method));
                        }

                        throw new ScriptException(buildScript);
                    }
                }
                else
                {
                    throw new NotSupportedException("Only local file system is supported for python scripts!");
                }
            }
            finally
            {
                runtime.Shutdown();
            }
        }
开发者ID:vigoo,项目名称:bari,代码行数:96,代码来源:ProjectBuildScriptRunner.cs

示例11: WriteCompilerParameters

        private void WriteCompilerParameters(XmlWriter writer, Project project)
        {
            VCppProjectCompilerParameters compilerParameters = project.HasParameters("cpp-compiler")
                                                                   ? project.GetParameters<VCppProjectCompilerParameters>("cpp-compiler")
                                                                   : new VCppProjectCompilerParameters(Suite);

            compilerParameters.FillProjectSpecificMissingInfo(project, GetCLIMode(project), targetDir as LocalFileSystemDirectory);

            writer.WriteStartElement("ClCompile");
            compilerParameters.ToVcxprojProperties(writer);

            if (project.GetSourceSet("cpp").Files.Any(file => Path.GetFileName(file) == "stdafx.cpp"))
                writer.WriteElementString("PrecompiledHeader", "Use");

            writer.WriteEndElement();
        }
开发者ID:zvrana,项目名称:bari,代码行数:16,代码来源:PropertiesSection.cs

示例12: FillProjectSpecificMissingInfo

        public void FillProjectSpecificMissingInfo(Project project)
        {
            if (RootNamespace == null)
                RootNamespace = project.Name;

            if (project.HasNonEmptySourceSet("resources"))
            {
                var resources = project.GetSourceSet("resources");
                var icons = resources.Files.Where(p => Path.GetExtension(p) == ".ico").ToList();

                if (icons.Count == 1 && ApplicationIcon == null)
                {
                    ApplicationIcon = project.Module.Suite.SuiteRoot.GetRelativePathFrom(project.RootDirectory.GetChildDirectory("resources"), icons[0]);
                }
            }
        }
开发者ID:zvrana,项目名称:bari,代码行数:16,代码来源:CsharpProjectParameters.cs

示例13: GetSourceSets

 /// <summary>
 /// Gets the source sets to include 
 /// </summary>
 /// <param name="project">The project to get its source sets</param>
 /// <returns>Returns an enumeration of source sets, all belonging to the given project</returns>
 protected override IEnumerable<ISourceSet> GetSourceSets(Project project)
 {
     return new[] { project.GetSourceSet("cpp").FilterCppSourceSet(project.RootDirectory.GetChildDirectory("cpp"), suiteRoot) };
 }
开发者ID:vigoo,项目名称:bari,代码行数:9,代码来源:SourceItemsSection.cs

示例14: DiscoverProjectSources

 /// <summary>
 /// Goes through all the subdirectories of a project and interprets them as source sets
 /// </summary>
 /// <param name="project">The project to be extended with source sets</param>
 /// <param name="projectDir">The project's directory</param>
 /// <param name="ignoreLists">The suite's source set ignore lists</param>
 private void DiscoverProjectSources(Project project, IFileSystemDirectory projectDir, SourceSetIgnoreLists ignoreLists)
 {
     foreach (var sourceSetName in projectDir.ChildDirectories)
     {
         var sourceSet = project.GetSourceSet(sourceSetName);
         AddAllFiles(sourceSet, projectDir.GetChildDirectory(sourceSetName), ignoreLists.Get(new SourceSetType(sourceSetName)));
     }
 }
开发者ID:vigoo,项目名称:bari,代码行数:14,代码来源:ModuleProjectDiscovery.cs


注:本文中的Project.GetSourceSet方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。