/// <summary>
        /// Gives the field a default value from the gcould config.
        /// </summary>
        /// <param name="field">
        /// The field info.
        /// </param>
        /// <param name="instance">
        /// The instance the field is a member of.
        /// </param>
        public void SetConfigDefault(FieldInfo field, GCloudCmdlet instance)
        {
            bool isBoundParameter = instance.MyInvocation.BoundParameters.ContainsKey(field.Name);
            if (!isBoundParameter)
            {
                string settingsValue = CloudSdkSettings.GetSettingsValue(Property);
                if (string.IsNullOrEmpty(settingsValue))
                {
                    throw new PSInvalidOperationException(
                        $"Parameter {field.Name} was not set and does not have a default value.");
                }

                field.SetValue(instance, settingsValue);
            }
        }
Beispiel #2
0
 /// <summary>
 /// This methods returns a new storage service.
 /// </summary>
 private static StorageService GetNewService()
 {
     return(new StorageService(GCloudCmdlet.GetBaseClientServiceInitializer()));
 }
 /// <summary>
 /// Gives the property a default value from the gcould config if needed.
 /// </summary>
 /// <param name="property">
 /// The property info.
 /// </param>
 /// <param name="instance">
 /// The instance the property is a member of.
 /// </param>
 public void SetConfigDefault(PropertyInfo property, GCloudCmdlet instance)
 {
     bool isBoundParameter = instance.MyInvocation.BoundParameters.ContainsKey(property.Name);
     if (!isBoundParameter)
     {
         SetObjectConfigDefault(property, instance);
     }
 }