ConfigurationParameter.cpp (4581B)
1 // Copyright (c) Microsoft Corporation. 2 // Licensed under the MIT License. 3 #include "pch.h" 4 #include "ConfigurationParameter.h" 5 #include "ConfigurationParameter.g.cpp" 6 #include "ArgumentValidation.h" 7 8 namespace winrt::Microsoft::Management::Configuration::implementation 9 { 10 hstring ConfigurationParameter::Name() const 11 { 12 return m_name; 13 } 14 15 void ConfigurationParameter::Name(hstring const& value) 16 { 17 m_name = value; 18 } 19 20 hstring ConfigurationParameter::Description() const 21 { 22 return m_description; 23 } 24 25 void ConfigurationParameter::Description(hstring const& value) 26 { 27 m_description = value; 28 } 29 30 Windows::Foundation::Collections::ValueSet ConfigurationParameter::Metadata() const 31 { 32 return m_metadata; 33 } 34 35 void ConfigurationParameter::Metadata(const Windows::Foundation::Collections::ValueSet& value) 36 { 37 THROW_HR_IF(E_POINTER, !value); 38 m_metadata = value; 39 } 40 41 bool ConfigurationParameter::IsSecure() const 42 { 43 return m_isSecure; 44 } 45 46 void ConfigurationParameter::IsSecure(bool value) 47 { 48 m_isSecure = value; 49 } 50 51 Windows::Foundation::PropertyType ConfigurationParameter::Type() const 52 { 53 return m_type; 54 } 55 56 void ConfigurationParameter::Type(Windows::Foundation::PropertyType value) 57 { 58 EnsureSupportedType(value); 59 m_type = value; 60 } 61 62 Windows::Foundation::IInspectable ConfigurationParameter::DefaultValue() const 63 { 64 return m_defaultValue; 65 } 66 67 void ConfigurationParameter::DefaultValue(Windows::Foundation::IInspectable const& value) 68 { 69 if (value) 70 { 71 EnsureObjectType(value, m_type); 72 } 73 74 m_defaultValue = value; 75 } 76 77 Windows::Foundation::Collections::IVector<Windows::Foundation::IInspectable> ConfigurationParameter::AllowedValues() const 78 { 79 return m_allowedValues; 80 } 81 82 void ConfigurationParameter::AllowedValues(Windows::Foundation::Collections::IVector<Windows::Foundation::IInspectable> const& value) 83 { 84 if (value) 85 { 86 for (const auto& item : value) 87 { 88 if (item) 89 { 90 EnsureObjectType(item, m_type); 91 } 92 } 93 } 94 95 m_allowedValues = value; 96 } 97 98 void ConfigurationParameter::AllowedValues(std::vector<Windows::Foundation::IInspectable>&& value) 99 { 100 m_allowedValues = winrt::multi_threaded_vector<Windows::Foundation::IInspectable>(std::move(value)); 101 } 102 103 uint32_t ConfigurationParameter::MinimumLength() const 104 { 105 return m_minimumLength; 106 } 107 108 void ConfigurationParameter::MinimumLength(uint32_t value) 109 { 110 EnsureLengthType(m_type); 111 m_minimumLength = value; 112 } 113 114 uint32_t ConfigurationParameter::MaximumLength() const 115 { 116 return m_maximumLength; 117 } 118 119 void ConfigurationParameter::MaximumLength(uint32_t value) 120 { 121 EnsureLengthType(m_type); 122 m_maximumLength = value; 123 } 124 125 Windows::Foundation::IInspectable ConfigurationParameter::MinimumValue() const 126 { 127 return m_minimumValue; 128 } 129 130 void ConfigurationParameter::MinimumValue(Windows::Foundation::IInspectable const& value) 131 { 132 if (value) 133 { 134 EnsureObjectType(value, m_type); 135 EnsureComparableType(m_type); 136 } 137 138 m_minimumValue = value; 139 } 140 141 Windows::Foundation::IInspectable ConfigurationParameter::MaximumValue() const 142 { 143 return m_maximumValue; 144 } 145 146 void ConfigurationParameter::MaximumValue(Windows::Foundation::IInspectable const& value) 147 { 148 if (value) 149 { 150 EnsureObjectType(value, m_type); 151 EnsureComparableType(m_type); 152 } 153 154 m_maximumValue = value; 155 } 156 157 Windows::Foundation::IInspectable ConfigurationParameter::ProvidedValue() const 158 { 159 return m_providedValue; 160 } 161 162 void ConfigurationParameter::ProvidedValue(Windows::Foundation::IInspectable const& value) 163 { 164 if (value) 165 { 166 EnsureObjectType(value, m_type); 167 } 168 169 m_providedValue = value; 170 } 171 172 HRESULT STDMETHODCALLTYPE ConfigurationParameter::SetLifetimeWatcher(IUnknown* watcher) 173 { 174 return AppInstaller::WinRT::LifetimeWatcherBase::SetLifetimeWatcher(watcher); 175 } 176 }