generated/api/Models/GlobalSettingsItem.PowerShell.cs

// Code generated by Microsoft (R) AutoRest Code Generator (autorest: 3.9.2, generator: @autorest/powershell@3.0.494)
// Changes may cause incorrect behavior and will be lost if the code is regenerated.

namespace Commvault.Powershell.Models
{
    using Commvault.Powershell.Runtime.PowerShell;

    /// <summary>GlobalSettingsItem</summary>
    [System.ComponentModel.TypeConverter(typeof(GlobalSettingsItemTypeConverter))]
    public partial class GlobalSettingsItem
    {

        /// <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);

        /// <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);

        /// <summary>
        /// <c>OverrideToString</c> will be called if it is implemented. Implement this method in a partial class to enable this behavior
        /// </summary>
        /// <param name="stringResult">/// instance serialized to a string, normally it is a Json</param>
        /// <param name="returnNow">/// set returnNow to true if you provide a customized OverrideToString function</param>

        partial void OverrideToString(ref string stringResult, ref bool returnNow);

        /// <summary>
        /// Deserializes a <see cref="global::System.Collections.IDictionary" /> into an instance of <see cref="Commvault.Powershell.Models.GlobalSettingsItem"
        /// />.
        /// </summary>
        /// <param name="content">The global::System.Collections.IDictionary content that should be used.</param>
        /// <returns>an instance of <see cref="Commvault.Powershell.Models.IGlobalSettingsItem" />.</returns>
        public static Commvault.Powershell.Models.IGlobalSettingsItem DeserializeFromDictionary(global::System.Collections.IDictionary content)
        {
            return new GlobalSettingsItem(content);
        }

        /// <summary>
        /// Deserializes a <see cref="global::System.Management.Automation.PSObject" /> into an instance of <see cref="Commvault.Powershell.Models.GlobalSettingsItem"
        /// />.
        /// </summary>
        /// <param name="content">The global::System.Management.Automation.PSObject content that should be used.</param>
        /// <returns>an instance of <see cref="Commvault.Powershell.Models.IGlobalSettingsItem" />.</returns>
        public static Commvault.Powershell.Models.IGlobalSettingsItem DeserializeFromPSObject(global::System.Management.Automation.PSObject content)
        {
            return new GlobalSettingsItem(content);
        }

        /// <summary>
        /// Creates a new instance of <see cref="GlobalSettingsItem" />, deserializing the content from a json string.
        /// </summary>
        /// <param name="jsonText">a string containing a JSON serialized instance of this model.</param>
        /// <returns>an instance of the <see cref="GlobalSettingsItem" /> model class.</returns>
        public static Commvault.Powershell.Models.IGlobalSettingsItem FromJsonString(string jsonText) => FromJson(Commvault.Powershell.Runtime.Json.JsonNode.Parse(jsonText));

        /// <summary>
        /// Deserializes a <see cref="global::System.Collections.IDictionary" /> into a new instance of <see cref="Commvault.Powershell.Models.GlobalSettingsItem"
        /// />.
        /// </summary>
        /// <param name="content">The global::System.Collections.IDictionary content that should be used.</param>
        internal GlobalSettingsItem(global::System.Collections.IDictionary content)
        {
            bool returnNow = false;
            BeforeDeserializeDictionary(content, ref returnNow);
            if (returnNow)
            {
                return;
            }
            // actually deserialize
            if (content.Contains("Name"))
            {
                ((Commvault.Powershell.Models.IGlobalSettingsItemInternal)this).Name = (string) content.GetValueForProperty("Name",((Commvault.Powershell.Models.IGlobalSettingsItemInternal)this).Name, global::System.Convert.ToString);
            }
            if (content.Contains("Description"))
            {
                ((Commvault.Powershell.Models.IGlobalSettingsItemInternal)this).Description = (string) content.GetValueForProperty("Description",((Commvault.Powershell.Models.IGlobalSettingsItemInternal)this).Description, global::System.Convert.ToString);
            }
            if (content.Contains("AcceptableValues"))
            {
                ((Commvault.Powershell.Models.IGlobalSettingsItemInternal)this).AcceptableValues = (string[]) content.GetValueForProperty("AcceptableValues",((Commvault.Powershell.Models.IGlobalSettingsItemInternal)this).AcceptableValues, __y => TypeConverterExtensions.SelectToArray<string>(__y, global::System.Convert.ToString));
            }
            if (content.Contains("DefaultValue"))
            {
                ((Commvault.Powershell.Models.IGlobalSettingsItemInternal)this).DefaultValue = (string) content.GetValueForProperty("DefaultValue",((Commvault.Powershell.Models.IGlobalSettingsItemInternal)this).DefaultValue, global::System.Convert.ToString);
            }
            if (content.Contains("Value"))
            {
                ((Commvault.Powershell.Models.IGlobalSettingsItemInternal)this).Value = (string) content.GetValueForProperty("Value",((Commvault.Powershell.Models.IGlobalSettingsItemInternal)this).Value, global::System.Convert.ToString);
            }
            if (content.Contains("Comment"))
            {
                ((Commvault.Powershell.Models.IGlobalSettingsItemInternal)this).Comment = (string) content.GetValueForProperty("Comment",((Commvault.Powershell.Models.IGlobalSettingsItemInternal)this).Comment, global::System.Convert.ToString);
            }
            if (content.Contains("IsModified"))
            {
                ((Commvault.Powershell.Models.IGlobalSettingsItemInternal)this).IsModified = (bool?) content.GetValueForProperty("IsModified",((Commvault.Powershell.Models.IGlobalSettingsItemInternal)this).IsModified, (__y)=> (bool) global::System.Convert.ChangeType(__y, typeof(bool)));
            }
            if (content.Contains("Type"))
            {
                ((Commvault.Powershell.Models.IGlobalSettingsItemInternal)this).Type = (string) content.GetValueForProperty("Type",((Commvault.Powershell.Models.IGlobalSettingsItemInternal)this).Type, global::System.Convert.ToString);
            }
            if (content.Contains("IsRestartRequired"))
            {
                ((Commvault.Powershell.Models.IGlobalSettingsItemInternal)this).IsRestartRequired = (bool?) content.GetValueForProperty("IsRestartRequired",((Commvault.Powershell.Models.IGlobalSettingsItemInternal)this).IsRestartRequired, (__y)=> (bool) global::System.Convert.ChangeType(__y, typeof(bool)));
            }
            if (content.Contains("MinValue"))
            {
                ((Commvault.Powershell.Models.IGlobalSettingsItemInternal)this).MinValue = (long?) content.GetValueForProperty("MinValue",((Commvault.Powershell.Models.IGlobalSettingsItemInternal)this).MinValue, (__y)=> (long) global::System.Convert.ChangeType(__y, typeof(long)));
            }
            if (content.Contains("MaxValue"))
            {
                ((Commvault.Powershell.Models.IGlobalSettingsItemInternal)this).MaxValue = (long?) content.GetValueForProperty("MaxValue",((Commvault.Powershell.Models.IGlobalSettingsItemInternal)this).MaxValue, (__y)=> (long) global::System.Convert.ChangeType(__y, typeof(long)));
            }
            if (content.Contains("Category"))
            {
                ((Commvault.Powershell.Models.IGlobalSettingsItemInternal)this).Category = (string) content.GetValueForProperty("Category",((Commvault.Powershell.Models.IGlobalSettingsItemInternal)this).Category, global::System.Convert.ToString);
            }
            AfterDeserializeDictionary(content);
        }

        /// <summary>
        /// Deserializes a <see cref="global::System.Management.Automation.PSObject" /> into a new instance of <see cref="Commvault.Powershell.Models.GlobalSettingsItem"
        /// />.
        /// </summary>
        /// <param name="content">The global::System.Management.Automation.PSObject content that should be used.</param>
        internal GlobalSettingsItem(global::System.Management.Automation.PSObject content)
        {
            bool returnNow = false;
            BeforeDeserializePSObject(content, ref returnNow);
            if (returnNow)
            {
                return;
            }
            // actually deserialize
            if (content.Contains("Name"))
            {
                ((Commvault.Powershell.Models.IGlobalSettingsItemInternal)this).Name = (string) content.GetValueForProperty("Name",((Commvault.Powershell.Models.IGlobalSettingsItemInternal)this).Name, global::System.Convert.ToString);
            }
            if (content.Contains("Description"))
            {
                ((Commvault.Powershell.Models.IGlobalSettingsItemInternal)this).Description = (string) content.GetValueForProperty("Description",((Commvault.Powershell.Models.IGlobalSettingsItemInternal)this).Description, global::System.Convert.ToString);
            }
            if (content.Contains("AcceptableValues"))
            {
                ((Commvault.Powershell.Models.IGlobalSettingsItemInternal)this).AcceptableValues = (string[]) content.GetValueForProperty("AcceptableValues",((Commvault.Powershell.Models.IGlobalSettingsItemInternal)this).AcceptableValues, __y => TypeConverterExtensions.SelectToArray<string>(__y, global::System.Convert.ToString));
            }
            if (content.Contains("DefaultValue"))
            {
                ((Commvault.Powershell.Models.IGlobalSettingsItemInternal)this).DefaultValue = (string) content.GetValueForProperty("DefaultValue",((Commvault.Powershell.Models.IGlobalSettingsItemInternal)this).DefaultValue, global::System.Convert.ToString);
            }
            if (content.Contains("Value"))
            {
                ((Commvault.Powershell.Models.IGlobalSettingsItemInternal)this).Value = (string) content.GetValueForProperty("Value",((Commvault.Powershell.Models.IGlobalSettingsItemInternal)this).Value, global::System.Convert.ToString);
            }
            if (content.Contains("Comment"))
            {
                ((Commvault.Powershell.Models.IGlobalSettingsItemInternal)this).Comment = (string) content.GetValueForProperty("Comment",((Commvault.Powershell.Models.IGlobalSettingsItemInternal)this).Comment, global::System.Convert.ToString);
            }
            if (content.Contains("IsModified"))
            {
                ((Commvault.Powershell.Models.IGlobalSettingsItemInternal)this).IsModified = (bool?) content.GetValueForProperty("IsModified",((Commvault.Powershell.Models.IGlobalSettingsItemInternal)this).IsModified, (__y)=> (bool) global::System.Convert.ChangeType(__y, typeof(bool)));
            }
            if (content.Contains("Type"))
            {
                ((Commvault.Powershell.Models.IGlobalSettingsItemInternal)this).Type = (string) content.GetValueForProperty("Type",((Commvault.Powershell.Models.IGlobalSettingsItemInternal)this).Type, global::System.Convert.ToString);
            }
            if (content.Contains("IsRestartRequired"))
            {
                ((Commvault.Powershell.Models.IGlobalSettingsItemInternal)this).IsRestartRequired = (bool?) content.GetValueForProperty("IsRestartRequired",((Commvault.Powershell.Models.IGlobalSettingsItemInternal)this).IsRestartRequired, (__y)=> (bool) global::System.Convert.ChangeType(__y, typeof(bool)));
            }
            if (content.Contains("MinValue"))
            {
                ((Commvault.Powershell.Models.IGlobalSettingsItemInternal)this).MinValue = (long?) content.GetValueForProperty("MinValue",((Commvault.Powershell.Models.IGlobalSettingsItemInternal)this).MinValue, (__y)=> (long) global::System.Convert.ChangeType(__y, typeof(long)));
            }
            if (content.Contains("MaxValue"))
            {
                ((Commvault.Powershell.Models.IGlobalSettingsItemInternal)this).MaxValue = (long?) content.GetValueForProperty("MaxValue",((Commvault.Powershell.Models.IGlobalSettingsItemInternal)this).MaxValue, (__y)=> (long) global::System.Convert.ChangeType(__y, typeof(long)));
            }
            if (content.Contains("Category"))
            {
                ((Commvault.Powershell.Models.IGlobalSettingsItemInternal)this).Category = (string) content.GetValueForProperty("Category",((Commvault.Powershell.Models.IGlobalSettingsItemInternal)this).Category, global::System.Convert.ToString);
            }
            AfterDeserializePSObject(content);
        }

        /// <summary>Serializes this instance to a json string.</summary>

        /// <returns>a <see cref="System.String" /> containing this model serialized to JSON text.</returns>
        public string ToJsonString() => ToJson(null, Commvault.Powershell.Runtime.SerializationMode.IncludeAll)?.ToString();

        public override string ToString()
        {
            var returnNow = false;
            var result = global::System.String.Empty;
            OverrideToString(ref result, ref returnNow);
            if (returnNow)
            {
                return result;
            }
            return ToJsonString();
        }
    }
    /// GlobalSettingsItem
    [System.ComponentModel.TypeConverter(typeof(GlobalSettingsItemTypeConverter))]
    public partial interface IGlobalSettingsItem

    {

    }
}