Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(57)

Side by Side Diff: visual_studio/NativeClientVSAddIn/NativeClientVSAddIn/ProcessInfo.cs

Issue 10836143: Refactored the VS add-in (Closed) Base URL: https://nativeclient-sdk.googlecode.com/svn/trunk/src
Patch Set: Created 8 years, 4 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch | Annotate | Revision Log
OLDNEW
1 // Copyright (c) 2012 The Chromium Authors. All rights reserved. 1 // Copyright (c) 2012 The Chromium Authors. All rights reserved.
2 // Use of this source code is governed by a BSD-style license that can be 2 // Use of this source code is governed by a BSD-style license that can be
3 // found in the LICENSE file. 3 // found in the LICENSE file.
4 4
5 namespace NativeClientVSAddIn 5 namespace NativeClientVSAddIn
6 { 6 {
7 using System; 7 using System;
8 using System.Globalization; 8 using System.Globalization;
9 using System.Management; 9 using System.Management;
10 10
11 /// <summary> 11 /// <summary>
12 /// Holds information about a process for a ProcessSearcher. 12 /// Holds information about a process for a ProcessSearcher.
13 /// </summary> 13 /// </summary>
14 public class ProcessInfo 14 public class ProcessInfo
15 { 15 {
16 /// <summary> 16 /// <summary>
17 /// Constructs a process entry. 17 /// Constructs a process entry.
18 /// </summary> 18 /// </summary>
19 /// <param name="id">Process ID.</param> 19 /// <param name="id">Process ID.</param>
20 /// <param name="parentId">Process ID of the parent process.</param> 20 /// <param name="parentId">Process ID of the parent process.</param>
21 /// <param name="creationDate"> 21 /// <param name="creationDate">
22 /// String date in format 'yyyyMMddHHmmss.ffffff', or if empty then current time used. 22 /// String date in format 'yyyyMMddHHmmss.ffffff', or if empty then current time used.
23 /// </param> 23 /// </param>
24 /// <param name="commandLine">Command line arguments to the process.</param> 24 /// <param name="commandLine">Command line arguments to the process.</param>
25 /// <param name="name">Process name.</param> 25 /// <param name="name">Process name.</param>
26 public ProcessInfo(uint id, uint parentId, string creationDate, string comma ndLine, string name) 26 public ProcessInfo(uint id, uint parentId, string creationDate, string comma ndLine, string name)
27 { 27 {
28 // Convert an empty creationDate string into the current timestamp.
29 if (string.IsNullOrEmpty(creationDate)) 28 if (string.IsNullOrEmpty(creationDate))
30 { 29 {
31 int timezoneMinutes = (int)Math.Round((DateTime.Now - DateTime.UtcNow).T otalMinutes); 30 // If creationDate string is empty, then use the current timestamp.
32 creationDate = string.Format("{0:yyyyMMddHHmmss.ffffff}{1}", DateTime.No w, timezoneMinutes); 31 CreationDate = DateTime.UtcNow;
33 } 32 }
34 33 else
35 // Example creationDate: "20120622150149.843021-420". 34 {
36 CreationDate = DateTime.ParseExact( 35 // Example creationDate: "20120622150149.843021-420".
37 creationDate.Substring(0, 21), 36 CreationDate = DateTime.ParseExact(
38 "yyyyMMddHHmmss.ffffff", 37 creationDate.Substring(0, 21),
39 CultureInfo.InvariantCulture); 38 "yyyyMMddHHmmss.ffffff",
40 long timeZoneMinutes = long.Parse(creationDate.Substring(21)); 39 CultureInfo.InvariantCulture);
41 CreationDate = CreationDate.AddMinutes(-timeZoneMinutes); 40 long timeZoneMinutes = long.Parse(creationDate.Substring(21));
41 CreationDate = CreationDate.AddMinutes(-timeZoneMinutes);
42 }
42 43
43 ID = id; 44 ID = id;
44 ParentID = parentId; 45 ParentID = parentId;
45 CommandLine = commandLine; 46 CommandLine = commandLine;
46 Name = name; 47 Name = name;
47 } 48 }
48 49
49 /// <summary> 50 /// <summary>
50 /// Gets or sets Process ID of the represented process. 51 /// Gets or sets Process ID of the represented process.
51 /// </summary> 52 /// </summary>
(...skipping 28 matching lines...) Expand all
80 { 81 {
81 return new ProcessInfo( 82 return new ProcessInfo(
82 id: (uint)from["ProcessID"], 83 id: (uint)from["ProcessID"],
83 parentId: (uint)from["ParentProcessID"], 84 parentId: (uint)from["ParentProcessID"],
84 creationDate: from["CreationDate"] as string, 85 creationDate: from["CreationDate"] as string,
85 commandLine: from["CommandLine"] as string, 86 commandLine: from["CommandLine"] as string,
86 name: from["Name"] as string); 87 name: from["Name"] as string);
87 } 88 }
88 } 89 }
89 } 90 }
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698