Policy.Autorest/custom/PolicyDefinitionReference.cs

// Copyright (c) Microsoft Corporation. All rights reserved.
// Licensed under the MIT License. See License.txt in the project root for license information.
// Code generated by Microsoft (R) AutoRest Code Generator.
// Changes may cause incorrect behavior and will be lost if the code is regenerated.
 
namespace Microsoft.Azure.PowerShell.Cmdlets.Policy.Models
{
    using System;
    using System.Linq;
    using Microsoft.Azure.PowerShell.Cmdlets.Policy.Runtime.PowerShell;
 
    /// <summary>The policy definition reference.</summary>
    public partial class PolicyDefinitionReference
    {
        /// <summary>
        /// <c>AfterDeserializeDictionary</c> will be called after the deserialization has finished, allowing customization of the
        /// object before it is returned. Implement this method in a partial class to enable this behavior
        /// </summary>
        /// <param name="content">The global::System.Collections.IDictionary content that should be used.</param>
 
        partial void AfterDeserializeDictionary(global::System.Collections.IDictionary content)
        {
        }
 
        /// <summary>
        /// <c>AfterDeserializePSObject</c> will be called after the deserialization has finished, allowing customization of the object
        /// before it is returned. Implement this method in a partial class to enable this behavior
        /// </summary>
        /// <param name="content">The global::System.Management.Automation.PSObject content that should be used.</param>
 
        partial void AfterDeserializePSObject(global::System.Management.Automation.PSObject content)
        {
        }
 
        /// <summary>
        /// <c>BeforeDeserializeDictionary</c> will be called before the deserialization has commenced, allowing complete customization
        /// of the object before it is deserialized.
        /// If you wish to disable the default deserialization entirely, return <c>true</c> in the <paramref name="returnNow" /> output
        /// parameter.
        /// Implement this method in a partial class to enable this behavior.
        /// </summary>
        /// <param name="content">The global::System.Collections.IDictionary content that should be used.</param>
        /// <param name="returnNow">Determines if the rest of the serialization should be processed, or if the method should return
        /// instantly.</param>
 
        partial void BeforeDeserializeDictionary(global::System.Collections.IDictionary content, ref bool returnNow)
        {
            // get properties from hashtable in case-insensitive way
            var keyValuePair = content.Cast<System.Collections.DictionaryEntry>().FirstOrDefault((kvp) => "PolicyDefinitionId".Equals(kvp.Key.ToString(), StringComparison.OrdinalIgnoreCase));
            if (keyValuePair.Key != null)
            {
                ((IPolicyDefinitionReferenceInternal)this).PolicyDefinitionId = content.GetValueForProperty(keyValuePair.Key.ToString(), ((IPolicyDefinitionReferenceInternal)this).PolicyDefinitionId, Convert.ToString);
            }
 
            keyValuePair = content.Cast<System.Collections.DictionaryEntry>().FirstOrDefault((kvp) => "DefinitionVersion".Equals(kvp.Key.ToString(), StringComparison.OrdinalIgnoreCase));
            if (keyValuePair.Key != null)
            {
                ((IPolicyDefinitionReferenceInternal)this).DefinitionVersion = content.GetValueForProperty(keyValuePair.Key.ToString(), ((IPolicyDefinitionReferenceInternal)this).DefinitionVersion, Convert.ToString);
            }
 
            keyValuePair = content.Cast<System.Collections.DictionaryEntry>().FirstOrDefault((kvp) => "Parameters".Equals(kvp.Key.ToString(), StringComparison.OrdinalIgnoreCase));
            if (keyValuePair.Key != null)
            {
                ((IPolicyDefinitionReferenceInternal)this).Parameter = content.GetValueForProperty(keyValuePair.Key.ToString(), ((IPolicyDefinitionReferenceInternal)this).Parameter, ParameterValuesTypeConverter.ConvertFrom);
            }
 
            // Github issue: https://github.com/Azure/azure-powershell/issues/25112
            // fix the serialization: the input property name is policyDefinitionReferenceId, but the generated model has it as Id.
            keyValuePair = content.Cast<System.Collections.DictionaryEntry>().FirstOrDefault((kvp) => "PolicyDefinitionReferenceId".Equals(kvp.Key.ToString(), StringComparison.OrdinalIgnoreCase));
            if (keyValuePair.Key != null)
            {
                ((IPolicyDefinitionReferenceInternal)this).Id = content.GetValueForProperty(keyValuePair.Key.ToString(), ((IPolicyDefinitionReferenceInternal)this).Id, Convert.ToString);
            }
 
            keyValuePair = content.Cast<System.Collections.DictionaryEntry>().FirstOrDefault((kvp) => "GroupNames".Equals(kvp.Key.ToString(), StringComparison.OrdinalIgnoreCase));
            if (keyValuePair.Key != null)
            {
                ((IPolicyDefinitionReferenceInternal)this).GroupName = content.GetValueForProperty(keyValuePair.Key.ToString(), ((IPolicyDefinitionReferenceInternal)this).GroupName, __y => TypeConverterExtensions.SelectToList<string>(__y, Convert.ToString));
            }
 
            returnNow = true;
        }
 
        /// <summary>
        /// <c>BeforeDeserializePSObject</c> will be called before the deserialization has commenced, allowing complete customization
        /// of the object before it is deserialized.
        /// If you wish to disable the default deserialization entirely, return <c>true</c> in the <paramref name="returnNow" /> output
        /// parameter.
        /// Implement this method in a partial class to enable this behavior.
        /// </summary>
        /// <param name="content">The global::System.Management.Automation.PSObject content that should be used.</param>
        /// <param name="returnNow">Determines if the rest of the serialization should be processed, or if the method should return
        /// instantly.</param>
 
        partial void BeforeDeserializePSObject(global::System.Management.Automation.PSObject content, ref bool returnNow)
        {
        }
    }
}