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


C# Dictionary.Select方法代码示例

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


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

示例1: mfas

        public List<Edge<int>> mfas(BidirectionalGraph<int, Edge<int>> G)
        {
            List<Edge<int>> F = new List<Edge<int>>();
            IDictionary<int, int> P = new Dictionary<int, int>();

            int sccCount = G.StronglyConnectedComponents(out P);

            if (sccCount == 0)
            {
                return F;
            }

            if (sccCount == 1)
            {
                Tuple<List<int>, List<int>> T = bisect(G);
                F = mfas(subGraph(T.Item1, G));
                F.AddRange(mfas(subGraph(T.Item2, G)));
                F.AddRange(fromV2toV1(T, G));
            }
            else
            {
                var scc = new HashSet<int>(P.Values);
                foreach (int k in scc)
                {
                    List<int> S = P.Select(x => x).Where(x => x.Value == k).Select(x => x.Key).ToList<int>();
                    F.AddRange(mfas(subGraph(S, G)));
                }
            }

            return F;
        }
开发者ID:dima6120,项目名称:Home-Work,代码行数:31,代码来源:FASSE.cs

示例2: ApplyPropertyCasing

 public static Dictionary<string, PropertyInfo> ApplyPropertyCasing(DeserializationContext context, Dictionary<string, PropertyInfo> properties)
 {
     if (context.JsonContractResolver is CamelCasePropertyNamesContractResolver)
     {
         var camel = new Func<string, string>(name => string.Format("{0}{1}", name.Substring(0,1).ToLowerInvariant(), name.Substring(1, name.Length-1)));
         return properties.Select(x => new { Key = camel(x.Key), x.Value }).ToDictionary(x => x.Key, x => x.Value);
     }
     return properties;
 }
开发者ID:KodrAus,项目名称:Neo4jClient,代码行数:9,代码来源:CommonDeserializerMethods.cs

示例3: DictToString

 private static string DictToString(Dictionary<string, object> dict)
 {
     var res = string.Join("; ", dict.Select(
         p => string.Format(
         "{0}, {1}"
         ,   p.Key
         ,   p.Value != null ? p.Value.ToString() : ""
         )
         ).ToArray());
     return res.ToString ();
 }
开发者ID:xsolla,项目名称:xsolla-unity-sdk,代码行数:11,代码来源:TransactionHelper.cs

示例4: CreateTableForType

        private static void CreateTableForType(Type type, Type parent, Dictionary<string, Type> values, string embeddedPrefix = "")
        {
            // Save all scalar and inline types first, so we have the new entry id for our mn-table later
            foreach (var property in PersistentProperty.GetPersistentProperties(type, embeddedPrefix, parent))
            {
                if (property.IsSimpleType)
                {
                    // save array of basic types
                    if (property.Type.IsArray && property.ArrayCount != -1)
                    {
                        for (int i = 0; i < property.ArrayCount; i++)
                        {
                            values.Add(property.ColumnName + "_" + i, property.Property.PropertyType);
                        }
                    }
                    else
                    {
                        values.Add(property.ColumnName, property.Type);
                    }
                    continue;
                }

                if (property.IsGenericList || property.IsGenericDictionary)
                {
                    string query = "";

                    if (property.IsGenericList)
                    {
                        query = "CREATE TABLE {0} ({1}Id NUMERIC, {2}Id NUMERIC)";
                    }

                    if (property.IsGenericDictionary)
                    {
                        query = "CREATE TABLE {0} ({1}Id NUMERIC, {2}Id NUMERIC, Key TEXT)";
                    }

                    query = String.Format(query, property.RelationTableName, parent == null ? type.Name : parent.Name, property.ListType.Name);

                    using (var cmd = new SQLiteCommand(query, DBManager.MPQMirror))
                    {
                        cmd.ExecuteNonQuery();
                    }

                    CreateTableForType(property.ListType, null, new Dictionary<string, Type>());
                    continue;
                }

                values.Add(property.ColumnName + "_", typeof(string));
                CreateTableForType(property.Type, parent == null ? type : parent, values, property.ColumnName + "_");
            }

            // Only create tables for parent classes
            if (parent == null && !tableExists(type.Name))
            {
                if (type.Namespace == "System")
                {
                    values.Add("Value", typeof(string));
                }

                var columnDefinitions = values.Select(v => v.Key + " " + ((v.Value == typeof(String) || v.Value == typeof(byte[])) ? "TEXT" : "NUMERIC")).ToList<string>();
                columnDefinitions.Add("Id INTEGER PRIMARY KEY");
                var tableDefinition = String.Join(",", columnDefinitions.ToArray<string>());

                using (var cmd = new SQLiteCommand(String.Format("CREATE TABLE {0} ({1})", type.Name, tableDefinition), DBManager.MPQMirror))
                {
                    cmd.ExecuteNonQuery();
                }
            }
        }
开发者ID:venci17,项目名称:mooege,代码行数:69,代码来源:PersistenceManager.cs

示例5: Page_Load

		protected void Page_Load(object sender, EventArgs e)
		{
			if (!Page.IsPostBack)
			{
				
				
				DsiPage page = (DsiPage)this.Page;

				var musicTypes = new Dictionary<string, int>() {{"All Music", 0}};
				var musicTypeSet = new MusicTypeSet(new Query(new Q(Bobs.MusicType.Columns.K, page.RelevantMusic.ToArray())));
				foreach (var musicType in musicTypeSet)
				{
					musicTypes[musicType.Name] = musicType.K;
				}
				foreach (var musicType in Identity.Current.FavouriteMusicTypes.ConvertAll(k => new MusicType(k)))
				{
					musicTypes[musicType.Name] = musicType.K;
				}
				this.uiMusicTypes.Items.AddRange(musicTypes.Select(mt => new ListItem(mt.Key, mt.Value.ToString())).ToArray());

				var places = new Dictionary<string, int>() {{"Anywhere", -1}};
				var placeSet = new PlaceSet(new Query(new Q(Bobs.Place.Columns.K, page.RelevantMusic.ToArray())));
				foreach (var place in placeSet)
				{
					places[place.Name] = place.K;
				}
				foreach (var place in Identity.Current.PlacesVisited.ConvertAll(k => new Place(k)))
				{
					places[place.Name] = place.K;
				}
				this.uiPlaces.Items.AddRange(places.Select(mt => new ListItem(mt.Key, mt.Value.ToString())).ToArray());
			}
			//if (Common.Settings.UseCometToServeRequests)
			//{
			//    this.uiBuddyMultiSelector.WebServiceMethod = "";
			//    this.uiBuddyMultiSelector.WebServiceUrl = "";
			//    this.uiBuddyMultiSelector.CometServiceUrl = @"/WebServices/CometAutoComplete/GetBuddiesThenUsrs.ashx";
			//}

			uiBuddyMultiSelector.TextBoxTabIndex = TabIndexBase + 1;
			uiJustBuddiesRadio.TabIndex = (short)(TabIndexBase + 2);
			uiAllMembersRadio.TabIndex = (short)(TabIndexBase + 3);
			uiShowBuddyList.TabIndex = (short)(TabIndexBase + 4);
			uiBuddyList.TabIndex = (short)(TabIndexBase + 5);
			uiShowAddAll.TabIndex = (short)(TabIndexBase + 6);
			uiAddAllButton.Attributes["tabindex"] = (TabIndexBase + 7).ToString();
			uiShowAddBy.TabIndex = (short)(TabIndexBase + 8);
			uiPlaces.TabIndex = (short)(TabIndexBase + 9);
			uiMusicTypes.TabIndex = (short)(TabIndexBase + 10);
			uiAddByMusicAndPlace.Attributes["tabindex"] = (TabIndexBase + 11).ToString();
			uiShowAllTownsAndMusic.TabIndex = (short)(TabIndexBase + 12);


		}
开发者ID:davelondon,项目名称:dontstayin,代码行数:54,代码来源:MultiBuddyChooser.ascx.cs

示例6: CreateQueryString

 public static string CreateQueryString(Dictionary<string, object> dict)
 {
     return (dict == null || dict.Count == 0)
     ?	string.Empty
     :	CreateQueryString(
             dict.Select(kv =>
                 kv.Value is bool
                     ? new KeyValuePair<string, string>(kv.Key, (bool)kv.Value ? "1" : "0")
                     : new KeyValuePair<string, string>(kv.Key, kv.Value != null ? kv.Value.ToString() : null)
             )
         );
 }
开发者ID:wooga,项目名称:ps_social_jam,代码行数:12,代码来源:WwwHelper.cs

示例7: DoDeserializeValue

 protected override object DoDeserializeValue(XmlReader reader, bool isSimpleValue)
 {
   IDictionary<string, MediaCategory_DTO> result_dtos = new Dictionary<string, MediaCategory_DTO>();
   if (SoapHelper.ReadEmptyStartElement(reader)) // Read start of enclosing element
     return new List<MediaCategory>();
   while (reader.NodeType != XmlNodeType.EndElement)
   {
     MediaCategory_DTO result_dto = MediaCategory_DTO.Deserialize(reader);
     result_dtos.Add(result_dto.CategoryName, result_dto);
   }
   reader.ReadEndElement(); // End of enclosing element
   return new List<MediaCategory>(result_dtos.Select(mCatDtoKvp => mCatDtoKvp.Value.GetMediaCategory(result_dtos)));
 }
开发者ID:chekiI,项目名称:MediaPortal-2,代码行数:13,代码来源:UPnPDtMediaCategoryEnumeration.cs

示例8: Serialize

        // Methods
        public static string Serialize(object value = null, string prefix = null)
        {
            // Require
            if (value == null) return string.Empty;

            // Result
            var nameValueDictionary = new Dictionary<string, string>();

            // Serialize
            SerializeObject(ref nameValueDictionary, value, prefix);

            // Return
            return string.Join("&", nameValueDictionary.Select(nameValuePair => (nameValuePair.Key + "=" + Uri.EscapeDataString(nameValuePair.Value))));
        }
开发者ID:Clark159,项目名称:CLK.Web.Mvc,代码行数:15,代码来源:ModelSerializer.cs

示例9: GetErrors

        /// <summary>
        ///     Updates errorEntryList with a page of errors from the repository in descending order of logged time and returns
        ///     total number of entries
        /// </summary>
        public override int GetErrors(int pageIndex, int pageSize, IList errorEntryList)
        {
            var errors = new Dictionary<string, ErrorRecord>();

            // todo: proper async support
            var totalCount = _errorRepository.GetErrorsAsync(pageIndex, pageSize, errors).Result;
            var errorLogEntries = errors.Select(error => new ErrorLogEntry(this, error.Key, error.Value.ToError()));

            foreach (var errorLogEntry in errorLogEntries)
            {
                errorEntryList.Add(errorLogEntry);
            }

            return totalCount;
        }
开发者ID:OpenMagic,项目名称:ElmahMagic.Repository,代码行数:19,代码来源:RepositoryErrorLog.cs

示例10: OnGameLoad

        private static void OnGameLoad(EventArgs args)
        {
            try
            {
                pSkins = GetSkins(ObjectManager.Player.ChampionName);

                Config = new Menu("鐨偆淇敼", "Skin Changer", true);
                var SelectedSkin = Config.AddItem(new MenuItem("currentSkin", " ").SetValue(new StringList(pSkins.Select(item => item.Value).ToArray())).DontSave());
                var SwitchSkin = Config.AddItem(new MenuItem("keySwitch", "鐐规垜淇敼").SetValue(new KeyBind("9".ToCharArray()[0], KeyBindType.Press)));

                SelectedSkin.ValueChanged += (object sender, OnValueChangeEventArgs vcArgs) =>
                {
                    Packet.S2C.UpdateModel.Encoded(new Packet.S2C.UpdateModel.Struct(ObjectManager.Player.NetworkId, vcArgs.GetNewValue<StringList>().SelectedIndex, ObjectManager.Player.ChampionName)).Process(PacketChannel.S2C);
                };
            {

            Config.AddSubMenu(new Menu("L#涓枃绀惧尯姹夊寲", "LOLL35.Com"));
                Config.SubMenu("LOLL35.Com").AddItem(new MenuItem("wangzhi", "www.loll35.com"));
                Config.SubMenu("LOLL35.Com").AddItem(new MenuItem("qunhao2", "姹夊寲缇わ細397983217"));
            }

                SwitchSkin.ValueChanged += (object sender, OnValueChangeEventArgs vcArgs) =>
                {
                    if (vcArgs.GetOldValue<KeyBind>().Active) return;

                    var currentSkin = Config.Item("currentSkin");
                    var OldValues = currentSkin.GetValue<StringList>();
                    var newSkinId = OldValues.SelectedIndex + 1 >= OldValues.SList.Count() ? 0 : OldValues.SelectedIndex + 1;
                    currentSkin.SetValue(new StringList(OldValues.SList, newSkinId));
                };

                Config.AddToMainMenu();

                Game.PrintChat("<font color=\"#0066FF\">[<font color=\"#FFFFFF\">madk</font>]</font><font color=\"#FFFFFF\"> Skin Changer loaded!</font>");
            }
            catch(Exception ex)
            {
                Game.PrintChat("<font color=\"#0066FF\">[<font color=\"#FFFFFF\">madk</font>]</font><font color=\"#FFFFFF\"> An error ocurred loading Skin Changer.</font>");

                Console.WriteLine("~~ Skin Changer exception found ~~");
                Console.WriteLine(ex);
                Console.WriteLine("~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~");
            }
        }
开发者ID:lanyi777,项目名称:CN,代码行数:44,代码来源:Program.cs

示例11: Filter

 /// <summary>
 /// Given a Lucene Query, this will build the facets and append them to find the Bit comparison of two queries.
 /// </summary>
 /// <returns>List of FacetReturn</returns>
 /// <param name="query">The initial query</param>
 /// <param name="searchQuery">The raw search query</param>
 /// <param name="locationFilter">The location used to determine which index to use</param>
 /// <param name="baseQuery">The initial queries bit array</param>
 public List<FacetReturn> Filter(Query query, List<SearchStringModel> searchQuery, string locationFilter, BitArray baseQuery)
 {
     var listOfDates = new Dictionary<DateTime, string>
         {
             { DateTime.Now.AddDays(-1), "Within a Day" },
             { DateTime.Now.AddDays(-7), "Within a Week" },
             { DateTime.Now.AddMonths(-1), "Within a Month" },
             { DateTime.Now.AddYears(-1), "Within a Year" },
             { DateTime.Now.AddYears(-3), "Older" }
         };
     var returnFacets =
                   this.GetSearch(query, listOfDates.Select(date => date.Key.ToString() + "|" + date.Value).ToList(), searchQuery, locationFilter, baseQuery).Select(
                   facet =>
                   new FacetReturn
                       {
                           KeyName = DecodeDateSearch(DateTime.Parse(facet.Key.Split('|')[0]), listOfDates),
                           Value = facet.Value.ToString(),
                           Type = "date range"
                       });
     return returnFacets.ToList();
 }
开发者ID:csteeg,项目名称:Sitecore-Item-Buckets,代码行数:29,代码来源:DateRangeFacet.cs

示例12: RosetteRelationship

 /// <summary>
 /// Creates a grammatical relationship
 /// </summary>
 /// <param name="predicate">The main action or verb acting on the first argument, or the action connecting multiple arguments.</param>
 /// <param name="arguments">The mention(s), mapped to the argument number, of one or more arguments in the relationship</param>
 /// <param name="IDs">The IDs of the arguments, mapped to the corresponding argument number.  The ID with key 1 should correspond to the argument with key 1.</param>
 /// <param name="temporals">Time frames of the action.  May be empty.</param>
 /// <param name="locatives">Locations of the action.  May be empty.</param>
 /// <param name="adjunts">All other parts of the relationship.  May be empty.</param>
 /// <param name="confidence">A score for each relationship result, ranging from 0 to 1. You can use this measurement as a threshold to filter out undesired results.</param>
 /// <param name="modalities">The modalities of the relationship.</param>
 public RosetteRelationship(string predicate, Dictionary<int, string> arguments, Dictionary<int, string> IDs, List<string> temporals, List<string> locatives, List<string> adjunts, Nullable<decimal> confidence, HashSet<string> modalities)
 {
     this.Predicate = predicate;
     #pragma warning disable 618
     this.Arguments = arguments.Select(kvp => kvp.Value).ToList();
     this.ArgumentsFull = new List<Argument>(arguments.Select<KeyValuePair<int, string>, Argument>((kvp, index) => new Argument(kvp.Key, kvp.Value, IDs == null || !IDs.ContainsKey(kvp.Key) || IDs[kvp.Key] == null ? null : new EntityID(IDs[kvp.Key]))));
     #pragma warning restore 618
     this.Temporals = temporals;
     this.Locatives = locatives;
     this.Adjucts = adjunts;
     this.Confidence = confidence;
     this.Modalities = modalities;
 }
开发者ID:rosette-api,项目名称:csharp,代码行数:24,代码来源:RelationshipsResponse.cs

示例13: testCAPTCHA


//.........这里部分代码省略.........
                    }
                    Array.Sort(edgedists[i], (a, b) => a.Value.CompareTo(b.Value));
                }
                #endregion

                var charlist = new List<Tuple<string, int, PointF>>(); // <ch, count, center>
                //for (int rc = 0, rt = 0; rc < randcount && rt < maxrandcount; ++rt) {
                //    #region 随机取一个中心点,并且取离他近的点计算形状上下文
                //int center = rand.Next(sq);
                //if (edge_vi[center]) continue;
                //else rc++;
                //rc++;
                //var nearby = new List<Point>();
                //foreach (var pair in edgedists[center].Take((int)(s * 1.5))) {
                //    nearby.Add(edge[pair.Index]);
                //    edge_vi[pair.Index] = true;
                //}
                //nearby = nearby.Sample(s);
                for (int wd = 0; wd < windowcount; ++wd) {
                    #region 滑动窗口位置
                    //int window_center = wd * windowstep + (windowwidth / 2);
                    double window_center = (wd * 2 + overlap / 2.0) * slice_width;
                    g.DrawLine(Pens.Green, (float)window_center, 0, (float)window_center, img.Height);
                    var nearby = edge.Where(p => Math.Abs(p.X - window_center) < img.Height)
                                     .OrderBy(p => Math.Abs(p.X - window_center))
                                     .Take((int)(s * 1.2))
                                     .ToList().Sample(s);
                    if (nearby.Average(p => Math.Abs(p.X - window_center)) > img.Height) continue;
                    var sc = Jim.OCR.ShapeContext2D.ShapeContext.ComputeSC2(nearby);

                    #endregion

                    #region 对待测图的形状上下文进行量化

                    int[] histogram = new int[K];
                    for (int i = 0; i < s; ++i) {
                        double[] ds = new double[K];
                        for (int j = 0; j < K; ++j)
                            ds[j] = Jim.OCR.ShapeContext2D.ShapeContext.HistCost(sc[i], shapemes[j]);
                        int id = ds.Select((v, idx) => new ValueIndexPair<double> { Value = v, Index = idx })
                            .OrderBy(p => p.Value)
                            .First().Index;
                        ++histogram[id];
                    }

                    #endregion

                    #region 计算量化后的比较距离

                    double[] dists = new double[templatecount];
                    for (int i = 0; i < templatecount; ++i) {
                        //dists[i] = Jim.OCR.ShapeContext2D.ShapeContext.ChiSquareDistance(histogram, templatehistograms[i]);
                        dists[i] = Jim.OCR.ShapeContext2D.ShapeContext.HistCost(
                            histogram.Select(d => (double)d).ToArray(),
                            templatehistograms[i].Select(d => (double)d).ToArray());
                    }

                    #endregion

                    #region 对结果进行排序和统计

                    var arr = dists.Select((d, i) => new ValueIndexPair<double> { Value = d, Index = i })
                        .OrderBy(p => p.Value)
                        .Select(p => new { Distance = p.Value, Char = templatechars[p.Index] })
                        .Where(p => "0123456789".IndexOf(p.Char) != -1)
                        .ToArray();
                    Dictionary<string, int> matchcount = new Dictionary<string, int>();
                    int knn = 10;
                    foreach (var pair in arr.Take(knn)) {
                        string ch = pair.Char;
                        matchcount[ch] = matchcount.ContainsKey(ch) ? matchcount[ch] + 1 : 1;
                    }
                    var match = matchcount.Select(pair => new { Count = pair.Value, Ch = pair.Key })
                        .Where(v => v.Count > 0)
                        .OrderByDescending(v => v.Count).ToArray();
                    var firstmatch = match[0];
                    PointF newcenter = new PointF(nearby.Average(p => (float)p.X), nearby.Average(p => (float)p.Y));
                    charlist.Add(new Tuple<string, int, PointF> {
                        First = firstmatch.Ch,
                        Second = firstmatch.Count,
                        Third = newcenter
                    });

                    #endregion
                }
                foreach (var tp in charlist) {
                    string ch = tp.First;
                    int acc = tp.Second;
                    PointF center = tp.Third;
                    //g.DrawString(num.ToString(), new Font("Arial", 24), new SolidBrush(Color.FromArgb(40 + 20 * acc, 0, 0)),
                    //            new PointF(center.X - 12, center.Y - 12));
                    g.DrawString(ch, new Font("Arial", 24), (acc >= 5 ? Brushes.Red : Brushes.DarkGreen),
                                new PointF(center.X - 12, center.Y - 12));
                }
                mmp.Save(Path.Combine(@"D:\Play Data\测试玩意\", filename + ".jpg"));
                Debug("{0}-{1}ms", filename, timer.Stop());

            }
            #endregion
        }
开发者ID:pakerliu,项目名称:sharp-context,代码行数:101,代码来源:Program.cs

示例14: CheckOrder

        public void CheckOrder(OrderMaster orderMaster)
        {
            BusinessException ex = new BusinessException();
            if (orderMaster.Type == com.Sconit.CodeMaster.OrderType.CustomerGoods
                || orderMaster.Type == com.Sconit.CodeMaster.OrderType.Procurement)
            {
                ex.AddMessage("订单" + orderMaster.OrderNo + "无需检查库存");
            }
            else
            {
                var paramList = new List<object>();
                string sql = string.Empty;
                paramList.Add(orderMaster.LocationFrom);

                var itemQtyDic = new Dictionary<string, decimal>();
                if (orderMaster.Type == CodeMaster.OrderType.Production)
                {
                    TryLoadOrderBomDetails(orderMaster);
                    if (orderMaster.OrderDetails != null)
                    {
                        itemQtyDic = orderMaster.OrderDetails
                            .SelectMany(p => p.OrderBomDetails)
                            .GroupBy(p => p.Item).ToDictionary(d => d.Key, d => d.Sum(q => q.OrderedQty));
                    }

                    string hql = @"select distinct(isnull(d.LocFrom,f.LocFrom)) from Scm_FlowDet as d 
                               join SCM_FlowMstr f on d.Flow = f.Code
                               where f.IsActive = ? and (d.LocTo =? or (d.LocTo is null and f.LocTo = ? ))
                               and d.Item in(?  ";
                    var locations = genericMgr.FindAllWithNativeSqlIn<string>
                        (hql, itemQtyDic.Select(p => p.Key), new object[] { true, orderMaster.LocationFrom, orderMaster.LocationFrom });

                    foreach (var location in locations)
                    {
                        if (sql == string.Empty)
                        {
                            sql = @" select l.* from VIEW_LocationDet as l with(nolock) where l.ATPQty>0 and l.Location in(?,? ";
                        }
                        else
                        {
                            sql += ",?";
                        }
                    }
                    paramList.AddRange(locations);
                }
                else
                {
                    TryLoadOrderDetails(orderMaster);
                    if (orderMaster.OrderDetails != null)
                    {
                        itemQtyDic = orderMaster.OrderDetails
                            .GroupBy(p => p.Item).ToDictionary(d => d.Key, d => d.Sum(q => q.OrderedQty));
                    }
                    sql = @" select l.* from VIEW_LocationDet as l with(nolock) where l.ATPQty>0 and (l.Location =? ";
                }
                sql += @" ) and l.Item in(? ";

                IList<LocationDetailView> locationDetailViewList = this.genericMgr.FindEntityWithNativeSqlIn<LocationDetailView>
                    (sql, itemQtyDic.Select(p => p.Key), paramList);

                var invDic = (from p in locationDetailViewList
                              group p by p.Item into g
                              select new
                              {
                                  Item = g.Key,
                                  Qty = g.Sum(q => q.ATPQty)
                              }).ToDictionary(d => d.Item, d => d.Qty);
                foreach (var itemQty in itemQtyDic)
                {
                    var diffQty = itemQty.Value - invDic.ValueOrDefault(itemQty.Key);
                    if (diffQty > 0)
                    {
                        ex.AddMessage(string.Format("物料:{0}[{1}]没有足够的库存,缺口:{2}",
                            itemQty.Key, itemMgr.GetCacheItem(itemQty.Key).FullDescription, diffQty.ToString("0.##")));
                    }
                }
            }
            if (ex.GetMessages() != null && ex.GetMessages().Count > 0)
            {
                throw ex;
            }
        }
开发者ID:druidwang,项目名称:Les_parts,代码行数:82,代码来源:OrderMgrImpl.cs

示例15: LoadHyphenationSettings

        private void LoadHyphenationSettings()
        {
            var ssf = _settingsHelper.GetSettingsFilename(_settingsHelper.Database);
            if (ssf != null && ssf.Trim().Length > 0)
            {
	            if (AppDomain.CurrentDomain.FriendlyName.ToLower() == "paratext.exe")
	            {
		            var paratextpath = Path.Combine(Path.GetDirectoryName(ssf), _settingsHelper.Database);
		            Param.DatabaseName = _settingsHelper.Database;
		            Param.IsHyphen = false;
		            Param.HyphenLang = Common.ParaTextDcLanguage(_settingsHelper.Database, true);
		            foreach (string filename in Directory.GetFiles(paratextpath, "*.txt"))
		            {
			            if (filename.Contains("hyphen"))
			            {
				            Param.IsHyphen = true;
				            Param.HyphenFilepath = filename;
				            Param.HyphenationSelectedLanguagelist.AddRange(Param.HyphenLang.Split(','));
			            }
		            }
	            }
	            if (AppDomain.CurrentDomain.FriendlyName.ToLower().Contains("fieldworks"))
	            {
		            var xdoc = new XmlDocument();
		            try
		            {
						IDictionary<string,string> value=new Dictionary<string, string>();
						var settingsFile = ssf;
			            xdoc.Load(settingsFile);
			            var curVernWssnode = xdoc.SelectSingleNode("//CurVernWss/Uni");
			            if (curVernWssnode != null)
			            {
				            foreach (var lang in curVernWssnode.InnerText.Split(' '))
				            {
								var langname = GetLanguageValues(lang);
					            if (!string.IsNullOrEmpty(lang) && (langname != null) && !value.ContainsKey(lang))
						            value.Add(lang, langname.Replace(',',' '));
				            }
			            }
			            var curAnalysisWssnode = xdoc.SelectSingleNode("//CurAnalysisWss/Uni");
			            if (curAnalysisWssnode != null)
			            {
							foreach (var lang in curAnalysisWssnode.InnerText.Split(' '))
				            {
								var langname = GetLanguageValues(lang);
								if (!string.IsNullOrEmpty(lang) && (langname != null) && !value.ContainsKey(lang))
									value.Add(lang, langname.Replace(',', ' '));
				            }
			            }
						Param.HyphenLang = string.Join(",", value.Select(x => x.Key + ":" + x.Value).ToArray());
		            }
		            catch (Exception)
		            {
		            }
	            }

            }
			Common.EnableHyphenation();
            CreatingHyphenationSettings.ReadHyphenationSettings(_settingsHelper.Database, InputType);
            foreach (string lang in Param.HyphenLang.Split(','))
            {
                    clbHyphenlang.Items.Add(lang, (Param.HyphenationSelectedLanguagelist.Contains(lang) ? true : false));
            }
        }
开发者ID:neilmayhew,项目名称:pathway,代码行数:64,代码来源:ExportThroughPathway.cs


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