Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
269 changes: 269 additions & 0 deletions Common.Logging.2010-sl40.sln

Large diffs are not rendered by default.

80 changes: 80 additions & 0 deletions src/Common.Logging.Portable/Common.Logging.2010-portable.csproj
Original file line number Diff line number Diff line change
@@ -0,0 +1,80 @@
<?xml version="1.0" encoding="utf-8"?>
<Project ToolsVersion="4.0" DefaultTargets="Build" xmlns="http://schemas.microsoft.com/developer/msbuild/2003">
<Import Project="$(MSBuildExtensionsPath)\$(MSBuildToolsVersion)\Microsoft.Common.props" Condition="Exists('$(MSBuildExtensionsPath)\$(MSBuildToolsVersion)\Microsoft.Common.props')" />
<PropertyGroup>
<MinimumVisualStudioVersion>10.0</MinimumVisualStudioVersion>
<Configuration Condition=" '$(Configuration)' == '' ">Debug</Configuration>
<Platform Condition=" '$(Platform)' == '' ">AnyCPU</Platform>
<ProjectGuid>{34E2A46F-8D61-4AA8-9094-DF0D5035427E}</ProjectGuid>
<OutputType>Library</OutputType>
<AppDesignerFolder>Properties</AppDesignerFolder>
<RootNamespace>Common</RootNamespace>
<AssemblyName>Common.Logging</AssemblyName>
<TargetFrameworkVersion>v4.0</TargetFrameworkVersion>
<TargetFrameworkProfile>Profile1</TargetFrameworkProfile>
<FileAlignment>512</FileAlignment>
<ProjectTypeGuids>{786C830F-07A1-408B-BD7F-6EE04809D6DB};{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}</ProjectTypeGuids>
</PropertyGroup>
<PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'Debug|AnyCPU' ">
<DebugSymbols>true</DebugSymbols>
<DebugType>full</DebugType>
<Optimize>false</Optimize>
<OutputPath>..\..\build\portable\Common.Logging\Debug\</OutputPath>
<DefineConstants>TRACE;DEBUG;PORTABLE</DefineConstants>
<ErrorReport>prompt</ErrorReport>
<WarningLevel>4</WarningLevel>
</PropertyGroup>
<PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'Release|AnyCPU' ">
<DebugType>pdbonly</DebugType>
<Optimize>true</Optimize>
<OutputPath>..\..\build\portable\Common.Logging\Release\</OutputPath>
<DefineConstants>TRACE;PORTABLE</DefineConstants>
<ErrorReport>prompt</ErrorReport>
<WarningLevel>4</WarningLevel>
</PropertyGroup>
<ItemGroup>
<!-- A reference to the entire .NET Framework is automatically included -->
<Compile Include="..\CommonAssemblyInfo.cs">
<Link>CommonAssemblyInfo.cs</Link>
</Compile>
<Compile Include="..\Common.Logging\AssemblyDoc.cs" />
<Compile Include="..\Common.Logging\AssemblyInfo.cs" />
<Compile Include="..\Common.Logging\Collections\NameValueCollection.cs" />
<Compile Include="..\Common.Logging\CoverageExcludeAttribute.cs" />
<Compile Include="..\Common.Logging\Logging\ConfigurationException.cs" />
<Compile Include="..\Common.Logging\Logging\Configuration\ArgUtils.cs" />
<Compile Include="..\Common.Logging\Logging\Configuration\DefaultConfigurationReader.cs" />
<Compile Include="..\Common.Logging\Logging\Configuration\LogSetting.cs" />
<Compile Include="..\Common.Logging\Logging\Configuration\NamespaceDoc.cs" />
<Compile Include="..\Common.Logging\Logging\Factory\AbstractCachingLoggerFactoryAdapter.cs" />
<Compile Include="..\Common.Logging\Logging\Factory\AbstractLogger.cs" />
<Compile Include="..\Common.Logging\Logging\Factory\NamespaceDoc.cs" />
<Compile Include="..\Common.Logging\Logging\FormatMessageHandler.cs" />
<Compile Include="..\Common.Logging\Logging\IConfigurationReader.cs" />
<Compile Include="..\Common.Logging\Logging\ILog.cs" />
<Compile Include="..\Common.Logging\Logging\ILoggerFactoryAdapter.cs" />
<Compile Include="..\Common.Logging\Logging\LogLevel.cs" />
<Compile Include="..\Common.Logging\Logging\LogManager.cs" />
<Compile Include="..\Common.Logging\Logging\NamespaceDoc.cs" />
<Compile Include="..\Common.Logging\Logging\Simple\AbstractSimpleLogger.cs" />
<Compile Include="..\Common.Logging\Logging\Simple\AbstractSimpleLoggerFactoryAdapter.cs" />
<Compile Include="..\Common.Logging\Logging\Simple\CapturingLogger.cs" />
<Compile Include="..\Common.Logging\Logging\Simple\CapturingLoggerEvent.cs" />
<Compile Include="..\Common.Logging\Logging\Simple\CapturingLoggerFactoryAdapter.cs" />
<Compile Include="..\Common.Logging\Logging\Simple\NamespaceDoc.cs" />
<Compile Include="..\Common.Logging\Logging\Simple\NoOpLogger.cs" />
<Compile Include="..\Common.Logging\Logging\Simple\NoOpLoggerFactoryAdapter.cs" />
<Compile Include="..\Common.Logging\NamespaceDoc_Introduction.cs" />
</ItemGroup>
<ItemGroup>
<Folder Include="Properties\" />
</ItemGroup>
<Import Project="$(MSBuildExtensionsPath32)\Microsoft\Portable\$(TargetFrameworkVersion)\Microsoft.Portable.CSharp.targets" />
<!-- To modify your build process, add your task inside one of the targets below and uncomment it.
Other similar extension points exist, see Microsoft.Common.targets.
<Target Name="BeforeBuild">
</Target>
<Target Name="AfterBuild">
</Target>
-->
</Project>
112 changes: 112 additions & 0 deletions src/Common.Logging.Silverlight/Common.Logging.2010-sl40.csproj
Original file line number Diff line number Diff line change
@@ -0,0 +1,112 @@
<?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>
<ProductVersion>8.0.50727</ProductVersion>
<SchemaVersion>2.0</SchemaVersion>
<ProjectGuid>{C185F156-BEFC-44A0-8F25-065558AEDB6A}</ProjectGuid>
<ProjectTypeGuids>{A1591282-1198-4647-A2B1-27E5FF5F6F3B};{fae04ec0-301f-11d3-bf4b-00c04f79efbc}</ProjectTypeGuids>
<OutputType>Library</OutputType>
<AppDesignerFolder>Properties</AppDesignerFolder>
<RootNamespace>Common</RootNamespace>
<AssemblyName>Common.Logging</AssemblyName>
<TargetFrameworkIdentifier>Silverlight</TargetFrameworkIdentifier>
<TargetFrameworkVersion>v4.0</TargetFrameworkVersion>
<SilverlightVersion>$(TargetFrameworkVersion)</SilverlightVersion>
<SilverlightApplication>false</SilverlightApplication>
<ValidateXaml>true</ValidateXaml>
<ThrowErrorsInValidation>true</ThrowErrorsInValidation>
</PropertyGroup>
<!-- This property group is only here to support building this project using the
MSBuild 3.5 toolset. In order to work correctly with this older toolset, it needs
to set the TargetFrameworkVersion to v3.5 -->
<PropertyGroup Condition="'$(MSBuildToolsVersion)' == '3.5'">
<TargetFrameworkVersion>v3.5</TargetFrameworkVersion>
</PropertyGroup>
<PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'Debug|AnyCPU' ">
<DebugSymbols>true</DebugSymbols>
<DebugType>full</DebugType>
<Optimize>false</Optimize>
<OutputPath>..\..\build\sl40\Common.Logging\Debug\</OutputPath>
<DefineConstants>TRACE;DEBUG;SILVERLIGHT PORTABLE</DefineConstants>
<NoStdLib>true</NoStdLib>
<NoConfig>true</NoConfig>
<ErrorReport>prompt</ErrorReport>
<WarningLevel>4</WarningLevel>
<DocumentationFile>..\..\build\sl40\Common.Logging\Debug\Common.Logging.XML</DocumentationFile>
</PropertyGroup>
<PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'Release|AnyCPU' ">
<DebugType>pdbonly</DebugType>
<Optimize>true</Optimize>
<OutputPath>..\..\build\sl40\Common.Logging\Release\</OutputPath>
<DefineConstants>TRACE;SILVERLIGHT PORTABLE</DefineConstants>
<NoStdLib>true</NoStdLib>
<NoConfig>true</NoConfig>
<ErrorReport>prompt</ErrorReport>
<WarningLevel>4</WarningLevel>
<DocumentationFile>..\..\build\sl40\Common.Logging\Release\Common.Logging.XML</DocumentationFile>
</PropertyGroup>
<ItemGroup>
<Reference Include="mscorlib" />
<Reference Include="System.Windows" />
<Reference Include="system" />
<Reference Include="System.Core" />
<Reference Include="System.Xml" />
<Reference Include="System.Net" />
<Reference Include="System.Windows.Browser" />
</ItemGroup>
<ItemGroup>
<Compile Include="..\CommonAssemblyInfo.cs">
<Link>CommonAssemblyInfo.cs</Link>
</Compile>
<Compile Include="..\Common.Logging\AssemblyDoc.cs" />
<Compile Include="..\Common.Logging\AssemblyInfo.cs" />
<Compile Include="..\Common.Logging\Collections\NameValueCollection.cs" />
<Compile Include="..\Common.Logging\CoverageExcludeAttribute.cs" />
<Compile Include="..\Common.Logging\Logging\ConfigurationException.cs" />
<Compile Include="..\Common.Logging\Logging\Configuration\ArgUtils.cs" />
<Compile Include="..\Common.Logging\Logging\Configuration\DefaultConfigurationReader.cs" />
<Compile Include="..\Common.Logging\Logging\Configuration\LogSetting.cs" />
<Compile Include="..\Common.Logging\Logging\Configuration\NamespaceDoc.cs" />
<Compile Include="..\Common.Logging\Logging\Factory\AbstractCachingLoggerFactoryAdapter.cs" />
<Compile Include="..\Common.Logging\Logging\Factory\AbstractLogger.cs" />
<Compile Include="..\Common.Logging\Logging\Factory\NamespaceDoc.cs" />
<Compile Include="..\Common.Logging\Logging\FormatMessageHandler.cs" />
<Compile Include="..\Common.Logging\Logging\IConfigurationReader.cs" />
<Compile Include="..\Common.Logging\Logging\ILog.cs" />
<Compile Include="..\Common.Logging\Logging\ILoggerFactoryAdapter.cs" />
<Compile Include="..\Common.Logging\Logging\LogLevel.cs" />
<Compile Include="..\Common.Logging\Logging\LogManager.cs" />
<Compile Include="..\Common.Logging\Logging\NamespaceDoc.cs" />
<Compile Include="..\Common.Logging\Logging\Simple\AbstractSimpleLogger.cs" />
<Compile Include="..\Common.Logging\Logging\Simple\AbstractSimpleLoggerFactoryAdapter.cs" />
<Compile Include="..\Common.Logging\Logging\Simple\CapturingLogger.cs" />
<Compile Include="..\Common.Logging\Logging\Simple\CapturingLoggerEvent.cs" />
<Compile Include="..\Common.Logging\Logging\Simple\CapturingLoggerFactoryAdapter.cs" />
<Compile Include="..\Common.Logging\Logging\Simple\ConsoleOutLogger.cs" />
<Compile Include="..\Common.Logging\Logging\Simple\ConsoleOutLoggerFactoryAdapter.cs" />
<Compile Include="..\Common.Logging\Logging\Simple\NamespaceDoc.cs" />
<Compile Include="..\Common.Logging\Logging\Simple\NoOpLogger.cs" />
<Compile Include="..\Common.Logging\Logging\Simple\NoOpLoggerFactoryAdapter.cs" />
<Compile Include="..\Common.Logging\NamespaceDoc_Introduction.cs" />
</ItemGroup>
<ItemGroup>
<Folder Include="Properties\" />
</ItemGroup>
<Import Project="$(MSBuildExtensionsPath32)\Microsoft\Silverlight\$(SilverlightVersion)\Microsoft.Silverlight.CSharp.targets" />
<ProjectExtensions>
<VisualStudio>
<FlavorProperties GUID="{A1591282-1198-4647-A2B1-27E5FF5F6F3B}">
<SilverlightProjectProperties />
</FlavorProperties>
</VisualStudio>
</ProjectExtensions>
<!-- To modify your build process, add your task inside one of the targets below and uncomment it.
Other similar extension points exist, see Microsoft.Common.targets.
<Target Name="BeforeBuild">
</Target>
<Target Name="AfterBuild">
</Target>
-->
</Project>
25 changes: 25 additions & 0 deletions src/Common.Logging/Collections/NameValueCollection.cs
Original file line number Diff line number Diff line change
@@ -0,0 +1,25 @@
using System;
using System.Collections.Generic;

namespace Common.Logging
{
#if PORTABLE

/// <summary>
/// Substitute NameValueCollection in System.Collections.Specialized.
/// </summary>
public class NameValueCollection : Dictionary<string, string>
{
/// <summary>
/// Creates a new instance of <seealso cref="NameValueCollection">NameValueCollection</seealso>.
/// </summary>
public NameValueCollection()
: base(StringComparer.OrdinalIgnoreCase)
{

}
}

#else
#endif
}
2 changes: 1 addition & 1 deletion src/Common.Logging/Common.Logging.2010-net40.csproj
Original file line number Diff line number Diff line change
Expand Up @@ -55,7 +55,7 @@
<OutputPath>..\..\build\net40\Common.Logging\Release\</OutputPath>
<DefineConstants>TRACE;NET_4_0</DefineConstants>
<ErrorReport>prompt</ErrorReport>
<WarningLevel>4</WarningLevel>
<WarningLevel>3</WarningLevel>
<DocumentationFile>Common.Logging.xml</DocumentationFile>
<TreatWarningsAsErrors>true</TreatWarningsAsErrors>
<NoWarn>1607</NoWarn>
Expand Down
6 changes: 6 additions & 0 deletions src/Common.Logging/Common.Logging.nuspec
Original file line number Diff line number Diff line change
Expand Up @@ -17,5 +17,11 @@
<file src="..\..\build\net40\Common.Logging\Release\Common.Logging.dll" target="lib\net40" />
<file src="..\..\build\net40\Common.Logging\Release\Common.Logging.pdb" target="lib\net40" />
<file src="..\..\build\net40\Common.Logging\Release\Common.Logging.xml" target="lib\net40" />
<file src="..\..\build\sl40\Common.Logging\Release\Common.Logging.dll" target="lib\sl40" />
<file src="..\..\build\sl40\Common.Logging\Release\Common.Logging.pdb" target="lib\sl40" />
<file src="..\..\build\sl40\Common.Logging\Release\Common.Logging.xml" target="lib\sl40" />
<file src="..\..\build\portable\Common.Logging\Release\Common.Logging.dll" target="lib\portable-win+net40+sl40+wp+xbox" />
<file src="..\..\build\portable\Common.Logging\Release\Common.Logging.pdb" target="lib\portable-win+net40+sl40+wp+xbox" />
<file src="..\..\build\portable\Common.Logging\Release\Common.Logging.xml" target="lib\portable-win+net40+sl40+wp+xbox" />
</files>
</package>
46 changes: 32 additions & 14 deletions src/Common.Logging/Logging/Configuration/ArgUtils.cs
Original file line number Diff line number Diff line change
Expand Up @@ -19,9 +19,14 @@
#endregion

using System;
using System.Collections.Generic;
using System.Diagnostics;

#if PORTABLE
#else
using System.Collections;
using System.Collections.Specialized;
using System.Diagnostics;
#endif

namespace Common.Logging.Configuration
{
Expand All @@ -36,21 +41,21 @@ public static class ArgUtils
/// </summary>
public delegate T ParseHandler<T>(string strValue);

private static readonly Hashtable s_parsers;
private static readonly Dictionary<Type, object> s_parsers;

/// <summary>
/// Initialize all members before any of this class' methods can be accessed (avoids beforeFieldInit)
/// </summary>
static ArgUtils()
{
s_parsers = new Hashtable();
RegisterTypeParser<bool>(delegate(string s) { return Convert.ToBoolean(s); });
RegisterTypeParser<short>(delegate(string s) { return Convert.ToInt16(s); });
RegisterTypeParser<int>(delegate(string s) { return Convert.ToInt32(s); });
RegisterTypeParser<long>(delegate(string s) { return Convert.ToInt64(s); });
RegisterTypeParser<float>(delegate(string s) { return Convert.ToSingle(s); });
RegisterTypeParser<double>(delegate(string s) { return Convert.ToDouble(s); });
RegisterTypeParser<decimal>(delegate(string s) { return Convert.ToDecimal(s); });
s_parsers = new Dictionary<Type, object>();
RegisterTypeParser(Convert.ToBoolean);
RegisterTypeParser(Convert.ToInt16);
RegisterTypeParser(Convert.ToInt32);
RegisterTypeParser(Convert.ToInt64);
RegisterTypeParser(Convert.ToSingle);
RegisterTypeParser(Convert.ToDouble);
RegisterTypeParser(Convert.ToDecimal);
}

/// <summary>
Expand Down Expand Up @@ -86,9 +91,9 @@ public static string GetValue(NameValueCollection values, string name, string de
{
if (values != null)
{
foreach (string key in values.AllKeys)
foreach (string key in values.Keys)
{
if (string.Compare(name, key, true) == 0)
if (string.Compare(name, key, StringComparison.OrdinalIgnoreCase) == 0)
{
return values[name];
}
Expand Down Expand Up @@ -162,7 +167,11 @@ public static T TryParseEnum<T>(T defaultValue, string stringValue) where T : st
}
catch
{
#if PORTABLE
Debug.WriteLine(string.Format("WARN: failed converting value '{0}' to enum type '{1}'", stringValue, defaultValue.GetType().FullName));
#else
Trace.WriteLine(string.Format("WARN: failed converting value '{0}' to enum type '{1}'", stringValue, defaultValue.GetType().FullName));
#endif
}
return result;
}
Expand All @@ -181,19 +190,24 @@ public static T TryParse<T>(T defaultValue, string stringValue)
return defaultValue;
}

ParseHandler<T> parser = s_parsers[typeof(T)] as ParseHandler<T>;
if (parser == null)
object untypedParser;
if (!s_parsers.TryGetValue(typeof(T), out untypedParser) || !(untypedParser is ParseHandler<T>))
{
throw new ArgumentException(string.Format("There is no parser registered for type {0}", typeof(T).FullName));
}

var parser = (ParseHandler<T>)untypedParser;
try
{
result = parser(stringValue);
}
catch
{
#if PORTABLE
Debug.WriteLine(string.Format("WARN: failed converting value '{0}' to type '{1}' - returning default '{2}'", stringValue, typeof(T).FullName, result));
#else
Trace.WriteLine(string.Format("WARN: failed converting value '{0}' to type '{1}' - returning default '{2}'", stringValue, typeof(T).FullName, result));
#endif
}
return result;
}
Expand Down Expand Up @@ -250,7 +264,11 @@ public static Type AssertIsAssignable<T>(string paramName, Type valType, string

if (!typeof(T).IsAssignableFrom(valType))
{
#if PORTABLE
throw new ArgumentOutOfRangeException(paramName, string.Format(messageFormat, args));
#else
throw new ArgumentOutOfRangeException(paramName, valType, string.Format(messageFormat, args));
#endif
}
return valType;
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -18,8 +18,11 @@

#endregion

#if PORTABLE
#else
using System.Collections.Specialized;
using System.Configuration;
#endif

namespace Common.Logging.Configuration
{
Expand Down Expand Up @@ -47,7 +50,11 @@ public class DefaultConfigurationReader : IConfigurationReader
/// <see cref="ConfigurationSectionHandler"/>
public object GetSection(string sectionName)
{
#if PORTABLE
return null;
#else
return ConfigurationManager.GetSection(sectionName);
#endif
}
}
}
3 changes: 3 additions & 0 deletions src/Common.Logging/Logging/Configuration/LogSetting.cs
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,10 @@
#endregion

using System;
#if PORTABLE
#else
using System.Collections.Specialized;
#endif

namespace Common.Logging.Configuration
{
Expand Down
Loading