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


C# List.GetRange方法代码示例

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


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

示例1: WriteFileToGK

		public void WriteFileToGK(XDevice gkDevice)
		{
			var bytesList = new List<byte>();
			var gkFileInfo = new GKFileInfo();
			gkFileInfo.Initialize(XManager.DeviceConfiguration, gkDevice);
			bytesList.AddRange(gkFileInfo.InfoBlock);
			var sendResult = SendManager.Send(gkDevice, 0, 21, 0);
			if (sendResult.HasError)
				{ Error = "Невозможно начать процедуру записи "; return; }
            bytesList.AddRange(gkFileInfo.FileBytes);
			var progressCallback = GKProcessorManager.StartProgress("Запись файла в " + gkDevice.PresentationName, null, bytesList.Count / 256, true, GKProgressClientType.Administrator);
			for (var i = 0; i < bytesList.Count; i += 256)
			{
				if (progressCallback.IsCanceled)
					{ Error = "Операция отменена"; return; }
				GKProcessorManager.DoProgress("Запись блока данных " + i + 1, progressCallback);
				var bytesBlock = BitConverter.GetBytes((uint)(i / 256 + 1)).ToList();
				bytesBlock.AddRange(bytesList.GetRange(i, Math.Min(256, bytesList.Count - i)));
				sendResult = SendManager.Send(gkDevice, (ushort)bytesBlock.Count(), 22, 0, bytesBlock);
				if (sendResult.HasError)
				{
					Error = "Невозможно записать блок данных " + i;
					break;
				}
			}
			var endBlock = BitConverter.GetBytes((uint) (bytesList.Count()/256 + 1)).ToList();
			sendResult = SendManager.Send(gkDevice, 0, 22, 0, endBlock);
			if (sendResult.HasError)
				{ Error = "Невозможно завершить запись файла "; }
		}
开发者ID:saeednazari,项目名称:Rubezh,代码行数:30,代码来源:GKFileReaderWriter.cs

示例2: SortMail


//.........这里部分代码省略.........
                {
                    foreach (BsonValue MailFrom in Mail.GetValue("MailFrom").AsBsonArray)
                    {
                        if (!MailFrom.AsBsonArray[0].IsBsonNull)
                        {
                            Weights += MailNikeName.Find((x) => x.GetValue("_id").AsObjectId == MailFrom.AsBsonArray[0].AsObjectId).GetValue("RepeatTimes").AsInt32;
                        }
                        if (!MailFrom.AsBsonArray[1].IsBsonNull)
                        {
                            Weights += MailAddress.Find((x) => x.GetValue("_id").AsObjectId == MailFrom.AsBsonArray[1].AsObjectId).GetValue("RepeatTimes").AsInt32;
                        }
                    }
                }
                if (Mail.Contains("MailTO"))
                {
                    foreach (BsonValue MailTO in Mail.GetValue("MailTO").AsBsonArray)
                    {
                        if (!MailTO.AsBsonArray[0].IsBsonNull)
                        {
                            Weights += MailNikeName.Find((x) => x.GetValue("_id").AsObjectId == MailTO.AsBsonArray[0].AsObjectId).GetValue("RepeatTimes").AsInt32;
                        }
                        if (!MailTO.AsBsonArray[1].IsBsonNull)
                        {
                            Weights += MailAddress.Find((x) => x.GetValue("_id").AsObjectId == MailTO.AsBsonArray[1].AsObjectId).GetValue("RepeatTimes").AsInt32;
                        }
                    }
                }
                if (Mail.Contains("MailCC"))
                {
                    foreach (BsonValue MailCC in Mail.GetValue("MailCC").AsBsonArray)
                    {
                        if (!MailCC.AsBsonArray[0].IsBsonNull)
                        {
                            Weights += MailNikeName.Find((x) => x.GetValue("_id").AsObjectId == MailCC.AsBsonArray[0].AsObjectId).GetValue("RepeatTimes").AsInt32;
                        }
                        if (!MailCC.AsBsonArray[1].IsBsonNull)
                        {
                            Weights += MailAddress.Find((x) => x.GetValue("_id").AsObjectId == MailCC.AsBsonArray[1].AsObjectId).GetValue("RepeatTimes").AsInt32;
                        }
                    }
                }
                if (Mail.Contains("MailBCC"))
                {
                    foreach (BsonValue MailBCC in Mail.GetValue("MailBCC").AsBsonArray)
                    {
                        if (!MailBCC.AsBsonArray[0].IsBsonNull)
                        {
                            Weights += MailAddress.Find((x) => x.GetValue("_id").AsObjectId == MailBCC.AsBsonArray[0].AsObjectId).GetValue("RepeatTimes").AsInt32;
                        }
                        if (!MailBCC.AsBsonArray[1].IsBsonNull)
                        {
                            Weights += MailAddress.Find((x) => x.GetValue("_id").AsObjectId == MailBCC.AsBsonArray[1].AsObjectId).GetValue("RepeatTimes").AsInt32;
                        }
                    }
                }
                for (int i = 0; i < Mail.GetValue("HTMLBodyIps").AsBsonArray.Count; i += 2)
                {
                    Weights += MailIp.Find((x) => x.GetValue("Ip") == Mail.GetValue("HTMLBodyIps").AsBsonArray[i].AsString).GetValue("RepeatTimes").AsInt32 * Mail.GetValue("HTMLBodyIps").AsBsonArray[i + 1].AsInt32;
                }
                for (int i = 0; i < Mail.GetValue("HTMLBodyMailAddress").AsBsonArray.Count; i += 2)
                {
                    Weights += MailAddress.Find((x) => x.GetValue("Address").AsString == Mail.GetValue("HTMLBodyMailAddress").AsBsonArray[i].AsString).GetValue("RepeatTimes").AsInt32 * Mail.GetValue("HTMLBodyMailAddress").AsBsonArray[i + 1].AsInt32;
                }
                for (int i = 0; i < Mail.GetValue("HTMLBodyPhone").AsBsonArray.Count; i += 2)
                {
                    Weights += MailPhone.Find((x) => x.GetValue("Phone") == Mail.GetValue("HTMLBodyPhone").AsBsonArray[i].AsString).GetValue("RepeatTimes").AsInt32 * Mail.GetValue("HTMLBodyPhone").AsBsonArray[i + 1].AsInt32;
                }
                for (int i = 0; i < Mail.GetValue("HTMLBodyContainer").AsBsonArray.Count; i += 2)
                {
                    Weights += MailContainer.Find((x) => x.GetValue("Container") == Mail.GetValue("HTMLBodyContainer").AsBsonArray[i].AsString).GetValue("RepeatTimes").AsInt32 * Mail.GetValue("HTMLBodyContainer").AsBsonArray[i + 1].AsInt32;
                }
                for (int i = 0; i < Mail.GetValue("TextBodyIps").AsBsonArray.Count; i += 2)
                {
                    Weights += MailIp.Find((x) => x.GetValue("Ip") == Mail.GetValue("TextBodyIps").AsBsonArray[i].AsString).GetValue("RepeatTimes").AsInt32 * Mail.GetValue("TextBodyIps").AsBsonArray[i + 1].AsInt32;
                }
                for (int i = 0; i < Mail.GetValue("TextBodyMailAddress").AsBsonArray.Count; i += 2)
                {
                    Weights += MailAddress.Find((x) => x.GetValue("Address").AsString == Mail.GetValue("TextBodyMailAddress").AsBsonArray[i].AsString).GetValue("RepeatTimes").AsInt32 * Mail.GetValue("TextBodyMailAddress").AsBsonArray[i + 1].AsInt32;
                }
                for (int i = 0; i < Mail.GetValue("TextBodyPhone").AsBsonArray.Count; i += 2)
                {
                    Weights += MailPhone.Find((x) => x.GetValue("Phone") == Mail.GetValue("TextBodyPhone").AsBsonArray[i].AsString).GetValue("RepeatTimes").AsInt32 * Mail.GetValue("TextBodyPhone").AsBsonArray[i + 1].AsInt32;
                }
                for (int i = 0; i < Mail.GetValue("TextBodyContainer").AsBsonArray.Count; i += 2)
                {
                    Weights += MailContainer.Find((x) => x.GetValue("Container") == Mail.GetValue("TextBodyContainer").AsBsonArray[i].AsString).GetValue("RepeatTimes").AsInt32 * Mail.GetValue("TextBodyContainer").AsBsonArray[i + 1].AsInt32;
                }
                Mail.Add("Weights", Weights);
            }
            MailList.Sort((X, Y) => -X.GetValue("Weights").AsInt32.CompareTo(Y.GetValue("Weights").AsInt32));
            if (MailList.Count > 1000)
            {
                return MailList.GetRange(0, 1000);
            }
            else
            {
                return MailList;
            }

        }
开发者ID:Zane0816,项目名称:Mail-.Net,代码行数:101,代码来源:MailManager.cs

示例3: WriteFileToGK

		public void WriteFileToGK(GKDevice gkControllerDevice, Guid clientUID)
		{
			using (var gkLifecycleManager = new GKLifecycleManager(gkControllerDevice, "Запись файла в ГК"))
			{
				gkLifecycleManager.AddItem("Формирование хэша");
				var gkFileInfo = new GKFileInfo();
				gkFileInfo.Initialize(gkControllerDevice);
				var bytesList = new List<byte>();
				bytesList.AddRange(gkFileInfo.InfoBlock);
				bytesList.AddRange(gkFileInfo.FileBytes);

				gkLifecycleManager.AddItem("Перевод в режим записи файла");
				var sendResult = SendManager.Send(gkControllerDevice, 0, 21, 0);
				if (sendResult.HasError)
				{
					Error = "Невозможно начать процедуру записи ";
					gkLifecycleManager.AddItem("Ошибка");
					return;
				}

				var progressCallback = GKProcessorManager.StartProgress("Запись файла в " + gkControllerDevice.PresentationName, null, bytesList.Count / 256, false, GKProgressClientType.Administrator, clientUID);
				for (var i = 0; i < bytesList.Count; i += 256)
				{
					gkLifecycleManager.Progress(i + 1, bytesList.Count);
					GKProcessorManager.DoProgress("Запись блока данных " + i + 1, progressCallback, clientUID);

					var bytesBlock = BitConverter.GetBytes((uint)(i / 256 + 1)).ToList();
					bytesBlock.AddRange(bytesList.GetRange(i, Math.Min(256, bytesList.Count - i)));
					for (int j = 0; j < 10; j++)
					{
						sendResult = SendManager.Send(gkControllerDevice, (ushort)bytesBlock.Count(), 22, 0, bytesBlock);
						var result = sendResult.Bytes.Count > 0 && sendResult.Bytes[0] == 1;
						if (!sendResult.HasError && result)
							break;
						if (j == 9)
						{
							Error = "Невозможно записать блок данных " + i;
							gkLifecycleManager.AddItem("Ошибка");
							return;
						}
					}
				}
				gkLifecycleManager.AddItem("Запись последнего блока данных");
				var endBlock = BitConverter.GetBytes((uint)(bytesList.Count() / 256 + 1)).ToList();
				sendResult = SendManager.Send(gkControllerDevice, 0, 22, 0, endBlock);
				var endResult = sendResult.Bytes.Count > 0 && sendResult.Bytes[0] == 0;
				if (sendResult.HasError || !endResult)
				{
					Error = "Невозможно завершить запись файла ";
					gkLifecycleManager.AddItem("Ошибка");
				}
				var sendResultRead = SendManager.Send(gkControllerDevice, 4, 23, 256, new List<byte>(BitConverter.GetBytes(1)));
				if (!gkFileInfo.InfoBlock.SequenceEqual(sendResultRead.Bytes))
				{
					Error = "Не удалось корректно записать информационный блок ";
					gkLifecycleManager.AddItem("Ошибка");
				}
			}
		}
开发者ID:xbadcode,项目名称:Rubezh,代码行数:59,代码来源:GKFileReaderWriter.cs

示例4: Parce

		public FS2JournalItem Parce(DeviceConfiguration deviceConfiguration, Device panelDevice, List<byte> bytes, int journalType)
		{
			if (bytes.Count != 32)
				return null;
			Bytes = bytes;
			DeviceConfiguration = deviceConfiguration;

			FSInternalJournal = new FSInternalJournal()
			{
				ShleifNo = bytes[17] + 1,
				EventCode = bytes[0],
				AdditionalEventCode = bytes[5],
				DeviceType = bytes[7],
				AddressOnShleif = bytes[8],
				State = bytes[9],
				UnusedDescriptorNo = BytesHelper.ExtractTriple(bytes, 12),
				ZoneNo = BytesHelper.ExtractShort(bytes, 10)
			};

			FS2JournalItem = new FS2JournalItem()
			{
				BytesString = BytesHelper.BytesToString(bytes),
				PanelDevice = panelDevice,
				PanelUID = panelDevice.UID,
				PanelName = panelDevice.DottedPresentationNameAndAddress,
				DeviceTime = TimeParceHelper.ParceDateTime(bytes.GetRange(1, 4)),
				SystemTime = DateTime.Now,
				EventCode = FSInternalJournal.EventCode,
				AdditionalEventCode = FSInternalJournal.AdditionalEventCode
			};
			switch (journalType)
			{
				case 0x00:
					FS2JournalItem.SubsystemType = SubsystemType.Fire;
					break;
				case 0x02:
					FS2JournalItem.SubsystemType = SubsystemType.Guard;
					break;
			}

			MetadataEvent = MetadataHelper.Metadata.events.FirstOrDefault(x => x.rawEventCode == "$" + FSInternalJournal.EventCode.ToString("X2"));

			if (MetadataHelper.HasDevise(FSInternalJournal.EventCode))
			{
				var intAddress = FSInternalJournal.AddressOnShleif + 256 * FSInternalJournal.ShleifNo;
				FS2JournalItem.Device = ConfigurationManager.Devices.FirstOrDefault(x => x.IntAddress == intAddress && x.ParentPanel == FS2JournalItem.PanelDevice && !x.Driver.IsGroupDevice);
				if (FS2JournalItem.Device != null)
				{
					FS2JournalItem.DeviceUID = FS2JournalItem.Device.UID;
					FS2JournalItem.DeviceName = FS2JournalItem.Device.PresentationName + " " + FS2JournalItem.Device.PresentationAddress;

					if (FSInternalJournal.DeviceType == 1)
						FS2JournalItem.DeviceName = "АСПТ " + (FSInternalJournal.ShleifNo - 1) + ".";
				}
				else
				{
					if (FSInternalJournal.DeviceType > 0)
					{
						var driverUID = MetadataHelper.GetUidById(FSInternalJournal.DeviceType);
						if (driverUID != Guid.Empty)
						{
							var driver = ConfigurationManager.Drivers.FirstOrDefault(x => x.UID == driverUID);
							FS2JournalItem.DeviceName = driver.ShortName + " " + FSInternalJournal.ShleifNo + "." + FSInternalJournal.AddressOnShleif;
						}
					}
				}
			}

			FS2JournalItem.HasZone = MetadataHelper.HasZone(FSInternalJournal.AdditionalEventCode);
			InitializeZone();
			FS2JournalItem.StateType = GetEventStateType();
			FS2JournalItem.Description = GetEventName();
			FS2JournalItem.Detalization = GetDetalization();
			FS2JournalItem.UserName = GetUserName();

			//Initialize_0x80_Event();
			if (FS2JournalItem.Description.Contains("Пожарная тревога"))
			{
				;
			}
			return FS2JournalItem;
		}
开发者ID:saeednazari,项目名称:Rubezh,代码行数:82,代码来源:JournalParser.cs


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