#pragma warning disable CS0612 // Type or member is obsolete protected CommandModelBase(MixItUp.Base.Commands.CommandBase command) { if (command != null) { this.ID = command.ID; this.GroupName = command.GroupName; this.IsEnabled = command.IsEnabled; this.Unlocked = command.Unlocked; if (command is MixItUp.Base.Commands.PermissionsCommandBase) { MixItUp.Base.Commands.PermissionsCommandBase pCommand = (MixItUp.Base.Commands.PermissionsCommandBase)command; this.Requirements = new RequirementsSetModel(pCommand.Requirements); } foreach (MixItUp.Base.Actions.ActionBase action in command.Actions) { this.Actions.AddRange(ActionModelBase.UpgradeAction(action)); } } else { this.ID = Guid.NewGuid(); } }
public static async Task <CommandModelBase> ImportCommandFromFile() { string fileName = ChannelSession.Services.FileService.ShowOpenFileDialog(string.Format("Mix It Up Command (*{0})|*{0},*{1}|All files (*.*)|*.*", MixItUpCommandFileExtension, MixItUpOldCommandFileExtension)); if (!string.IsNullOrEmpty(fileName)) { if (Path.GetExtension(fileName).Equals(MixItUpOldCommandFileExtension)) { #pragma warning disable CS0612 // Type or member is obsolete MixItUp.Base.Commands.CommandBase command = await FileSerializerHelper.DeserializeFromFile <MixItUp.Base.Commands.CommandBase>(fileName); ActionGroupCommandModel actionGroup = new ActionGroupCommandModel(command.Name, false); foreach (MixItUp.Base.Actions.ActionBase action in command.Actions) { actionGroup.Actions.AddRange(ActionModelBase.UpgradeAction(action)); } return(actionGroup); #pragma warning restore CS0612 // Type or member is obsolete } else { return(await FileSerializerHelper.DeserializeFromFile <CommandModelBase>(fileName)); } } return(null); }
public static async Task <T> ImportCommandFromFile <T>(string filePath) where T : CommandModelBase { if (!string.IsNullOrEmpty(filePath)) { if (Path.GetExtension(filePath).Equals(MixItUpOldCommandFileExtension)) { #pragma warning disable CS0612 // Type or member is obsolete MixItUp.Base.Commands.CommandBase command = await FileSerializerHelper.DeserializeFromFile <MixItUp.Base.Commands.CommandBase>(filePath); ActionGroupCommandModel actionGroup = new ActionGroupCommandModel(command.Name, false); foreach (MixItUp.Base.Actions.ActionBase action in command.Actions) { actionGroup.Actions.AddRange(ActionModelBase.UpgradeAction(action)); } return(actionGroup as T); #pragma warning restore CS0612 // Type or member is obsolete } else { return(await FileSerializerHelper.DeserializeFromFile <T>(filePath)); } } return(null); }