DeveelDB  20151217
complete SQL database system, primarly developed for .NET/Mono frameworks
ProductInfo.cs
Go to the documentation of this file.
1 //
2 // Copyright 2010-2015 Deveel
3 //
4 // Licensed under the Apache License, Version 2.0 (the "License");
5 // you may not use this file except in compliance with the License.
6 // You may obtain a copy of the License at
7 //
8 // http://www.apache.org/licenses/LICENSE-2.0
9 //
10 // Unless required by applicable law or agreed to in writing, software
11 // distributed under the License is distributed on an "AS IS" BASIS,
12 // WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13 // See the License for the specific language governing permissions and
14 // limitations under the License.
15 //
16 
17 using System;
18 using System.Reflection;
19 
20 using Deveel.Data;
21 
22 namespace Deveel.Data.Util {
23  class ProductInfo {
24  private ProductInfo() {
25  }
26 
27  private static ProductInfo current;
28 
31  public static ProductInfo Current {
32  get {
33  if (current == null)
34  current = GetProductInfo(typeof(Database).Assembly);
35  return current;
36  }
37  }
38 
39  public string Title { get; private set; }
40 
41  public string Copyright { get; private set; }
42 
43  public string Company { get; private set; }
44 
45  public Version Version { get; private set; }
46 
47  public string Description { get; private set; }
48 
49  private static ProductInfo GetProductInfo(Assembly assembly) {
50  ProductInfo productInfo = new ProductInfo();
51 
52  object[] attributes = assembly.GetCustomAttributes(false);
53  for (int i = 0; i < attributes.Length; i++) {
54  object attr = attributes[i];
55  if (attr is AssemblyCopyrightAttribute)
56  productInfo.Copyright = ((AssemblyCopyrightAttribute)attr).Copyright;
57  else if (attr is AssemblyVersionAttribute)
58  productInfo.Version = new Version(((AssemblyVersionAttribute)attr).Version);
59  else if (attr is AssemblyCompanyAttribute)
60  productInfo.Company = ((AssemblyCompanyAttribute)attr).Company;
61  else if (attr is AssemblyTitleAttribute)
62  productInfo.Title = ((AssemblyTitleAttribute)attr).Title;
63  else if (attr is AssemblyDescriptionAttribute)
64  productInfo.Description = ((AssemblyDescriptionAttribute)attr).Description;
65  }
66 
67  return productInfo;
68  }
69  }
70 }
The default implementation of a database in a system.
Definition: Database.cs:38
static ProductInfo GetProductInfo(Assembly assembly)
Definition: ProductInfo.cs:49
static ProductInfo current
Definition: ProductInfo.cs:27