public override void ExecuteCmdlet() { if (ParameterSetName == ObjectParameterSet) { ResourceGroupName = CdnProfile.ResourceGroupName; ProfileName = CdnProfile.Name; } var existingProfile = CdnManagementClient.Profiles.List() .Select(p => p.ToPsProfile()) .Where(p => p.Name.ToLower() == ProfileName.ToLower()) .FirstOrDefault(p => p.ResourceGroupName.ToLower() == ResourceGroupName.ToLower()); if (existingProfile == null) { throw new PSArgumentException(string.Format( Resources.Error_DeleteNonExistingProfile, ProfileName, ResourceGroupName)); } ConfirmAction(Force, string.Format(Resources.Confirm_RemoveProfile, ProfileName), this.MyInvocation.InvocationName, ProfileName, () => CdnManagementClient.Profiles.Delete(ResourceGroupName, ProfileName), () => ContainsEndpoints()); if (PassThru) { WriteObject(true); } }
public LoadProfile(Dictionary <string, string> args) : base(args) { QBCLog.BehaviorLoggingContext = this; try { // QuestRequirement* attributes are explained here... // http://www.thebuddyforum.com/mediawiki/index.php?title=Honorbuddy_Programming_Cookbook:_QuestId_for_Custom_Behaviors // ...and also used for IsDone processing. ProfileName = GetAttributeAs <string>("ProfileName", true, ConstrainAs.StringNonEmpty, new[] { "Profile" }) ?? ""; RememberProfile = GetAttributeAsNullable <bool>("RememberProfile", false, null, null) ?? false; if (!ProfileName.ToLower().EndsWith(".xml")) { ProfileName += ".xml"; } } catch (Exception except) { // Maintenance problems occur for a number of reasons. The primary two are... // * Changes were made to the behavior, and boundary conditions weren't properly tested. // * The Honorbuddy core was changed, and the behavior wasn't adjusted for the new changes. // In any case, we pinpoint the source of the problem area here, and hopefully it // can be quickly resolved. QBCLog.Exception(except); IsAttributeProblem = true; } }
/// <summary> /// Allows you to load a profile, it needs to be in the same folder as your current profile. /// ##Syntax## /// ProfileName: The name of the profile with the ".xml" extension. /// </summary> /// public LoadProfile(Dictionary <string, string> args) : base(args) { try { // QuestRequirement* attributes are explained here... // http://www.thebuddyforum.com/mediawiki/index.php?title=Honorbuddy_Programming_Cookbook:_QuestId_for_Custom_Behaviors // ...and also used for IsDone processing. ProfileName = GetAttributeAs <string>("ProfileName", true, ConstrainAs.StringNonEmpty, new[] { "Profile" }) ?? ""; if (!ProfileName.ToLower().EndsWith(".xml")) { ProfileName += ".xml"; } } catch (Exception except) { // Maintenance problems occur for a number of reasons. The primary two are... // * Changes were made to the behavior, and boundary conditions weren't properly tested. // * The Honorbuddy core was changed, and the behavior wasn't adjusted for the new changes. // In any case, we pinpoint the source of the problem area here, and hopefully it // can be quickly resolved. LogMessage("error", "BEHAVIOR MAINTENANCE PROBLEM: " + except.Message + "\nFROM HERE:\n" + except.StackTrace + "\n"); IsAttributeProblem = true; } }
public override void ExecuteCmdlet() { var existingProfile = CdnManagementClient.Profiles.ListBySubscriptionId().Select(p => p.ToPsProfile()) .Where(p => p.Name.ToLower() == ProfileName.ToLower()) .Where(p => p.ResourceGroupName.ToLower() == ResourceGroupName.ToLower()) .FirstOrDefault(); if (existingProfile != null) { throw new PSArgumentException(string.Format(Resources.Error_CreateExistingProfile, ProfileName, ResourceGroupName)); } ConfirmAction(MyInvocation.InvocationName, ProfileName, NewProfile); }