Skip to content

Commit

Permalink
updated FubuCore ref to clean up some trash, added the basic localiza…
Browse files Browse the repository at this point in the history
…tion support and bootstrapping
  • Loading branch information
jeremydmiller committed Nov 15, 2011
1 parent 3ba77bb commit 15aab95
Show file tree
Hide file tree
Showing 61 changed files with 632 additions and 180 deletions.
19 changes: 4 additions & 15 deletions src/Fubu/Fubu.csproj
Expand Up @@ -36,16 +36,16 @@
</PropertyGroup>
<ItemGroup>
<Reference Include="Bottles">
<HintPath>..\packages\Bottles.0.9.1.156\lib\Bottles.dll</HintPath>
<HintPath>..\packages\Bottles.0.9.1.137\lib\Bottles.dll</HintPath>
</Reference>
<Reference Include="Bottles.Deployers.Iis">
<HintPath>..\packages\Bottles.Deployers.IIS.0.9.1.156\lib\Bottles.Deployers.Iis.dll</HintPath>
<HintPath>..\packages\Bottles.Deployers.IIS.0.9.1.137\lib\Bottles.Deployers.Iis.dll</HintPath>
</Reference>
<Reference Include="Bottles.Deployment">
<HintPath>..\packages\Bottles.Deployment.0.9.1.156\lib\Bottles.Deployment.dll</HintPath>
<HintPath>..\packages\Bottles.Deployment.0.9.1.137\lib\Bottles.Deployment.dll</HintPath>
</Reference>
<Reference Include="FubuCore">
<HintPath>..\packages\FubuCore.0.9.2.96\lib\FubuCore.dll</HintPath>
<HintPath>..\packages\FubuCore.0.9.2.93\lib\FubuCore.dll</HintPath>
</Reference>
<Reference Include="HtmlTags, Version=1.0.0.0, Culture=neutral, processorArchitecture=MSIL">
<HintPath>..\packages\HtmlTags.1.0.0.23\lib\4.0\HtmlTags.dll</HintPath>
Expand Down Expand Up @@ -76,18 +76,10 @@
</Compile>
<Compile Include="CreateDeploymentCommand.cs" />
<Compile Include="IncludeWebContentCommand.cs" />
<Compile Include="IProcess.cs" />
<Compile Include="IProcessFactory.cs" />
<Compile Include="IKeywordReplacer.cs" />
<Compile Include="InstallPackageCommand.cs" />
<Compile Include="InstallPackageInput.cs" />
<Compile Include="KeywordReplacer.cs" />
<Compile Include="NewCommand.cs" />
<Compile Include="NewCommandInput.cs" />
<Compile Include="PackagesCommand.cs" />
<Compile Include="PackagesInput.cs" />
<Compile Include="ProcessFactory.cs" />
<Compile Include="ProcessWrapper.cs" />
<Compile Include="Program.cs" />
<Compile Include="Properties\AssemblyInfo.cs" />
<Compile Include="RestartCommand.cs" />
Expand All @@ -105,9 +97,6 @@
<ItemGroup>
<None Include="app.config" />
<None Include="packages.config" />
<None Include="fubu">
<CopyToOutputDirectory>PreserveNewest</CopyToOutputDirectory>
</None>
</ItemGroup>
<Import Project="$(MSBuildToolsPath)\Microsoft.CSharp.targets" />
<!-- To modify your build process, add your task inside one of the targets below and uncomment it.
Expand Down
8 changes: 4 additions & 4 deletions src/Fubu/packages.config
@@ -1,11 +1,11 @@
<?xml version="1.0" encoding="utf-8"?>
<packages>
<package id="Bottles" version="0.9.1.156" />
<package id="Bottles.Deployers.IIS" version="0.9.1.156" />
<package id="Bottles.Deployment" version="0.9.1.156" />
<package id="Bottles" version="0.9.1.137" />
<package id="Bottles.Deployers.IIS" version="0.9.1.137" />
<package id="Bottles.Deployment" version="0.9.1.137" />
<package id="CommonServiceLocator" version="1.0" />
<package id="DotNetZip" version="1.9.1.8" />
<package id="FubuCore" version="0.9.2.96" />
<package id="FubuCore" version="0.9.2.93" />
<package id="HtmlTags" version="1.0.0.23" />
<package id="structuremap" version="2.6.3" />
</packages>
2 changes: 1 addition & 1 deletion src/FubuKayak/FubuKayak.csproj
Expand Up @@ -36,7 +36,7 @@
</PropertyGroup>
<ItemGroup>
<Reference Include="FubuCore">
<HintPath>..\packages\FubuCore.0.9.2.96\lib\FubuCore.dll</HintPath>
<HintPath>..\packages\FubuCore.0.9.2.93\lib\FubuCore.dll</HintPath>
</Reference>
<Reference Include="Gate">
<HintPath>..\packages\Gate.0.1.4\lib\Gate.dll</HintPath>
Expand Down
2 changes: 1 addition & 1 deletion src/FubuKayak/packages.config
@@ -1,7 +1,7 @@
<?xml version="1.0" encoding="utf-8"?>
<packages>
<package id="CommonServiceLocator" version="1.0" />
<package id="FubuCore" version="0.9.2.96" />
<package id="FubuCore" version="0.9.2.93" />
<package id="Gate" version="0.1.4" />
<package id="Gate.Kayak" version="0.1.4" />
<package id="HtmlTags" version="1.0.0.23" />
Expand Down
21 changes: 9 additions & 12 deletions src/FubuMVC.Core/FubuMVC.Core.csproj
Expand Up @@ -23,8 +23,6 @@
<WarningLevel>4</WarningLevel>
<TreatWarningsAsErrors>false</TreatWarningsAsErrors>
<TargetFrameworkVersion>v4.0</TargetFrameworkVersion>
<NoWarn>1591,1570</NoWarn>
<DocumentationFile>bin\Debug\FubuMVC.Core.XML</DocumentationFile>
</PropertyGroup>
<PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'Release|AnyCPU' ">
<DebugType>pdbonly</DebugType>
Expand All @@ -37,16 +35,16 @@
</PropertyGroup>
<ItemGroup>
<Reference Include="Bottles">
<HintPath>..\packages\Bottles.0.9.1.156\lib\Bottles.dll</HintPath>
<HintPath>..\packages\Bottles.0.9.1.137\lib\Bottles.dll</HintPath>
</Reference>
<Reference Include="Bottles.Deployment">
<HintPath>..\packages\Bottles.Deployment.0.9.1.156\lib\Bottles.Deployment.dll</HintPath>
<HintPath>..\packages\Bottles.Deployment.0.9.1.137\lib\Bottles.Deployment.dll</HintPath>
</Reference>
<Reference Include="FubuCore">
<HintPath>..\packages\FubuCore.0.9.2.96\lib\FubuCore.dll</HintPath>
<HintPath>..\packages\FubuCore.0.9.2.93\lib\FubuCore.dll</HintPath>
</Reference>
<Reference Include="FubuLocalization">
<HintPath>..\packages\FubuLocalization.0.9.2.96\lib\FubuLocalization.dll</HintPath>
<HintPath>..\packages\FubuLocalization.0.9.2.85\lib\FubuLocalization.dll</HintPath>
</Reference>
<Reference Include="HtmlTags">
<HintPath>..\packages\HtmlTags.1.0.0.23\lib\4.0\HtmlTags.dll</HintPath>
Expand Down Expand Up @@ -91,10 +89,6 @@
<Compile Include="Assets\Caching\AssetFileWatchingActivator.cs" />
<Compile Include="Assets\Caching\IAssetFileChangeListener.cs" />
<Compile Include="Assets\Caching\IAssetFileWatcher.cs" />
<Compile Include="Assets\Diagnostics\AssetLog.cs" />
<Compile Include="Assets\Diagnostics\AssetLogEntry.cs" />
<Compile Include="Assets\Diagnostics\AssetLogsCache.cs" />
<Compile Include="Assets\Diagnostics\AssetRegistrationDiagnostics.cs" />
<Compile Include="Assets\Content\ITransformerPolicyLibrary.cs" />
<Compile Include="Assets\Content\IContentPlanCache.cs" />
<Compile Include="Assets\Http\AssetEtagInvocationFilter.cs" />
Expand Down Expand Up @@ -199,8 +193,7 @@
<Compile Include="Caching\SetContentType.cs" />
<Compile Include="Caching\WriteFileRecord.cs" />
<Compile Include="Caching\WriteStream.cs" />
<Compile Include="Caching\WriteTextOutput.cs" />
<Compile Include="Continuations\IRedirectable.cs" />
<Compile Include="Caching\WriteText.cs" />
<Compile Include="Diagnostics\Assets\BasicAssetDiagnostics.cs" />
<Compile Include="Http\AspNet\AspNetAggregateDictionary.cs" />
<Compile Include="Http\AspNet\AspNetHttpWriter.cs" />
Expand Down Expand Up @@ -231,6 +224,10 @@
<Compile Include="Http\RequestDataSource.cs" />
<Compile Include="Http\RequestHeaders.cs" />
<Compile Include="Http\StreamingDataExtensions.cs" />
<Compile Include="Localization\BasicLocalizationSupport.cs" />
<Compile Include="Localization\LabelBuilder.cs" />
<Compile Include="Localization\RegisterXmlDirectoryLocalizationStorage.cs" />
<Compile Include="Localization\SpinUpLocalizationCaches.cs" />
<Compile Include="Packaging\ContentOnlyPackageInfo.cs" />
<Compile Include="Registration\BehaviorAggregator.cs" />
<Compile Include="Registration\Conventions\ConnegAttachmentPolicy.cs" />
Expand Down
14 changes: 14 additions & 0 deletions src/FubuMVC.Core/FubuRegistry.Expressions.cs
Expand Up @@ -172,6 +172,20 @@ public void Import<T>() where T : IFubuRegistryExtension, new()
_importedTypes.Add(typeof(T));
}

/// <summary>
/// Imports the declarations of an IFubuRegistryExtension
/// </summary>
/// <typeparam name="T"></typeparam>
public void Import<T>(Action<T> configuration) where T : IFubuRegistryExtension, new()
{
var extension = new T();
configuration(extension);

extension.Configure(this);

_importedTypes.Add(typeof(T));
}

private readonly IList<Type> _importedTypes = new List<Type>();

/// <summary>
Expand Down
72 changes: 72 additions & 0 deletions src/FubuMVC.Core/Localization/BasicLocalizationSupport.cs
@@ -0,0 +1,72 @@
using System.Globalization;
using Bottles;
using FubuCore;
using FubuLocalization;
using FubuLocalization.Basic;
using FubuMVC.Core.Registration.ObjectGraph;

namespace FubuMVC.Core.Localization
{
public class BasicLocalizationSupport : IFubuRegistryExtension
{
private readonly FubuPackageRegistry _internalRegistry = new FubuPackageRegistry();
private bool _useTheDefaultStorageMechanism = true;
private ObjectDef _localizationLoader;

public BasicLocalizationSupport()
{
_internalRegistry.Services(x =>
{
x.SetServiceIfNone(new CultureInfo("en-US"));
x.SetServiceIfNone<ILocalizationCache, LocalizationCache>();
x.SetServiceIfNone<ILocalizationMissingHandler, LocalizationMissingHandler>();
x.SetServiceIfNone<ILocalizationProviderFactory, LocalizationProviderFactory>();
});

_internalRegistry.HtmlConvention(x => x.Labels.Builder<LabelBuilder>());

}

public CultureInfo DefaultCulture
{
set
{
_internalRegistry.Services(x => x.ReplaceService(value));
}
}

void IFubuRegistryExtension.Configure(FubuRegistry registry)
{
_internalRegistry.As<IFubuRegistryExtension>().Configure(registry);

registry.Services(x =>
{
if (_useTheDefaultStorageMechanism)
{
x.AddService<IActivator, RegisterXmlDirectoryLocalizationStorage>();
}
if (_localizationLoader != null)
{
x.AddService(typeof (IActivator), _localizationLoader);
}
x.AddService<IActivator, SpinUpLocalizationCaches>();
});


}

public void LoadLocalizationWith<T>() where T : IActivator
{
_localizationLoader = ObjectDef.ForType<T>();
_useTheDefaultStorageMechanism = false;
}

public void LocalizationStorageIs<T>() where T : ILocalizationStorage
{
_internalRegistry.Services(x => x.ReplaceService<ILocalizationStorage, T>());
_useTheDefaultStorageMechanism = false;
}
}
}
20 changes: 20 additions & 0 deletions src/FubuMVC.Core/Localization/LabelBuilder.cs
@@ -0,0 +1,20 @@
using FubuLocalization;
using FubuMVC.Core.UI.Configuration;
using HtmlTags;

namespace FubuMVC.Core.Localization
{
public class LabelBuilder : ElementBuilder
{
protected override bool matches(AccessorDef def)
{
return true;
}

public override HtmlTag Build(ElementRequest request)
{
string header = LocalizationManager.GetHeader(request.Accessor.InnerProperty);
return new HtmlTag("label").Attr("for", request.ElementId).Text(header);
}
}
}
@@ -0,0 +1,34 @@
using System.Collections.Generic;
using Bottles;
using Bottles.Diagnostics;
using FubuLocalization.Basic;
using FubuMVC.Core.Bootstrapping;
using FubuMVC.Core.Packaging;
using FubuMVC.Core.Registration.ObjectGraph;

namespace FubuMVC.Core.Localization
{
public class RegisterXmlDirectoryLocalizationStorage : IActivator
{
private readonly IContainerFacility _facility;

public RegisterXmlDirectoryLocalizationStorage(IContainerFacility facility)
{
_facility = facility;
}

public void Activate(IEnumerable<IPackageInfo> packages, IPackageLog log)
{
var list = new List<string>();
log.Trace("Setting up the {0} with directories", typeof(XmlDirectoryLocalizationStorage).Name);

list.Add(FubuMvcPackageFacility.GetApplicationPath());

packages.Each(pak => pak.ForFolder(BottleFiles.WebContentFolder, list.Add));

var storage = new XmlDirectoryLocalizationStorage(list);

_facility.Register(typeof(ILocalizationStorage), ObjectDef.ForValue(storage));
}
}
}
23 changes: 23 additions & 0 deletions src/FubuMVC.Core/Localization/SpinUpLocalizationCaches.cs
@@ -0,0 +1,23 @@
using System.Collections.Generic;
using Bottles;
using Bottles.Diagnostics;
using FubuLocalization.Basic;

namespace FubuMVC.Core.Localization
{
public class SpinUpLocalizationCaches : IActivator
{
private readonly ILocalizationProviderFactory _factory;

public SpinUpLocalizationCaches(ILocalizationProviderFactory factory)
{
_factory = factory;
}

public void Activate(IEnumerable<IPackageInfo> packages, IPackageLog log)
{
_factory.LoadAll(text => log.Trace(text));
_factory.ApplyToLocalizationManager();
}
}
}
8 changes: 4 additions & 4 deletions src/FubuMVC.Core/packages.config
@@ -1,11 +1,11 @@
<?xml version="1.0" encoding="utf-8"?>
<packages>
<package id="Bottles" version="0.9.1.156" />
<package id="Bottles.Deployment" version="0.9.1.156" />
<package id="Bottles" version="0.9.1.137" />
<package id="Bottles.Deployment" version="0.9.1.137" />
<package id="CommonServiceLocator" version="1.0" />
<package id="DotNetZip" version="1.9.1.8" />
<package id="FubuCore" version="0.9.2.96" />
<package id="FubuLocalization" version="0.9.2.96" />
<package id="FubuCore" version="0.9.2.93" />
<package id="FubuLocalization" version="0.9.2.85" />
<package id="HtmlTags" version="1.0.0.23" />
<package id="structuremap" version="2.6.3" />
</packages>
8 changes: 4 additions & 4 deletions src/FubuMVC.Deployers/FubuMVC.Deployers.csproj
Expand Up @@ -32,16 +32,16 @@
</PropertyGroup>
<ItemGroup>
<Reference Include="Bottles">
<HintPath>..\packages\Bottles.0.9.1.156\lib\Bottles.dll</HintPath>
<HintPath>..\packages\Bottles.0.9.1.137\lib\Bottles.dll</HintPath>
</Reference>
<Reference Include="Bottles.Deployers.Iis">
<HintPath>..\packages\Bottles.Deployers.IIS.0.9.1.156\lib\Bottles.Deployers.Iis.dll</HintPath>
<HintPath>..\packages\Bottles.Deployers.IIS.0.9.1.137\lib\Bottles.Deployers.Iis.dll</HintPath>
</Reference>
<Reference Include="Bottles.Deployment">
<HintPath>..\packages\Bottles.Deployment.0.9.1.156\lib\Bottles.Deployment.dll</HintPath>
<HintPath>..\packages\Bottles.Deployment.0.9.1.137\lib\Bottles.Deployment.dll</HintPath>
</Reference>
<Reference Include="FubuCore">
<HintPath>..\packages\FubuCore.0.9.2.96\lib\FubuCore.dll</HintPath>
<HintPath>..\packages\FubuCore.0.9.2.93\lib\FubuCore.dll</HintPath>
</Reference>
<Reference Include="HtmlTags">
<HintPath>..\packages\HtmlTags.1.0.0.23\lib\4.0\HtmlTags.dll</HintPath>
Expand Down
8 changes: 4 additions & 4 deletions src/FubuMVC.Deployers/packages.config
@@ -1,11 +1,11 @@
<?xml version="1.0" encoding="utf-8"?>
<packages>
<package id="Bottles" version="0.9.1.156" />
<package id="Bottles.Deployers.IIS" version="0.9.1.156" />
<package id="Bottles.Deployment" version="0.9.1.156" />
<package id="Bottles" version="0.9.1.137" />
<package id="Bottles.Deployers.IIS" version="0.9.1.137" />
<package id="Bottles.Deployment" version="0.9.1.137" />
<package id="CommonServiceLocator" version="1.0" />
<package id="DotNetZip" version="1.9.1.8" />
<package id="FubuCore" version="0.9.2.96" />
<package id="FubuCore" version="0.9.2.93" />
<package id="HtmlTags" version="1.0.0.23" />
<package id="structuremap" version="2.6.3" />
</packages>

0 comments on commit 15aab95

Please sign in to comment.