/// <summary>
 /// Function to append errors in validation error dictionary.
 /// </summary>
 /// <param name="errorsDictionary">Errors dictionary</param>
 /// <param name="errors">List of errors</param>
 public static void Append(this Dictionary<string, string> errorsDictionary, IList<ErrorListItem> errors)
 {
     if (errors != null)
     {
         errors.ForEach(item => Append(errorsDictionary, item));
     }
 }
Example #2
1
 private void PopulateProperties( GraphicStructure paletteStructure, IList<GraphicStructure> pixelStructures )
 {
     Palette = new Palette( paletteStructure.Pixels, Palette.ColorDepth._16bit );
     List<byte> pix = new List<byte>();
     pixelStructures.ForEach( p => pix.AddRange( p.Pixels ) );
     Pixels = pix.AsReadOnly();
 }
 private static string get_lines(IList<FinishedAndRawInventoryCounted> counteds)
 {
     var retVal = "Dell Part Number	Available FG Qty	Available RAW Qty\r\n";
     counteds.ForEach(
         i => retVal += get_line(i) + "\r\n");
     return retVal;
 }
        public static void FillActiveUserFilesListView(IList<ActiveUserFile> activeUserFiles, ListView target)
        {
            target.Items.Clear();
            target.Columns.Clear();
            target.Columns.Add("File Name");
            target.Columns.Add("Reference Computer");
            target.Columns.Add("Memory Use");
            target.Columns.Add("CPU Use");
            target.Columns.Add("Description");

            IList<String> images = new List<string>();
            images.Add("TrendWinForm.Images.Icons.File_byJesse_48.png");
            PopulateListViewImages(images, target);
            activeUserFiles.ForEach(auf =>
            {
                var item = new ListViewItem(auf.ReferenceComputer.ToString());
                item.Text = auf.FileName;
                item.SubItems.Add(auf.ReferenceComputer.Make + " " + auf.ReferenceComputer.Model);
                item.SubItems.Add(auf.MemoryUsage.ToString());
                item.SubItems.Add(auf.CpuUsage.ToString());
                item.SubItems.Add(auf.Description);
                item.ImageIndex = 0;
                target.Items.Add(item);
            });
        }
        protected IList<ICountryDetails> GetContryDetailsModel(IList<Country> countries)
        {
            var contryDetails = new List<ICountryDetails>();
            countries.ForEach(c => contryDetails.Add(GetContryDetailsModel(c)));

            return contryDetails;
        }
 private void AddBuildings(TreeViewItem projectItem, IList<Web.Models.Building> buildings)
 {
     buildings.ForEach(b =>
                           {
                               var buildingItem = new TreeViewItem() { };
                               View1.Items.Add(projectItem);
                           });
 }
        /// <summary>
        /// Copies the validation errors.
        /// </summary>
        /// <param name="modelState">State of the model.</param>
        /// <param name="validationErrors">The validation errors.</param>
        public static void CopyValidationErrors(this ModelStateDictionary modelState, IList<ValidationError> validationErrors)
        {
            validationErrors.ForEach(error => modelState.AddModelError(error.Property, /* strValue, */ error.Message));

            //string strValue = null;
                //if (error.AttemptedValue != null)
                //    strValue = error.AttemptedValue.ToString();
        }
Example #8
1
 private static bool AskOrBoolReturnHooks(CommandArgs args, IList<Func<CommandArgs, bool>> hooks)
 {
     bool ret = false;
     hooks.ForEach(delegate(Func<CommandArgs, bool> a){
         ret |= a(args);
     });
     return ret;
 }
Example #9
1
 private static IEnumerable<NodeData> EncodeNodes(
      IList<ExplorationNode> nodes,
      Dictionary<ExplorationEdge, uint> edgeToId)
 {
     List<NodeData> nodeData = new List<NodeData>();
     nodes.ForEach(
         (node) => nodeData.Add(new NodeData(node, edgeToId)));
     return nodeData.OrderBy((node) => node.NodeId);
 }
Example #10
1
 public IList<Token> Scan(IList<Token> tokens, Options options)
 {
     tokens.ForEach(token => token.Tag(
         new ITag[]
             {
                 ScanOrdinal(token, options),
                 ScanOrdinalDay(token)
             }.Where(
                 x => x != null).ToList()));
     return tokens;
 }
        private IDictionary<GenusTypeDto, PhotoDto> BuildGenusTypeDictionary(IList<GenusTypeDto> dtoList)
        {
            var dictionary = new Dictionary<GenusTypeDto, PhotoDto>();

            dtoList.ForEach(x =>
                {
                    var photo = this.photosRepository.GetSingleForGenusType(x.Id);

                    dictionary.Add(x, photo == null ? null : DtoFactory.Build(photo));
                });

            return dictionary;
        }
Example #12
1
        public OrderLine(Product product, int quantity, IList<Outcome> outcomes):this()
        {
            Product = product;
            Quantity = quantity;
            Price = product.Price;
            ProductName = product.Name;

            Outcomes = outcomes;
            outcomes.ForEach(x => x.OrderLine = this);

            Profit = Outcomes.Sum(outcome => outcome.Profit);
            SummWithDiscount = Outcomes.Sum(outcome => outcome.SummWithDiscount);

        }
        public void ParseResult(IList<string> lines)
        {
            lines.ForEach(l =>
            {
                if (l.StartsWith("dangling commit "))
                {
                    var commit = new BareCommitResult();
                    commit.ParseResult(new List<string>() { l.Remove(0, l.LastIndexOf(" ", StringComparison.Ordinal) + 1)});

                    Commits.Add(commit);
                }
            });
        }
        public InteractiveTests()
        {
            InitializeComponent();

            _tests = AllTypes.InCurrentAssembly()
                .Where(x => x.IsConcrete() && x.IsAssignableTo<UiTest>())
                .Select(x => (UiTest)Activator.CreateInstance(x))
                .ToList();

            _tests
                .ForEach(x => x.Owner = this);

            _tests.Select(x => x.Module)
                .Distinct()
                .ForEach(x => _moduleNames.Add(x));

            _modules.DataSource = _moduleNames.ToList() ;
        }
Example #15
0
        /// <summary>
        /// Compresses the specified file.
        /// </summary>
        /// <typeparam name="T">Must be <see cref="IStringSectioned"/> and <see cref="ICompressed"/></typeparam>
        /// <param name="file">The file to compress.</param>
        /// <param name="ignoreSections">A dictionary indicating which entries to not compress, with each key being the section that contains the ignored
        /// entries and each item in the value being an entry to ignore</param>
        /// <param name="callback">The progress callback.</param>
        public static CompressionResult Compress( IList<IList<string>> sections, byte terminator, GenericCharMap charmap, IList<bool> allowedSections )
        {
            int length = 0;
            sections.ForEach( s => length += charmap.StringsToByteArray( s, terminator ).Length );

            byte[] result = new byte[length];
            int[] lengths = new int[sections.Count];

            int pos = 0;
            for( int section = 0; section < sections.Count; section++ )
            {
                int oldPos = pos;

                if ( allowedSections == null || allowedSections[section] )
                {
                    CompressSection( charmap.StringsToByteArray( sections[section], terminator ), result, ref pos );
                }
                else
                {
                    byte[] secResult = charmap.StringsToByteArray( sections[section], terminator );
                    secResult.CopyTo( result, pos );
                    pos += secResult.Length;
                }

                lengths[section] = pos - oldPos;

            }

            return new CompressionResult( result.Sub( 0, pos - 1 ), lengths );
        }
 private void DeleteSourceMessages(CloudQueue sourceQueue, IList<CloudQueueMessage> inboundMessages, Stopwatch stopWatch)
 {
     inboundMessages.ForEach(inMsg => sourceQueue.DeleteMessage(inMsg));
     this.LogInformation("Done deleting {0} messages from {1} queue. Elapsed {2}.", inboundMessages.Count, sourceQueue.Name, stopWatch.Elapsed);
 }
Example #17
0
 public void Store(IList<MarkdownFile> files)
 {
     files.ForEach(Store);
 }
Example #18
0
        public void UpdateAttributeOptionDisplayOrder(Product product, IList<SortItem> options)
        {
            if (product != null && options != null && options.Count > 0)
            {
                _session.Transact(session =>
                {
                    options.ForEach(item =>
                    {
                        var option = session.Get<ProductOption>(item.Id);

                        if (option == null)
                            return;

                        product.Options.Remove(option);
                        product.Options.Insert(item.Order, option);
                    });
                    session.Update(product);
                });
            }
        }
Example #19
0
 public void UpdateSpecificationAttributeDisplayOrder(IList<SortItem> options)
 {
     _session.Transact(session => options.ForEach(item =>
     {
         var formItem =
             session.Get<ProductSpecificationAttribute>(item.Id);
         formItem.DisplayOrder = item.Order;
         session.Update(formItem);
     }));
 }
Example #20
0
 public GraphicsStructureImage( IList<GraphicStructureList> lists )
 {
     List<GraphicStructure> structs = new List<GraphicStructure>();
     lists.ForEach( l => structs.AddRange( l.Structures ) );
     PopulateProperties( structs[0], structs.Sub( 1 ) );
 }
Example #21
0
 public IList<Token> Scan(IList<Token> tokens, Options options)
 {
     tokens.ForEach((token, nextToken) => token.Tag(
         new ITag[]
             {
                 Scan(token, nextToken, options),
                 ScanDay(token, nextToken, options),
                 ScanMonth(token, nextToken, options),
                 ScanYear(token, nextToken, options),
             }.Where(
                 x => x != null).ToList()));
     return tokens;
 }
Example #22
0
 public IList<Token> Scan(IList<Token> tokens, Options options)
 {
     tokens.ForEach(ApplyTags);
     return tokens;
 }
 protected void WriteStorageAccountList(IList<StorageModels.StorageAccount> storageAccounts)
 {
     List<PSStorageAccount> output = new List<PSStorageAccount>();
     storageAccounts.ForEach(storageAccount => output.Add(PSStorageAccount.Create(storageAccount, this.StorageClient)));
     WriteObject(output, true);
 }
Example #24
0
        public static IList<GoodsDetail> GetItems(IList<int> ids)
        {
            var r = new List<GoodsDetail>();
            if (ids != null && ids.Any())
            {
                ids.ForEach(id =>
                {
                    var rData = Commodity.GetShopItemDetail(id);

                    if (rData != null)
                    {
                        r.Add(new GoodsDetail
                        {
                            Picture = rData.Picture,
                            Pictures = rData.Pictures,
                            MarketPrice = rData.MarketPrice,
                            Partners = rData.Partners,
                            Price = rData.Price,
                            Id = rData.Id,
                            ItemTitle = rData.ItemTitle,
                            Sales = rData.Sales
                        });
                    }

                });
            }

            return r;
        }
Example #25
0
 private void GetSubmoduleStatus(IList<GitItemStatus> status, string from, string to)
 {
     status.ForEach(item =>
     {
         if (item.IsSubmodule)
         {
             item.SubmoduleStatus = Task.Factory.StartNew(() =>
             {
                 Patch patch = GetSingleDiff(from, to, item.Name, item.OldName, "", SystemEncoding, true);
                 string text = patch != null ? patch.Text : "";
                 var submoduleStatus = GitCommandHelpers.GetSubmoduleStatus(text);
                 if (submoduleStatus.Commit != submoduleStatus.OldCommit)
                 {
                     var submodule = submoduleStatus.GetSubmodule(this);
                     submoduleStatus.CheckSubmoduleStatus(submodule);
                 }
                 return submoduleStatus;
             });
         }
     });
 }
Example #26
0
        public IList<Token> Scan(IList<Token> tokens, Options options)
        {
            tokens.ForEach(token =>
                {
                    foreach (var scanner in _scanners)
                    {
                        var tag = scanner(token, options);
                        if (tag != null)
                        {
                            token.Tag(tag);
                            break;
                        }
                    }
                });

            return tokens;
        }
Example #27
0
        protected override void ExecuteIndexingWork(IList<IndexToWorkOn> indexesToWorkOn, Etag synchronizationEtag)
		{
			indexesToWorkOn = context.Configuration.IndexingScheduler.FilterMapIndexes(indexesToWorkOn);

            var lastIndexedGuidForAllIndexes =
                   indexesToWorkOn.Min(x => new ComparableByteArray(x.LastIndexedEtag.ToByteArray())).ToEtag();
            var startEtag = CalculateSynchronizationEtag(synchronizationEtag, lastIndexedGuidForAllIndexes);

			context.CancellationToken.ThrowIfCancellationRequested();

			var operationCancelled = false;
			TimeSpan indexingDuration = TimeSpan.Zero;
			List<JsonDocument> jsonDocs = null;
			var lastEtag = Etag.Empty;

			indexesToWorkOn.ForEach(x => x.Index.IsMapIndexingInProgress = true);

			try
			{
				jsonDocs = prefetchingBehavior.GetDocumentsBatchFrom(startEtag);

				if (Log.IsDebugEnabled)
				{
					Log.Debug("Found a total of {0} documents that requires indexing since etag: {1}: ({2})",
							  jsonDocs.Count, startEtag, string.Join(", ", jsonDocs.Select(x => x.Key)));
				}

				context.ReportIndexingActualBatchSize(jsonDocs.Count);
				context.CancellationToken.ThrowIfCancellationRequested();

				if (jsonDocs.Count <= 0)
					return;

				var sw = Stopwatch.StartNew();
				lastEtag = DoActualIndexing(indexesToWorkOn, jsonDocs);
				indexingDuration = sw.Elapsed;
			}
			catch (OperationCanceledException)
			{
				operationCancelled = true;
			}
			finally
			{
				if (operationCancelled == false && jsonDocs != null && jsonDocs.Count > 0)
				{
					prefetchingBehavior.CleanupDocuments(lastEtag);
					prefetchingBehavior.UpdateAutoThrottler(jsonDocs, indexingDuration);
				}

				prefetchingBehavior.BatchProcessingComplete();

				indexesToWorkOn.ForEach(x => x.Index.IsMapIndexingInProgress = false);
			}
		}
 /// <summary>
 /// Assigns the persons list.
 /// </summary>
 /// <param name="presenter">The presenter.</param>
 /// <param name="projectPerson">The project person.</param>
 private void AssignPersonsList(ProjectPresenter presenter, IList<ProjectPersonListItem> projectPerson)
 {
     projectPerson.ForEach(p => presenter.Project.ProjectPersons.Add(this.MapProjectListItemToProjectPerson(p, presenter)));
 }
Example #29
0
 public void UpdateDisplayOrder(IList<SortItem> options)
 {
     _session.Transact(session => options.ForEach(item =>
     {
         var formItem = session.Get<Country>(item.Id);
         formItem.DisplayOrder = item.Order;
         session.Update(formItem);
     }));
 }
Example #30
0
        private static IDisposable MapIndexingInProgress(IList<IndexToWorkOn> indexesToWorkOn)
        {
            indexesToWorkOn.ForEach(x => x.Index.IsMapIndexingInProgress = true);

            return new DisposableAction(() => indexesToWorkOn.ForEach(x => x.Index.IsMapIndexingInProgress = false));
        }