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


C# Results.AddRange方法代码示例

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


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

示例1: EverythingSimulationTest

        public void EverythingSimulationTest()
        {
            Stream everythingConfigStream = Assembly.GetExecutingAssembly().GetManifestResourceStream(
                "RemoteInstallUnitTests.TestConfigs.Everything.config");

            string configFileName = Path.GetTempFileName();

            using (StreamReader everythingConfigReader = new StreamReader(everythingConfigStream))
            {
                File.WriteAllText(configFileName, everythingConfigReader.ReadToEnd());
            }

            Stream everythingXmlStream = Assembly.GetExecutingAssembly().GetManifestResourceStream(
                "RemoteInstallUnitTests.TestConfigs.EverythingTask.xml");

            using (StreamReader everythingXmlReader = new StreamReader(everythingXmlStream))
            {
                File.WriteAllText(Path.Combine(Path.GetDirectoryName(configFileName), "EverythingTask.xml"),
                    everythingXmlReader.ReadToEnd());
            }

            string outputDir = Path.Combine(Path.GetTempPath(), Guid.NewGuid().ToString());
            Directory.CreateDirectory(outputDir);

            NameValueCollection vars = new NameValueCollection();
            vars["root"] = @"..\..\..\..";

            Driver driver = new Driver(
                outputDir,
                true,
                configFileName,
                vars,
                1);

            // save results
            Results results = new Results();
            results.AddRange(driver.Run());
            string xmlFileName = Path.Combine(outputDir, "Results.xml");
            new ResultCollectionXmlWriter().Write(results, xmlFileName);
            // make sure results is a valid xml document with a number of results
            XmlDocument xmlResults = new XmlDocument();
            xmlResults.Load(xmlFileName);
            Assert.AreEqual(1, xmlResults.SelectNodes("/remoteinstallresultsgroups").Count);
            // reload the xml results
            Results resultsCopy = new Results();
            resultsCopy.Load(xmlResults);
            Assert.AreEqual(1, resultsCopy.GetXml().SelectNodes("/remoteinstallresultsgroups").Count);
            Directory.Delete(outputDir, true);
            File.Delete(configFileName);
        }
开发者ID:blinds52,项目名称:remoteinstall,代码行数:50,代码来源:ConfigUnitTests.cs

示例2: Process

        public override void Process(HttpContext context)
        {
            string query = context.Request.QueryString["q"];
            if (query == null)
                return;

            // Look for special searches
            if (SpecialSearches.ContainsKey(query))
            {
                string path = SpecialSearches[query];

                if (context.Request.QueryString["jsonp"] != null)
                {
                    // TODO: Does this include the JSONP headers?
                    SendFile(context, JsonConstants.MediaType, path);
                    return;
                }

                if (Accepts(context, JsonConstants.MediaType))
                {
                    SendFile(context, JsonConstants.MediaType, path);
                    return;
                }
                return;
            }

            //
            // Do the search
            //
            ResourceManager resourceManager = new ResourceManager(context.Server, context.Cache);
            SectorMap map = SectorMap.FromName(SectorMap.DefaultSetting, resourceManager);

            query = query.Replace('*', '%'); // Support * and % as wildcards
            query = query.Replace('?', '_'); // Support ? and _ as wildcards

            if (UWP_REGEXP.IsMatch(query))
                query = "uwp:" + query;

            const int NUM_RESULTS = 160;

            var searchResults = SearchEngine.PerformSearch(query, resourceManager, SearchEngine.SearchResultsType.Default, NUM_RESULTS);

            Results resultsList = new Results();

            if (searchResults != null)
            {
                resultsList.AddRange(searchResults
                    .Select(loc => Results.LocationToSearchResult(map, resourceManager, loc))
                    .OfType<Results.SearchResultItem>()
                    .OrderByDescending(item => item.Importance)
                    .Take(NUM_RESULTS));
            }

            SendResult(context, resultsList);
        }
开发者ID:Matt--,项目名称:travellermap,代码行数:55,代码来源:SearchHandler.cs

示例3: GetResultsFromUAProf

 /// <summary>
 /// Returns all the devices that match the UA prof provided.
 /// </summary>
 /// <param name="uaprof">UA prof to search for.</param>
 /// <returns>Results containing all the matching devices.</returns>
 internal Results GetResultsFromUAProf(string uaprof)
 {
     BaseDeviceInfo[] devices = GetDeviceInfo(_uaprofs, uaprof);
     if (devices != null && devices.Length > 0)
     {
         // Add the devices to the list of results and return.
         Results results = new Results();
         results.AddRange(devices);
         return results;
     }
     return null;
 }
开发者ID:davelondon,项目名称:dontstayin,代码行数:17,代码来源:Handler.cs

示例4: Exec

        public override void Exec()
        {
            UIHierarchy solExplorer = this.ApplicationObject.ToolWindows.SolutionExplorer;
            if (((System.Array)solExplorer.SelectedItems).Length != 1)
                return;

            UIHierarchyItem hierItem = ((UIHierarchyItem)((System.Array)solExplorer.SelectedItems).GetValue(0));
            ProjectItem pi = (ProjectItem)hierItem.Object;

            Window w = pi.Open(BIDSViewKinds.Designer); //opens the designer
            w.Activate();

            IDesignerHost designer = w.Object as IDesignerHost;
            if (designer == null) return;
            EditorWindow win = (EditorWindow)designer.GetService(typeof(Microsoft.DataWarehouse.ComponentModel.IComponentNavigator));
            Package package = win.PropertiesLinkComponent as Package;
            if (package == null) return;

            Results results = new Results();

            foreach (DesignPractice practice in _practices)
            {
                if (!practice.Enabled) continue;
                practice.Check(package, pi);
                results.AddRange(practice.Results);
            }

            AddErrorsToVSErrorList(w, results);
        }
开发者ID:sgtgold,项目名称:bids-helper-extension,代码行数:29,代码来源:DesignPracticesPlugin.cs

示例5: SimulateAllMsiSequencesTest

        public void SimulateAllMsiSequencesTest()
        {
            Stream sequencesConfigStream = Assembly.GetExecutingAssembly().GetManifestResourceStream(
                "RemoteInstallUnitTests.TestConfigs.MsiSequences.config");

            string configFileName = Path.GetTempFileName();
            using (StreamReader sequencesConfigReader = new StreamReader(sequencesConfigStream))
            {
                File.WriteAllText(configFileName, sequencesConfigReader.ReadToEnd());
            }

            string outputDir = Path.Combine(Path.GetTempPath(), Guid.NewGuid().ToString());
            Directory.CreateDirectory(outputDir);

            foreach (InstallersSequence sequence in Enum.GetValues(typeof(InstallersSequence)))
            {
                Console.WriteLine("Sequence: {0}", sequence);
                NameValueCollection vars = new NameValueCollection();
                vars["root"] = @"..\..\..\..";
                vars["sequence"] = sequence.ToString();

                Driver driver = new Driver(
                    outputDir,
                    true,
                    configFileName,
                    vars,
                    1);

                Results results = new Results();
                results.AddRange(driver.Run());

                switch (sequence)
                {
                    case InstallersSequence.clean:
                        // a clean sequence is like 2 separate, clean installations
                        Assert.AreEqual(2, results.Count);
                        Assert.AreEqual(1, results[0].Count);
                        Assert.AreEqual(1, results[1].Count);
                        break;
                    case InstallersSequence.alternate:
                    case InstallersSequence.install:
                    case InstallersSequence.uninstall:
                        // two installers alternating with install+uninstall in the same run
                        // or just install or uninstall
                        Assert.AreEqual(1, results.Count);
                        Assert.AreEqual(2, results[0].Count);
                        break;
                    default:
                        // two installers split into install+uninstall in a sequence of 4
                        Assert.AreEqual(1, results.Count);
                        Assert.AreEqual(4, results[0].Count);
                        break;
                }
            }

            Directory.Delete(outputDir, true);
            File.Delete(configFileName);
        }
开发者ID:blinds52,项目名称:remoteinstall,代码行数:58,代码来源:SequencesUnitTest.cs

示例6: GetDeviceInfo

        /// <summary>
        /// Use the HttpRequest fields to determine the closest matching device
        /// from the handlers provided.
        /// </summary>
        /// <param name="request">HttpRequest object.</param>
        /// <param name="handlers">Handlers capable of finding devices for the request.</param>
        /// <returns>The closest matching device or null if one can't be found.</returns>
        private static DeviceInfo GetDeviceInfo(HttpRequest request, Handler[] handlers)
        {
            DeviceInfo device = null;
            Results results = new Results();

            #if VER4
            foreach (Results temp in handlers.Select(t => t.Match(request)).Where(temp => temp != null))
            {
                results.AddRange(temp);
            }
            #elif VER2
            for (int i = 0; i < handlers.Length; i++)
            {
                // Find the closest matching devices.
                Results temp = handlers[i].Match(request);
                // If some results have been found.
                if (temp != null)
                    // Combine the results with results from previous
                    // handlers.
                    results.AddRange(temp);
            }
            #endif
            if (results.Count == 1)
            {
                // Use the only result provided.
                device = results[0].Device;
            }
            else if (results.Count > 1)
            {
                // Uses the matcher to narrow down the results.
                device = Matcher.Match(GetUserAgent(request), results);
            }
            if (device == null)
                // No device was found so use the default device for the first
                // handler provided.
                device = handlers[0].DefaultDevice;
            return device;
        }
开发者ID:irobinson,项目名称:51DegreesDNN,代码行数:45,代码来源:Provider.cs

示例7: Page_Load

        private void Page_Load(object sender, System.EventArgs e)
        {
            if (!ServiceConfiguration.CheckEnabled("search", Response))
            {
                return;
            }

            string query = Request.QueryString["q"];
            if (query == null)
                return;

            // Look for special searches
            var index = Array.FindIndex(SpecialSearchTerms, s => String.Compare(s, query, ignoreCase: true, culture: CultureInfo.InvariantCulture) == 0);
            if (index != -1)
            {
                if (Request.QueryString["jsonp"] != null)
                {
                    // TODO: Does this include the JSONP headers?
                    SendFile(JsonConstants.MediaType, SpecialSearchResultsJson[index]);
                    return;
                }

                foreach (var type in AcceptTypes)
                {
                    if (type == JsonConstants.MediaType)
                    {
                        SendFile(JsonConstants.MediaType, SpecialSearchResultsJson[index]);
                        return;
                    }
                    if (type == MediaTypeNames.Text.Xml)
                    {
                        SendFile(MediaTypeNames.Text.Xml, SpecialSearchResultsXml[index]);
                        return;
                    }
                }
                SendFile(MediaTypeNames.Text.Xml, SpecialSearchResultsXml[index]);
                return;
            }

            //
            // Do the search
            //
            ResourceManager resourceManager = new ResourceManager(Server, Cache);
            SectorMap map = SectorMap.FromName(SectorMap.DefaultSetting, resourceManager);

            query = query.Replace('*', '%'); // Support * and % as wildcards
            query = query.Replace('?', '_'); // Support ? and _ as wildcards

            if (UWP_REGEXP.IsMatch(query))
            {
                query = "uwp:" + query;
            }

            var searchResults = SearchEngine.PerformSearch(query, resourceManager, SearchEngine.SearchResultsType.Default, 160);

            Results resultsList = new Results();

            if (searchResults != null)
            {
                resultsList.AddRange(searchResults
                    .Select(loc => Results.LocationToSearchResult(map, resourceManager, loc))
                    .OfType<Results.SearchResultItem>());
            }

            SendResult(resultsList);
        }
开发者ID:robertsconley,项目名称:travellermap,代码行数:66,代码来源:Search.aspx.cs

示例8: SnapshotsWithParametersTest

        public void SnapshotsWithParametersTest()
        {
            Stream configStream = Assembly.GetExecutingAssembly().GetManifestResourceStream(
                "RemoteInstallUnitTests.TestConfigs.SnapshotWithParameters.config");
            string configFileName = Path.GetTempFileName();

            using (StreamReader sr = new StreamReader(configStream))
            {
                File.WriteAllText(configFileName, sr.ReadToEnd());
            }

            string outputDir = Path.Combine(Path.GetTempPath(), Guid.NewGuid().ToString());
            Directory.CreateDirectory(outputDir);

            try
            {
                Driver driver = new Driver(outputDir, true, configFileName, null, 0);
                Results results = new Results();
                results.AddRange(driver.Run());
                // four individual results
                Assert.AreEqual(4, results.Count);
                foreach (ResultsGroup group in results)
                {
                    Console.WriteLine("{0}: {1}", group.Vm, group.Snapshot);
                    foreach(Result result in group)
                    {
                        // installer name is defined as name="@{snapshot.installargs}"
                        // and each installargs is vm.snapshot
                        Assert.AreEqual(string.Format("{0}.{1}", group.Vm, group.Snapshot),
                            result.InstallerName);
                    }
                }
            }
            finally
            {
                Directory.Delete(outputDir, true);
                File.Delete(configFileName);
            }
        }
开发者ID:blinds52,项目名称:remoteinstall,代码行数:39,代码来源:ConfigUnitTests.cs

示例9: NothingToDoTest

        public void NothingToDoTest()
        {
            Stream configStream = Assembly.GetExecutingAssembly().GetManifestResourceStream(
                "RemoteInstallUnitTests.TestConfigs.NothingToDo.config");
            string configFileName = Path.GetTempFileName();

            using (StreamReader sr = new StreamReader(configStream))
            {
                File.WriteAllText(configFileName, sr.ReadToEnd());
            }

            string outputDir = Path.Combine(Path.GetTempPath(), Guid.NewGuid().ToString());
            Directory.CreateDirectory(outputDir);

            try
            {
                Driver driver = new Driver(outputDir, true, configFileName, null, 0);
                Results results = new Results();
                results.AddRange(driver.Run());
                Assert.Fail("Expected InvalidConfigurationException");
            }
            catch (InvalidConfigurationException ex)
            {
                Console.WriteLine("Expected exception: {0}", ex.Message);
            }
            finally
            {
                Directory.Delete(outputDir, true);
                File.Delete(configFileName);
            }
        }
开发者ID:blinds52,项目名称:remoteinstall,代码行数:31,代码来源:ConfigUnitTests.cs


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