浏览代码

Inline object initializations

Source commit: 513045ecbe82058c1bf7c6d92d16fc17807163ca
Martin Prikryl 8 年之前
父节点
当前提交
601996a40d
共有 3 个文件被更改,包括 17 次插入9 次删除
  1. 5 3
      dotnet/FilePermissions.cs
  2. 4 2
      dotnet/internal/ExeSessionProcess.cs
  3. 8 4
      dotnet/internal/Job.cs

+ 5 - 3
dotnet/FilePermissions.cs

@@ -158,9 +158,11 @@ namespace WinSCP
 
         internal static FilePermissions CreateReadOnlyFromText(string text)
         {
-            FilePermissions result = new FilePermissions();
-            result.Numeric = TextToNumeric(text);
-            result._readOnly = true;
+            FilePermissions result = new FilePermissions
+            {
+                Numeric = TextToNumeric(text),
+                _readOnly = true
+            };
             return result;
         }
 

+ 4 - 2
dotnet/internal/ExeSessionProcess.cs

@@ -199,8 +199,10 @@ namespace WinSCP
 
                 _logger.WriteLine("Started process {0}", _process.Id);
 
-                _thread = new Thread(ProcessEvents);
-                _thread.IsBackground = true;
+                _thread = new Thread(ProcessEvents)
+                {
+                    IsBackground = true
+                };
                 _thread.Start();
             }
         }

+ 8 - 4
dotnet/internal/Job.cs

@@ -18,11 +18,15 @@ namespace WinSCP
             {
                 _logger.WriteLine("Job created");
 
-                JobObjectBasicLimitInformation info = new JobObjectBasicLimitInformation();
-                info.LimitFlags = 0x2000; // JOB_OBJECT_LIMIT_KILL_ON_JOB_CLOSE
+                JobObjectBasicLimitInformation info = new JobObjectBasicLimitInformation
+                {
+                    LimitFlags = 0x2000 // JOB_OBJECT_LIMIT_KILL_ON_JOB_CLOSE
+                };
 
-                JobObjectExtendedLimitInformation extendedInfo = new JobObjectExtendedLimitInformation();
-                extendedInfo.BasicLimitInformation = info;
+                JobObjectExtendedLimitInformation extendedInfo = new JobObjectExtendedLimitInformation
+                {
+                    BasicLimitInformation = info
+                };
 
                 int length = Marshal.SizeOf(typeof(JobObjectExtendedLimitInformation));
                 IntPtr extendedInfoPtr = Marshal.AllocHGlobal(length);