diff --git a/BuildScripts/default.ps1 b/BuildScripts/default.ps1 index d0a4066ed..7e5cd26ae 100644 --- a/BuildScripts/default.ps1 +++ b/BuildScripts/default.ps1 @@ -258,7 +258,7 @@ Task -Name __InstallChocolatey -Description $private -Action { } exec { - Invoke-Expression "$script:chocolateyCommand upgrade chocolatey"; + Invoke-Expression "$script:chocolateyCommand upgrade chocolatey -pre"; } Write-Output "Latest Chocolatey installed." @@ -358,7 +358,7 @@ Task -Name __InstallGitVersion -Depends __InstallChocolatey -Description $privat if (-not (Test-Path $gitVersionExe)) { exec { - Invoke-Expression "$script:chocolateyCommand install GitVersion.Portable -pre -y -source https://www.myget.org/F/gep13/"; + Invoke-Expression "$script:chocolateyCommand install GitVersion.Portable -y"; } } else { Write-Output "GitVersion.Portable already installed"; diff --git a/BuildScripts/dupfinder.config b/BuildScripts/dupfinder.config index 53e81d5cf..eec14f1cd 100644 Binary files a/BuildScripts/dupfinder.config and b/BuildScripts/dupfinder.config differ diff --git a/BuildScripts/inspectcode.config b/BuildScripts/inspectcode.config index 1357d2ec5..59b6e0cd9 100644 Binary files a/BuildScripts/inspectcode.config and b/BuildScripts/inspectcode.config differ diff --git a/Source/ChocolateyGui.sln b/Source/ChocolateyGui.sln index 473555529..e0f30a02d 100644 --- a/Source/ChocolateyGui.sln +++ b/Source/ChocolateyGui.sln @@ -1,7 +1,7 @@  Microsoft Visual Studio Solution File, Format Version 12.00 -# Visual Studio 2013 -VisualStudioVersion = 12.0.31101.0 +# Visual Studio 14 +VisualStudioVersion = 14.0.23107.0 MinimumVisualStudioVersion = 10.0.40219.1 Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "ChocolateyGui", "ChocolateyGui\ChocolateyGui.csproj", "{851FC2F6-AFB0-4153-8520-BF68E1BEA3CB}" EndProject @@ -17,6 +17,7 @@ Project("{2150E333-8FDC-42A3-9474-1A3956D46DE8}") = "BuildScripts", "BuildScript ..\BuildScripts\dupfinder.config = ..\BuildScripts\dupfinder.config ..\BuildScripts\dupfinder.xsl = ..\BuildScripts\dupfinder.xsl ..\BuildScripts\inspectcode.config = ..\BuildScripts\inspectcode.config + Settings.StyleCop = Settings.StyleCop ..\BuildScripts\StyleCop.props = ..\BuildScripts\StyleCop.props ..\BuildScripts\StyleCopReport.xsl = ..\BuildScripts\StyleCopReport.xsl EndProjectSection diff --git a/Source/ChocolateyGui.sln.DotSettings b/Source/ChocolateyGui.sln.DotSettings index 87c7713c0..7b7e42e8b 100644 --- a/Source/ChocolateyGui.sln.DotSettings +++ b/Source/ChocolateyGui.sln.DotSettings @@ -4,4 +4,6 @@ ERROR 0 UI - True \ No newline at end of file + True + True + True \ No newline at end of file diff --git a/Source/ChocolateyGui/App.xaml.cs b/Source/ChocolateyGui/App.xaml.cs index c54997543..ccec1f808 100644 --- a/Source/ChocolateyGui/App.xaml.cs +++ b/Source/ChocolateyGui/App.xaml.cs @@ -11,8 +11,10 @@ namespace ChocolateyGui using Autofac; using ChocolateyGui.IoC; using ChocolateyGui.Services; - using ChocolateyGui.Utilities.Extensions; - using ChocolateyGui.Views.Windows; + using ChocolateyGui.Utilities.Extensions; + using ChocolateyGui.ViewModels.Items; + using ChocolateyGui.Views.Windows; + using NuGet; /// /// Interaction logic for App.xaml @@ -23,7 +25,10 @@ static App() { Container = AutoFacConfiguration.RegisterAutoFac(); - Log = typeof(App).GetLogger(); + Log = typeof(App).GetLogger(); + + AutoMapper.Mapper.CreateMap(); + AutoMapper.Mapper.CreateMap(); AppDomain.CurrentDomain.FirstChanceException += CurrentDomain_FirstChanceException; AppDomain.CurrentDomain.UnhandledException += CurrentDomain_UnhandledException; diff --git a/Source/ChocolateyGui/AsyncProcess/ProcessEx.cs b/Source/ChocolateyGui/AsyncProcess/ProcessEx.cs deleted file mode 100644 index 81e933430..000000000 --- a/Source/ChocolateyGui/AsyncProcess/ProcessEx.cs +++ /dev/null @@ -1,94 +0,0 @@ -// -------------------------------------------------------------------------------------------------------------------- -// -// Copyright (c) 2013 James Manning -// This file was taken from here: -// https://github.com/jamesmanning/RunProcessAsTask -// and adapted under the MIT licensing rules. Original copyright is in tact. -// Modifications: -// - prevent the creation of a new window when executing task -// - correcting FxCop errors -// -// -------------------------------------------------------------------------------------------------------------------- - -namespace ChocolateyGui.AsyncProcess -{ - using System; - using System.Collections.Generic; - using System.Diagnostics; - using System.Threading; - using System.Threading.Tasks; - - /// - /// The ProcessEx Class - /// - [System.Diagnostics.CodeAnalysis.SuppressMessage("Microsoft.Naming", "CA1711:IdentifiersShouldNotHaveIncorrectSuffix", Justification = "Not our code.")] - public static partial class ProcessEx - { - public static Task RunAsync(ProcessStartInfo processStartInfo) - { - return RunAsync(processStartInfo, CancellationToken.None); - } - - [System.Diagnostics.CodeAnalysis.SuppressMessage("Microsoft.Reliability", "CA2000:Dispose objects before losing scope", Justification = "Not our code, and works as is.")] - public static Task RunAsync(ProcessStartInfo processStartInfo, CancellationToken cancellationToken) - { - if (processStartInfo == null) - { - throw new ArgumentNullException("processStartInfo"); - } - - // force some settings in the start info so we can capture the output - processStartInfo.UseShellExecute = false; - processStartInfo.RedirectStandardOutput = true; - processStartInfo.RedirectStandardError = true; - processStartInfo.CreateNoWindow = true; - - var tcs = new TaskCompletionSource(); - - var standardOutput = new List(); - var standardError = new List(); - - var process = new Process - { - StartInfo = processStartInfo, - EnableRaisingEvents = true, - }; - - process.OutputDataReceived += (sender, args) => - { - if (args.Data != null) - { - standardOutput.Add(args.Data); - } - }; - - process.ErrorDataReceived += (sender, args) => - { - if (args.Data != null) - { - standardError.Add(args.Data); - } - }; - - process.Exited += (sender, args) => tcs.TrySetResult(new ProcessResults(process, standardOutput, standardError)); - - cancellationToken.Register(() => - { - tcs.TrySetCanceled(); - process.CloseMainWindow(); - }); - - cancellationToken.ThrowIfCancellationRequested(); - - if (process.Start() == false) - { - tcs.TrySetException(new InvalidOperationException("Failed to start process")); - } - - process.BeginOutputReadLine(); - process.BeginErrorReadLine(); - - return tcs.Task; - } - } -} \ No newline at end of file diff --git a/Source/ChocolateyGui/AsyncProcess/ProcessEx.overloads.cs b/Source/ChocolateyGui/AsyncProcess/ProcessEx.overloads.cs deleted file mode 100644 index b11c1ec94..000000000 --- a/Source/ChocolateyGui/AsyncProcess/ProcessEx.overloads.cs +++ /dev/null @@ -1,59 +0,0 @@ -// -------------------------------------------------------------------------------------------------------------------- -// -// Copyright (c) 2013 James Manning -// This file was taken from here: -// https://github.com/jamesmanning/RunProcessAsTask -// and adapted under the MIT licensing rules. Original copyright is in tact. -// Modifications: -// - prevent the creation of a new window when executing task -// -// -------------------------------------------------------------------------------------------------------------------- - -namespace ChocolateyGui.AsyncProcess -{ - using System.Diagnostics; - using System.Security; - using System.Threading.Tasks; - - /// - /// Overloads for ProcessEx - /// - /// - /// these overloads match the ones in Process.Start to make it a simpler transition for callers - /// see http://msdn.microsoft.com/en-us/library/system.diagnostics.process.start.aspx - /// - public partial class ProcessEx - { - public static Task RunAsync(string fileName) - { - return RunAsync(new ProcessStartInfo(fileName)); - } - - public static Task RunAsync(string fileName, string arguments) - { - return RunAsync(new ProcessStartInfo(fileName, arguments)); - } - - public static Task RunAsync(string fileName, string userName, SecureString password, string domain) - { - return RunAsync(new ProcessStartInfo(fileName) - { - UserName = userName, - Password = password, - Domain = domain, - UseShellExecute = false - }); - } - - public static Task RunAsync(string fileName, string arguments, string userName, SecureString password, string domain) - { - return RunAsync(new ProcessStartInfo(fileName, arguments) - { - UserName = userName, - Password = password, - Domain = domain, - UseShellExecute = false - }); - } - } -} \ No newline at end of file diff --git a/Source/ChocolateyGui/AsyncProcess/ProcessResults.cs b/Source/ChocolateyGui/AsyncProcess/ProcessResults.cs deleted file mode 100644 index e0e213e54..000000000 --- a/Source/ChocolateyGui/AsyncProcess/ProcessResults.cs +++ /dev/null @@ -1,45 +0,0 @@ -// -------------------------------------------------------------------------------------------------------------------- -// -// Copyright (c) 2013 James Manning -// This file was taken from here: -// https://github.com/jamesmanning/RunProcessAsTask -// and adapted under the MIT licensing rules. Original copyright is in tact. -// Modifications: -// - prevent the creation of a new window when executing task -// -// -------------------------------------------------------------------------------------------------------------------- - -namespace ChocolateyGui.AsyncProcess -{ - using System.Collections.Generic; - using System.Diagnostics; - - public class ProcessResults - { - private readonly Process _process; - private readonly IEnumerable _standardOutput; - private readonly IEnumerable _standardError; - - public ProcessResults(Process process, IEnumerable standardOutput, IEnumerable standardError) - { - this._process = process; - this._standardOutput = standardOutput; - this._standardError = standardError; - } - - public Process Process - { - get { return this._process; } - } - - public IEnumerable StandardOutput - { - get { return this._standardOutput; } - } - - public IEnumerable StandardError - { - get { return this._standardError; } - } - } -} \ No newline at end of file diff --git a/Source/ChocolateyGui/ChocolateyGui.csproj b/Source/ChocolateyGui/ChocolateyGui.csproj index d35e43c8c..e5a4ca853 100644 --- a/Source/ChocolateyGui/ChocolateyGui.csproj +++ b/Source/ChocolateyGui/ChocolateyGui.csproj @@ -66,6 +66,10 @@ False ..\packages\AutoMapper.3.2.1\lib\net40\AutoMapper.Net4.dll + + False + ..\lib\chocolatey.lib.0.9.10-beta-20160323\lib\chocolatey.dll + False ..\packages\log4net.2.0.3\lib\net40-full\log4net.dll @@ -154,15 +158,12 @@ - - ChocolateyDialog.xaml - @@ -176,50 +177,40 @@ - - True - - - True - - - True - True - Reference.datasvcmap - - - - - + + + + + - - + + - - + + - + - + - + @@ -306,7 +297,6 @@ - Code @@ -336,9 +326,6 @@ - - True - SettingsSingleFileGenerator @@ -346,27 +333,14 @@ - PreserveNewest - - - - - DataServicesCoreClientGenerator - Reference.cs - - - - datasvcmap - - diff --git a/Source/ChocolateyGui/Controls/ChocolateyHost.cs b/Source/ChocolateyGui/Controls/ChocolateyHost.cs deleted file mode 100644 index 9006b0dcc..000000000 --- a/Source/ChocolateyGui/Controls/ChocolateyHost.cs +++ /dev/null @@ -1,85 +0,0 @@ -// -------------------------------------------------------------------------------------------------------------------- -// -// Copyright 2014 - Present Rob Reynolds, the maintainers of Chocolatey, and RealDimensions Software, LLC -// -// -------------------------------------------------------------------------------------------------------------------- - -namespace ChocolateyGui.Controls -{ - using System; - using System.Globalization; - using System.Management.Automation.Host; - using System.Reflection; - using ChocolateyGui.Services; - - internal class ChocolateyHost : PSHost - { - private readonly ChocolateyHostUserInterface _chocolateyHostUserInterface; - - private readonly Guid _hostInstanceId = Guid.NewGuid(); - - private readonly CultureInfo _originalCultureInfo = - System.Threading.Thread.CurrentThread.CurrentCulture; - - private readonly CultureInfo _originalUiCultureInfo = - System.Threading.Thread.CurrentThread.CurrentUICulture; - - public ChocolateyHost(IProgressService progressService) - { - this._chocolateyHostUserInterface = new ChocolateyHostUserInterface(progressService); - } - - public override CultureInfo CurrentCulture - { - get { return this._originalCultureInfo; } - } - - public override CultureInfo CurrentUICulture - { - get { return this._originalUiCultureInfo; } - } - - public override Guid InstanceId - { - get { return this._hostInstanceId; } - } - - public override string Name - { - get { return @"ChocolateyGUI PowerShell Host"; } - } - - public override PSHostUserInterface UI - { - get { return this._chocolateyHostUserInterface; } - } - - public override Version Version - { - get { return Assembly.GetExecutingAssembly().GetName().Version; } - } - - public override void EnterNestedPrompt() - { - throw new NotImplementedException(); - } - - public override void ExitNestedPrompt() - { - throw new NotImplementedException(); - } - - public override void NotifyBeginApplication() - { - } - - public override void NotifyEndApplication() - { - } - - public override void SetShouldExit(int exitCode) - { - throw new NotImplementedException(); - } - } -} \ No newline at end of file diff --git a/Source/ChocolateyGui/Controls/ChocolateyHostRawUserInterface.cs b/Source/ChocolateyGui/Controls/ChocolateyHostRawUserInterface.cs deleted file mode 100644 index 1ece52c05..000000000 --- a/Source/ChocolateyGui/Controls/ChocolateyHostRawUserInterface.cs +++ /dev/null @@ -1,218 +0,0 @@ -// -------------------------------------------------------------------------------------------------------------------- -// -// Copyright 2014 - Present Rob Reynolds, the maintainers of Chocolatey, and RealDimensions Software, LLC -// -// -------------------------------------------------------------------------------------------------------------------- - -namespace ChocolateyGui.Controls -{ - using System; - using System.Management.Automation.Host; - - internal class ChocolateyHostRawUserInterface : PSHostRawUserInterface - { - /// - /// Gets or sets the background color of the displayed text. - /// This maps to the corresponding Console.Background property. - /// - public override ConsoleColor BackgroundColor - { - get { return Console.BackgroundColor; } - set { Console.BackgroundColor = value; } - } - - /// - /// Gets or sets the size of the host buffer. In this example the - /// buffer size is adapted from the Console buffer size members. - /// - public override Size BufferSize - { - get { return new Size(0, 0); } - set { } - } - - /// - /// Gets or sets the cursor position. In this example this - /// functionality is not needed so the property throws a - /// NotImplementException exception. - /// - public override Coordinates CursorPosition - { - get - { - throw new NotImplementedException( - "CursorPosition is not implemented."); - } - - set - { - throw new NotImplementedException( - "NotImplementedException is not implemented."); - } - } - - /// - /// Gets or sets the size of the displayed cursor. In this example - /// the cursor size is taken directly from the Console.CursorSize - /// property. - /// - public override int CursorSize - { - get { return Console.CursorSize; } - set { Console.CursorSize = value; } - } - - /// - /// Gets or sets the foreground color of the displayed text. - /// This maps to the corresponding Console.ForegroundColor property. - /// - public override ConsoleColor ForegroundColor - { - get { return Console.ForegroundColor; } - set { Console.ForegroundColor = value; } - } - - /// - /// Gets a value indicating whether the user has pressed a key. This maps - /// to the corresponding Console.KeyAvailable property. - /// - public override bool KeyAvailable - { - get { return Console.KeyAvailable; } - } - - /// - /// Gets the dimensions of the largest window that could be - /// rendered in the current display, if the buffer was at the least - /// that large. This example uses the Console.LargestWindowWidth and - /// Console.LargestWindowHeight properties to determine the returned - /// value of this property. - /// - public override Size MaxPhysicalWindowSize - { - get { return new Size(Console.LargestWindowWidth, Console.LargestWindowHeight); } - } - - /// - /// Gets the dimensions of the largest window size that can be - /// displayed. This example uses the Console.LargestWindowWidth and - /// console.LargestWindowHeight properties to determine the returned - /// value of this property. - /// - public override Size MaxWindowSize - { - get { return new Size(Console.LargestWindowWidth, Console.LargestWindowHeight); } - } - - /// - /// Gets or sets the position of the displayed window. This example - /// uses the Console window position APIs to determine the returned - /// value of this property. - /// - public override Coordinates WindowPosition - { - get { return new Coordinates(Console.WindowLeft, Console.WindowTop); } - set { Console.SetWindowPosition(value.X, value.Y); } - } - - /// - /// Gets or sets the size of the displayed window. This example - /// uses the corresponding Console window size APIs to determine the - /// returned value of this property. - /// - public override Size WindowSize - { - get { return new Size(Console.WindowWidth, Console.WindowHeight); } - set { Console.SetWindowSize(value.Width, value.Height); } - } - - /// - /// Gets or sets the title of the displayed window. The example - /// maps the Console.Title property to the value of this property. - /// - public override string WindowTitle - { - get { return Console.Title; } - set { Console.Title = value; } - } - - /// - /// This API resets the input buffer. In this example this - /// functionality is not needed so the method returns nothing. - /// - public override void FlushInputBuffer() - { - } - - /// - /// This API returns a rectangular region of the screen buffer. In - /// this example this functionality is not needed so the method throws - /// a NotImplementException exception. - /// - /// Defines the size of the rectangle. - /// Throws a NotImplementedException exception. - public override BufferCell[,] GetBufferContents(Rectangle rectangle) - { - throw new NotImplementedException( - "GetBufferContents is not implemented."); - } - - /// - /// This API reads a pressed, released, or pressed and released keystroke - /// from the keyboard device, blocking processing until a keystroke is - /// typed that matches the specified keystroke options. In this example - /// this functionality is not needed so the method throws a - /// NotImplementException exception. - /// - /// Options, such as IncludeKeyDown, used when - /// reading the keyboard. - /// Throws a NotImplementedException exception. - public override KeyInfo ReadKey(ReadKeyOptions options) - { - throw new NotImplementedException( - "ReadKey is not implemented."); - } - - /// - /// This API crops a region of the screen buffer. In this example - /// this functionality is not needed so the method throws a - /// NotImplementException exception. - /// - /// The region of the screen to be scrolled. - /// The region of the screen to receive the - /// source region contents. - /// The region of the screen to include in the operation. - /// The character and attributes to be used to fill all cell. - public override void ScrollBufferContents(Rectangle source, Coordinates destination, Rectangle clip, BufferCell fill) - { - throw new NotImplementedException( - "ScrollBufferContents is not implemented."); - } - - /// - /// This method copies an array of buffer cells into the screen buffer - /// at a specified location. In this example this functionality is - /// not needed so the method throws a NotImplementedException exception. - /// - /// The parameter is not used. - /// The parameter is not used. - public override void SetBufferContents(Coordinates origin, BufferCell[,] contents) - { - throw new NotImplementedException( - "SetBufferContents is not implemented."); - } - - /// - /// This method copies a given character, foreground color, and background - /// color to a region of the screen buffer. In this example this - /// functionality is not needed so the method throws a - /// NotImplementException exception./// - /// Defines the area to be filled. - /// Defines the fill character. - public override void SetBufferContents(Rectangle rectangle, BufferCell fill) - { - throw new NotImplementedException( - "SetBufferContents is not implemented."); - } - } -} \ No newline at end of file diff --git a/Source/ChocolateyGui/Controls/ChocolateyHostUserInterface.cs b/Source/ChocolateyGui/Controls/ChocolateyHostUserInterface.cs deleted file mode 100644 index 6c5e2c023..000000000 --- a/Source/ChocolateyGui/Controls/ChocolateyHostUserInterface.cs +++ /dev/null @@ -1,136 +0,0 @@ -// -------------------------------------------------------------------------------------------------------------------- -// -// Copyright 2014 - Present Rob Reynolds, the maintainers of Chocolatey, and RealDimensions Software, LLC -// -// -------------------------------------------------------------------------------------------------------------------- - -namespace ChocolateyGui.Controls -{ - using System; - using System.Collections.Generic; - using System.Management.Automation; - using System.Management.Automation.Host; - using ChocolateyGui.Models; - using ChocolateyGui.Services; - - internal class ChocolateyHostUserInterface : PSHostUserInterface - { - private readonly ChocolateyHostRawUserInterface _chocoRawUI = new ChocolateyHostRawUserInterface(); - private readonly IProgressService _progressService; - - public ChocolateyHostUserInterface(IProgressService progressService) - { - this._progressService = progressService; - } - - public override PSHostRawUserInterface RawUI - { - get { return this._chocoRawUI; } - } - - public override Dictionary Prompt( - string caption, - string message, - System.Collections.ObjectModel.Collection descriptions) - { - throw new NotImplementedException( - "Prompt is not implemented."); - } - - public override int PromptForChoice(string caption, string message, System.Collections.ObjectModel.Collection choices, int defaultChoice) - { - throw new NotImplementedException("PromptForChoice is not implemented."); - } - - public override PSCredential PromptForCredential( - string caption, - string message, - string userName, - string targetName) - { - throw new NotImplementedException("PromptForCredential is not implemented."); - } - - public override PSCredential PromptForCredential( - string caption, - string message, - string userName, - string targetName, - PSCredentialTypes allowedCredentialTypes, - PSCredentialUIOptions options) - { - Console.WriteLine("ReadLine"); - throw new NotImplementedException("PromptForCredential is not implemented."); - } - - public override string ReadLine() - { - throw new NotImplementedException("ReadLine is not implemented."); - } - - public override System.Security.SecureString ReadLineAsSecureString() - { - throw new NotImplementedException("ReadLineAsSecureString is not implemented."); - } - - public override void Write(string value) - { - this._progressService.Output.Add(new PowerShellOutputLine(value, PowerShellLineType.Output, newLine: false)); - } - - public override void Write( - ConsoleColor foregroundColor, - ConsoleColor backgroundColor, - string value) - { - // Colors are ignored. - this._progressService.Output.Add(new PowerShellOutputLine(value, PowerShellLineType.Output, newLine: false)); - } - - public override void WriteDebugLine(string message) - { - this._progressService.Output.Add(new PowerShellOutputLine(message, PowerShellLineType.Debug)); - } - - public override void WriteErrorLine(string value) - { - this._progressService.Output.Add(new PowerShellOutputLine(value, PowerShellLineType.Error)); - } - - public override void WriteLine() - { - this._progressService.Output.Add(new PowerShellOutputLine(string.Empty, PowerShellLineType.Output)); - } - - public override void WriteLine(string value) - { - this._progressService.Output.Add(new PowerShellOutputLine(value, PowerShellLineType.Output)); - } - - public override void WriteLine(ConsoleColor foregroundColor, ConsoleColor backgroundColor, string value) - { - // Write to the output stream, ignore the colors - this._progressService.Output.Add(new PowerShellOutputLine(value, PowerShellLineType.Output)); - } - - public override void WriteProgress(long sourceId, ProgressRecord record) - { - if (record == null) - { - throw new ArgumentNullException("record"); - } - - this._progressService.Report(record.PercentComplete); - } - - public override void WriteVerboseLine(string message) - { - this._progressService.Output.Add(new PowerShellOutputLine(message, PowerShellLineType.Warning)); - } - - public override void WriteWarningLine(string message) - { - this._progressService.Output.Add(new PowerShellOutputLine(message, PowerShellLineType.Warning)); - } - } -} \ No newline at end of file diff --git a/Source/ChocolateyGui/Controls/Dialogs/ChocolateyDialog.xaml b/Source/ChocolateyGui/Controls/Dialogs/ChocolateyDialog.xaml index 71dcd18e7..7a8a44b20 100644 --- a/Source/ChocolateyGui/Controls/Dialogs/ChocolateyDialog.xaml +++ b/Source/ChocolateyGui/Controls/Dialogs/ChocolateyDialog.xaml @@ -4,10 +4,9 @@ xmlns:MahDialogs="clr-namespace:MahApps.Metro.Controls.Dialogs;assembly=MahApps.Metro" xmlns:Controls="clr-namespace:ChocolateyGui.Controls" xmlns:Dialogs="clr-namespace:ChocolateyGui.Controls.Dialogs" - xmlns:conv="clr-namespace:MahApps.Metro.Converters;assembly=MahApps.Metro" xmlns:d="http://schemas.microsoft.com/expression/blend/2008" xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006" - mc:Ignorable="d" + mc:Ignorable="d" x:Class="ChocolateyGui.Controls.Dialogs.ChocolateyDialog" d:DesignHeight="300" d:DesignWidth="1300"> @@ -18,10 +17,10 @@ + IsReadOnly="True"/> @@ -36,7 +35,7 @@ - diff --git a/Source/ChocolateyGui/Controls/ObservableRingBufferCollection.cs b/Source/ChocolateyGui/Controls/ObservableRingBufferCollection.cs index a7285b5b9..21d069618 100644 --- a/Source/ChocolateyGui/Controls/ObservableRingBufferCollection.cs +++ b/Source/ChocolateyGui/Controls/ObservableRingBufferCollection.cs @@ -25,25 +25,25 @@ public sealed class ObservableRingBufferCollection : INotifyCollectionChanged private T[] _buffer; /// - /// The all-over position within the ring buffer. The position - /// increases continuously by adding new items to the buffer. This - /// value is needed to calculate the current relative position within the + /// The all-over position within the ring buffer. The position + /// increases continuously by adding new items to the buffer. This + /// value is needed to calculate the current relative position within the /// buffer. /// private int _position; /// - /// The current version of the buffer, this is required for a correct + /// The current version of the buffer, this is required for a correct /// exception handling while enumerating over the items of the buffer. /// private long _version; /// - /// Initializes a new instance of the class. + /// Initializes a new instance of the class. /// The observable ring buffer collection. /// /// - /// The maximum count of items to be stored within + /// The maximum count of items to be stored within /// the ring buffer. /// public ObservableRingBufferCollection(int capacity) @@ -97,7 +97,7 @@ public void Add(T item) } this._buffer[index] = item; - + // increase the count if capacity is not yet reached if (this.Count < this.Capacity) { @@ -110,12 +110,12 @@ public void Add(T item) } /// - /// Clears the whole buffer and releases all referenced objects + /// Clears the whole buffer and releases all referenced objects /// currently stored within the buffer. /// public void Clear() { - for (int i = 0; i < this.Count; i++) + for (var i = 0; i < this.Count; i++) { this._buffer[i] = default(T); } @@ -132,18 +132,18 @@ public void Clear() /// /// The item to search for within the current /// buffer. - /// True if the specified item is currently present within + /// True if the specified item is currently present within /// the buffer; otherwise false. public bool Contains(T item) { - int index = this.IndexOf(item); + var index = this.IndexOf(item); return index != -1; } /// /// Copies the current items within the buffer to a specified array. /// - /// The target array to copy the items of + /// The target array to copy the items of /// the buffer to. /// The start position within the target /// array to start copying. @@ -154,7 +154,7 @@ public void CopyTo(T[] array, int arrayIndex) throw new ArgumentNullException("array"); } - for (int i = 0; i < this.Count; i++) + for (var i = 0; i < this.Count; i++) { array[i + arrayIndex] = this._buffer[(this._position - this.Count + i) % this.Capacity]; } @@ -167,8 +167,8 @@ public void CopyTo(T[] array, int arrayIndex) /// public IEnumerator GetEnumerator() { - long version = this._version; - for (int i = 0; i < this.Count; i++) + var version = this._version; + for (var i = 0; i < this.Count; i++) { if (version != this._version) { @@ -198,16 +198,16 @@ IEnumerator IEnumerable.GetEnumerator() /// from the buffer; otherwise false. /// /// Warning - /// Frequent usage of this method might become a bad idea if you are - /// working with a large buffer capacity. The removing of an item + /// Frequent usage of this method might become a bad idea if you are + /// working with a large buffer capacity. The removing of an item /// requires a scan of the buffer to get the position of the specified - /// item. If the item was found, the deletion requires a move of all + /// item. If the item was found, the deletion requires a move of all /// items stored above the found position. /// public bool Remove(T item) { // find the position of the specified item - int index = this.IndexOf(item); + var index = this.IndexOf(item); // item was not found; return false if (index == -1) @@ -225,16 +225,16 @@ public bool Remove(T item) /// Gets the position of a specified item within the ring buffer. /// /// The item to get the current position for. - /// The zero based index of the found item within the + /// The zero based index of the found item within the /// buffer. If the item was not present within the buffer, this /// method returns -1. private int IndexOf(T item) { // loop over the current count of items - for (int i = 0; i < this.Count; i++) + for (var i = 0; i < this.Count; i++) { // get the item at the relative position within the internal array - T item2 = this._buffer[(this._position - this.Count + i) % this.Capacity]; + var item2 = this._buffer[(this._position - this.Count + i) % this.Capacity]; // if both items are null, return true if (null == item && null == item2) @@ -268,8 +268,8 @@ private void NotifyCollectionChanged(NotifyCollectionChangedEventArgs args) /// Thrown when incorrect argument passed in. /// /// Warning - /// Frequent usage of this method might become a bad idea if you are - /// working with a large buffer capacity. The deletion requires a move + /// Frequent usage of this method might become a bad idea if you are + /// working with a large buffer capacity. The deletion requires a move /// of all items stored above the found position. /// private void RemoveAt(int index) @@ -282,27 +282,27 @@ private void RemoveAt(int index) // move all items above the specified position one step // closer to zero - for (int i = index; i < this.Count - 1; i++) + for (var i = index; i < this.Count - 1; i++) { // get the next relative target position of the item - int to = (this._position - this.Count + i) % this.Capacity; - - // get the next relative source position of the item - int from = (this._position - this.Count + i + 1) % this.Capacity; - + var to = (this._position - this.Count + i) % this.Capacity; + + // get the next relative source position of the item + var from = (this._position - this.Count + i + 1) % this.Capacity; + // move the item this._buffer[to] = this._buffer[from]; } // get the relative position of the last item, which becomes empty // after deletion and set the item as empty - int last = (this._position - 1) % this.Capacity; + var last = (this._position - 1) % this.Capacity; this._buffer[last] = default(T); // adjust storage information this._position--; this.Count--; - + // buffer changed; next version this._version++; diff --git a/Source/ChocolateyGui/GlobalSuppressions.cs b/Source/ChocolateyGui/GlobalSuppressions.cs index df7308fef..54563c93d 100644 Binary files a/Source/ChocolateyGui/GlobalSuppressions.cs and b/Source/ChocolateyGui/GlobalSuppressions.cs differ diff --git a/Source/ChocolateyGui/IoC/AutoFacConfiguration.cs b/Source/ChocolateyGui/IoC/AutoFacConfiguration.cs index 3aff512b2..70350fbc9 100644 --- a/Source/ChocolateyGui/IoC/AutoFacConfiguration.cs +++ b/Source/ChocolateyGui/IoC/AutoFacConfiguration.cs @@ -28,15 +28,7 @@ public static IContainer RegisterAutoFac() var configurationProvider = new ChocolateyConfigurationProvider(); builder.RegisterInstance(configurationProvider).As().SingleInstance(); - - if (configurationProvider.IsChocolateyExecutableBeingUsed) - { - RegisterCSharpService(builder); - } - else - { - RegisterPowerShellService(builder); - } + builder.RegisterType().As().SingleInstance(); // Register View Models builder.RegisterType().As(); @@ -53,13 +45,13 @@ public static IContainer RegisterAutoFac() builder.RegisterType().As(); builder.RegisterType().As(); builder.RegisterType().As(); - builder.Register(c => new PackageViewModel(c.Resolve(), c.Resolve(), c.Resolve())).As(); + builder.Register(c => new PackageViewModel(c.Resolve(), c.Resolve(), c.Resolve())).As(); // Register Services builder.Register((c, parameters) => new Log4NetLoggingService(parameters.TypedAs())).As(); - builder.RegisterType().As().SingleInstance(); + builder.RegisterType().As().SingleInstance(); builder.RegisterType().As().SingleInstance(); - builder.RegisterType().As().SingleInstance(); + builder.RegisterType().As().SingleInstance(); builder.RegisterType().As().SingleInstance(); builder.RegisterType().As().SingleInstance(); @@ -72,16 +64,6 @@ public static IContainer RegisterAutoFac() builder.Register((c, pvm) => new PackageControl(c.Resolve(), pvm.TypedAs())); return builder.Build(); - } - - private static void RegisterPowerShellService(ContainerBuilder builder) - { - builder.RegisterType().As().SingleInstance(); - } - - private static void RegisterCSharpService(ContainerBuilder builder) - { - builder.RegisterType().As().SingleInstance(); } } } \ No newline at end of file diff --git a/Source/ChocolateyGui/Models/PackageConfigEntry.cs b/Source/ChocolateyGui/Models/PackageConfigEntry.cs index a8b3105e1..b081c1d8e 100644 --- a/Source/ChocolateyGui/Models/PackageConfigEntry.cs +++ b/Source/ChocolateyGui/Models/PackageConfigEntry.cs @@ -6,7 +6,8 @@ namespace ChocolateyGui.Models { - using System; + using System; + using NuGet; public class PackageConfigEntry { diff --git a/Source/ChocolateyGui/Models/PackageSearchOptions.cs b/Source/ChocolateyGui/Models/PackageSearchOptions.cs index f31c25a97..a51d6c550 100644 --- a/Source/ChocolateyGui/Models/PackageSearchOptions.cs +++ b/Source/ChocolateyGui/Models/PackageSearchOptions.cs @@ -20,8 +20,6 @@ public struct PackageSearchOptions private readonly string _sortColumn; - private readonly bool _sortDescending; - #pragma warning disable 649 private readonly string[] _tagsQuery; #pragma warning restore 649 @@ -33,22 +31,20 @@ public PackageSearchOptions(int pageSize, int currentPage) this._currentPage = currentPage; } - public PackageSearchOptions(int pageSize, int currentPage, string sortColumn, bool sortDescending) + public PackageSearchOptions(int pageSize, int currentPage, string sortColumn) : this() { this._pageSize = pageSize; this._currentPage = currentPage; this._sortColumn = sortColumn; - this._sortDescending = sortDescending; } - public PackageSearchOptions(int pageSize, int currentPage, string sortColumn, bool sortDescending, bool includePrerelease, bool includeAllVersions, bool matchWord) + public PackageSearchOptions(int pageSize, int currentPage, string sortColumn, bool includePrerelease, bool includeAllVersions, bool matchWord) : this() { this._pageSize = pageSize; this._currentPage = currentPage; this._sortColumn = sortColumn; - this._sortDescending = sortDescending; this._includeAllVersions = includeAllVersions; this._includedPrerelease = includePrerelease; this._matchQuery = matchWord; @@ -102,14 +98,6 @@ public string SortColumn } } - public bool SortDescending - { - get - { - return this._sortDescending; - } - } - public string[] TagsQuery { get diff --git a/Source/ChocolateyGui/Models/SemanticVersion.cs b/Source/ChocolateyGui/Models/SemanticVersion.cs deleted file mode 100644 index 0c2cfc24c..000000000 --- a/Source/ChocolateyGui/Models/SemanticVersion.cs +++ /dev/null @@ -1,298 +0,0 @@ -// -------------------------------------------------------------------------------------------------------------------- -// -// Copyright 2014 - Present Rob Reynolds, the maintainers of Chocolatey, and RealDimensions Software, LLC -// -// -------------------------------------------------------------------------------------------------------------------- - -namespace ChocolateyGui.Models -{ - // Full credit to the NuGet team for this implementation! - using System; - using System.ComponentModel; - using System.Globalization; - using System.Text.RegularExpressions; - using ChocolateyGui.Properties; - using ChocolateyGui.Utilities.TypeConverters; - - [TypeConverter(typeof(SemanticVersionTypeConverter))] - [Serializable] - public sealed class SemanticVersion : IComparable, IComparable, IEquatable - { - private const long BaseCombinedHash64 = 5381L; - - private static readonly Regex SemanticVersionRegex = - new Regex( - "^(?\\d+(\\s*\\.\\s*\\d+){0,3})(?-[a-z][0-9a-z-]*)?$", - RegexOptions.IgnoreCase | RegexOptions.ExplicitCapture | RegexOptions.Compiled); - - private static readonly Regex StrictSemanticVersionRegex = - new Regex( - "^(?\\d+(\\.\\d+){2})(?-[a-z][0-9a-z-]*)?$", - RegexOptions.IgnoreCase | RegexOptions.ExplicitCapture | RegexOptions.Compiled); - - private readonly Func _addIntToHash = (obj, hashCode) => (hashCode << 5) + hashCode ^ (long)(obj != null ? obj.GetHashCode() : 0); - - private readonly string _originalString; - - public SemanticVersion(string version) - : this(Parse(version)) - { - this._originalString = version; - } - - public SemanticVersion(int major, int minor, int build, int revision) - : this(new Version(major, minor, build, revision)) - { - } - - public SemanticVersion(int major, int minor, int build, string specialVersion) - : this(new Version(major, minor, build), specialVersion) - { - } - - public SemanticVersion(Version version) - : this(version, string.Empty) - { - } - - public SemanticVersion(Version version, string specialVersion) - : this(version, specialVersion, null) - { - } - - internal SemanticVersion(SemanticVersion semVer) - { - this._originalString = semVer.ToString(); - Version = semVer.Version; - this.SpecialVersion = semVer.SpecialVersion; - } - - private SemanticVersion(Version version, string specialVersion, string originalString) - { - if (version == null) - { - throw new ArgumentNullException("version"); - } - - Version = NormalizeVersionValue(version); - - this.SpecialVersion = specialVersion ?? string.Empty; - this._originalString = string.IsNullOrEmpty(originalString) - ? version + (!string.IsNullOrEmpty(specialVersion) ? "-" + specialVersion : null) - : originalString; - } - - public string SpecialVersion { get; private set; } - - public Version Version { get; private set; } - - public static bool operator !=(SemanticVersion version1, SemanticVersion version2) - { - return !(version1 == version2); - } - - public static bool operator <(SemanticVersion version1, SemanticVersion version2) - { - if (version1 == null) - { - throw new ArgumentNullException("version1"); - } - - return version1.CompareTo(version2) < 0; - } - - public static bool operator <=(SemanticVersion version1, SemanticVersion version2) - { - if (!(version1 == version2)) - { - return version1 < version2; - } - - return true; - } - - public static bool operator ==(SemanticVersion version1, SemanticVersion version2) - { - if (ReferenceEquals(version1, version2)) - { - return true; - } - - // If one is null, but not both, return false. - if (((object)version1 == null) || ((object)version2 == null)) - { - return false; - } - - return version1.Equals(version2); - } - - public static bool operator >(SemanticVersion version1, SemanticVersion version2) - { - if (version1 == null) - { - throw new ArgumentNullException("version1"); - } - - return version2 < version1; - } - - public static bool operator >=(SemanticVersion version1, SemanticVersion version2) - { - if (!(version1 == version2)) - { - return version1 > version2; - } - - return true; - } - - public static SemanticVersion Parse(string version) - { - if (string.IsNullOrEmpty(version)) - { - throw new ArgumentException(Resources.Argument_cant_be_null_or_empty, "version"); - } - - SemanticVersion semanticVersion; - if (TryParse(version, out semanticVersion)) - { - return semanticVersion; - } - - throw new ArgumentException( - string.Format( - CultureInfo.CurrentCulture, - Resources.InvalidVersionString, - new object[1] { version }), - "version"); - } - - public static SemanticVersion ParseOptionalVersion(string version) - { - SemanticVersion semanticVersion; - bool success = TryParse(version, out semanticVersion); - if (!success) - { - semanticVersion = null; - } - - return semanticVersion; - } - - public static bool TryParse(string version, out SemanticVersion value) - { - return TryParseInternal(version, SemanticVersionRegex, out value); - } - - public static bool TryParseStrict(string version, out SemanticVersion value) - { - return TryParseInternal(version, StrictSemanticVersionRegex, out value); - } - - public int CompareTo(object obj) - { - if (obj == null) - { - return 1; - } - - var other = obj as SemanticVersion; - - if (other == null) - { - throw new ArgumentException(Resources.TypeMustBeASemanticVersion, "obj"); - } - - return this.CompareTo(other); - } - - public int CompareTo(SemanticVersion other) - { - if (other == null) - { - return 1; - } - - var num = Version.CompareTo(other.Version); - if (num != 0) - { - return num; - } - - var thisSvNull = string.IsNullOrEmpty(this.SpecialVersion); - var otherSvNull = string.IsNullOrEmpty(other.SpecialVersion); - - if (thisSvNull && otherSvNull) - { - return 0; - } - - if (thisSvNull) - { - return 1; - } - - if (otherSvNull) - { - return -1; - } - - return StringComparer.OrdinalIgnoreCase.Compare(this.SpecialVersion, other.SpecialVersion); - } - - public bool Equals(SemanticVersion other) - { - if (other != null && Version == other.Version) - { - return this.SpecialVersion.Equals(other.SpecialVersion, StringComparison.OrdinalIgnoreCase); - } - - return false; - } - - public override bool Equals(object obj) - { - var other = obj as SemanticVersion; - return other != null && this.Equals(other); - } - - public override int GetHashCode() - { - return this._addIntToHash(this.SpecialVersion, this._addIntToHash(Version, BaseCombinedHash64)).GetHashCode(); - } - - public override string ToString() - { - return this._originalString; - } - - private static Version NormalizeVersionValue(Version version) - { - return new Version(version.Major, version.Minor, Math.Max(version.Build, 0), Math.Max(version.Revision, 0)); - } - - private static bool TryParseInternal(string version, Regex regex, out SemanticVersion semVer) - { - semVer = null; - if (string.IsNullOrEmpty(version)) - { - return false; - } - - var match = regex.Match(version.Trim()); - Version result; - if (!match.Success || !Version.TryParse(match.Groups["Version"].Value, out result)) - { - return false; - } - - semVer = new SemanticVersion( - NormalizeVersionValue(result), - match.Groups["Release"].Value.TrimStart(new[] { '-' }), - version.Replace(" ", string.Empty)); - - return true; - } - } -} \ No newline at end of file diff --git a/Source/ChocolateyGui/Properties/AssemblyInfo.cs b/Source/ChocolateyGui/Properties/AssemblyInfo.cs index a62a19e41..e4dbb8c06 100644 --- a/Source/ChocolateyGui/Properties/AssemblyInfo.cs +++ b/Source/ChocolateyGui/Properties/AssemblyInfo.cs @@ -25,7 +25,7 @@ [assembly: AssemblyTrademark("")] [assembly: AssemblyCulture("")] [assembly: NeutralResourcesLanguage("en-US")] -[assembly: CLSCompliant(true)] +[assembly: CLSCompliant(false)] // Setting ComVisible to false makes the types in this assembly not visible // to COM components. If you need to access a type in this assembly from diff --git a/Source/ChocolateyGui/Resources/ControlStyles/Flyout.xaml b/Source/ChocolateyGui/Resources/ControlStyles/Flyout.xaml index 06d06226c..c5c914165 100644 --- a/Source/ChocolateyGui/Resources/ControlStyles/Flyout.xaml +++ b/Source/ChocolateyGui/Resources/ControlStyles/Flyout.xaml @@ -1,6 +1,5 @@  + xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"> - + - +