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// ContextEntry.hpp
7//
8
9
10//
11// Defines the ContextEntry class
12//
13// ============================================================
14
15#ifndef __BINDER__CONTEXT_ENTRY_HPP__
16#define __BINDER__CONTEXT_ENTRY_HPP__
17
18#include "assemblyentry.hpp"
19#include "assembly.hpp"
20
21namespace BINDER_SPACE
22{
23 class ContextEntry : public AssemblyEntry
24 {
25 public:
26 typedef enum
27 {
28 RESULT_FLAG_NONE = 0x00,
29 RESULT_FLAG_IS_DYNAMIC_BIND = 0x01,
30 RESULT_FLAG_IS_IN_GAC = 0x02,
31 //RESULT_FLAG_FROM_MANIFEST = 0x04,
32 RESULT_FLAG_CONTEXT_BOUND = 0x08,
33 RESULT_FLAG_FIRST_REQUEST = 0x10,
34 RESULT_FLAG_IS_SHARABLE = 0x20
35 } ResultFlags;
36
37 ContextEntry() : AssemblyEntry()
38 {
39 m_dwResultFlags = RESULT_FLAG_NONE;
40 m_pIUnknownAssembly = NULL;
41 }
42
43 ~ContextEntry()
44 {
45 SAFE_RELEASE(m_pIUnknownAssembly);
46 }
47
48 BOOL GetIsDynamicBind()
49 {
50 return ((m_dwResultFlags & RESULT_FLAG_IS_DYNAMIC_BIND) != 0);
51 }
52
53 void SetIsDynamicBind(BOOL fIsDynamicBind)
54 {
55 if (fIsDynamicBind)
56 {
57 m_dwResultFlags |= RESULT_FLAG_IS_DYNAMIC_BIND;
58 }
59 else
60 {
61 m_dwResultFlags &= ~RESULT_FLAG_IS_DYNAMIC_BIND;
62 }
63 }
64
65 BOOL GetIsInGAC()
66 {
67 return ((m_dwResultFlags & RESULT_FLAG_IS_IN_GAC) != 0);
68 }
69
70 void SetIsInGAC(BOOL fIsInGAC)
71 {
72 if (fIsInGAC)
73 {
74 m_dwResultFlags |= RESULT_FLAG_IS_IN_GAC;
75 }
76 else
77 {
78 m_dwResultFlags &= ~RESULT_FLAG_IS_IN_GAC;
79 }
80 }
81
82 BOOL GetIsFirstRequest()
83 {
84 return ((m_dwResultFlags & RESULT_FLAG_FIRST_REQUEST) != 0);
85 }
86
87 void SetIsFirstRequest(BOOL fIsFirstRequest)
88 {
89 if (fIsFirstRequest)
90 {
91 m_dwResultFlags |= RESULT_FLAG_FIRST_REQUEST;
92 }
93 else
94 {
95 m_dwResultFlags &= ~RESULT_FLAG_FIRST_REQUEST;
96 }
97 }
98
99 BOOL GetIsSharable()
100 {
101 return ((m_dwResultFlags & RESULT_FLAG_IS_SHARABLE) != 0);
102 }
103
104 void SetIsSharable(BOOL fIsSharable)
105 {
106 if (fIsSharable)
107 {
108 m_dwResultFlags |= RESULT_FLAG_IS_SHARABLE;
109 }
110 else
111 {
112 m_dwResultFlags &= ~RESULT_FLAG_IS_SHARABLE;
113 }
114 }
115
116 IUnknown *GetAssembly(BOOL fAddRef = FALSE)
117 {
118 IUnknown *pIUnknownAssembly = m_pIUnknownAssembly;
119
120 if (fAddRef && (pIUnknownAssembly != NULL))
121 {
122 pIUnknownAssembly->AddRef();
123 }
124
125 return pIUnknownAssembly;
126 }
127
128 void SetAssembly(IUnknown *pIUnknownAssembly)
129 {
130 SAFE_RELEASE(m_pIUnknownAssembly);
131
132 if (pIUnknownAssembly != NULL)
133 {
134 pIUnknownAssembly->AddRef();
135 }
136
137 m_pIUnknownAssembly = pIUnknownAssembly;
138 }
139
140 protected:
141 DWORD m_dwResultFlags;
142 IUnknown *m_pIUnknownAssembly;
143 };
144};
145
146#endif
147