From: <jer...@us...> - 2009-12-26 18:39:48
|
Revision: 300 http://structuremap.svn.sourceforge.net/structuremap/?rev=300&view=rev Author: jeremydmiller Date: 2009-12-26 18:39:40 +0000 (Sat, 26 Dec 2009) Log Message: ----------- code cleanup Modified Paths: -------------- trunk/Source/StructureMap/Configuration/ConfigurationParser.cs trunk/Source/StructureMap/Configuration/ConfigurationParserBuilder.cs trunk/Source/StructureMap/Configuration/DictionaryReader.cs trunk/Source/StructureMap/Configuration/FamilyParser.cs trunk/Source/StructureMap/Configuration/PrimitiveArrayReader.cs trunk/Source/StructureMap/Configuration/XmlExtensions.cs trunk/Source/StructureMap/Construction/BuilderCompiler.cs trunk/Source/StructureMap/Construction/ConstructorFunctionBuilder.cs trunk/Source/StructureMap/Construction/SetterBuilder.cs trunk/Source/StructureMap/Diagnostics/BuildError.cs trunk/Source/StructureMap/Diagnostics/CharacterWidth.cs trunk/Source/StructureMap/Diagnostics/DoctorRunner.cs trunk/Source/StructureMap/Diagnostics/Error.cs trunk/Source/StructureMap/Diagnostics/ValidationBuildSession.cs trunk/Source/StructureMap/Diagnostics/ValidationError.cs trunk/Source/StructureMap/Diagnostics/WhatDoIHaveWriter.cs trunk/Source/StructureMap/Example.cs trunk/Source/StructureMap/Exceptions/InstancePropertyValueException.cs trunk/Source/StructureMap/Exceptions/MissingPluginFamilyException.cs trunk/Source/StructureMap/Exceptions/StructureMapConfigurationException.cs trunk/Source/StructureMap/Graph/AssemblyScanner.cs trunk/Source/StructureMap/Graph/ImplementationMap.cs trunk/Source/StructureMap/Graph/PluginFamilyCollection.cs trunk/Source/StructureMap/Graph/PluginGraph.cs trunk/Source/StructureMap/Interceptors/CompoundInterceptor.cs trunk/Source/StructureMap/Interceptors/Interceptors.cs trunk/Source/StructureMap/Interceptors/MatchedTypeInterceptor.cs trunk/Source/StructureMap/Pipeline/ConfiguredInstanceBase.cs trunk/Source/StructureMap/Pipeline/HttpContextLifecycle.cs trunk/Source/StructureMap/Pipeline/HybridSessionLifecycle.cs trunk/Source/StructureMap/Pipeline/InstanceKey.cs trunk/Source/StructureMap/Pipeline/Lifecycles.cs trunk/Source/StructureMap/Pipeline/MainObjectCache.cs trunk/Source/StructureMap/Pipeline/SessionWrapper.cs trunk/Source/StructureMap/Pipeline/UniquePerRequestLifecycle.cs trunk/Source/StructureMap/Pipeline/UserControlInstance.cs trunk/Source/StructureMap/Source/BasicXmlMementoSource.cs trunk/Source/StructureMap/Source/MemoryMementoSource.cs trunk/Source/StructureMap/SystemRegistry.cs trunk/Source/StructureMap/TypeExtensions.cs Modified: trunk/Source/StructureMap/Configuration/ConfigurationParser.cs =================================================================== --- trunk/Source/StructureMap/Configuration/ConfigurationParser.cs 2009-12-26 18:26:08 UTC (rev 299) +++ trunk/Source/StructureMap/Configuration/ConfigurationParser.cs 2009-12-26 18:39:40 UTC (rev 300) @@ -62,16 +62,12 @@ } - public string FilePath - { - get { return _filePath; } - set { _filePath = value; } - } + public string FilePath { get { return _filePath; } set { _filePath = value; } } public void ForEachFile(GraphLog log, Action<string> action) { string includePath = getIncludePath(); - + // Find the text in every child node of _structureMapNode and // perform an action with that text _structureMapNode.ForTextInChild("Include/@File").Do(fileName => Modified: trunk/Source/StructureMap/Configuration/ConfigurationParserBuilder.cs =================================================================== --- trunk/Source/StructureMap/Configuration/ConfigurationParserBuilder.cs 2009-12-26 18:26:08 UTC (rev 299) +++ trunk/Source/StructureMap/Configuration/ConfigurationParserBuilder.cs 2009-12-26 18:39:40 UTC (rev 300) @@ -17,6 +17,11 @@ public class ConfigurationParserBuilder : IConfigurationParserBuilder { + /// <summary> + /// The name of the default configuration file. The value is always <c>StructurMap.config</c> + /// </summary> + public static readonly string DefaultConfigurationFilename = "StructureMap.config"; + private readonly GraphLog _log; private readonly List<string> _otherFiles = new List<string>(); private readonly List<ConfigurationParser> _parsers = new List<ConfigurationParser>(); @@ -32,24 +37,12 @@ #region IConfigurationParserBuilder Members - public bool UseAndEnforceExistenceOfDefaultFile - { - get { return _useAndEnforceExistenceOfDefaultFile; } - set { _useAndEnforceExistenceOfDefaultFile = value; } - } + public bool UseAndEnforceExistenceOfDefaultFile { get { return _useAndEnforceExistenceOfDefaultFile; } set { _useAndEnforceExistenceOfDefaultFile = value; } } - public bool IgnoreDefaultFile - { - get { return _ignoreDefaultFile; } - set { _ignoreDefaultFile = value; } - } + public bool IgnoreDefaultFile { get { return _ignoreDefaultFile; } set { _ignoreDefaultFile = value; } } - public bool PullConfigurationFromAppConfig - { - get { return _pullConfigurationFromAppConfig; } - set { _pullConfigurationFromAppConfig = value; } - } + public bool PullConfigurationFromAppConfig { get { return _pullConfigurationFromAppConfig; } set { _pullConfigurationFromAppConfig = value; } } public void IncludeFile(string filename) { @@ -91,7 +84,7 @@ ConfigurationParser childParser = ConfigurationParser.FromFile(filename); list.Add(childParser); }) - .AndReportErrorAs(150, filename)); + .AndReportErrorAs(150, filename)); } } @@ -114,7 +107,7 @@ { foreach (string filename in _otherFiles) { - var absolutePath = locateFileAsAbsolutePath(filename); + string absolutePath = locateFileAsAbsolutePath(filename); _log.Try(() => { ConfigurationParser parser = ConfigurationParser.FromFile(absolutePath); @@ -128,7 +121,7 @@ { if (_ignoreDefaultFile) return; // Pick up the configuration in the default StructureMap.config - var pathToStructureMapConfig = GetStructureMapConfigurationPath(); + string pathToStructureMapConfig = GetStructureMapConfigurationPath(); if ((_useAndEnforceExistenceOfDefaultFile || File.Exists(pathToStructureMapConfig))) { _log.Try(() => @@ -150,11 +143,6 @@ } /// <summary> - /// The name of the default configuration file. The value is always <c>StructurMap.config</c> - /// </summary> - public static readonly string DefaultConfigurationFilename = "StructureMap.config"; - - /// <summary> /// Returns the absolute path to the StructureMap.config file /// </summary> /// <returns></returns> @@ -166,8 +154,8 @@ private static string locateFileAsAbsolutePath(string filename) { if (Path.IsPathRooted(filename)) return filename; - var basePath = AppDomain.CurrentDomain.SetupInformation.ApplicationBase; - var configPath = Path.Combine(basePath, filename); + string basePath = AppDomain.CurrentDomain.SetupInformation.ApplicationBase; + string configPath = Path.Combine(basePath, filename); if (!File.Exists(configPath)) { Modified: trunk/Source/StructureMap/Configuration/DictionaryReader.cs =================================================================== --- trunk/Source/StructureMap/Configuration/DictionaryReader.cs 2009-12-26 18:26:08 UTC (rev 299) +++ trunk/Source/StructureMap/Configuration/DictionaryReader.cs 2009-12-26 18:39:40 UTC (rev 300) @@ -63,10 +63,7 @@ _dictionary.Add(key, theValue); } - public object Object - { - get { return _dictionary; } - } + public object Object { get { return _dictionary; } } #endregion } @@ -96,10 +93,7 @@ _collection.Add(name, value); } - public object Object - { - get { return _collection; } - } + public object Object { get { return _collection; } } #endregion } Modified: trunk/Source/StructureMap/Configuration/FamilyParser.cs =================================================================== --- trunk/Source/StructureMap/Configuration/FamilyParser.cs 2009-12-26 18:26:08 UTC (rev 299) +++ trunk/Source/StructureMap/Configuration/FamilyParser.cs 2009-12-26 18:39:40 UTC (rev 300) @@ -121,7 +121,8 @@ private void attachInterceptors(PluginFamily family, XmlElement familyElement) { - string contextBase = string.Format("creating an InstanceInterceptor for {0}\n", family.PluginType.AssemblyQualifiedName); + string contextBase = string.Format("creating an InstanceInterceptor for {0}\n", + family.PluginType.AssemblyQualifiedName); familyElement.ForEachChild("*/Interceptor").Do(element => { var interceptorMemento = new XmlAttributeInstanceMemento(element); Modified: trunk/Source/StructureMap/Configuration/PrimitiveArrayReader.cs =================================================================== --- trunk/Source/StructureMap/Configuration/PrimitiveArrayReader.cs 2009-12-26 18:26:08 UTC (rev 299) +++ trunk/Source/StructureMap/Configuration/PrimitiveArrayReader.cs 2009-12-26 18:39:40 UTC (rev 300) @@ -1,6 +1,5 @@ using System; using System.Xml; -using StructureMap.Graph; using StructureMap.Pipeline; using StructureMap.TypeRules; Modified: trunk/Source/StructureMap/Configuration/XmlExtensions.cs =================================================================== --- trunk/Source/StructureMap/Configuration/XmlExtensions.cs 2009-12-26 18:26:08 UTC (rev 299) +++ trunk/Source/StructureMap/Configuration/XmlExtensions.cs 2009-12-26 18:39:40 UTC (rev 300) @@ -16,26 +16,6 @@ return new XmlTextExpression(node, xpath); } - public class XmlTextExpression - { - private readonly XmlNodeList _list; - - internal XmlTextExpression(XmlNode parent, string attributePath) - { - _list = parent.SelectNodes(attributePath); - } - - public void Do(Action<string> action) - { - if (_list == null) return; - - foreach (XmlNode node in _list) - { - action(node.InnerText); - } - } - } - public static XmlNodeExpression ForEachChild(this XmlNode node, string xpath) { return new XmlNodeExpression(node, xpath); @@ -113,8 +93,26 @@ #region Nested type: XmlTextExpression + public class XmlTextExpression + { + private readonly XmlNodeList _list; + internal XmlTextExpression(XmlNode parent, string attributePath) + { + _list = parent.SelectNodes(attributePath); + } + public void Do(Action<string> action) + { + if (_list == null) return; + + foreach (XmlNode node in _list) + { + action(node.InnerText); + } + } + } + #endregion } } \ No newline at end of file Modified: trunk/Source/StructureMap/Construction/BuilderCompiler.cs =================================================================== --- trunk/Source/StructureMap/Construction/BuilderCompiler.cs 2009-12-26 18:26:08 UTC (rev 299) +++ trunk/Source/StructureMap/Construction/BuilderCompiler.cs 2009-12-26 18:39:40 UTC (rev 300) @@ -21,8 +21,8 @@ private static FuncCompiler getCompiler(Plugin plugin) { - var compilerType = typeof (FuncCompiler<>).MakeGenericType(plugin.PluggedType); - return (FuncCompiler)Activator.CreateInstance(compilerType); + Type compilerType = typeof (FuncCompiler<>).MakeGenericType(plugin.PluggedType); + return (FuncCompiler) Activator.CreateInstance(compilerType); } public static Action<IArguments, object> CompileBuildUp(Plugin plugin) @@ -32,6 +32,8 @@ return compiler.BuildUp(plugin); } + #region Nested type: FuncCompiler + public interface FuncCompiler { Func<IArguments, object> Compile(Plugin plugin); @@ -46,12 +48,12 @@ public InstanceBuilder CreateBuilder(Plugin plugin) { - var ctor = new ConstructorFunctionBuilder<T>().CreateBuilder(plugin); - var setters = this.buildUp(plugin); + Func<IArguments, T> ctor = new ConstructorFunctionBuilder<T>().CreateBuilder(plugin); + Action<IArguments, T> setters = buildUp(plugin); Func<IArguments, object> creator = args => { - var target = ctor(args); + T target = ctor(args); setters(args, target); return target; }; @@ -63,27 +65,33 @@ public Func<IArguments, object> Compile(Plugin plugin) { - var ctor = new ConstructorFunctionBuilder<T>().CreateBuilder(plugin); - var buildUp = this.buildUp(plugin); + Func<IArguments, T> ctor = new ConstructorFunctionBuilder<T>().CreateBuilder(plugin); + Action<IArguments, T> buildUp = this.buildUp(plugin); return args => { // Call the constructor - var target = ctor(args); + T target = ctor(args); buildUp(args, target); return target; }; } + public Action<IArguments, object> BuildUp(Plugin plugin) + { + Action<IArguments, T> func = buildUp(plugin); + return (args, raw) => func(args, (T) raw); + } + private Action<IArguments, T> buildUp(Plugin plugin) { - var mandatories = plugin.Setters.Where(x => x.IsMandatory) - .Select(x => _setterBuilder.BuildMandatorySetter((PropertyInfo)x.Property)) + Action<IArguments, T>[] mandatories = plugin.Setters.Where(x => x.IsMandatory) + .Select(x => _setterBuilder.BuildMandatorySetter((PropertyInfo) x.Property)) .ToArray(); - var optionals = plugin.Setters.Where(x => !x.IsMandatory) + Action<IArguments, T>[] optionals = plugin.Setters.Where(x => !x.IsMandatory) .Select(x => _setterBuilder.BuildOptionalSetter(x.Property)) .ToArray(); @@ -102,12 +110,8 @@ } }; } + } - public Action<IArguments, object> BuildUp(Plugin plugin) - { - var func = buildUp(plugin); - return (args, raw) => func(args, (T)raw); - } - } + #endregion } } \ No newline at end of file Modified: trunk/Source/StructureMap/Construction/ConstructorFunctionBuilder.cs =================================================================== --- trunk/Source/StructureMap/Construction/ConstructorFunctionBuilder.cs 2009-12-26 18:26:08 UTC (rev 299) +++ trunk/Source/StructureMap/Construction/ConstructorFunctionBuilder.cs 2009-12-26 18:39:40 UTC (rev 300) @@ -1,4 +1,5 @@ using System; +using System.Collections.Generic; using System.Linq; using System.Linq.Expressions; using System.Reflection; @@ -18,20 +19,22 @@ { ConstructorInfo constructor = plugin.GetConstructor(); - var args = Expression.Parameter(typeof (IArguments), "x"); + ParameterExpression args = Expression.Parameter(typeof (IArguments), "x"); - - var arguments = constructor.GetParameters().Select(param => ToParameterValueGetter(args, param.ParameterType, param.Name)); - var ctorCall = Expression.New(constructor, arguments); + IEnumerable<Expression> arguments = + constructor.GetParameters().Select( + param => ToParameterValueGetter(args, param.ParameterType, param.Name)); - var lambda = Expression.Lambda(typeof (Func<IArguments, T>), ctorCall, args); + NewExpression ctorCall = Expression.New(constructor, arguments); + + LambdaExpression lambda = Expression.Lambda(typeof (Func<IArguments, T>), ctorCall, args); return (Func<IArguments, T>) lambda.Compile(); } public static Expression ToParameterValueGetter(ParameterExpression args, Type type, string argName) { - MethodInfo method = typeof(IArguments).GetMethod("Get").MakeGenericMethod(type); + MethodInfo method = typeof (IArguments).GetMethod("Get").MakeGenericMethod(type); return Expression.Call(args, method, Expression.Constant(argName)); } } Modified: trunk/Source/StructureMap/Construction/SetterBuilder.cs =================================================================== --- trunk/Source/StructureMap/Construction/SetterBuilder.cs 2009-12-26 18:26:08 UTC (rev 299) +++ trunk/Source/StructureMap/Construction/SetterBuilder.cs 2009-12-26 18:39:40 UTC (rev 300) @@ -14,33 +14,31 @@ public Action<IArguments, T> BuildMandatorySetter(PropertyInfo property) { - var args = Expression.Parameter(typeof (IArguments), "args"); - var target = Expression.Parameter(typeof (T), "target"); + ParameterExpression args = Expression.Parameter(typeof (IArguments), "args"); + ParameterExpression target = Expression.Parameter(typeof (T), "target"); - var getValue = ConstructorFunctionBuilder<T>.ToParameterValueGetter(args, property.PropertyType, property.Name); - var method = property.GetSetMethod(); + Expression getValue = ConstructorFunctionBuilder<T>.ToParameterValueGetter(args, property.PropertyType, + property.Name); + MethodInfo method = property.GetSetMethod(); - var callSetMethod = Expression.Call(target, method, getValue); + MethodCallExpression callSetMethod = Expression.Call(target, method, getValue); - var lambda = Expression.Lambda(typeof (Action<IArguments, T>), callSetMethod, args, target); + LambdaExpression lambda = Expression.Lambda(typeof (Action<IArguments, T>), callSetMethod, args, target); return (Action<IArguments, T>) lambda.Compile(); } public Action<IArguments, T> BuildOptionalSetter(PropertyInfo property) { - var name = property.Name; - var func = BuildMandatorySetter(property); - return (args, target) => - { - if (args.Has(name)) func(args, target); - }; + string name = property.Name; + Action<IArguments, T> func = BuildMandatorySetter(property); + return (args, target) => { if (args.Has(name)) func(args, target); }; } public Action<IArguments, T> BuildOptionalSetter(string propertyName) { - PropertyInfo property = typeof(T).GetProperty(propertyName); + PropertyInfo property = typeof (T).GetProperty(propertyName); return BuildOptionalSetter(property); } } Modified: trunk/Source/StructureMap/Diagnostics/BuildError.cs =================================================================== --- trunk/Source/StructureMap/Diagnostics/BuildError.cs 2009-12-26 18:26:08 UTC (rev 299) +++ trunk/Source/StructureMap/Diagnostics/BuildError.cs 2009-12-26 18:39:40 UTC (rev 300) @@ -52,20 +52,11 @@ _pluginType = pluginType; } - public List<BuildDependency> Dependencies - { - get { return _dependencies; } - } + public List<BuildDependency> Dependencies { get { return _dependencies; } } - public Instance Instance - { - get { return _instance; } - } + public Instance Instance { get { return _instance; } } - public Type PluginType - { - get { return _pluginType; } - } + public Type PluginType { get { return _pluginType; } } public StructureMapException Exception { get; set; } Modified: trunk/Source/StructureMap/Diagnostics/CharacterWidth.cs =================================================================== --- trunk/Source/StructureMap/Diagnostics/CharacterWidth.cs 2009-12-26 18:26:08 UTC (rev 299) +++ trunk/Source/StructureMap/Diagnostics/CharacterWidth.cs 2009-12-26 18:39:40 UTC (rev 300) @@ -4,10 +4,7 @@ { private int _width; - internal int Width - { - get { return _width; } - } + internal int Width { get { return _width; } } internal static CharacterWidth[] For(int count) { Modified: trunk/Source/StructureMap/Diagnostics/DoctorRunner.cs =================================================================== --- trunk/Source/StructureMap/Diagnostics/DoctorRunner.cs 2009-12-26 18:26:08 UTC (rev 299) +++ trunk/Source/StructureMap/Diagnostics/DoctorRunner.cs 2009-12-26 18:39:40 UTC (rev 300) @@ -13,7 +13,10 @@ public DoctorReport RunReport(string bootstrapperTypeName) { - var report = new DoctorReport {Result = DoctorResult.Success}; + var report = new DoctorReport + { + Result = DoctorResult.Success + }; IBootstrapper bootstrapper; Modified: trunk/Source/StructureMap/Diagnostics/Error.cs =================================================================== --- trunk/Source/StructureMap/Diagnostics/Error.cs 2009-12-26 18:26:08 UTC (rev 299) +++ trunk/Source/StructureMap/Diagnostics/Error.cs 2009-12-26 18:39:40 UTC (rev 300) @@ -24,7 +24,8 @@ _message = ErrorMessages.GetMessage(errorCode, args); } - public Error(int errorCode, Exception ex, params object[] args) : this(errorCode, args) + public Error(int errorCode, Exception ex, params object[] args) + : this(errorCode, args) { _message += "\n\n" + ex.Message; @@ -41,10 +42,7 @@ } - public int Code - { - get { return _code; } - } + public int Code { get { return _code; } } #region IEquatable<Error> Members Modified: trunk/Source/StructureMap/Diagnostics/ValidationBuildSession.cs =================================================================== --- trunk/Source/StructureMap/Diagnostics/ValidationBuildSession.cs 2009-12-26 18:26:08 UTC (rev 299) +++ trunk/Source/StructureMap/Diagnostics/ValidationBuildSession.cs 2009-12-26 18:39:40 UTC (rev 300) @@ -21,25 +21,17 @@ { } - public ValidationBuildSession(PluginGraph graph) : base(graph) + public ValidationBuildSession(PluginGraph graph) + : base(graph) { } - public bool Success - { - get { return _errors.BuildErrors.Length == 0 && _validationErrors.Count == 0; } - } + public bool Success { get { return _errors.BuildErrors.Length == 0 && _validationErrors.Count == 0; } } - public BuildError[] BuildErrors - { - get { return _errors.BuildErrors; } - } + public BuildError[] BuildErrors { get { return _errors.BuildErrors; } } - public ValidationError[] ValidationErrors - { - get { return _validationErrors.ToArray(); } - } + public ValidationError[] ValidationErrors { get { return _validationErrors.ToArray(); } } public override object CreateInstance(Type pluginType, Instance instance) { @@ -133,7 +125,6 @@ writer.WriteLine(); - writer.WriteLine("StructureMap Failures: {0} Build/Configuration Failures and {1} Validation Errors", _errors.BuildErrors.Length, _validationErrors.Count); Modified: trunk/Source/StructureMap/Diagnostics/ValidationError.cs =================================================================== --- trunk/Source/StructureMap/Diagnostics/ValidationError.cs 2009-12-26 18:26:08 UTC (rev 299) +++ trunk/Source/StructureMap/Diagnostics/ValidationError.cs 2009-12-26 18:39:40 UTC (rev 300) @@ -1,7 +1,6 @@ using System; using System.IO; using System.Reflection; -using StructureMap.Graph; using StructureMap.Pipeline; namespace StructureMap.Diagnostics Modified: trunk/Source/StructureMap/Diagnostics/WhatDoIHaveWriter.cs =================================================================== --- trunk/Source/StructureMap/Diagnostics/WhatDoIHaveWriter.cs 2009-12-26 18:26:08 UTC (rev 299) +++ trunk/Source/StructureMap/Diagnostics/WhatDoIHaveWriter.cs 2009-12-26 18:39:40 UTC (rev 300) @@ -67,11 +67,11 @@ { _writer.AddDivider('-'); var contents = new[] - { - "{0} ({1})".ToFormat(pluginType.PluginType.GetName(), pluginType.PluginType.GetFullName()), - string.Empty, - string.Empty - }; + { + "{0} ({1})".ToFormat(pluginType.PluginType.GetName(), pluginType.PluginType.GetFullName()), + string.Empty, + string.Empty + }; if (pluginType.Default != null) { Modified: trunk/Source/StructureMap/Example.cs =================================================================== --- trunk/Source/StructureMap/Example.cs 2009-12-26 18:26:08 UTC (rev 299) +++ trunk/Source/StructureMap/Example.cs 2009-12-26 18:39:40 UTC (rev 300) @@ -1,5 +1,3 @@ -using System; - namespace StructureMap { public interface IMessageSender @@ -21,10 +19,12 @@ return new SendExpression(text, _messageSender); } + #region Nested type: SendExpression + public class SendExpression : ToExpression { + private readonly IMessageSender _messageSender; private readonly string _text; - private readonly IMessageSender _messageSender; private string _sender; public SendExpression(string text, IMessageSender messageSender) @@ -33,22 +33,28 @@ _messageSender = messageSender; } + void ToExpression.To(string receiver) + { + _messageSender.SendMessage(_text, _sender, receiver); + } + public ToExpression From(string sender) { _sender = sender; return this; } - - void ToExpression.To(string receiver) - { - _messageSender.SendMessage(_text, _sender, receiver); - } } + #endregion + + #region Nested type: ToExpression + public interface ToExpression { void To(string receiver); } + + #endregion } public class SendMessageRequest @@ -68,34 +74,34 @@ public class APIConsumer { - // Snippet from a class that uses IMessageSender - public void SendMessage(IMessageSender sender) - { - // Is this right? - sender.SendMessage("the message body", "PARTNER001", "PARTNER002"); + // Snippet from a class that uses IMessageSender + public void SendMessage(IMessageSender sender) + { + // Is this right? + sender.SendMessage("the message body", "PARTNER001", "PARTNER002"); - // or this? - sender.SendMessage("PARTNER001", "the message body", "PARTNER002"); + // or this? + sender.SendMessage("PARTNER001", "the message body", "PARTNER002"); - // or this? - sender.SendMessage("PARTNER001", "PARTNER002", "the message body"); - } + // or this? + sender.SendMessage("PARTNER001", "PARTNER002", "the message body"); + } - public void SendMessageFluently(FluentMessageSender sender) - { - sender - .SendText("the message body") - .From("PARTNER001").To("PARTNER002"); - } + public void SendMessageFluently(FluentMessageSender sender) + { + sender + .SendText("the message body") + .From("PARTNER001").To("PARTNER002"); + } - public void SendMessageAsParameter(ParameterObjectMessageSender sender) - { - sender.Send(new SendMessageRequest() + public void SendMessageAsParameter(ParameterObjectMessageSender sender) { - Text = "the message body", - Receiver = "PARTNER001", - Sender = "PARTNER002" - }); + sender.Send(new SendMessageRequest + { + Text = "the message body", + Receiver = "PARTNER001", + Sender = "PARTNER002" + }); + } } - } } \ No newline at end of file Modified: trunk/Source/StructureMap/Exceptions/InstancePropertyValueException.cs =================================================================== --- trunk/Source/StructureMap/Exceptions/InstancePropertyValueException.cs 2009-12-26 18:26:08 UTC (rev 299) +++ trunk/Source/StructureMap/Exceptions/InstancePropertyValueException.cs 2009-12-26 18:39:40 UTC (rev 300) @@ -15,8 +15,9 @@ { } - protected InstancePropertyValueException(SerializationInfo info, StreamingContext context) : - base(info, context) + protected InstancePropertyValueException(SerializationInfo info, StreamingContext context) + : + base(info, context) { } } Modified: trunk/Source/StructureMap/Exceptions/MissingPluginFamilyException.cs =================================================================== --- trunk/Source/StructureMap/Exceptions/MissingPluginFamilyException.cs 2009-12-26 18:26:08 UTC (rev 299) +++ trunk/Source/StructureMap/Exceptions/MissingPluginFamilyException.cs 2009-12-26 18:39:40 UTC (rev 300) @@ -13,16 +13,14 @@ _message = string.Format("Type {0} is not a configured PluginFamily", pluginTypeName); } - protected MissingPluginFamilyException(SerializationInfo info, StreamingContext context) : - base(info, context) + protected MissingPluginFamilyException(SerializationInfo info, StreamingContext context) + : + base(info, context) { _message = info.GetString("message"); } - public override string Message - { - get { return _message; } - } + public override string Message { get { return _message; } } public override void GetObjectData(SerializationInfo info, StreamingContext context) { Modified: trunk/Source/StructureMap/Exceptions/StructureMapConfigurationException.cs =================================================================== --- trunk/Source/StructureMap/Exceptions/StructureMapConfigurationException.cs 2009-12-26 18:26:08 UTC (rev 299) +++ trunk/Source/StructureMap/Exceptions/StructureMapConfigurationException.cs 2009-12-26 18:39:40 UTC (rev 300) @@ -6,13 +6,15 @@ [Serializable] public class StructureMapConfigurationException : ApplicationException { - public StructureMapConfigurationException(string message) : base(message) + public StructureMapConfigurationException(string message) + : base(message) { } - protected StructureMapConfigurationException(SerializationInfo info, StreamingContext context) : - base(info, context) + protected StructureMapConfigurationException(SerializationInfo info, StreamingContext context) + : + base(info, context) { } } Modified: trunk/Source/StructureMap/Graph/AssemblyScanner.cs =================================================================== --- trunk/Source/StructureMap/Graph/AssemblyScanner.cs 2009-12-26 18:26:08 UTC (rev 299) +++ trunk/Source/StructureMap/Graph/AssemblyScanner.cs 2009-12-26 18:39:40 UTC (rev 300) @@ -40,9 +40,10 @@ { private readonly List<Assembly> _assemblies = new List<Assembly>(); private readonly CompositeFilter<Type> _filter = new CompositeFilter<Type>(); + private readonly ImplementationMap _implementationMap = new ImplementationMap(); - private readonly List<ITypeScanner> _scanners = new List<ITypeScanner>(); private readonly List<Action<PluginGraph>> _postScanningActions = new List<Action<PluginGraph>>(); + private readonly List<ITypeScanner> _scanners = new List<ITypeScanner>(); public AssemblyScanner() { @@ -174,8 +175,6 @@ With(new GenericConnectionScanner(openGenericType)); } - - private readonly ImplementationMap _implementationMap = new ImplementationMap(); public void SingleImplementationsOfInterface() { @@ -232,10 +231,8 @@ internal void ScanForAll(PluginGraph pluginGraph) { - pluginGraph.Types.For(_assemblies, _filter).Each(type => - { - _scanners.Each(x => x.Process(type, pluginGraph)); - }); + pluginGraph.Types.For(_assemblies, _filter).Each( + type => { _scanners.Each(x => x.Process(type, pluginGraph)); }); _postScanningActions.Each(x => x(pluginGraph)); } Modified: trunk/Source/StructureMap/Graph/ImplementationMap.cs =================================================================== --- trunk/Source/StructureMap/Graph/ImplementationMap.cs 2009-12-26 18:26:08 UTC (rev 299) +++ trunk/Source/StructureMap/Graph/ImplementationMap.cs 2009-12-26 18:39:40 UTC (rev 300) @@ -10,6 +10,11 @@ { private readonly Cache<Type, List<Type>> _types = new Cache<Type, List<Type>>(t => new List<Type>()); + public void Process(Type type, PluginGraph graph) + { + RegisterType(type); + } + public void Register(Type interfaceType, Type concreteType) { _types[interfaceType].Add(concreteType); @@ -22,11 +27,6 @@ type.GetInterfaces().Where(i => i.IsVisible).Each(i => Register(i, type)); } - public void Process(Type type, PluginGraph graph) - { - RegisterType(type); - } - public void RegisterSingleImplementations(PluginGraph graph) { _types.Each((pluginType, types) => Modified: trunk/Source/StructureMap/Graph/PluginFamilyCollection.cs =================================================================== --- trunk/Source/StructureMap/Graph/PluginFamilyCollection.cs 2009-12-26 18:26:08 UTC (rev 299) +++ trunk/Source/StructureMap/Graph/PluginFamilyCollection.cs 2009-12-26 18:39:40 UTC (rev 300) @@ -32,10 +32,7 @@ } } - public int Count - { - get { return _pluginFamilies.Count; } - } + public int Count { get { return _pluginFamilies.Count; } } public IEnumerable<PluginFamily> All { Modified: trunk/Source/StructureMap/Graph/PluginGraph.cs =================================================================== --- trunk/Source/StructureMap/Graph/PluginGraph.cs 2009-12-26 18:26:08 UTC (rev 299) +++ trunk/Source/StructureMap/Graph/PluginGraph.cs 2009-12-26 18:39:40 UTC (rev 300) @@ -54,7 +54,7 @@ _reference.Target = _builder(); } - return (T)_reference.Target; + return (T) _reference.Target; } } } @@ -72,9 +72,9 @@ private readonly ProfileManager _profileManager = new ProfileManager(); private readonly List<Registry> _registries = new List<Registry>(); private readonly List<AssemblyScanner> _scanners = new List<AssemblyScanner>(); + private readonly WeakReference<TypePool> _types; private GraphLog _log = new GraphLog(); private bool _sealed; - private readonly WeakReference<TypePool> _types; public PluginGraph() @@ -83,13 +83,7 @@ _types = new WeakReference<TypePool>(() => new TypePool(this)); } - public TypePool Types - { - get - { - return _types.Value; - } - } + public TypePool Types { get { return _types.Value; } } public List<Registry> Registries { get { return _registries; } } Modified: trunk/Source/StructureMap/Interceptors/CompoundInterceptor.cs =================================================================== --- trunk/Source/StructureMap/Interceptors/CompoundInterceptor.cs 2009-12-26 18:26:08 UTC (rev 299) +++ trunk/Source/StructureMap/Interceptors/CompoundInterceptor.cs 2009-12-26 18:39:40 UTC (rev 300) @@ -10,10 +10,7 @@ } - public InstanceInterceptor[] Interceptors - { - get { return _interceptors; } - } + public InstanceInterceptor[] Interceptors { get { return _interceptors; } } #region InstanceInterceptor Members Modified: trunk/Source/StructureMap/Interceptors/Interceptors.cs =================================================================== --- trunk/Source/StructureMap/Interceptors/Interceptors.cs 2009-12-26 18:26:08 UTC (rev 299) +++ trunk/Source/StructureMap/Interceptors/Interceptors.cs 2009-12-26 18:39:40 UTC (rev 300) @@ -1,5 +1,6 @@ namespace StructureMap.Interceptors { public delegate object EnrichmentHandler<T>(T target); + public delegate object ContextEnrichmentHandler<T>(IContext context, T target); } \ No newline at end of file Modified: trunk/Source/StructureMap/Interceptors/MatchedTypeInterceptor.cs =================================================================== --- trunk/Source/StructureMap/Interceptors/MatchedTypeInterceptor.cs 2009-12-26 18:26:08 UTC (rev 299) +++ trunk/Source/StructureMap/Interceptors/MatchedTypeInterceptor.cs 2009-12-26 18:39:40 UTC (rev 300) @@ -45,6 +45,5 @@ { _interception = interception; } - } } \ No newline at end of file Modified: trunk/Source/StructureMap/Pipeline/ConfiguredInstanceBase.cs =================================================================== --- trunk/Source/StructureMap/Pipeline/ConfiguredInstanceBase.cs 2009-12-26 18:26:08 UTC (rev 299) +++ trunk/Source/StructureMap/Pipeline/ConfiguredInstanceBase.cs 2009-12-26 18:39:40 UTC (rev 300) @@ -1,7 +1,5 @@ using System; using System.Collections.Generic; -using StructureMap.Graph; -using StructureMap.TypeRules; namespace StructureMap.Pipeline { @@ -213,7 +211,7 @@ // _children.Add(name, instance); // } - + // } // protected void setChildArray(string name, Instance[] array) @@ -224,7 +222,7 @@ // { // throw new ApplicationException("There is a null value in the array of child Instances"); // } - + // } // _arrays.Add(name, array); Modified: trunk/Source/StructureMap/Pipeline/HttpContextLifecycle.cs =================================================================== --- trunk/Source/StructureMap/Pipeline/HttpContextLifecycle.cs 2009-12-26 18:26:08 UTC (rev 299) +++ trunk/Source/StructureMap/Pipeline/HttpContextLifecycle.cs 2009-12-26 18:39:40 UTC (rev 300) @@ -8,16 +8,6 @@ public static readonly string ITEM_NAME = "STRUCTUREMAP-INSTANCES"; - public static bool HasContext() - { - return HttpContext.Current != null; - } - - public static void DisposeAndClearAll() - { - new HttpContextLifecycle().FindCache().DisposeAndClear(); - } - public void EjectAll() { FindCache().DisposeAndClear(); @@ -33,7 +23,7 @@ { if (!items.Contains(ITEM_NAME)) { - MainObjectCache cache = new MainObjectCache(); + var cache = new MainObjectCache(); items.Add(ITEM_NAME, cache); return cache; @@ -41,10 +31,20 @@ } } - return (IObjectCache)items[ITEM_NAME]; + return (IObjectCache) items[ITEM_NAME]; } + public static bool HasContext() + { + return HttpContext.Current != null; + } + public static void DisposeAndClearAll() + { + new HttpContextLifecycle().FindCache().DisposeAndClear(); + } + + protected virtual IDictionary findHttpDictionary() { return HttpContext.Current.Items; Modified: trunk/Source/StructureMap/Pipeline/HybridSessionLifecycle.cs =================================================================== --- trunk/Source/StructureMap/Pipeline/HybridSessionLifecycle.cs 2009-12-26 18:26:08 UTC (rev 299) +++ trunk/Source/StructureMap/Pipeline/HybridSessionLifecycle.cs 2009-12-26 18:39:40 UTC (rev 300) @@ -2,6 +2,5 @@ { public class HybridSessionLifecycle : HttpLifecycleBase<HttpSessionLifecycle, ThreadLocalStorageLifecycle> { - } } \ No newline at end of file Modified: trunk/Source/StructureMap/Pipeline/InstanceKey.cs =================================================================== --- trunk/Source/StructureMap/Pipeline/InstanceKey.cs 2009-12-26 18:26:08 UTC (rev 299) +++ trunk/Source/StructureMap/Pipeline/InstanceKey.cs 2009-12-26 18:39:40 UTC (rev 300) @@ -4,12 +4,8 @@ { public class InstanceKey { - public string Name { get; set; } - public Type PluginType { get; set; } - [Obsolete("Kill!")] - private WeakReference _session; - [Obsolete("Kill!")] - private WeakReference _instance; + [Obsolete("Kill!")] private WeakReference _instance; + [Obsolete("Kill!")] private WeakReference _session; public InstanceKey() { @@ -21,20 +17,16 @@ PluginType = pluginType; } + public string Name { get; set; } + public Type PluginType { get; set; } + [Obsolete("Kill!")] - public BuildSession Session - { - get { return (BuildSession) _session.Target; } - set { _session = new WeakReference(value); } - } + public BuildSession Session { get { return (BuildSession) _session.Target; } set { _session = new WeakReference(value); } } [Obsolete("Kill!")] public Instance Instance { - get - { - return (Instance) _instance.Target; - } + get { return (Instance) _instance.Target; } set { Name = value.Name; @@ -53,15 +45,16 @@ { if (ReferenceEquals(null, obj)) return false; if (ReferenceEquals(this, obj)) return true; - if (obj.GetType() != typeof(InstanceKey)) return false; - return Equals((InstanceKey)obj); + if (obj.GetType() != typeof (InstanceKey)) return false; + return Equals((InstanceKey) obj); } public override int GetHashCode() { unchecked { - return ((Name != null ? Name.GetHashCode() : 0) * 397) ^ (PluginType != null ? PluginType.GetHashCode() : 0); + return ((Name != null ? Name.GetHashCode() : 0)*397) ^ + (PluginType != null ? PluginType.GetHashCode() : 0); } } } Modified: trunk/Source/StructureMap/Pipeline/Lifecycles.cs =================================================================== --- trunk/Source/StructureMap/Pipeline/Lifecycles.cs 2009-12-26 18:26:08 UTC (rev 299) +++ trunk/Source/StructureMap/Pipeline/Lifecycles.cs 2009-12-26 18:39:40 UTC (rev 300) @@ -30,7 +30,7 @@ case InstanceScope.HybridHttpSession: return new HybridSessionLifecycle(); } - + throw new ArgumentOutOfRangeException("scope"); } } Modified: trunk/Source/StructureMap/Pipeline/MainObjectCache.cs =================================================================== --- trunk/Source/StructureMap/Pipeline/MainObjectCache.cs 2009-12-26 18:26:08 UTC (rev 299) +++ trunk/Source/StructureMap/Pipeline/MainObjectCache.cs 2009-12-26 18:39:40 UTC (rev 300) @@ -5,18 +5,12 @@ { public class MainObjectCache : IObjectCache { - private readonly IDictionary<InstanceKey, object> _objects = new Dictionary<InstanceKey,object>(); private readonly object _locker = new object(); + private readonly IDictionary<InstanceKey, object> _objects = new Dictionary<InstanceKey, object>(); - public object Locker - { - get { return _locker; } - } + public object Locker { get { return _locker; } } - public int Count - { - get { return _objects.Count; } - } + public int Count { get { return _objects.Count; } } public object Get(Type pluginType, Instance instance) { @@ -45,21 +39,23 @@ { lock (Locker) { - foreach (var @object in _objects.Values) + foreach (object @object in _objects.Values) { if (@object is Container) continue; - IDisposable disposable = @object as IDisposable; + var disposable = @object as IDisposable; if (disposable != null) { try { disposable.Dispose(); } - catch (Exception) { } + catch (Exception) + { + } } } - + _objects.Clear(); } } Modified: trunk/Source/StructureMap/Pipeline/SessionWrapper.cs =================================================================== --- trunk/Source/StructureMap/Pipeline/SessionWrapper.cs 2009-12-26 18:26:08 UTC (rev 299) +++ trunk/Source/StructureMap/Pipeline/SessionWrapper.cs 2009-12-26 18:39:40 UTC (rev 300) @@ -25,20 +25,11 @@ _session.CopyTo(array, index); } - public int Count - { - get { return _session.Count; } - } + public int Count { get { return _session.Count; } } - public object SyncRoot - { - get { return _session.SyncRoot; } - } + public object SyncRoot { get { return _session.SyncRoot; } } - public bool IsSynchronized - { - get { return _session.IsSynchronized; } - } + public bool IsSynchronized { get { return _session.IsSynchronized; } } public bool Contains(object key) { @@ -65,31 +56,15 @@ _session.Remove(key.ToString()); } - public object this[object key] - { - get { return _session[key.ToString()]; } - set { _session[key.ToString()] = value; } - } + public object this[object key] { get { return _session[key.ToString()]; } set { _session[key.ToString()] = value; } } - public ICollection Keys - { - get { return _session.Keys; } - } + public ICollection Keys { get { return _session.Keys; } } - public ICollection Values - { - get { throw new NotImplementedException(); } - } + public ICollection Values { get { throw new NotImplementedException(); } } - public bool IsReadOnly - { - get { return _session.IsReadOnly; } - } + public bool IsReadOnly { get { return _session.IsReadOnly; } } - public bool IsFixedSize - { - get { return false; } - } + public bool IsFixedSize { get { return false; } } #endregion } Modified: trunk/Source/StructureMap/Pipeline/UniquePerRequestLifecycle.cs =================================================================== --- trunk/Source/StructureMap/Pipeline/UniquePerRequestLifecycle.cs 2009-12-26 18:26:08 UTC (rev 299) +++ trunk/Source/StructureMap/Pipeline/UniquePerRequestLifecycle.cs 2009-12-26 18:39:40 UTC (rev 300) @@ -1,5 +1,3 @@ -using System; - namespace StructureMap.Pipeline { /// <summary> @@ -9,7 +7,6 @@ { public void EjectAll() { - } public IObjectCache FindCache() @@ -18,9 +15,9 @@ } //#region IBuildInterceptor Members - + //private IBuildPolicy _innerPolicy = new BuildPolicy(); - + //public IBuildPolicy InnerPolicy //{ // get { return _innerPolicy; } @@ -52,4 +49,4 @@ //#endregion } -} +} \ No newline at end of file Modified: trunk/Source/StructureMap/Pipeline/UserControlInstance.cs =================================================================== --- trunk/Source/StructureMap/Pipeline/UserControlInstance.cs 2009-12-26 18:26:08 UTC (rev 299) +++ trunk/Source/StructureMap/Pipeline/UserControlInstance.cs 2009-12-26 18:39:40 UTC (rev 300) @@ -1,6 +1,5 @@ using System; using System.Web.UI; -using StructureMap.Graph; using StructureMap.TypeRules; namespace StructureMap.Pipeline @@ -14,16 +13,10 @@ _url = url; } - protected override UserControlInstance thisInstance - { - get { return this; } - } + protected override UserControlInstance thisInstance { get { return this; } } - public string Url - { - get { return _url; } - } + public string Url { get { return _url; } } protected override object build(Type pluginType, BuildSession session) { Modified: trunk/Source/StructureMap/Source/BasicXmlMementoSource.cs =================================================================== --- trunk/Source/StructureMap/Source/BasicXmlMementoSource.cs 2009-12-26 18:26:08 UTC (rev 299) +++ trunk/Source/StructureMap/Source/BasicXmlMementoSource.cs 2009-12-26 18:39:40 UTC (rev 300) @@ -15,10 +15,7 @@ _node = Node; } - public override string Description - { - get { return "BasicXmlMementoSource"; } - } + public override string Description { get { return "BasicXmlMementoSource"; } } protected override XmlNode getRootNode() { Modified: trunk/Source/StructureMap/Source/MemoryMementoSource.cs =================================================================== --- trunk/Source/StructureMap/Source/MemoryMementoSource.cs 2009-12-26 18:26:08 UTC (rev 299) +++ trunk/Source/StructureMap/Source/MemoryMementoSource.cs 2009-12-26 18:39:40 UTC (rev 300) @@ -14,10 +14,7 @@ _mementos = new Hashtable(); } - public override string Description - { - get { return "DefaultMementoSource"; } - } + public override string Description { get { return "DefaultMementoSource"; } } protected override InstanceMemento[] fetchInternalMementos() { Modified: trunk/Source/StructureMap/SystemRegistry.cs =================================================================== --- trunk/Source/StructureMap/SystemRegistry.cs 2009-12-26 18:26:08 UTC (rev 299) +++ trunk/Source/StructureMap/SystemRegistry.cs 2009-12-26 18:39:40 UTC (rev 300) @@ -30,7 +30,7 @@ private void AddLifecycleType<T>(InstanceScope scope) where T : ILifecycle { - addExpression(graph => graph.AddType(typeof(ILifecycle), typeof(T), scope.ToString())); + addExpression(graph => graph.AddType(typeof (ILifecycle), typeof (T), scope.ToString())); } private void AddMementoSourceType<T>(string name) Modified: trunk/Source/StructureMap/TypeExtensions.cs =================================================================== --- trunk/Source/StructureMap/TypeExtensions.cs 2009-12-26 18:26:08 UTC (rev 299) +++ trunk/Source/StructureMap/TypeExtensions.cs 2009-12-26 18:39:40 UTC (rev 300) @@ -153,7 +153,7 @@ public static IEnumerable<Type> AllInterfaces(this Type type) { - foreach (var @interface in type.GetInterfaces()) + foreach (Type @interface in type.GetInterfaces()) { yield return @interface; } This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |