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


C# Collection类代码示例

本文整理汇总了C#中Collection的典型用法代码示例。如果您正苦于以下问题:C# Collection类的具体用法?C# Collection怎么用?C# Collection使用的例子?那么, 这里精选的类代码示例或许可以为您提供帮助。


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

示例1: ConnectControlViewModel_AddNewServer_ResourceRepositoryReturnExistingServers_False

 public void ConnectControlViewModel_AddNewServer_ResourceRepositoryReturnExistingServers_False()
 {
     //------------Setup for test--------------------------
     var mainViewModel = new Mock<IMainViewModel>();
     var connectControlSingleton = new Mock<IConnectControlSingleton>();
     var env1 = new TestEnvironmentModel(new Mock<IEventAggregator>().Object, Guid.NewGuid(), CreateConnection(true, false).Object, new Mock<IResourceRepository>().Object, false);
     var env2 = new TestEnvironmentModel(new Mock<IEventAggregator>().Object, Guid.NewGuid(), CreateConnection(true, false).Object, new Mock<IResourceRepository>().Object, false);
     var connectControlEnvironments = new ObservableCollection<IConnectControlEnvironment>();
     var controEnv1 = new Mock<IConnectControlEnvironment>();
     var controEnv2 = new Mock<IConnectControlEnvironment>();
     controEnv1.Setup(c => c.EnvironmentModel).Returns(env1);
     controEnv2.Setup(c => c.EnvironmentModel).Returns(env2);
     controEnv1.Setup(c => c.IsConnected).Returns(true);
     connectControlEnvironments.Add(controEnv2.Object);
     connectControlEnvironments.Add(controEnv1.Object);
     connectControlSingleton.Setup(c => c.Servers).Returns(connectControlEnvironments);
     var environmentRepository = new Mock<IEnvironmentRepository>();
     ICollection<IEnvironmentModel> environments = new Collection<IEnvironmentModel>
         {
             env1
         };
     environmentRepository.Setup(e => e.All()).Returns(environments);
     var viewModel = new ConnectControlViewModel(mainViewModel.Object, environmentRepository.Object, e => { }, connectControlSingleton.Object, "TEST : ", false);
     //------------Execution-------------------------------
     int serverIndex;
     var didAddNew = viewModel.AddNewServer(out serverIndex, i => { });
     //------------Assert----------------------------------
     Assert.IsNotNull(viewModel);
     Assert.IsFalse(didAddNew);
 }
开发者ID:Robin--,项目名称:Warewolf,代码行数:30,代码来源:ConnectControlViewModelTests.cs

示例2: Table_Should_Contain_GroupFooter

		public void Table_Should_Contain_GroupFooter()
		{
			ICSharpCode.Reports.Core.BaseTableItem table = CreateContainer();
			//GroupFooter
			var c =  new Collection<ICSharpCode.Reports.Core.GroupFooter>(table.Items.OfType<ICSharpCode.Reports.Core.GroupFooter>().ToList());
			Assert.That(c.Count,Is.GreaterThanOrEqualTo(1));
		}
开发者ID:hpsa,项目名称:SharpDevelop,代码行数:7,代码来源:GenerateTableWithGrouping.cs

示例3: TryValidateEntity

		/// <summary>
		///     Validates a Entity
		/// </summary>
		/// <exception cref="ValidationException"></exception>
		public Tuple<bool, ICollection<ValidationResult>> TryValidateEntity(object instance)
		{
			var context = new ValidationContext(instance);
			var result = new Collection<ValidationResult>();
			var success = Validator.TryValidateObject(instance, context, result);
			return new Tuple<bool, ICollection<ValidationResult>>(success, result);
		}
开发者ID:JPVenson,项目名称:DataAccess,代码行数:11,代码来源:DbAccessLayerValidation.cs

示例4: CompileTest

		public void CompileTest()
		{
			var messages = new Collection<Tuple<string, int>>
			{
				new Tuple<string, int>("aaaaa", 200),
				new Tuple<string, int>("bbbbb", 200),
				new Tuple<string, int>("ccccc", 200),
				new Tuple<string, int>("ddddd", 200),
				new Tuple<string, int>("eeeee", 700),
				new Tuple<string, int>("fffff", 5000),
				new Tuple<string, int>("ggggg", 10000),
				new Tuple<string, int>("hhhhh", 100)
			};

			//using (var compiler = new ReentrantTask<string, bool>(500, Execute))
			//{
			//	foreach (var message in messages)
			//	{
			//		Thread.Sleep(message.Item2);
			//		compiler.StartNew(message.Item1);
			//	}
			//}

			Assert.Inconclusive();
		}
开发者ID:toolmagic,项目名称:RepeatableTask,代码行数:25,代码来源:CompileTaskTestSuite.cs

示例5: TaskList

 public TaskList()
 {
     PartitionKey = string.Empty;
     RowKey = string.Empty;
     Notes = new Collection<Note>();
     Share = new Collection<User>();
 }
开发者ID:luismdcp,项目名称:PROMPT11-10-CloudComputing,代码行数:7,代码来源:TaskList.cs

示例6: environmentTypes_Serialisation

        public void environmentTypes_Serialisation()
        {
            environmentType environmentType1;

            using (FileStream xmlStream = File.OpenRead(environmentXmlFile))
            {
                environmentType1 = SerialiserFactory.GetXmlSerialiser<environmentType>().Deserialise(xmlStream);
            }

            Assert.AreEqual(environmentType1.sessionToken, "2e5dd3ca282fc8ddb3d08dcacc407e8a", true, "Session token does not match.");

            environmentType environmentType2;

            using (FileStream xmlStream = File.OpenRead(environmentXmlFile))
            {
                environmentType2 = SerialiserFactory.GetXmlSerialiser<environmentType>().Deserialise(xmlStream);
            }

            Assert.AreEqual(environmentType2.sessionToken, "2e5dd3ca282fc8ddb3d08dcacc407e8a", true, "Session token does not match.");

            ICollection<environmentType> environmentTypes = new Collection<environmentType>
            {
                environmentType1,
                environmentType2
            };

            string xmlString = SerialiserFactory.GetXmlSerialiser<Collection<environmentType>>(new XmlRootAttribute("environments")).Serialise((Collection<environmentType>)environmentTypes);
            System.Console.WriteLine(xmlString);

            environmentTypes = SerialiserFactory.GetXmlSerialiser<Collection<environmentType>>(new XmlRootAttribute("environments")).Deserialise(xmlString);
            System.Console.WriteLine("Number deserialised is " + environmentTypes.Count);
        }
开发者ID:renier-venter,项目名称:Sif3Framework-dotNet,代码行数:32,代码来源:SerialisationUtilsTest.cs

示例7: GetSelectedValues

        private Collection<string> GetSelectedValues()
        {
            string selectedValues = this.selectedValuesHidden.Value;

            //Check if something was selected.
            if (string.IsNullOrWhiteSpace(selectedValues))
            {
                return new Collection<string>();
            }

            //Create a collection object to store the IDs.
            Collection<string> values = new Collection<string>();

            //Iterate through each value in the selected values
            //and determine if each value is a number.
            foreach (string value in selectedValues.Split(','))
            {
                //Parse the value to integer.
                int val = Conversion.TryCastInteger(value);

                if (val > 0)
                {
                    values.Add(value);
                }
            }

            return values;
        }
开发者ID:JonathanValle,项目名称:mixerp,代码行数:28,代码来源:SelectedValues.cs

示例8: GetMenuCollection

        public static Collection<MixERP.Net.Common.Models.Core.Menu> GetMenuCollection(int parentMenuId, short level)
        {
            Collection<MixERP.Net.Common.Models.Core.Menu> collection = new Collection<Common.Models.Core.Menu>();

            int userId = MixERP.Net.BusinessLayer.Helpers.SessionHelper.GetUserId();
            int officeId = MixERP.Net.BusinessLayer.Helpers.SessionHelper.GetOfficeId();
            string culture = MixERP.Net.BusinessLayer.Helpers.SessionHelper.GetCulture().TwoLetterISOLanguageName;

            using (DataTable table = MixERP.Net.DatabaseLayer.Core.Menu.GetMenuTable(parentMenuId, level, userId, officeId, culture))
            {
                if (table == null)
                {
                    return null;
                }

                foreach (DataRow row in table.Rows)
                {
                    MixERP.Net.Common.Models.Core.Menu model = new Common.Models.Core.Menu();

                    model.MenuId = Conversion.TryCastInteger(row["menu_id"]);
                    model.MenuText = Conversion.TryCastString(row["menu_text"]);
                    model.Url = Conversion.ResolveUrl(Conversion.TryCastString(row["url"]));
                    model.MenuCode = Conversion.TryCastString(row["menu_code"]);
                    model.Level = Conversion.TryCastInteger(row["level"]);
                    model.ParentMenuId = Conversion.TryCastInteger(row["parent_menu_id"]);

                    collection.Add(model);
                }
            }

            return collection;
        }
开发者ID:n4gava,项目名称:mixerp,代码行数:32,代码来源:Menu.cs

示例9: ObjectCommentRepository

        /// <summary>
        /// Default constructur
        /// </summary>
        public ObjectCommentRepository()
        {
            _comments = new Collection<CommentEntity>();

            Random rand = new Random();
            for (long i = 1; i < Repository.UserPostRepositoryInstance.GetCount(); i++)
            {
                // random count of comments for post
                for (int j = 1; j < rand.Next(1, 100); j++)
                {
                    if (Repository.UserPostRepositoryInstance.IsExists(i))
                    {
                        CommentEntity comment = new CommentEntity();
                        comment.Id = identityIdCounter++;
                        comment.CreatedUTC = DateTime.Now;
                        comment.PostId = i;
                        comment.UserId = Repository.UserPostRepositoryInstance.Get(i).AuthorUserId;
                        comment.Message = "";
                        for (int k = 0; k < rand.Next(1, 10); k++)
                            comment.Message += "Nice post!";

                        _comments.Add(comment);
                    }
                }
            }
        }
开发者ID:wishlist2012,项目名称:WishList,代码行数:29,代码来源:ObjectCommentRepository.cs

示例10: CalculateBolingerBand

 public CalculateBolingerBand(Collection<StockData> UpperBolinger, Collection<StockData> LowerBolinger, Collection<DataClass> priceList , Collection<StockData> movingAvrage)
 {
     this.UpperBolinger = UpperBolinger;
     this.LowerBolinger = LowerBolinger;
     this.priceList = priceList;
     this.movingAvrage = movingAvrage;
 }
开发者ID:JoelNordh,项目名称:StockApplication,代码行数:7,代码来源:CalculateBolingerBand.cs

示例11: CreatureSpawns

        public string CreatureSpawns()
        {
            if (!_stuffing.Objects.Any(wowObject => wowObject.Value.Type == ObjectType.Unit))
                return string.Empty;

            var units = _stuffing.Objects.Where(x => x.Value.Type == ObjectType.Unit);

            const string tableName = "creature";

            ICollection<Tuple<uint, uint>> keys = new Collection<Tuple<uint, uint>>();
            var rows = new List<QueryBuilder.SQLInsertRow>();
            foreach (var unit in units)
            {
                var row = new QueryBuilder.SQLInsertRow();

                var creature = unit.Value;

                if (Settings.AreaFilters.Length > 0)
                    if (!(creature.Area.ToString(CultureInfo.InvariantCulture).MatchesFilters(Settings.AreaFilters)))
                        continue;

                // If our unit got any of the folowing updated fields set,
                // it's probably a temporary spawn
                UpdateField uf;
                creature.UpdateFields.TryGetValue(UpdateFields.GetUpdateField(UnitField.UNIT_FIELD_SUMMONEDBY), out uf);
                creature.UpdateFields.TryGetValue(UpdateFields.GetUpdateField(UnitField.UNIT_CREATED_BY_SPELL), out uf);
                creature.UpdateFields.TryGetValue(UpdateFields.GetUpdateField(UnitField.UNIT_FIELD_CREATEDBY), out uf);
                var temporarySpawn = (uf != null && uf.Int32Value != 0);
                row.CommentOut = temporarySpawn;

                // If map is Eastern Kingdoms, Kalimdor, Outland, Northrend or Ebon Hold use a lower respawn time
                // TODO: Rank and if npc is needed for quest kill should change spawntime as well
                var spawnTimeSecs = (unit.Value.Map == 0 || unit.Value.Map == 1 || unit.Value.Map == 530 ||
                                     unit.Value.Map == 571 || unit.Value.Map == 609) ? 120 : 7200;
                var movementType = 0; // TODO: Find a way to check if our unit got random movement
                var spawnDist = (movementType == 1) ? 5 : 0;

                row.AddValue("guid", unit.Key.GetLow());
                row.AddValue("id", unit.Key.GetEntry());
                row.AddValue("map", creature.Map);
                row.AddValue("spawnMask", 1);
                row.AddValue("phaseMask", creature.PhaseMask);
                row.AddValue("position_x", creature.Movement.Position.X);
                row.AddValue("position_y", creature.Movement.Position.Y);
                row.AddValue("position_z", creature.Movement.Position.Z);
                row.AddValue("orientation", creature.Movement.Orientation);
                row.AddValue("spawntimesecs", spawnTimeSecs);
                row.AddValue("spawndist", spawnDist);
                row.AddValue("MovementType", movementType);
                row.Comment = StoreGetters.GetName(StoreNameType.Unit, (int) unit.Key.GetEntry(), false);
                row.Comment += " (Area: " + StoreGetters.GetName(StoreNameType.Area, creature.Area, false) + ")";
                if (temporarySpawn)
                    row.Comment += " - !!! might be temporary spawn !!!";

                rows.Add(row);
                keys.Add(new Tuple<uint, uint>((uint) unit.Key.GetLow(), unit.Key.GetEntry()));
            }

            return new QueryBuilder.SQLInsert(tableName, keys, new[] { "guid", "id" }, rows).Build();
        }
开发者ID:LegacyCorporation,项目名称:LegacyPacketParser,代码行数:60,代码来源:Builder.cs

示例12: BindParameters

 internal override Collection<CommandParameterInternal> BindParameters(Collection<CommandParameterInternal> arguments)
 {
     Collection<CommandParameterInternal> collection = new Collection<CommandParameterInternal>();
     foreach (CommandParameterInternal internal2 in arguments)
     {
         if (!internal2.ParameterNameSpecified)
         {
             collection.Add(internal2);
         }
         else
         {
             MergedCompiledCommandParameter parameter = base.BindableParameters.GetMatchingParameter(internal2.ParameterName, false, true, new InvocationInfo(base.InvocationInfo.MyCommand, internal2.ParameterExtent));
             if (parameter != null)
             {
                 if (base.BoundParameters.ContainsKey(parameter.Parameter.Name))
                 {
                     ParameterBindingException exception = new ParameterBindingException(ErrorCategory.InvalidArgument, base.InvocationInfo, base.GetParameterErrorExtent(internal2), internal2.ParameterName, null, null, "ParameterBinderStrings", "ParameterAlreadyBound", new object[0]);
                     throw exception;
                 }
                 this.BindParameter(int.MaxValue, internal2, parameter, ParameterBindingFlags.ShouldCoerceType);
             }
             else if (internal2.ParameterName.Equals("-%", StringComparison.Ordinal))
             {
                 base.DefaultParameterBinder.CommandLineParameters.SetImplicitUsingParameters(internal2.ArgumentValue);
             }
             else
             {
                 collection.Add(internal2);
             }
         }
     }
     return collection;
 }
开发者ID:nickchal,项目名称:pash,代码行数:33,代码来源:ScriptParameterBinderController.cs

示例13: GetParameters

        public static Collection<KeyValuePair<string, string>> GetParameters(string reportPath)
        {
            if(!File.Exists(reportPath))
            {
                return null;
            }

            Collection<KeyValuePair<string, string>> parameterCollection = new Collection<KeyValuePair<string, string>>();
            XmlNodeList dataSources = XmlHelper.GetNodes(reportPath, "//DataSource");

            foreach(XmlNode datasource in dataSources)
            {
                foreach(XmlNode parameters in datasource.ChildNodes)
                {
                    if(parameters.Name.Equals("Parameters"))
                    {
                        foreach(XmlNode parameter in parameters.ChildNodes)
                        {
                            if(parameter.Attributes != null && !KeyExists(parameter.Attributes["Name"].Value, parameterCollection))
                            {
                                parameterCollection.Add(new KeyValuePair<string, string>(parameter.Attributes["Name"].Value, parameter.Attributes["Type"].Value));
                            }
                        }
                    }
                }
            }

            return parameterCollection;
        }
开发者ID:kevinhuo88888,项目名称:mixerp,代码行数:29,代码来源:ParameterHelper.cs

示例14: ExploreRouteControllers

        private void ExploreRouteControllers(IDictionary<string, HttpControllerDescriptor> controllerMappings, IHttpRoute route, Collection<ApiDescription> apiDescriptions)
        {
            string routeTemplate = route.RouteTemplate;
            object controllerVariableValue;
            if (_controllerVariableRegex.IsMatch(routeTemplate))
            {
                // unbound controller variable, {controller}
                foreach (KeyValuePair<string, HttpControllerDescriptor> controllerMapping in controllerMappings)
                {
                    controllerVariableValue = controllerMapping.Key;
                    HttpControllerDescriptor controllerDescriptor = controllerMapping.Value;

                    if (DefaultExplorer.ShouldExploreController(controllerVariableValue.ToString(), controllerDescriptor, route))
                    {
                        // expand {controller} variable
                        string expandedRouteTemplate = _controllerVariableRegex.Replace(routeTemplate, controllerVariableValue.ToString());
                        ExploreRouteActions(route, expandedRouteTemplate, controllerDescriptor, apiDescriptions);
                    }
                }
            }
            else
            {
                // bound controller variable, {controller = "controllerName"}
                if (route.Defaults.TryGetValue(ControllerVariableName, out controllerVariableValue))
                {
                    HttpControllerDescriptor controllerDescriptor;
                    if (controllerMappings.TryGetValue(controllerVariableValue.ToString(), out controllerDescriptor) && DefaultExplorer.ShouldExploreController(controllerVariableValue.ToString(), controllerDescriptor, route))
                    {
                        ExploreRouteActions(route, routeTemplate, controllerDescriptor, apiDescriptions);
                    }
                }
            }
        }
开发者ID:davidsavagejr,项目名称:SDammann.WebApi.Versioning,代码行数:33,代码来源:VersionedApiExplorer.cs

示例15: GetFilesToRename_WithValidFiles_ReturnsFileMetaDatasForMatchingFiles

        public void GetFilesToRename_WithValidFiles_ReturnsFileMetaDatasForMatchingFiles()
        {
            // Assert
            var fileNames = new List<string>
            {
                @".\Resources\2013_05_10_00_00_00.pdf",
                @"Resources\2014_06_10_15_10_58.pdf",
                @"Resources\2013_05_01.pdf"
            };

            var pdfInfos = new Collection<PdfInfo>
            {
                new PdfInfo("My Bank", @"C:\Temp", "mybank.com",
                    @"\d{1,2}(?:st|nd|rd|th)\s[A-Z,a-z]{3}\s20\d{2}\sto\s(?<day>\d{1,2})(?:st|nd|rd|th)\s(?<month>[A-Z,a-z]{3})\s(?<year>20\d{2})"),
                new PdfInfo("Bank2 Credit Card", @"C:\Temp", "67904567",
                    @"Statement:\s\d{1,2}\s[A-Z,a-z]+?\sto\s(?<day>\d{1,2})\s(?<month>[A-Z,a-z]{3})[a-z]*\s(?<year>20\d{2})")
            };

            // Act
            List<FileMetaData> filesToRename = PdfParser.GetFilesToRename(fileNames, pdfInfos).ToList();

            // Assert
            Assert.That(filesToRename.Count, Is.EqualTo(2), "filesToRename.Count");
            Assert.That(filesToRename[0].OldPath, Is.EqualTo(@".\Resources\2013_05_10_00_00_00.pdf"), "filesToRename[0].OldPath");
            Assert.That(filesToRename[0].NewPath, Is.EqualTo(@"C:\Temp\My Bank 2013_05_10.pdf"),
                "filesToRename[0].NewPath");
            Assert.That(filesToRename[0].Date, Is.EqualTo(new DateTime(2013, 5, 10)), "filesToRename[0].Date");
        }
开发者ID:openshac,项目名称:PdfFiler,代码行数:28,代码来源:PdfParserTests.cs


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