-
Notifications
You must be signed in to change notification settings - Fork 20
Expand file tree
/
Copy pathPiaHeader.cs
More file actions
46 lines (37 loc) · 1.5 KB
/
PiaHeader.cs
File metadata and controls
46 lines (37 loc) · 1.5 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
//
// Copyright © 2014 Parrish Husband (parrish.husband@gmail.com)
// The MIT License (MIT) - See LICENSE.txt for further details.
//
using System;
using System.Globalization;
namespace PiaNO
{
public class PiaHeader
{
private string _headerData;
public double PiaFileVersion { get; private set; }
public short TypeVersion { get; private set; }
public PiaType PiaType { get; private set; }
public PiaHeader(string headerString)
{
_headerData = headerString;
var firstLine = headerString.Split()[0];
var headerArray = headerString.Split(new char[] { ',', '_'});
if (headerArray.Length < 4)
throw new ArgumentOutOfRangeException();
NumberFormatInfo wNFI = new NumberFormatInfo();
wNFI.CurrencyDecimalSeparator=".";
PiaFileVersion = Double.Parse(headerArray[1], wNFI);
var typeString = headerArray[2].Substring(0, 3);
PiaType = (PiaType)Enum.Parse(typeof(PiaType), typeString);
var versionString = headerArray[2].Substring(3).ToUpper().Replace("VER", string.Empty);
TypeVersion = Int16.Parse(versionString);
}
public override string ToString()
{
return _headerData;
//var fileversionString = string.Format("{0:0.0}", Math.Truncate(PiaFileVersion * 10) / 10);
//return string.Format(PIA_HEADER_FORMAT, fileversionString, PiaType, TypeVersion);
}
}
}