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 | // BindResult.inl |
7 | // |
8 | |
9 | |
10 | // |
11 | // Implements the inline methods of BindResult |
12 | // |
13 | // ============================================================ |
14 | |
15 | #ifndef __BINDER__BIND_RESULT_INL__ |
16 | #define __BINDER__BIND_RESULT_INL__ |
17 | |
18 | #include "contextentry.hpp" |
19 | #include "assembly.hpp" |
20 | |
21 | namespace BINDER_SPACE |
22 | { |
23 | BindResult::BindResult() |
24 | { |
25 | m_dwResultFlags = ContextEntry::RESULT_FLAG_NONE; |
26 | m_pAssemblyName = NULL; |
27 | m_pRetargetedAssemblyName = NULL; |
28 | m_pIUnknownAssembly = NULL; |
29 | } |
30 | |
31 | BindResult::~BindResult() |
32 | { |
33 | SAFE_RELEASE(m_pAssemblyName); |
34 | SAFE_RELEASE(m_pRetargetedAssemblyName); |
35 | } |
36 | |
37 | AssemblyName *BindResult::GetAssemblyName(BOOL fAddRef /* = FALSE */) |
38 | { |
39 | AssemblyName *pAssemblyName = m_pAssemblyName; |
40 | |
41 | if (fAddRef && (pAssemblyName != NULL)) |
42 | { |
43 | pAssemblyName->AddRef(); |
44 | } |
45 | |
46 | return pAssemblyName; |
47 | } |
48 | |
49 | AssemblyName *BindResult::GetRetargetedAssemblyName() |
50 | { |
51 | return m_pRetargetedAssemblyName; |
52 | } |
53 | |
54 | void BindResult::SetRetargetedAssemblyName(AssemblyName *pRetargetedAssemblyName) |
55 | { |
56 | SAFE_RELEASE(m_pRetargetedAssemblyName); |
57 | |
58 | if (pRetargetedAssemblyName) |
59 | { |
60 | pRetargetedAssemblyName->AddRef(); |
61 | } |
62 | |
63 | m_pRetargetedAssemblyName = pRetargetedAssemblyName; |
64 | } |
65 | |
66 | IUnknown *BindResult::GetAssembly(BOOL fAddRef /* = FALSE */) |
67 | { |
68 | IUnknown *pIUnknownAssembly = m_pIUnknownAssembly; |
69 | |
70 | if (fAddRef && (pIUnknownAssembly != NULL)) |
71 | { |
72 | pIUnknownAssembly->AddRef(); |
73 | } |
74 | |
75 | return pIUnknownAssembly; |
76 | } |
77 | |
78 | Assembly *BindResult::GetAsAssembly(BOOL fAddRef /* = FALSE */) |
79 | { |
80 | return static_cast<Assembly *>(GetAssembly(fAddRef)); |
81 | } |
82 | |
83 | BOOL BindResult::GetIsDynamicBind() |
84 | { |
85 | return ((m_dwResultFlags & ContextEntry::RESULT_FLAG_IS_DYNAMIC_BIND) != 0); |
86 | } |
87 | |
88 | void BindResult::SetIsDynamicBind(BOOL fIsDynamicBind) |
89 | { |
90 | if (fIsDynamicBind) |
91 | { |
92 | m_dwResultFlags |= ContextEntry::RESULT_FLAG_IS_DYNAMIC_BIND; |
93 | } |
94 | else |
95 | { |
96 | m_dwResultFlags &= ~ContextEntry::RESULT_FLAG_IS_DYNAMIC_BIND; |
97 | } |
98 | } |
99 | |
100 | BOOL BindResult::GetIsInGAC() |
101 | { |
102 | return ((m_dwResultFlags & ContextEntry::RESULT_FLAG_IS_IN_GAC) != 0); |
103 | } |
104 | |
105 | void BindResult::SetIsInGAC(BOOL fIsInGAC) |
106 | { |
107 | if (fIsInGAC) |
108 | { |
109 | m_dwResultFlags |= ContextEntry::RESULT_FLAG_IS_IN_GAC; |
110 | } |
111 | else |
112 | { |
113 | m_dwResultFlags &= ~ContextEntry::RESULT_FLAG_IS_IN_GAC; |
114 | } |
115 | } |
116 | |
117 | BOOL BindResult::GetIsContextBound() |
118 | { |
119 | return ((m_dwResultFlags & ContextEntry::RESULT_FLAG_CONTEXT_BOUND) != 0); |
120 | } |
121 | |
122 | void BindResult::SetIsContextBound(BOOL fIsContextBound) |
123 | { |
124 | if (fIsContextBound) |
125 | { |
126 | m_dwResultFlags |= ContextEntry::RESULT_FLAG_CONTEXT_BOUND; |
127 | } |
128 | else |
129 | { |
130 | m_dwResultFlags &= ~ContextEntry::RESULT_FLAG_CONTEXT_BOUND; |
131 | } |
132 | } |
133 | |
134 | BOOL BindResult::GetIsFirstRequest() |
135 | { |
136 | return ((m_dwResultFlags & ContextEntry::RESULT_FLAG_FIRST_REQUEST) != 0); |
137 | } |
138 | |
139 | void BindResult::SetIsFirstRequest(BOOL fIsFirstRequest) |
140 | { |
141 | if (fIsFirstRequest) |
142 | { |
143 | m_dwResultFlags |= ContextEntry::RESULT_FLAG_FIRST_REQUEST; |
144 | } |
145 | else |
146 | { |
147 | m_dwResultFlags &= ~ContextEntry::RESULT_FLAG_FIRST_REQUEST; |
148 | } |
149 | } |
150 | |
151 | BOOL BindResult::GetIsSharable() |
152 | { |
153 | return ((m_dwResultFlags & ContextEntry::RESULT_FLAG_IS_SHARABLE) != 0); |
154 | } |
155 | |
156 | void BindResult::SetIsSharable(BOOL fIsSharable) |
157 | { |
158 | if (fIsSharable) |
159 | { |
160 | m_dwResultFlags |= ContextEntry::RESULT_FLAG_IS_SHARABLE; |
161 | } |
162 | else |
163 | { |
164 | m_dwResultFlags &= ~ContextEntry::RESULT_FLAG_IS_SHARABLE; |
165 | } |
166 | } |
167 | |
168 | void BindResult::SetResult(ContextEntry *pContextEntry, BOOL fIsContextBound /* = TRUE */) |
169 | { |
170 | _ASSERTE(pContextEntry != NULL); |
171 | |
172 | SetIsDynamicBind(pContextEntry->GetIsDynamicBind()); |
173 | SetIsInGAC(pContextEntry->GetIsInGAC()); |
174 | SetIsContextBound(fIsContextBound); |
175 | SetIsSharable(pContextEntry->GetIsSharable()); |
176 | SAFE_RELEASE(m_pAssemblyName); |
177 | m_pAssemblyName = pContextEntry->GetAssemblyName(TRUE /* fAddRef */); |
178 | m_pIUnknownAssembly = pContextEntry->GetAssembly(TRUE /* fAddRef */); |
179 | } |
180 | |
181 | void BindResult::SetResult(Assembly *pAssembly) |
182 | { |
183 | _ASSERTE(pAssembly != NULL); |
184 | |
185 | SetIsDynamicBind(pAssembly->GetIsDynamicBind()); |
186 | SetIsInGAC(pAssembly->GetIsInGAC()); |
187 | SetIsSharable(pAssembly->GetIsSharable()); |
188 | SAFE_RELEASE(m_pAssemblyName); |
189 | m_pAssemblyName = pAssembly->GetAssemblyName(TRUE /* fAddRef */); |
190 | pAssembly->AddRef(); |
191 | m_pIUnknownAssembly = static_cast<IUnknown *>(pAssembly); |
192 | } |
193 | |
194 | void BindResult::SetResult(BindResult *pBindResult) |
195 | { |
196 | _ASSERTE(pBindResult != NULL); |
197 | |
198 | m_dwResultFlags = pBindResult->m_dwResultFlags; |
199 | SAFE_RELEASE(m_pAssemblyName); |
200 | m_pAssemblyName = pBindResult->GetAssemblyName(TRUE /* fAddRef */); |
201 | m_pIUnknownAssembly = pBindResult->GetAssembly(TRUE /* fAddRef */); |
202 | } |
203 | |
204 | void BindResult::SetNoResult() |
205 | { |
206 | m_pAssemblyName = NULL; |
207 | } |
208 | |
209 | BOOL BindResult::HaveResult() |
210 | { |
211 | return (GetAssemblyName() != NULL); |
212 | } |
213 | |
214 | IUnknown *BindResult::ExtractAssembly() |
215 | { |
216 | return m_pIUnknownAssembly.Extract(); |
217 | } |
218 | |
219 | void BindResult::Reset() |
220 | { |
221 | SAFE_RELEASE(m_pAssemblyName); |
222 | SAFE_RELEASE(m_pRetargetedAssemblyName); |
223 | m_pIUnknownAssembly = NULL; |
224 | m_dwResultFlags = ContextEntry::RESULT_FLAG_NONE; |
225 | } |
226 | |
227 | } |
228 | |
229 | #endif |
230 |