ConfigurationSetUtilities.h (2465B)
1 // Copyright (c) Microsoft Corporation. 2 // Licensed under the MIT License. 3 #pragma once 4 #include <string_view> 5 #include <winrt/Microsoft.Management.Configuration.h> 6 7 namespace winrt::Microsoft::Management::Configuration::implementation 8 { 9 // The various configuration fields that are used in parsing/serialization. 10 enum class ConfigurationField 11 { 12 // v0.1 and v0.2 13 ConfigurationVersion, 14 Properties, 15 Resource, 16 Directives, 17 Settings, 18 Assertions, 19 Id, 20 DependsOn, 21 22 // Universal 23 Resources, 24 ModuleDirective, 25 SecurityContextMetadata, 26 27 // v0.3 28 Schema, 29 Metadata, 30 Parameters, 31 Variables, 32 Type, 33 Description, 34 Name, 35 IsGroupMetadata, 36 DefaultValue, 37 AllowedValues, 38 MinimumLength, 39 MaximumLength, 40 MinimumValue, 41 MaximumValue, 42 WingetMetadataRoot, 43 ProcessorMetadata, 44 ProcessorIdentifierMetadata, 45 ProcessorPropertiesMetadata, 46 }; 47 48 // Gets the name value of the configuration field. 49 std::string_view GetConfigurationFieldName(ConfigurationField fieldName); 50 51 winrt::hstring GetConfigurationFieldNameHString(ConfigurationField fieldName); 52 53 // Attempts to parse a security context from a string. 54 // Returns true if successful; false otherwise. 55 bool TryParseSecurityContext(const hstring& value, SecurityContext& result); 56 57 // Parses a security context from a string. 58 SecurityContext ParseSecurityContext(const hstring& value); 59 60 // Gets the string representation of a security context. 61 std::string_view ToString(SecurityContext value); 62 63 // Gets the string representation of a security context. 64 std::wstring_view ToWString(SecurityContext value); 65 66 // Tries to get the field value from the given value set; only if it is a value set. 67 Windows::Foundation::Collections::ValueSet TryLookupValueSet(const Windows::Foundation::Collections::ValueSet& valueSet, ConfigurationField field); 68 69 // Tries to get the field value from the given value set; only if it is a value set. 70 Windows::Foundation::IPropertyValue TryLookupProperty(const Windows::Foundation::Collections::ValueSet& valueSet, ConfigurationField field, Windows::Foundation::PropertyType type = Windows::Foundation::PropertyType::Empty); 71 }