1// Licensed to the .NET Foundation under one or more agreements.
2// The .NET Foundation licenses this file to you under the MIT license.
3// See the LICENSE file in the project root for more information.
4// ============================================================
5//
6// AssemblyVersion.inl
7//
8
9
10//
11// Implements the inline methods of AssemblyVersion
12//
13// ============================================================
14
15#ifndef __BINDER__ASSEMBLY_VERSION_INL__
16#define __BINDER__ASSEMBLY_VERSION_INL__
17
18AssemblyVersion::AssemblyVersion()
19{
20 m_dwMajor = m_dwMinor = m_dwBuild = m_dwRevision = static_cast<DWORD>(-1);
21}
22
23AssemblyVersion::~AssemblyVersion()
24{
25 // Noting to do here
26}
27
28BOOL AssemblyVersion::HasMajor()
29{
30 return m_dwMajor != Unspecified;
31}
32
33BOOL AssemblyVersion::HasMinor()
34{
35 return m_dwMinor != Unspecified;
36}
37
38BOOL AssemblyVersion::HasBuild()
39{
40 return m_dwBuild != Unspecified;
41}
42
43BOOL AssemblyVersion::HasRevision()
44{
45 return m_dwRevision != Unspecified;
46}
47
48DWORD AssemblyVersion::GetMajor()
49{
50 return m_dwMajor;
51}
52
53DWORD AssemblyVersion::GetMinor()
54{
55 return m_dwMinor;
56}
57
58DWORD AssemblyVersion::GetBuild()
59{
60 return m_dwBuild;
61}
62
63DWORD AssemblyVersion::GetRevision()
64{
65 return m_dwRevision;
66}
67
68void AssemblyVersion::SetFeatureVersion(DWORD dwMajor,
69 DWORD dwMinor)
70{
71 // BaseAssemblySpec and AssemblyName properties store uint16 components for the version. Version and AssemblyVersion store
72 // int32 or uint32. When the former are initialized from the latter, the components are truncated to uint16 size. When the
73 // latter are initialized from the former, they are zero-extended to int32 size. For uint16 components, the max value is
74 // used to indicate an unspecified component. For int32 components, -1 is used. Since we're treating the version as an
75 // assembly version here, map the uint16 unspecified value to the int32 size.
76 m_dwMajor = dwMajor == UnspecifiedShort ? Unspecified : dwMajor;
77 m_dwMinor = dwMinor == UnspecifiedShort ? Unspecified : dwMinor;
78}
79
80void AssemblyVersion::SetServiceVersion(DWORD dwBuild,
81 DWORD dwRevision)
82{
83 // See comment in SetFeatureVersion, the same applies here
84 m_dwBuild = dwBuild == UnspecifiedShort ? Unspecified : dwBuild;
85 m_dwRevision = dwRevision == UnspecifiedShort ? Unspecified : dwRevision;
86}
87
88void AssemblyVersion::SetVersion(AssemblyVersion *pAssemblyVersion)
89{
90 m_dwMajor = pAssemblyVersion->GetMajor();
91 m_dwMinor = pAssemblyVersion->GetMinor();
92 m_dwBuild = pAssemblyVersion->GetBuild();
93 m_dwRevision = pAssemblyVersion->GetRevision();
94}
95
96BOOL AssemblyVersion::Equals(AssemblyVersion *pAssemblyVersion)
97{
98 BOOL result = FALSE;
99 if ((GetMajor() == pAssemblyVersion->GetMajor()) &&
100 (GetMinor() == pAssemblyVersion->GetMinor()) &&
101 (GetBuild() == pAssemblyVersion->GetBuild()) &&
102 (GetRevision() == pAssemblyVersion->GetRevision()))
103 {
104 result = TRUE;
105 }
106 return result;
107}
108
109#endif
110