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


C# Collection.Aggregate方法代码示例

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


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

示例1: ClearProperty

        public void ClearProperty(string path, Collection<string> propertyToClear)
        {
            try
            {
                LogInfo("Executing ClearProperty(string path='{0}', string propertyToClear='{1}')",
                    path,
                    propertyToClear.Aggregate((seed, curr) => seed + ',' + curr));
                var item = GetItemForPath(path);
                item.Edit(args =>
                {
                    foreach (var property in propertyToClear)
                    {
                        if (ShouldProcess(path,
                            "Restoring property '" + property + "' to default set on Standard Values"))
                        {
                            item.Fields[property].Reset();
                        }
                    }
                });
            }

            catch (Exception ex)
            {
                LogError(ex, "Error while executing ClearProperty(string path='{0}', string propertyToClear='{1}')",
                    path,
                    propertyToClear.Aggregate((seed, curr) => seed + ',' + curr));
                throw;
            }
        }
开发者ID:sobek85,项目名称:Console,代码行数:29,代码来源:PsSitecoreItemProvider.PropertyProvider.cs

示例2: ClearProperty

        public void ClearProperty(string path, Collection<string> propertyToClear)
        {
            try
            {
                LogInfo("Executing ClearProperty(string path='{0}', string propertyToClear='{1}')",
                        path,
                        propertyToClear.Aggregate((seed, curr) => seed + ',' + curr));
                Item item = GetItemForPath(path);
                item.Edit(args =>
                    {
                        foreach (string property in propertyToClear)
                        {
                            item.Fields[property].Reset();
                        }
                    });
            }

            catch (Exception ex)
            {
                LogError(ex, "Error while executing ClearProperty(string path='{0}', string propertyToClear='{1}')",
                         path,
                         propertyToClear.Aggregate((seed, curr) => seed + ',' + curr));
                throw;
            }
        }
开发者ID:scjunkie,项目名称:Console,代码行数:25,代码来源:PsSitecoreItemProvider.PropertyProvider.cs

示例3: ReadParameter

        private static ICollection<DataProperty> ReadParameter(ICollection<XElement> properties,
            ICollection<Parameter> parameters)
        {
            var proplist = new Collection<DataProperty>();
            var proplistError = new Collection<DataProperty>();

            foreach (var property in GetPropertyNodesWithSpecificType(properties, DataPropertyType.Parameter))
            {
                var prop = new DataProperty
                               {
                                   Id = XmlTools.GetNamedAttributeValue(property, "id", null),
                                   PropertyType = DataPropertyType.Parameter
                               };

                if (prop.Id == null)
                {
                    var msg = "Missing 'id' attribute in Property Node: '" + XmlTools.GetOuterXml(property) + "'";
                    Log.WriteError(msg, "ExtractProperties");
                    throw new InstallerVerificationLibraryException(msg);
                }

                var parameterId = XmlTools.GetNamedAttributeValue(property, "parameterID", null);
                if (!string.IsNullOrEmpty(parameterId))
                {
                    var found = false;
                    foreach (var parm in parameters.Where(parm => parm.Id == parameterId))
                    {
                        prop.Value = parm.Value;
                        proplist.Add(prop);
                        found = true;
                        break;
                    }

                    if (found)
                    {
                        //// If found delete if property exist in error list
                        if (proplistError.Contains(prop))
                        {
                            proplistError.Remove(prop);
                        }
                    }
                    else
                    {
                        //// If not found and it doesn't allready exist add property to error list
                        if (!proplist.Contains(prop))
                        {
                            prop.Value = XmlTools.GetOuterXml(property);
                            proplistError.Add(prop);
                        }
                    }
                }
                else
                {
                    var msg = "parameterID attribute is missing for property '" + XmlTools.GetOuterXml(property) + "'";
                    Log.WriteError(msg, "ExtractProperties");
                    throw new InstallerVerificationLibraryException(msg);
                }
            }

            //// Check if any error exist
            if (proplistError.Count > 0)
            {
                var msg = proplistError.Aggregate(string.Empty, (current, prop) => current + ("Property Node: '" + prop.Value + "' doesn't contain a valid parameterId"));

                Log.WriteError(msg, "ExtractProperties");
                throw new InstallerVerificationLibraryException(msg);
            }

            return proplist;
        }
开发者ID:pwibeck,项目名称:InstallerVerificationFramework,代码行数:70,代码来源:DataPropertyTool.cs

示例4: ActionTestsParams

        public void ActionTestsParams()
        {
            
            var context = this.CreateWrappedContext<DefaultContainer>().Context;
            Employee e1 = new Employee {Salary = 300, Name = "bill", PersonId = 1005};
            Collection<string> specifications = new Collection<string> {"A", "B", "C"};
            DateTimeOffset purchaseTime = DateTimeOffset.Now;           
            ComputerDetail cd1 = new ComputerDetail {ComputerDetailId = 101, SpecificationsBag = new ObservableCollection<string>()};
            Customer c1 = new Customer { Name = "nill", CustomerId = 1007, Auditing = new AuditInfo { ModifiedBy = "No-one", ModifiedDate = DateTimeOffset.Now, Concurrency = new ConcurrencyInfo { Token = "Test", QueriedDateTime = DateTimeOffset.MinValue } } };
            AuditInfo a1 = new AuditInfo { ModifiedBy = "some-one", ModifiedDate =  DateTimeOffset.MinValue,Concurrency = new ConcurrencyInfo { Token = "Test", QueriedDateTime = DateTimeOffset.MinValue} };
            context.AddToCustomer(c1);
            context.AddToPerson(e1);
            context.AddToComputerDetail(cd1);
            var ar0 = context.BeginSaveChanges(null, null).EnqueueWait(this);
            context.EndSaveChanges(ar0);

            var ar1 = context.BeginExecute(new Uri("Person/Microsoft.Test.OData.Services.AstoriaDefaultService.Employee" + "/Microsoft.Test.OData.Services.AstoriaDefaultService.IncreaseSalaries", UriKind.Relative), null, null, "POST", new BodyOperationParameter("n", 100)).EnqueueWait(this);
            context.EndExecute(ar1);
            var ar11 = context.BeginLoadProperty(e1, "Salary", null, null).EnqueueWait(this);
            context.EndLoadProperty(ar11);
            Assert.AreEqual(400, e1.Salary);

            var ar2 = context.BeginExecute(new Uri("ComputerDetail(" + cd1.ComputerDetailId + ")" + "/Microsoft.Test.OData.Services.AstoriaDefaultService.ResetComputerDetailsSpecifications", UriKind.Relative), null, null, "POST", new BodyOperationParameter("specifications", specifications), new BodyOperationParameter("purchaseTime", purchaseTime)).EnqueueWait(this);
            context.EndExecute(ar2);
            var ar21 = context.BeginLoadProperty(cd1, "PurchaseDate", null, null).EnqueueWait(this);
            context.EndLoadProperty(ar21);
            var ar22 = context.BeginLoadProperty(cd1, "SpecificationsBag", null, null).EnqueueWait(this);
            context.EndLoadProperty(ar22);
            Assert.AreEqual(purchaseTime, cd1.PurchaseDate);
            Assert.AreEqual(specifications.Aggregate("", (current, item) => current + item),cd1.SpecificationsBag.Aggregate("", (current, item) => current + item));

            var ar3 = context.BeginExecute(new Uri("Customer(1007)/Microsoft.Test.OData.Services.AstoriaDefaultService.ChangeCustomerAuditInfo", UriKind.Relative), null, null, "POST", new BodyOperationParameter("auditInfo", a1)).EnqueueWait(this);
            context.EndExecute(ar3);
            var query = (from c in context.Customer where c.CustomerId == c1.CustomerId select c.Auditing ) as DataServiceQuery<AuditInfo>;
            var ar2222 = query.BeginExecute(null, null).EnqueueWait(this);
            var temp = (query.EndExecute(ar2222) as QueryOperationResponse<AuditInfo>);
            c1.Auditing = temp.SingleOrDefault();
            Assert.AreEqual(c1.Auditing.ModifiedBy , "some-one");
            Assert.AreEqual(c1.Auditing.ModifiedDate, DateTimeOffset.MinValue);
            this.EnqueueTestComplete();
        }
开发者ID:larsenjo,项目名称:odata.net,代码行数:41,代码来源:AsynchronousUpdateTests.cs


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