Lucene.Net  3.0.3
Lucene.Net is a port of the Lucene search engine library, written in C# and targeted at .NET runtime users.
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Properties Pages
OS.cs
Go to the documentation of this file.
1 /*
2  *
3  * Licensed to the Apache Software Foundation (ASF) under one
4  * or more contributor license agreements. See the NOTICE file
5  * distributed with this work for additional information
6  * regarding copyright ownership. The ASF licenses this file
7  * to you under the Apache License, Version 2.0 (the
8  * "License"); you may not use this file except in compliance
9  * with the License. You may obtain a copy of the License at
10  *
11  * http://www.apache.org/licenses/LICENSE-2.0
12  *
13  * Unless required by applicable law or agreed to in writing,
14  * software distributed under the License is distributed on an
15  * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
16  * KIND, either express or implied. See the License for the
17  * specific language governing permissions and limitations
18  * under the License.
19  *
20 */
21 
22 using System;
23 
24 namespace Lucene.Net.Support
25 {
26  /// <summary>
27  /// Provides platform infos.
28  /// </summary>
29  public class OS
30  {
31  static bool isUnix;
32  static bool isWindows;
33 
34  static OS()
35  {
36  PlatformID pid = Environment.OSVersion.Platform;
37  isWindows = pid == PlatformID.Win32NT || pid == PlatformID.Win32Windows;
38 
39  // we use integers instead of enum tags because "MacOS"
40  // requires 2.0 SP2, 3.0 SP2 or 3.5 SP1.
41  // 128 is mono's old platform tag for Unix.
42  int id = (int)pid;
43  isUnix = id == 4 || id == 6 || id == 128;
44  }
45 
46  /// <summary>
47  /// Whether we run under a Unix platform.
48  /// </summary>
49  public static bool IsUnix
50  {
51  get { return isUnix; }
52  }
53 
54  /// <summary>
55  /// Whether we run under a supported Windows platform.
56  /// </summary>
57  public static bool IsWindows
58  {
59  get { return isWindows; }
60  }
61  }
62 }