OpenKeyWord  Version: 426, Datum:
OKWSingeltonBase.cs
1 #region Header
2 /*
3  ==============================================================================
4  Author: Zoltan Hrabovszki <zh@openkeyword.de>
5 
6  Copyright © 2012, 2013, 2014, 2015 IT-Beratung Hrabovszki
7  www.OpenKeyWord.de
8  ==============================================================================
9 
10  This file is part of OpenKeyWord.
11 
12  OpenKeyWord is free software: you can redistribute it and/or modify
13  it under the terms of the GNU General Public License as published by
14  the Free Software Foundation, either version 3 of the License, or
15  (at your option) any later version.
16 
17  OpenKeyWord is distributed in the hope that it will be useful,
18  but WITHOUT ANY WARRANTY; without even the implied warranty of
19  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
20  GNU General Public License for more details.
21 
22  You should have received a copy of the GNU General Public License
23  along with OpenKeyWord. If not, see <http://www.gnu.org/licenses/>.
24 
25  Diese Datei ist Teil von OpenKeyWord.
26 
27  OpenKeyWord ist Freie Software: Sie können es unter den Bedingungen
28  der GNU General Public License, wie von der Free Software Foundation,
29  Version 3 der Lizenz oder (nach Ihrer Wahl) jeder späteren
30  veröffentlichten Version, weiterverbreiten und/oder modifizieren.
31 
32  OpenKeyWord wird in der Hoffnung, dass es nützlich sein wird, aber
33  OHNE JEDE GEWÄHRLEISTUNG, bereitgestellt; sogar ohne die implizite
34  Gewährleistung der MARKTFÄHIGKEIT oder EIGNUNG FÜR EINEN BESTIMMTEN ZWECK.
35  Siehe die GNU General Public License für weitere Details.
36 
37  Sie sollten eine Kopie der GNU General Public License zusammen mit
38  OpenKeyWord erhalten haben. Wenn nicht, siehe <http://www.gnu.org/licenses/>.
39 */
40 #endregion Header
41 
42 namespace OKW
43 {
44  using System;
45 
56  public abstract class OKWSingeltonBase<T> where T : class
57  {
58  #region Fields
59 
60  // private static readonly Lazy<T> instance = new Lazy<T>(() => CreateInstanceOfT());
61 
64  protected static Lazy<T> instance = new Lazy<T>(() => CreateInstanceOfT());
65 
66  #endregion Fields
67 
68  #region Properties
69 
76  public static T Instance
77  {
78  get { return instance.Value; }
79  }
80 
81  #endregion Properties
82 
83  #region Methods
84 
89  private static T CreateInstanceOfT()
90  {
91  return Activator.CreateInstance(typeof(T), true) as T;
92  }
93 
94  #endregion Methods
95  }
96 }
static T Instance
Holt die einzige Instanz dieser Klasse.
Baisklasse für das lesen von OKW *Log.xml Dateien Designpattern: Singelton Hier gilt das Highlander P...
static T CreateInstanceOfT()
Creates an instance of T via reflection since T's constructor is expected to be private.
Definition: Core.cs:40