Permalink
Browse files

Formalizing to project

  • Loading branch information...
serialseb committed Mar 11, 2012
1 parent 5468c7a commit 463071970126dce44d2409206ec38bda7f520560
View
@@ -0,0 +1,36 @@
+_cache
+_cache/*
+_*
+*/_*
+src/_*
+obj
+bin
+bin/*
+deploy
+deploy/*
+_ReSharper.*
+*.csproj.user
+*.user
+*.suo
+*.cache
+*.Cache
+~$*
+Thumbs.db
+*.cache
+.svn
+
+*.pidb
+*.user
+*.ndproj
+*.xls
+*.htm
+_*
+
+reports
+reports/*
+/*.wrap
+.milestone
+*.bin
+*/*.bin
+*.orig
+*/*.orig
@@ -0,0 +1,20 @@
+
+Microsoft Visual Studio Solution File, Format Version 11.00
+# Visual Studio 2010
+Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "OpenWrap.Preloading", "OpenWrap.Preloading\OpenWrap.Preloading.csproj", "{4E23A829-B9EF-4BDE-941A-D15B334C09AD}"
+EndProject
+Global
+ GlobalSection(SolutionConfigurationPlatforms) = preSolution
+ Debug|Any CPU = Debug|Any CPU
+ Release|Any CPU = Release|Any CPU
+ EndGlobalSection
+ GlobalSection(ProjectConfigurationPlatforms) = postSolution
+ {4E23A829-B9EF-4BDE-941A-D15B334C09AD}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
+ {4E23A829-B9EF-4BDE-941A-D15B334C09AD}.Debug|Any CPU.Build.0 = Debug|Any CPU
+ {4E23A829-B9EF-4BDE-941A-D15B334C09AD}.Release|Any CPU.ActiveCfg = Release|Any CPU
+ {4E23A829-B9EF-4BDE-941A-D15B334C09AD}.Release|Any CPU.Build.0 = Release|Any CPU
+ EndGlobalSection
+ GlobalSection(SolutionProperties) = preSolution
+ HideSolutionNode = FALSE
+ EndGlobalSection
+EndGlobal
@@ -0,0 +1,58 @@
+<?xml version="1.0" encoding="utf-8"?>
+<Project ToolsVersion="4.0" DefaultTargets="Build" xmlns="http://schemas.microsoft.com/developer/msbuild/2003">
+ <PropertyGroup>
+ <Configuration Condition=" '$(Configuration)' == '' ">Debug</Configuration>
+ <Platform Condition=" '$(Platform)' == '' ">AnyCPU</Platform>
+ <ProjectGuid>{4E23A829-B9EF-4BDE-941A-D15B334C09AD}</ProjectGuid>
+ <OutputType>Library</OutputType>
+ <NoStandardLibraries>false</NoStandardLibraries>
+ <AssemblyName>OpenWrap.Preloading</AssemblyName>
+ <TargetFrameworkVersion>v4.0</TargetFrameworkVersion>
+ <FileAlignment>512</FileAlignment>
+ </PropertyGroup>
+ <PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'Debug|AnyCPU' ">
+ <DebugSymbols>true</DebugSymbols>
+ <DebugType>full</DebugType>
+ <Optimize>false</Optimize>
+ <OutputPath>bin\Debug\</OutputPath>
+ <DefineConstants>DEBUG;TRACE</DefineConstants>
+ <ErrorReport>prompt</ErrorReport>
+ <WarningLevel>4</WarningLevel>
+ </PropertyGroup>
+ <PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'Release|AnyCPU' ">
+ <DebugType>pdbonly</DebugType>
+ <Optimize>true</Optimize>
+ <OutputPath>bin\Release\</OutputPath>
+ <DefineConstants>TRACE</DefineConstants>
+ <ErrorReport>prompt</ErrorReport>
+ <WarningLevel>4</WarningLevel>
+ </PropertyGroup>
+ <PropertyGroup>
+ <RootNamespace>OpenWrap</RootNamespace>
+ </PropertyGroup>
+ <ItemGroup>
+ <Reference Include="Microsoft.CSharp" />
+ <Reference Include="System" />
+ <Reference Include="System.Core" />
+ <Reference Include="System.Data" />
+ <Reference Include="System.Data.DataSetExtensions" />
+ <Reference Include="System.Xml" />
+ <Reference Include="System.Xml.Linq" />
+ </ItemGroup>
+ <ItemGroup>
+ <Compile Include="PackageManagement\PackageResolverVisitor.cs" />
+ <Compile Include="Preloading\INotifyDownload.cs" />
+ <Compile Include="Preloading\NotifyProgressWebClient.cs" />
+ <Compile Include="Preloading\Preloader.cs" />
+ <Compile Include="SemanticVersion.cs" />
+ <Compile Include="Preloading\TinySharpZip\ZipArchive.cs" />
+ <Compile Include="Preloading\TinySharpZip\ZipDirectoryEntry.cs" />
+ <Compile Include="Preloading\TinySharpZip\ZipEntry.cs" />
+ <Compile Include="Preloading\TinySharpZip\ZipFileEntry.cs" />
+ </ItemGroup>
+ <ItemGroup />
+ <Import Project="$(MSBuildToolsPath)\Microsoft.CSHARP.Targets" />
+ <ProjectExtensions>
+ <VisualStudio AllowExistingFolder="true" />
+ </ProjectExtensions>
+</Project>
@@ -0,0 +1,110 @@
+using System;
+using System.Collections.Generic;
+using System.Linq;
+
+namespace OpenWrap.PackageManagement.DependencyResolvers
+{
+ public class PackageResolverVisitor<T> where T : class
+ {
+ public PackageResolverVisitor(
+ IEnumerable<T> allPackages,
+ Func<T, IEnumerable<Func<T, bool?>>> dependencyReader,
+ Func<IEnumerable<T>, IEnumerable<T>> strategy,
+ IEnumerable<T> success = null,
+ IEnumerable<T> fail = null)
+ {
+ Strategy = strategy;
+ Packages = allPackages;
+ DependencyReader = dependencyReader;
+ SuccessfulPackages = CopyOrNew(success);
+ IncompatiblePackages = CopyOrNew(fail);
+ }
+
+ public Func<T, IEnumerable<Func<T, bool?>>> DependencyReader { get; set; }
+ public ICollection<T> IncompatiblePackages { get; set; }
+ public ICollection<T> SuccessfulPackages { get; set; }
+ protected IEnumerable<T> Packages { get; private set; }
+ protected Func<IEnumerable<T>, IEnumerable<T>> Strategy { get; private set; }
+
+
+ public virtual bool Visit(IEnumerable<Func<T, bool?>> dependencies)
+ {
+ return dependencies.All(info => VisitDependency(null, info));
+ }
+
+ protected virtual PackageResolverVisitor<T> CreateNestedResolver(IEnumerable<T> allPackages,
+ Func<T, IEnumerable<Func<T, bool?>>> dependencyReader,
+ Func<IEnumerable<T>, IEnumerable<T>> strategy,
+ ICollection<T> successfulPackages,
+ ICollection<T> incompatiblePackages)
+ {
+ return new PackageResolverVisitor<T>(allPackages, dependencyReader, strategy, successfulPackages, incompatiblePackages);
+ }
+
+ protected virtual void NestedPackageFail(PackageResolverVisitor<T> newResolver)
+ {
+ foreach (var package in newResolver.IncompatiblePackages)
+ IncompatiblePackages.Add(package);
+ }
+
+ protected virtual void NestedPackageSucceeds(PackageResolverVisitor<T> newResolver)
+ {
+ SuccessfulPackages = newResolver.SuccessfulPackages;
+ IncompatiblePackages = newResolver.IncompatiblePackages;
+ }
+
+ protected virtual bool VisitDependency(T package, Func<T, bool?> dependency)
+ {
+ var result = SuccessfulPackages.Select(dependency)
+ .FirstOrDefault(_ => _ != null);
+
+ if (result == true) return true;
+ if (result == false)
+ {
+ var incompatible = SuccessfulPackages.First(_ => dependency(_) == false);
+ IncompatiblePackages.Add(incompatible);
+ SuccessfulPackages.Remove(incompatible);
+ return false;
+ }
+
+ var matchingPackages =
+ Strategy(Packages
+ .Except(IncompatiblePackages)
+ .Where(_ => dependency(_) == true))
+ .ToList();
+
+ var b = VisitPackages(matchingPackages);
+ return b;
+ }
+
+
+ protected virtual bool VisitPackage(T package)
+ {
+ var newResolver = CreateNestedResolver(Packages, DependencyReader, Strategy, SuccessfulPackages, IncompatiblePackages);
+ newResolver.SuccessfulPackages.Add(package);
+ bool success;
+ if (newResolver.Visit(DependencyReader(package)))
+ {
+ NestedPackageSucceeds(newResolver);
+ success = true;
+ }
+ else
+ {
+ NestedPackageFail(newResolver);
+ success = false;
+ }
+
+ return success;
+ }
+
+ protected virtual bool VisitPackages(IEnumerable<T> matchingPackages)
+ {
+ return matchingPackages.Any(VisitPackage);
+ }
+
+ static List<T> CopyOrNew<T>(IEnumerable<T> collection)
+ {
+ return collection == null ? new List<T>() : new List<T>(collection);
+ }
+ }
+}
File renamed without changes.
@@ -20,8 +20,6 @@ static Preloader()
public static Action<Stream, string> Extractor { get; set; }
public static IEnumerable<string> GetPackageFolders(RemoteInstall remote, string projectPath, string systemRepositoryPath, params string[] packageNamesToLoad)
{
- var regex = new Regex(string.Format(@"^(?<name>{0})-(?<version>\d+(\.\d+(\.\d+(\.\d+)?)?)?)$", string.Join("|", packageNamesToLoad.ToArray())), RegexOptions.IgnoreCase);
-
IEnumerable<string> bootstrapPackagePaths = Enumerable.Empty<string>();
if (projectPath != null)
{
@@ -61,7 +59,11 @@ where Directory.Exists(assemblyPath)
static IEnumerable<string> GetFxVersions()
{
- if (Environment.Version.Major >= 4) yield return "bin-net40";
+ if (Environment.Version.Major >= 4)
+ {
+ yield return "bin-net45";
+ yield return "bin-net40";
+ }
yield return "bin-net35";
yield return "bin-net30";
yield return "bin-net20";
@@ -390,3 +392,6 @@ public static RemoteInstall FromServer(string uri, INotifyDownload notifier, str
}
}
}
+namespace OpenWrap.PackageManagement.Resolvers
+{
+}
Oops, something went wrong.

0 comments on commit 4630719

Please sign in to comment.