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


C# SortedList.TryGetValue方法代码示例

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


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

示例1: Main

        static void Main()
        {
            var books = new SortedList<string, string>();
              books.Add("Professional WPF Programming", "978–0–470–04180–2");
              books.Add("Professional ASP.NET MVC 3", "978–1–1180–7658–3");

              books["Beginning Visual C# 2010"] = "978–0–470-50226-6";
              books["Professional C# 4 and .NET 4"] = "978–0–470–50225–9";

              foreach (KeyValuePair<string, string> book in books)
              {
            Console.WriteLine("{0}, {1}", book.Key, book.Value);
              }

              foreach (string isbn in books.Values)
              {
            Console.WriteLine(isbn);
              }

              foreach (string title in books.Keys)
              {
            Console.WriteLine(title);
              }

              {
            string isbn;
            string title = "Professional C# 7.0";
            if (!books.TryGetValue(title, out isbn))
            {
              Console.WriteLine("{0} not found", title);
            }
              }
        }
开发者ID:Ricky-Hao,项目名称:ProCSharp,代码行数:33,代码来源:Program.cs

示例2: GetFrames

        /// <summary>
        /// Gets concentrated frames from the provided stream
        /// </summary>
        /// <param name="stream">the database to use</param>
        /// <returns></returns>
        public static SortedList<DateTime, FrameData> GetFrames(this TreeStream<HistorianKey, HistorianValue> stream)
        {
            SortedList<DateTime, FrameDataConstructor> results = new SortedList<DateTime, FrameDataConstructor>();
            ulong lastTime = ulong.MinValue;
            FrameDataConstructor lastFrame = null;
            HistorianKey key = new HistorianKey();
            HistorianValue value = new HistorianValue();
            while (stream.Read(key, value))
            {
                if (lastFrame == null || key.Timestamp != lastTime)
                {
                    lastTime = key.Timestamp;
                    DateTime timestamp = new DateTime((long)lastTime);

                    if (!results.TryGetValue(timestamp, out lastFrame))
                    {
                        lastFrame = new FrameDataConstructor();
                        results.Add(timestamp, lastFrame);
                    }
                }
                lastFrame.PointId.Add(key.PointID);
                lastFrame.Values.Add(value.ToStruct());
            }
            List<FrameData> data = new List<FrameData>(results.Count);
            data.AddRange(results.Values.Select(x => x.ToFrameData()));
            return SortedListConstructor.Create(results.Keys, data);
        }
开发者ID:GridProtectionAlliance,项目名称:openHistorian,代码行数:32,代码来源:GetFrameMethods_KeyValueStream.cs

示例3: Main

        static void Main(string[] args)
        {
            var books = new SortedList<string, string>();
            books.Add("C# 2008 Wrox Box", "978–0–470–047205–7");
            books.Add("Professional ASP.NET MVC 1.0", "978–0–470–38461–9");

            books["Beginning Visual C# 2008"] = "978–0–470-19135-4";
            books["Professional C# 2008"] = "978–0–470–19137–6";

            foreach (KeyValuePair<string, string> book in books)
            {
                Console.WriteLine("{0}, {1}", book.Key, book.Value);
            }

            foreach (string isbn in books.Values)
            {
                Console.WriteLine(isbn);
            }

            foreach (string title in books.Keys)
            {
                Console.WriteLine(title);
            }

            {
                string isbn;
                string title = "Professional C# 7.0";
                if (!books.TryGetValue(title, out isbn))
                {
                    Console.WriteLine("{0} not found", title);
                }
            }
            Console.ReadKey();
        }
开发者ID:CSharpDev,项目名称:Csharp,代码行数:34,代码来源:Program.cs

示例4: SelectData

        public SortedList<string, int[]> SelectData(string query)
        {
            SQLiteConnection m_dbConnection = new SQLiteConnection(ConnectString);
            m_dbConnection.Open();
            SQLiteCommand command = new SQLiteCommand(query, m_dbConnection);
            SQLiteDataReader reader = command.ExecuteReader();
            SortedList<String, int[]> sl = new SortedList<String, int[]>();

            /*
             * As the input we have strings formatted like "string year, string month, int sum"
             * So we'd parse this data and push it into sorted list named sl to output correctly.
             */
            while (reader.Read())
            {
                int year = 0;
                int month = 0;
                for (int i = 0; i < reader.FieldCount; i++)
                {
                    Console.Write(reader.GetValue(i) + "   ");

                    var tmp = reader.GetValue(i);

                    if (tmp.GetType() == typeof(System.String))  //if we have "string - type" variable
                    {
                        int temp = Convert.ToInt32(reader.GetValue(i));    //convert reader string value to int
                        if (temp / 100 != 0)
                        {
                            //memorise year
                            year = temp;
                            //add new year into list and create array for 12 months this year
                            sl.Add(tmp.ToString(), new int[13]);
                        }
                        else
                        {
                            //memorise month
                            month = temp;
                        }
                    }
                    else
                    {
                        int temp = Convert.ToInt32(reader.GetValue(i));
                        int[] value;
                        //get values (array of months and sums)
                        sl.TryGetValue(year.ToString(), out value);
                        value[month] = temp;
                    }
                }
            }
            //close the connection with DB
            m_dbConnection.Close();
            return sl;
        }
开发者ID:AlexPy,项目名称:Test-task,代码行数:52,代码来源:SqlQuery2.cs

示例5: Aggregate

        public static List<Point> Aggregate(SortedList<long, int>[] hists, int repeats, int sums, out long minTime)
        {
            SortedList<long, int> sumHist = new SortedList<long, int>();

            foreach (var hist in hists)
                foreach (var pair in hist)
                {
                    int ex;
                    if (sumHist.TryGetValue(pair.Key, out ex))
                        sumHist[pair.Key] = ex + pair.Value;
                    else
                        sumHist.Add(pair.Key, pair.Value);
                }

            minTime = sumHist.First().Key;

            return Normalize(sumHist, repeats * hists.Length, sums);
        }
开发者ID:ExM,项目名称:LogBenchmark,代码行数:18,代码来源:Toolkit.cs

示例6: AddToSortedBounds

        static void AddToSortedBounds(SortedList<int, BoundOwner> sortedBounds, int position, bool setA)
        {
            BoundOwner value;

            if (sortedBounds.TryGetValue(position, out value))
            {
                value.A ^= setA;
                value.B ^= !setA;

                sortedBounds[position] = value;
            }
            else
            {
                value.A = setA;
                value.B = !setA;

                sortedBounds.Add(position, value);
            }
        }
开发者ID:xiangyuan,项目名称:Unreal4,代码行数:19,代码来源:IntervalSet.cs

示例7: CreateHistogram

        public static SortedList<long, int> CreateHistogram(Action<int> action, int repeats, int sums)
        {
            SortedList<long, int> hist = new SortedList<long, int>();

            for(int i = 0; i < repeats; i++)
            {
                action(0);
                long start = Stopwatch.GetTimestamp();
                for(int j = 0; j < sums; j++)
                    action(j);
                long t = Stopwatch.GetTimestamp() - start;

                int ex;
                if (hist.TryGetValue(t, out ex))
                    hist[t] = ex + 1;
                else
                    hist.Add(t, 1);
            }

            return hist;
        }
开发者ID:ExM,项目名称:LogBenchmark,代码行数:21,代码来源:Toolkit.cs

示例8: Main

        static void Main()
        {
            var books = new SortedList<string, string>();
            books.Add("Professional WPF Programming", "978–0–470–04180–2");
            books.Add("Professional ASP.NET MVC 5", "978–1–118-79475–3");

            books["Beginning Visual C# 2012 Programming"] = "978–1–118-31441-8";
            books["Professional C# 5.0 and .NET 4.5.1"] = "978–1–118–83303–2";

            foreach (KeyValuePair<string, string> book in books)
            {
                WriteLine($"{book.Key}, {book.Value}");
            }

            foreach (string isbn in books.Values)
            {
                WriteLine(isbn);
            }

            foreach (string title in books.Keys)
            {
                WriteLine(title);
            }

            {
                string isbn;
                string title = "Professional C# 7.0";
                if (!books.TryGetValue(title, out isbn))
                {
                    WriteLine($"{title} not found");
                }
            }



        }
开发者ID:ProfessionalCSharp,项目名称:ProfessionalCSharp6,代码行数:36,代码来源:Program.cs

示例9: AddToOrderedMiddleDots


//.........这里部分代码省略.........
            catch (Exception)
            {
                dirInfo = null;
            }

            if (dirInfo != null)
            {

                string root = null;
                string company = null;
                string repository = null;
                string workingDir = null;

                workingDir = dirInfo.Name;
                dirInfo = dirInfo.Parent;
                if (dirInfo != null)
                {
                    repository = dirInfo.Name;
                    dirInfo = dirInfo.Parent;
                }
                bool addDots = false;

                if (dirInfo != null)
                {
                    while (dirInfo.Parent != null && dirInfo.Parent.Parent != null)
                    {
                        dirInfo = dirInfo.Parent;
                        addDots = true;
                    }
                    company = dirInfo.Name;
                    if (dirInfo.Parent != null)
                        root = dirInfo.Parent.Name;
                }

                Func<int, bool> shortenPath = delegate(int skipCount)
                {
                    bool result = false;
                    string c = null;
                    string r = null;
                    if (company != null)
                    {
                        if (company.Length > skipCount)
                        {
                            c = company.Substring(0, company.Length - skipCount);
                            result = true;
                        }
                    }

                    if (repository != null)
                    {
                        if (repository.Length > skipCount)
                        {
                            r = repository.Substring(skipCount, repository.Length - skipCount);
                            result = true;
                        }
                    }

                    repoInfo.Caption = MakePath(root, c);
                    if (addDots)
                        repoInfo.Caption = MakePath(repoInfo.Caption, "...");

                    repoInfo.Caption = MakePath(repoInfo.Caption, r);
                    repoInfo.Caption = MakePath(repoInfo.Caption, workingDir);

                    return result && addDots;
                };

                //if fixed width is not set then short as in pull request vccp's example
                //full "E:\CompanyName\Projects\git\ProductName\Sources\RepositoryName\WorkingDirName"
                //short "E:\CompanyName\...\RepositoryName\WorkingDirName"
                if (this.RecentReposComboMinWidth == 0)
                {
                    shortenPath(0);
                }
                //else skip symbols beginning from the middle to both sides,
                //so we'll see "E:\Compa......toryName\WorkingDirName" and "E:\...\WorkingDirName" at the end.
                else
                {
                    SizeF captionSize;
                    bool canShorten;
                    int skipCount = 0;
                    do
                    {
                        canShorten = shortenPath(skipCount);
                        skipCount++;
                        captionSize = graphics.MeasureString(repoInfo.Caption, measureFont);
                    }
                    while (captionSize.Width > RecentReposComboMinWidth && canShorten);
                }
            }

            List<RecentRepoInfo> list = null;

            if (!orderedRepos.TryGetValue(repoInfo.Caption, out list))
            {
                list = new List<RecentRepoInfo>();
                orderedRepos.Add(repoInfo.Caption, list);
            }
            list.Add(repoInfo);
        }
开发者ID:nitoyon,项目名称:gitextensions,代码行数:101,代码来源:RecentRepoInfo.cs

示例10: LinkProcAddressImports

		/// <summary>
		/// Link delegates fields using import declarations.
		/// </summary>
		/// <param name="path">
		/// A <see cref="System.String"/> that specifies the assembly file path containing the import functions.
		/// </param>
		/// <param name="type">
		/// A <see cref="System.Type"/> that specifies the type used for detecting import declarations and delegates fields.
		/// </param>
		/// <param name="getAddress">
		/// A <see cref="GetAddressDelegate"/> used for getting function pointers. This parameter is dependent on the currently running platform.
		/// </param>
		/// <param name="sImportMap">
		/// A <see cref="T:SortedList{String, MethodIndo}"/> mapping a <see cref="MethodInfo"/> with the relative function name.
		/// </param>
		/// <param name="sDelegates">
		/// A <see cref="T:List{FieldInfo}"/> listing <see cref="FieldInfo"/> related to function delegates.
		/// </param>
		/// <remarks>
		/// <para>
		/// The type <paramref name="type"/> shall have defined a nested class named "UnsafeNativeMethods" specifying the import declarations and a nested
		/// class named "Delagates" specifying the delegate fields.
		/// </para>
		/// </remarks>
		private static void LinkProcAddressImports(string path, Type type, GetAddressDelegate getAddress, out SortedList<string, MethodInfo> sImportMap, out List<FieldInfo> sDelegates)
		{
			Type impClass = type.GetNestedType("UnsafeNativeMethods", BindingFlags.Static | BindingFlags.NonPublic | BindingFlags.Public);
			Debug.Assert(impClass != null);

			Type delClass = type.GetNestedType("Delegates", BindingFlags.Static | BindingFlags.NonPublic);
			Debug.Assert(delClass != null);

			// Query imports declarations
			MethodInfo[] iMethods = impClass.GetMethods(BindingFlags.Static | BindingFlags.NonPublic);

			sImportMap = new SortedList<string, MethodInfo>(iMethods.Length);
			foreach (MethodInfo m in iMethods)
				sImportMap.Add(m.Name, m);

			// Query delegates declarations
			sDelegates = new List<FieldInfo>(delClass.GetFields(BindingFlags.Static | BindingFlags.NonPublic));

			foreach (FieldInfo fi in sDelegates) {
				Delegate pDelegate = null;
				string pImportName = fi.Name.Substring(1);
				IntPtr mAddr = getAddress(path, pImportName);

				if (mAddr != IntPtr.Zero) {
					// Try to load external symbol
					if ((pDelegate = Marshal.GetDelegateForFunctionPointer(mAddr, fi.FieldType)) == null) {
						MethodInfo mInfo;

						if (sImportMap.TryGetValue(pImportName, out mInfo) == true)
							pDelegate = Delegate.CreateDelegate(fi.FieldType, mInfo);
					}

					if (pDelegate != null)
						fi.SetValue(null, pDelegate);
				}
			}
		}
开发者ID:rhynodegreat,项目名称:OpenGL.Net,代码行数:61,代码来源:KhronosApi.cs

示例11: ValidateMatch

        /// <summary>
        ///     Validates whether new match is an exact sub match with any of the previous matches if not then returns the match in
        ///     out param.
        /// </summary>
        /// <param name="queryIndex">Query index</param>
        /// <param name="referenceIndex">Reference index</param>
        /// <param name="matchLength">Match length</param>
        /// <param name="previousMatches">Previous matches</param>
        /// <param name="match">New match</param>
        /// <returns>Returns true if the new match is not an exact sub match with any of the previous matches, else returns false</returns>
        private static bool ValidateMatch(
            long queryIndex,
            long referenceIndex,
            long matchLength,
            SortedList<long, Dictionary<long, SortedList<long, SortedSet<long>>>> previousMatches,
            out Match match)
        {
            bool isoverlapedMatchFound = false;

            long lastQueryEndIndex;
            int overlappingMatchesCount = previousMatches.Keys.Count();
            if (overlappingMatchesCount > 0)
            {
                lastQueryEndIndex = previousMatches.Keys.Last();
                if (lastQueryEndIndex < queryIndex)
                {
                    previousMatches.Clear();
                }
            }

            overlappingMatchesCount = previousMatches.Keys.Count();

            for (int listIndex = overlappingMatchesCount - 1; listIndex >= 0; listIndex--)
            {
                lastQueryEndIndex = previousMatches.Keys[listIndex];
                if (lastQueryEndIndex >= queryIndex + matchLength)
                {
                    Dictionary<long, SortedList<long, SortedSet<long>>> diffMap = previousMatches[lastQueryEndIndex];
                    SortedList<long, SortedSet<long>> refEndIndexMap;
                    if (diffMap.TryGetValue(queryIndex - referenceIndex, out refEndIndexMap))
                    {
                        int refEndIndexCount = refEndIndexMap.Count;
                        for (int refEndMapIndex = refEndIndexCount - 1; refEndMapIndex >= 0; refEndMapIndex--)
                        {
                            long refEndindex = refEndIndexMap.Keys[refEndMapIndex];

                            if (refEndindex >= referenceIndex + matchLength)
                            {
                                SortedSet<long> refStartIndexes = refEndIndexMap[refEndindex];
                                isoverlapedMatchFound =
                                    refStartIndexes.Any(refStartIndex => refStartIndex <= referenceIndex);
                                if (isoverlapedMatchFound)
                                {
                                    break;
                                }
                            }
                        }

                        if (isoverlapedMatchFound)
                        {
                            break;
                        }
                    }
                }
                else
                {
                    if (lastQueryEndIndex < queryIndex)
                    {
                        previousMatches.Remove(lastQueryEndIndex);
                    }

                    break;
                }
            }

            match = new Match();

            if (!isoverlapedMatchFound)
            {
                match.ReferenceSequenceOffset = referenceIndex;
                match.QuerySequenceOffset = queryIndex;
                match.Length = matchLength;
                long queryEndIndex = queryIndex + matchLength;
                long diffValue = queryIndex - referenceIndex;
                long refEndIndex = referenceIndex + matchLength;
                Dictionary<long, SortedList<long, SortedSet<long>>> diffsMap;
                SortedList<long, SortedSet<long>> refEndIndexMap;
                SortedSet<long> refStartIndexes;
                if (previousMatches.TryGetValue(queryEndIndex, out diffsMap))
                {
                    if (diffsMap.TryGetValue(diffValue, out refEndIndexMap))
                    {
                        if (refEndIndexMap.TryGetValue(refEndIndex, out refStartIndexes))
                        {
                            refStartIndexes.Add(referenceIndex);
                        }
                        else
                        {
                            refStartIndexes = new SortedSet<long>();
                            refStartIndexes.Add(referenceIndex);
//.........这里部分代码省略.........
开发者ID:cpatmoore,项目名称:bio,代码行数:101,代码来源:MultiWaySuffixTree.cs

示例12: AddToVerticalCounts

        private void AddToVerticalCounts(ref SortedList<int, int> slVerticalCounts, List<TextRecord> txtRow)
        {
             // deal with collected row!
            // remember last type - eg if last text, and this number, want number left/text right also
            if (txtRow.Count >= 1)
            {
                if (m_iMaxCols < txtRow.Count)  // ok as long as no multi text in one column :)
                    m_iMaxCols = txtRow.Count;

                // add rects into colgaps
                AddToColGaps(txtRow);

                // add rect left and/or right to slVerticalCounts
                foreach (TextRecord tr in txtRow)
                {
                    int iLeft = tr.Text.Bounds.Left;
                    int iRight = tr.Text.Bounds.Right;

                    // TODO: if last was text, and this number, then store range between the last right and current left
                    // as could be wider. Also, could possibly stash common col widths and use that!!

                    int iCount = 0;
                    if (iLeft > -1)
                    {
                        if (slVerticalCounts.TryGetValue(iLeft, out iCount))
                            slVerticalCounts[iLeft] = ++iCount;
                        else
                            slVerticalCounts[iLeft] = 1;
                    }

                    if (iRight > -1)
                    {
                        if (slVerticalCounts.TryGetValue(iRight, out iCount))
                            slVerticalCounts[iRight] = ++iCount;
                        else
                            slVerticalCounts[iRight] = 1;
                    }
                }
            }
        }
开发者ID:killbug2004,项目名称:WSProf,代码行数:40,代码来源:GridResolver.cs

示例13: ProcessRules

	static void ProcessRules (TextWriter writer, IEnumerable<XElement> rules)
	{
		SortedList<string, StringBuilder> properties = new SortedList<string, StringBuilder> ();
		foreach (var member in rules) {
			XElement item = member.Element ("summary");
			if (item == null)
				continue;

			StringBuilder rsb = new StringBuilder ();
			string name = member.Attribute ("name").Value;
			if (name.StartsWith ("P:")) {
				StringBuilder sb;
				int pp = name.LastIndexOf ('.') + 1;
				int pr = name.LastIndexOf ('.', pp - 2) + 1;
				string property = name.Substring (pp);
				string rule = name.Substring (pr, pp - pr - 1);
				if (!properties.TryGetValue (rule, out sb)) {
					sb = new StringBuilder ();
					properties.Add (rule, sb);
				} else
					sb.AppendLine ();

				sb.AppendFormat ("==== {0} ===={1}{1}", property, Environment.NewLine);
				ProcessText (sb, item.Nodes ());
				continue;
			}

			name = name.Substring (name.LastIndexOf ('.') + 1);
			rsb.AppendFormat ("=== {0} ===", name);
			rsb.AppendLine ();

//			tw.WriteLine (ProcessSummary (item));
			ProcessText (rsb, item.Nodes ());
			rsb.AppendLine ();
			rsb.AppendLine ();

			foreach (XNode example in member.Elements ("example").Nodes ()) {
				XText node = (example as XText);
				if (node != null) {
					string text = example.ToString ().Replace ("Bad", "'''Bad'''");
					text = text.Replace ("Good", "'''Good'''");
					rsb.AppendFormat ("{0}{1}{1}", text.Trim (), Environment.NewLine);
					continue;
				}

				XElement code = (example as XElement);
				if (code == null)
					continue;
				
				switch (code.Name.LocalName) {
				case "code":
					rsb.AppendFormat ("<csharp>{0}</csharp>{1}{1}", ProcessCode (code.Value),
						Environment.NewLine);
					break;
				case "c":
					rsb.AppendFormat (" {0}{1}{1}", code.Value, Environment.NewLine);
					break;
				}
			}

			XElement container = member.Element ("remarks");
			if (container != null) {
				IEnumerable<XNode> remarks = container.Nodes ();
				if (remarks.Count () > 0) {
					rsb.AppendLine ("'''Notes'''");
					foreach (XNode element in remarks) {
						rsb.AppendFormat ("* {0}", element.ToString ());
					}
					rsb.AppendLine ();
				}
			}

			StringBuilder psb;
			if (properties.TryGetValue (name, out psb)) {
				rsb.AppendFormat ("'''Configuration'''{0}{0}", Environment.NewLine);
				rsb.AppendFormat ("Some elements of this rule can be customized to better fit your needs.{0}{0}", Environment.NewLine);
				rsb.Append (psb);
				rsb.AppendLine ();
			}

			writer.WriteLine (rsb);
		}
	}
开发者ID:nolanlum,项目名称:mono-tools,代码行数:83,代码来源:xmldoc2wiki.cs

示例14: GetPackages

        public static async Task<SortedList<DateTime, IList<Tuple<Uri, FeedDetails>>>> GetPackages(HttpClient client, Uri uri, string keyDateProperty)
        {
            SortedList<DateTime, IList<Tuple<Uri, FeedDetails>>> result = new SortedList<DateTime, IList<Tuple<Uri, FeedDetails>>>();

            XElement feed;
            using (Stream stream = await client.GetStreamAsync(uri))
            {
                feed = XElement.Load(stream);
            }

            XNamespace atom = "http://www.w3.org/2005/Atom";
            XNamespace dataservices = "http://schemas.microsoft.com/ado/2007/08/dataservices";
            XNamespace metadata = "http://schemas.microsoft.com/ado/2007/08/dataservices/metadata";

            foreach (XElement entry in feed.Elements(atom + "entry"))
            {
                Uri content = new Uri(entry.Element(atom + "content").Attribute("src").Value);

                XElement propertiesElement = entry.Element(metadata + "properties");

                XElement createdElement = propertiesElement.Element(dataservices + CreatedDateProperty);
                string createdValue = createdElement != null ? createdElement.Value : null;
                DateTime createdDate = String.IsNullOrEmpty(createdValue) ? DateTime.MinValue : DateTime.Parse(createdValue);

                XElement lastEditedElement = propertiesElement.Element(dataservices + LastEditedDateProperty);
                string lastEditedValue = propertiesElement.Element(dataservices + LastEditedDateProperty).Value;
                DateTime lastEditedDate = String.IsNullOrEmpty(lastEditedValue) ? DateTime.MinValue : DateTime.Parse(lastEditedValue);

                XElement publishedElement = propertiesElement.Element(dataservices + PublishedDateProperty);
                string publishedValue = propertiesElement.Element(dataservices + PublishedDateProperty).Value;
                DateTime publishedDate = String.IsNullOrEmpty(publishedValue) ? createdDate : DateTime.Parse(publishedValue);

                XElement keyElement = propertiesElement.Element(dataservices + keyDateProperty);
                string keyEntryValue = propertiesElement.Element(dataservices + keyDateProperty).Value;
                DateTime keyDate = String.IsNullOrEmpty(keyEntryValue) ? createdDate : DateTime.Parse(keyEntryValue);

                // License details

                XElement licenseNamesElement = propertiesElement.Element(dataservices + LicenseNamesProperty);
                string licenseNames = licenseNamesElement != null ? licenseNamesElement.Value : null;

                XElement licenseReportUrlElement = propertiesElement.Element(dataservices + LicenseReportUrlProperty);
                string licenseReportUrl = licenseReportUrlElement != null ? licenseReportUrlElement.Value : null;

                // NOTE that DateTime returned by the v2 feed does not have Z at the end even though it is in UTC. So, the DateTime kind is unspecified
                // So, forcibly convert it to UTC here
                createdDate = ForceUTC(createdDate);
                lastEditedDate = ForceUTC(lastEditedDate);
                publishedDate = ForceUTC(publishedDate);
                keyDate = ForceUTC(keyDate);

                IList<Tuple<Uri, FeedDetails>> contentUris;
                if (!result.TryGetValue(keyDate, out contentUris))
                {
                    contentUris = new List<Tuple<Uri, FeedDetails>>();
                    result.Add(keyDate, contentUris);
                }

                FeedDetails details = new FeedDetails
                {
                    CreatedDate = createdDate,
                    LastEditedDate = lastEditedDate,
                    PublishedDate = publishedDate,
                    LicenseNames = licenseNames,
                    LicenseReportUrl = licenseReportUrl
                };

                contentUris.Add(new Tuple<Uri, FeedDetails>(content, details));
            }

            return result;
        }
开发者ID:joyhui,项目名称:NuGet.Services.Metadata,代码行数:72,代码来源:Feed2Catalog.cs

示例15: ImportCollections

 private void ImportCollections(string sourceDir, string targetDir, Rectangle sectorRect, Rectangle sectionRect, XmlElement xmlCollection)
 {
     new List<string>();
     new List<WorldImport.TextureSectorInfo>();
     SortedList<string, int> collectionsCoverage = new SortedList<string, int>();
     for (int i = sectionRect.Top; i <= sectionRect.Bottom; i++)
     {
         for (int j = sectionRect.Left; j <= sectionRect.Right; j++)
         {
             string str = j.ToString("D4") + "_" + i.ToString("D4");
             string text = sourceDir + "section" + str + ".xml";
             if (File.Exists(text))
             {
                 XmlDocument xmlDocument = new XmlDocument();
                 xmlDocument.Load(text);
                 XmlElement elementByName = XmlHelper.GetElementByName(xmlDocument.DocumentElement, "List");
                 foreach (XmlElement current in XmlHelper.GetElementsByName(elementByName, "Entry"))
                 {
                     string attribute = current.GetAttribute("Id");
                     int num;
                     collectionsCoverage.TryGetValue(attribute, out num);
                     num += int.Parse(current.GetAttribute("Coverage"));
                     collectionsCoverage[attribute] = num;
                 }
             }
         }
     }
     List<string> list = new List<string>(collectionsCoverage.Keys);
     list.Sort(delegate(string a, string b)
     {
         int num20 = collectionsCoverage[a];
         int num21 = collectionsCoverage[b];
         return num21 - num20;
     }
     );
     if (list.Count > 8)
     {
         list.RemoveRange(8, list.Count - 8);
     }
     byte[] array = new byte[262144];
     for (int k = sectionRect.Top; k <= sectionRect.Bottom; k++)
     {
         for (int l = sectionRect.Left; l <= sectionRect.Right; l++)
         {
             string str2 = l.ToString("D4") + "_" + k.ToString("D4");
             string text2 = sourceDir + "section" + str2 + ".xml";
             if (File.Exists(text2))
             {
                 XmlDocument xmlDocument2 = new XmlDocument();
                 xmlDocument2.Load(text2);
                 List<string> list2 = new List<string>();
                 XmlElement elementByName2 = XmlHelper.GetElementByName(xmlDocument2.DocumentElement, "List");
                 foreach (XmlElement current2 in XmlHelper.GetElementsByName(elementByName2, "Entry"))
                 {
                     string attribute2 = current2.GetAttribute("Id");
                     list2.Add(attribute2);
                 }
                 byte[] array2 = new byte[256];
                 for (int m = 0; m < 256; m++)
                 {
                     array2[m] = (byte)CollectionManager.EmptyCollectionId;
                 }
                 for (int n = 0; n < list2.Count; n++)
                 {
                     string item = list2[n];
                     int num2 = list.IndexOf(item);
                     if (num2 != -1)
                     {
                         array2[n + 1] = (byte)num2;
                     }
                 }
                 Image image = Image.FromFile(sourceDir + "section" + str2 + ".png");
                 Bitmap bitmap = new Bitmap(image);
                 BitmapData bitmapData = bitmap.LockBits(new Rectangle(0, 0, bitmap.Width, bitmap.Height), ImageLockMode.ReadOnly, PixelFormat.Format24bppRgb);
                 int num3 = l * 4;
                 int num4 = k * 4;
                 int num5 = Math.Max(num3, sectorRect.Left);
                 int num6 = Math.Max(num4, sectorRect.Top);
                 int num7 = num5 % 4;
                 int num8 = num6 % 4;
                 int num9 = Math.Min(num3 + 4, sectorRect.Right) - num5;
                 int num10 = Math.Min(num4 + 4, sectorRect.Bottom) - num6;
                 int num11 = num7 * 64;
                 int num12 = num8 * 64;
                 int num13 = (num5 - sectorRect.Left) * 64;
                 int num14 = (num6 - sectorRect.Top) * 64;
                 int num15 = num9 * 64;
                 int num16 = num10 * 64;
                 for (int num17 = 0; num17 < num16; num17++)
                 {
                     byte[] array3 = new byte[num15 * 3];
                     Marshal.Copy((IntPtr)(bitmapData.Scan0.ToInt32() + (num12 + num17) * bitmapData.Stride + num11 * 3), array3, 0, num15 * 3);
                     for (int num18 = 0; num18 < num15; num18++)
                     {
                         array[(num14 + num17) * 512 + (num13 + num18)] = array2[(int)array3[num18 * 3]];
                     }
                 }
                 bitmap.UnlockBits(bitmapData);
                 bitmap.Dispose();
                 image.Dispose();
//.........这里部分代码省略.........
开发者ID:Azerothian,项目名称:fc3editor,代码行数:101,代码来源:WorldImport.cs


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