Line endings

Line endings

--- src/AutoMapper/Configuration/MappingExpression.cs
+++ src/AutoMapper/Configuration/MappingExpression.cs
@@ -1,476 +1,476 @@
-namespace AutoMapper.Configuration
-{
-    using System;
-    using System.Collections.Generic;
-    using System.Linq;
-    using System.Linq.Expressions;
-    using System.Reflection;
-    using Execution;
-
-    public class MappingExpression : MappingExpression<object, object>, IMappingExpression
-    {
-        public MappingExpression(TypePair types, MemberList memberList) : base(memberList, types.SourceType, types.DestinationType)
-        {
-        }
-
-        public new IMappingExpression ReverseMap() => (IMappingExpression) base.ReverseMap();
-
-        public new IMappingExpression Substitute(Func<object, object> substituteFunc)
-            => (IMappingExpression) base.Substitute(substituteFunc);
-
-        public new IMappingExpression ConstructUsingServiceLocator()
-            => (IMappingExpression)base.ConstructUsingServiceLocator();
-
-        public void ForAllMembers(Action<IMemberConfigurationExpression> memberOptions)
-            => base.ForAllMembers(opts => memberOptions((IMemberConfigurationExpression)opts));
-
-        void IMappingExpression.ConvertUsing<TTypeConverter>()
-        {
-            ConvertUsing(typeof(TTypeConverter));
-        }
-
-        public void ConvertUsing(Type typeConverterType)
-        {
-            var interfaceType = typeof(ITypeConverter<,>).MakeGenericType(Types.SourceType, Types.DestinationType);
-            var convertMethodType = interfaceType.IsAssignableFrom(typeConverterType) ? interfaceType : typeConverterType;
-            var converter = new DeferredInstantiatedConverter(convertMethodType, typeConverterType.BuildCtor<object>());
-
-            TypeMapActions.Add(tm => tm.UseCustomMapper(converter.Convert));
-        }
-
-        public void As(Type typeOverride) => TypeMapActions.Add(tm => tm.DestinationTypeOverride = typeOverride);
-
+namespace AutoMapper.Configuration
+{
+    using System;
+    using System.Collections.Generic;
+    using System.Linq;
+    using System.Linq.Expressions;
+    using System.Reflection;
+    using Execution;
+
+    public class MappingExpression : MappingExpression<object, object>, IMappingExpression
+    {
+        public MappingExpression(TypePair types, MemberList memberList) : base(memberList, types.SourceType, types.DestinationType)
+        {
+        }
+
+        public new IMappingExpression ReverseMap() => (IMappingExpression) base.ReverseMap();
+
+        public new IMappingExpression Substitute(Func<object, object> substituteFunc)
+            => (IMappingExpression) base.Substitute(substituteFunc);
+
+        public new IMappingExpression ConstructUsingServiceLocator()
+            => (IMappingExpression)base.ConstructUsingServiceLocator();
+
+        public void ForAllMembers(Action<IMemberConfigurationExpression> memberOptions)
+            => base.ForAllMembers(opts => memberOptions((IMemberConfigurationExpression)opts));
+
+        void IMappingExpression.ConvertUsing<TTypeConverter>()
+        {
+            ConvertUsing(typeof(TTypeConverter));
+        }
+
+        public void ConvertUsing(Type typeConverterType)
+        {
+            var interfaceType = typeof(ITypeConverter<,>).MakeGenericType(Types.SourceType, Types.DestinationType);
+            var convertMethodType = interfaceType.IsAssignableFrom(typeConverterType) ? interfaceType : typeConverterType;
+            var converter = new DeferredInstantiatedConverter(convertMethodType, typeConverterType.BuildCtor<object>());
+
+            TypeMapActions.Add(tm => tm.UseCustomMapper(converter.Convert));
+        }
+
+        public void As(Type typeOverride) => TypeMapActions.Add(tm => tm.DestinationTypeOverride = typeOverride);
+
         public void ForAllOtherMembers(Action<IMemberConfigurationExpression> memberOptions)
         {
             base.ForAllOtherMembers(o => memberOptions((IMemberConfigurationExpression)o));
         }

-        public IMappingExpression ForMember(string name, Action<IMemberConfigurationExpression> memberOptions)
-            => (IMappingExpression)base.ForMember(name, c => memberOptions((IMemberConfigurationExpression)c));
-
-        public new IMappingExpression ForSourceMember(string sourceMemberName, Action<ISourceMemberConfigurationExpression> memberOptions)
-            => (IMappingExpression)base.ForSourceMember(sourceMemberName, memberOptions);
-
-        public new IMappingExpression Include(Type otherSourceType, Type otherDestinationType)
-            => (IMappingExpression)base.Include(otherSourceType, otherDestinationType);
-
-        public new IMappingExpression IgnoreAllPropertiesWithAnInaccessibleSetter()
-            => (IMappingExpression)base.IgnoreAllPropertiesWithAnInaccessibleSetter();
-
-        public new IMappingExpression IgnoreAllSourcePropertiesWithAnInaccessibleSetter()
-            => (IMappingExpression)base.IgnoreAllSourcePropertiesWithAnInaccessibleSetter();
-
-        public new IMappingExpression IncludeBase(Type sourceBase, Type destinationBase)
-            => (IMappingExpression)base.IncludeBase(sourceBase, destinationBase);
-
-        public new IMappingExpression BeforeMap(Action<object, object> beforeFunction)
-            => (IMappingExpression)base.BeforeMap(beforeFunction);
-
-        public new IMappingExpression BeforeMap<TMappingAction>() where TMappingAction : IMappingAction<object, object>
-            => (IMappingExpression)base.BeforeMap<TMappingAction>();
-
-        public new IMappingExpression AfterMap(Action<object, object> afterFunction)
-            => (IMappingExpression)base.AfterMap(afterFunction);
-
-        public new IMappingExpression AfterMap<TMappingAction>() where TMappingAction : IMappingAction<object, object>
-            => (IMappingExpression)base.AfterMap<TMappingAction>();
-
-        public new IMappingExpression ConstructUsing(Func<object, object> ctor)
-            => (IMappingExpression)base.ConstructUsing(ctor);
-
-        public new IMappingExpression ConstructUsing(Func<ResolutionContext, object> ctor)
-            => (IMappingExpression)base.ConstructUsing(ctor);
-
-        public IMappingExpression ConstructProjectionUsing(LambdaExpression ctor)
-        {
-            var func = ctor.Compile();
-
-            TypeMapActions.Add(tm => tm.ConstructExpression = ctor);
-
-            return ConstructUsing(ctxt => func.DynamicInvoke(ctxt.SourceValue));
-        }
-
-        public new IMappingExpression MaxDepth(int depth)
-            => (IMappingExpression)base.MaxDepth(depth);
-
-        public new IMappingExpression ForCtorParam(string ctorParamName, Action<ICtorParamConfigurationExpression<object>> paramOptions)
-            => (IMappingExpression)base.ForCtorParam(ctorParamName, paramOptions);
-
-        protected override IMemberConfiguration CreateMemberConfigurationExpression<TMember>(IMemberAccessor member,
-            Type sourceType)
-        {
-            return new MemberConfigurationExpression(member, sourceType);
-        }
-
-        protected override MappingExpression<object, object> CreateReverseMapExpression()
-        {
-            return new MappingExpression(new TypePair(DestinationType, SourceType), MemberList.Source);
-        }
-
-        private class MemberConfigurationExpression : MemberConfigurationExpression<object, object>, IMemberConfigurationExpression
-        {
-            public MemberConfigurationExpression(IMemberAccessor destinationMember, Type sourceType)
-                : base(destinationMember, sourceType)
-            {
-            }
-        }
-
-    }
-
-    public class MappingExpression<TSource, TDestination> : IMappingExpression<TSource, TDestination>, ITypeMapConfiguration
-    {
-        private readonly List<IMemberConfiguration> _memberConfigurations = new List<IMemberConfiguration>();
-        private readonly List<SourceMappingExpression> _sourceMemberConfigurations = new List<SourceMappingExpression>();
-        private readonly List<CtorParamConfigurationExpression<TSource>> _ctorParamConfigurations = new List<CtorParamConfigurationExpression<TSource>>();
-        private MappingExpression<TDestination, TSource> _reverseMap;
+        public IMappingExpression ForMember(string name, Action<IMemberConfigurationExpression> memberOptions)
+            => (IMappingExpression)base.ForMember(name, c => memberOptions((IMemberConfigurationExpression)c));
+
+        public new IMappingExpression ForSourceMember(string sourceMemberName, Action<ISourceMemberConfigurationExpression> memberOptions)
+            => (IMappingExpression)base.ForSourceMember(sourceMemberName, memberOptions);
+
+        public new IMappingExpression Include(Type otherSourceType, Type otherDestinationType)
+            => (IMappingExpression)base.Include(otherSourceType, otherDestinationType);
+
+        public new IMappingExpression IgnoreAllPropertiesWithAnInaccessibleSetter()
+            => (IMappingExpression)base.IgnoreAllPropertiesWithAnInaccessibleSetter();
+
+        public new IMappingExpression IgnoreAllSourcePropertiesWithAnInaccessibleSetter()
+            => (IMappingExpression)base.IgnoreAllSourcePropertiesWithAnInaccessibleSetter();
+
+        public new IMappingExpression IncludeBase(Type sourceBase, Type destinationBase)
+            => (IMappingExpression)base.IncludeBase(sourceBase, destinationBase);
+
+        public new IMappingExpression BeforeMap(Action<object, object> beforeFunction)
+            => (IMappingExpression)base.BeforeMap(beforeFunction);
+
+        public new IMappingExpression BeforeMap<TMappingAction>() where TMappingAction : IMappingAction<object, object>
+            => (IMappingExpression)base.BeforeMap<TMappingAction>();
+
+        public new IMappingExpression AfterMap(Action<object, object> afterFunction)
+            => (IMappingExpression)base.AfterMap(afterFunction);
+
+        public new IMappingExpression AfterMap<TMappingAction>() where TMappingAction : IMappingAction<object, object>
+            => (IMappingExpression)base.AfterMap<TMappingAction>();
+
+        public new IMappingExpression ConstructUsing(Func<object, object> ctor)
+            => (IMappingExpression)base.ConstructUsing(ctor);
+
+        public new IMappingExpression ConstructUsing(Func<ResolutionContext, object> ctor)
+            => (IMappingExpression)base.ConstructUsing(ctor);
+
+        public IMappingExpression ConstructProjectionUsing(LambdaExpression ctor)
+        {
+            var func = ctor.Compile();
+
+            TypeMapActions.Add(tm => tm.ConstructExpression = ctor);
+
+            return ConstructUsing(ctxt => func.DynamicInvoke(ctxt.SourceValue));
+        }
+
+        public new IMappingExpression MaxDepth(int depth)
+            => (IMappingExpression)base.MaxDepth(depth);
+
+        public new IMappingExpression ForCtorParam(string ctorParamName, Action<ICtorParamConfigurationExpression<object>> paramOptions)
+            => (IMappingExpression)base.ForCtorParam(ctorParamName, paramOptions);
+
+        protected override IMemberConfiguration CreateMemberConfigurationExpression<TMember>(IMemberAccessor member,
+            Type sourceType)
+        {
+            return new MemberConfigurationExpression(member, sourceType);
+        }
+
+        protected override MappingExpression<object, object> CreateReverseMapExpression()
+        {
+            return new MappingExpression(new TypePair(DestinationType, SourceType), MemberList.Source);
+        }
+
+        private class MemberConfigurationExpression : MemberConfigurationExpression<object, object>, IMemberConfigurationExpression
+        {
+            public MemberConfigurationExpression(IMemberAccessor destinationMember, Type sourceType)
+                : base(destinationMember, sourceType)
+            {
+            }
+        }
+
+    }
+
+    public class MappingExpression<TSource, TDestination> : IMappingExpression<TSource, TDestination>, ITypeMapConfiguration
+    {
+        private readonly List<IMemberConfiguration> _memberConfigurations = new List<IMemberConfiguration>();
+        private readonly List<SourceMappingExpression> _sourceMemberConfigurations = new List<SourceMappingExpression>();
+        private readonly List<CtorParamConfigurationExpression<TSource>> _ctorParamConfigurations = new List<CtorParamConfigurationExpression<TSource>>();
+        private MappingExpression<TDestination, TSource> _reverseMap;
         private Action<IMemberConfigurationExpression<TSource, object>> _allMemberOptions;
-        private Func<IMemberAccessor, bool> _memberFilter;
-
-        public MappingExpression(MemberList memberList)
-        {
-            MemberList = memberList;
-            Types = new TypePair(typeof(TSource), typeof(TDestination));
-        }
-
-        public MappingExpression(MemberList memberList, Type sourceType, Type destinationType)
-        {
-            MemberList = memberList;
-            Types = new TypePair(sourceType, destinationType);
-        }
-
-        public MemberList MemberList { get; }
-        public TypePair Types { get; }
-        public Type SourceType => Types.SourceType;
-        public Type DestinationType => Types.DestinationType;
-        public ITypeMapConfiguration ReverseTypeMap => _reverseMap;
-        protected List<Action<TypeMap>> TypeMapActions { get; } = new List<Action<TypeMap>>();
-
-        protected virtual IMemberConfiguration CreateMemberConfigurationExpression<TMember>(IMemberAccessor member, Type sourceType)
-        {
-            return new MemberConfigurationExpression<TSource, TMember>(member, sourceType);
-        }
-
-        protected virtual MappingExpression<TDestination, TSource> CreateReverseMapExpression()
-        {
-            return new MappingExpression<TDestination, TSource>(MemberList.Source, DestinationType, SourceType);
-        }
-
-        public IMappingExpression<TSource, TDestination> ForMember<TMember>(Expression<Func<TDestination, TMember>> destinationMember,
-                                                                   Action<IMemberConfigurationExpression<TSource, TMember>> memberOptions)
-        {
-            var memberInfo = ReflectionHelper.FindProperty(destinationMember);
-            IMemberAccessor destProperty = memberInfo.ToMemberAccessor();
-
-            ForDestinationMember(destProperty, memberOptions);
-
-            return this;
-        }
-
-        public IMappingExpression<TSource, TDestination> ForMember(string name,
-                                                                   Action<IMemberConfigurationExpression<TSource, object>> memberOptions)
-        {
-            IMemberAccessor destMember = null;
-            var propertyInfo = DestinationType.GetProperty(name);
-            if (propertyInfo != null)
-            {
-                destMember = new PropertyAccessor(propertyInfo);
-            }
-            if (destMember == null)
-            {
-                var fieldInfo = DestinationType.GetField(name);
-                if(fieldInfo == null)
-                {
-                    throw new ArgumentOutOfRangeException(nameof(name), "Cannot find a field or property named " + name);
-                }
-                destMember = new FieldAccessor(fieldInfo);
-            }
-            ForDestinationMember(destMember, memberOptions);
-            return this;
-        }
-
-        public void ForAllOtherMembers(Action<IMemberConfigurationExpression<TSource, object>> memberOptions)
-        {
-            _allMemberOptions = memberOptions;
-            _memberFilter = m => _memberConfigurations.All(c=>c.DestinationMember.MemberInfo != m.MemberInfo);
-        }
-
-        public void ForAllMembers(Action<IMemberConfigurationExpression<TSource, object>> memberOptions)
-        {
-            _allMemberOptions = memberOptions;
-            _memberFilter = _ => true;
-        }
-
-        public IMappingExpression<TSource, TDestination> IgnoreAllPropertiesWithAnInaccessibleSetter()
-        {
-            var properties = DestinationType.GetDeclaredProperties().Where(pm => pm.HasAnInaccessibleSetter());
-            foreach (var property in properties)
-                ForMember(property.Name, opt => opt.Ignore());
-            return this;
-        }
-
-        public IMappingExpression<TSource, TDestination> IgnoreAllSourcePropertiesWithAnInaccessibleSetter()
-        {
-            var properties = SourceType.GetDeclaredProperties().Where(pm => pm.HasAnInaccessibleSetter());
-            foreach (var property in properties)
-                ForSourceMember(property.Name, opt => opt.Ignore());
-            return this;
-        }
-
-        public IMappingExpression<TSource, TDestination> Include<TOtherSource, TOtherDestination>()
-            where TOtherSource : TSource
-            where TOtherDestination : TDestination
-        {
-            return Include(typeof(TOtherSource), typeof(TOtherDestination));
-        }
-
-        public IMappingExpression<TSource, TDestination> Include(Type otherSourceType, Type otherDestinationType)
-        {
-            TypeMapActions.Add(tm => tm.IncludeDerivedTypes(otherSourceType, otherDestinationType));
-
-            return this;
-        }
-
-        public IMappingExpression<TSource, TDestination> IncludeBase<TSourceBase, TDestinationBase>()
-        {
-            return IncludeBase(typeof(TSourceBase), typeof(TDestinationBase));
-        }
-
-        public IMappingExpression<TSource, TDestination> IncludeBase(Type sourceBase, Type destinationBase)
-        {
-            TypeMapActions.Add(tm => tm.IncludeBaseTypes(sourceBase, destinationBase));
-
-            return this;
-        }
-
-        public void ProjectUsing(Expression<Func<TSource, TDestination>> projectionExpression)
-        {
-            TypeMapActions.Add(tm => tm.UseCustomProjection(projectionExpression));
-
-            ConvertUsing(projectionExpression.Compile());
-        }
-
-        public IMappingExpression<TSource, TDestination> MaxDepth(int depth)
-        {
-            TypeMapActions.Add(tm => tm.MaxDepth = depth);
-
-            return this;
-        }
-
-        public IMappingExpression<TSource, TDestination> ConstructUsingServiceLocator()
-        {
-            TypeMapActions.Add(tm => tm.ConstructDestinationUsingServiceLocator = true);
-
-            return this;
-        }
-
-        public IMappingExpression<TDestination, TSource> ReverseMap()
-        {
-            var mappingExpression = CreateReverseMapExpression();
-
-            _reverseMap = mappingExpression;
-
-            return mappingExpression;
-        }
-
-        public IMappingExpression<TSource, TDestination> ForSourceMember(Expression<Func<TSource, object>> sourceMember, Action<ISourceMemberConfigurationExpression> memberOptions)
-        {
-            var memberInfo = ReflectionHelper.FindProperty(sourceMember);
-
-            var srcConfig = new SourceMappingExpression(memberInfo);
-
-            memberOptions(srcConfig);
-
-            _sourceMemberConfigurations.Add(srcConfig);
-
-            return this;
-        }
-
-        public IMappingExpression<TSource, TDestination> ForSourceMember(string sourceMemberName, Action<ISourceMemberConfigurationExpression> memberOptions)
-        {
-            var memberInfo = SourceType.GetMember(sourceMemberName).First();
-
-            var srcConfig = new SourceMappingExpression(memberInfo);
-
-            memberOptions(srcConfig);
-
-            _sourceMemberConfigurations.Add(srcConfig);
-
-            return this;
-        }
-
-        public IMappingExpression<TSource, TDestination> Substitute(Func<TSource, object> substituteFunc)
-        {
-            TypeMapActions.Add(tm => tm.Substitution = src => substituteFunc((TSource) src));
-
-            return this;
-        }
-
-        public void ConvertUsing(Func<TSource, TDestination> mappingFunction)
-        {
-            TypeMapActions.Add(tm => tm.UseCustomMapper((source, ctxt) => mappingFunction((TSource) source)));
-        }
-
-        public void ConvertUsing(Func<TSource, ResolutionContext, TDestination> mappingFunction)
-        {
-            TypeMapActions.Add(tm => tm.UseCustomMapper((source, ctxt) => mappingFunction((TSource) source, ctxt)));
-        }
-
-        public void ConvertUsing(ITypeConverter<TSource, TDestination> converter)
-        {
-            ConvertUsing(converter.Convert);
-        }
-
-        public void ConvertUsing<TTypeConverter>() where TTypeConverter : ITypeConverter<TSource, TDestination>
-        {
-            var converter = new DeferredInstantiatedConverter<TSource, TDestination>(typeof(TTypeConverter).BuildCtor<ITypeConverter<TSource, TDestination>>());
-
-            ConvertUsing(converter.Convert);
-        }
-
-        public IMappingExpression<TSource, TDestination> BeforeMap(Action<TSource, TDestination> beforeFunction)
-        {
-            TypeMapActions.Add(tm => tm.AddBeforeMapAction((src, dest, ctxt) => beforeFunction((TSource)src, (TDestination)dest)));
-
-            return this;
-        }
-
-        public IMappingExpression<TSource, TDestination> BeforeMap(Action<TSource, TDestination, ResolutionContext> beforeFunction)
-        {
-            TypeMapActions.Add(tm => tm.AddBeforeMapAction((src, dest, ctxt) => beforeFunction((TSource)src, (TDestination)dest, ctxt)));
-
-            return this;
-        }
-
-        public IMappingExpression<TSource, TDestination> BeforeMap<TMappingAction>() where TMappingAction : IMappingAction<TSource, TDestination>
-        {
-            Action<TSource, TDestination, ResolutionContext> beforeFunction = (src, dest, ctxt) =>
-                ((TMappingAction)ctxt.Options.ServiceCtor(typeof(TMappingAction))).Process(src, dest);
-
-            return BeforeMap(beforeFunction);
-        }
-
-        public IMappingExpression<TSource, TDestination> AfterMap(Action<TSource, TDestination> afterFunction)
-        {
-            TypeMapActions.Add(tm => tm.AddAfterMapAction((src, dest, ctxt) => afterFunction((TSource)src, (TDestination)dest)));
-
-            return this;
-        }
-
-        public IMappingExpression<TSource, TDestination> AfterMap(Action<TSource, TDestination, ResolutionContext> afterFunction)
-        {
-            TypeMapActions.Add(tm => tm.AddAfterMapAction((src, dest, ctxt) => afterFunction((TSource)src, (TDestination)dest, ctxt)));
-
-            return this;
-        }
-
-        public IMappingExpression<TSource, TDestination> AfterMap<TMappingAction>() where TMappingAction : IMappingAction<TSource, TDestination>
-        {
-            Action<TSource, TDestination, ResolutionContext> afterFunction = (src, dest, ctxt)
-                => ((TMappingAction)ctxt.Options.ServiceCtor(typeof(TMappingAction))).Process(src, dest);
-
-            return AfterMap(afterFunction);
-        }
-
-        public IMappingExpression<TSource, TDestination> ConstructUsing(Func<TSource, TDestination> ctor)
-        {
-            return ConstructUsing(ctxt => ctor((TSource)ctxt.SourceValue));
-        }
-
-        public IMappingExpression<TSource, TDestination> ConstructUsing(Func<ResolutionContext, TDestination> ctor)
-        {
-            TypeMapActions.Add(tm => tm.DestinationCtor = ctxt => ctor(ctxt));
-
-            return this;
-        }
-
-        public IMappingExpression<TSource, TDestination> ConstructProjectionUsing(Expression<Func<TSource, TDestination>> ctor)
-        {
-            var func = ctor.Compile();
-
-            TypeMapActions.Add(tm => tm.ConstructExpression = ctor);
-
-            return ConstructUsing(ctxt => func((TSource)ctxt.SourceValue));
-        }
-
-        private void ForDestinationMember<TMember>(IMemberAccessor destinationProperty, Action<IMemberConfigurationExpression<TSource, TMember>> memberOptions)
-        {
-            var expression = (MemberConfigurationExpression<TSource, TMember>) CreateMemberConfigurationExpression<TMember>(destinationProperty, SourceType);
-
-            _memberConfigurations.Add(expression);
-
-            memberOptions(expression);
-        }
-
-        public void As<T>()
-        {
-            TypeMapActions.Add(tm => tm.DestinationTypeOverride = typeof(T));
-        }
-
-        public IMappingExpression<TSource, TDestination> ForCtorParam(string ctorParamName, Action<ICtorParamConfigurationExpression<TSource>> paramOptions)
-        {
-            var ctorParamExpression = new CtorParamConfigurationExpression<TSource>(ctorParamName);
-
-            paramOptions(ctorParamExpression);
-
-            _ctorParamConfigurations.Add(ctorParamExpression);
-
-            return this;
-        }
-
-        public void Configure(IProfileConfiguration profile, TypeMap typeMap)
-        {
-            foreach (var destProperty in typeMap.DestinationTypeDetails.PublicWriteAccessors)
-            {
-                var attrs = destProperty.GetCustomAttributes(true);
-                if (attrs.Any(x => x is IgnoreMapAttribute))
-                {
-                    ForMember(destProperty.Name, y => y.Ignore());
-                    _reverseMap?.ForMember(destProperty.Name, opt => opt.Ignore());
-                }
-                if (profile.GlobalIgnores.Contains(destProperty.Name))
-                {
-                    ForMember(destProperty.Name, y => y.Ignore());
-                }
-            }
-
-            if (_allMemberOptions != null)
-            {
-                foreach (var accessor in typeMap.DestinationTypeDetails.PublicReadAccessors.Select(m=>m.ToMemberAccessor()).Where(_memberFilter))
-                {
-                    ForDestinationMember(accessor, _allMemberOptions);
-                }
-            }
-
-            foreach (var action in TypeMapActions)
-            {
-                action(typeMap);
-            }
-            foreach (var memberConfig in _memberConfigurations)
-            {
-                memberConfig.Configure(typeMap);
-            }
-            foreach (var memberConfig in _sourceMemberConfigurations)
-            {
-                memberConfig.Configure(typeMap);
-            }
-            foreach (var paramConfig in _ctorParamConfigurations)
-            {
-                paramConfig.Configure(typeMap);
-            }
-
-            if (_reverseMap != null)
-            {
-                foreach (var destProperty in typeMap.GetPropertyMaps().Where(pm => pm.IsIgnored()))
-                {
-                    _reverseMap.ForSourceMember(destProperty.DestinationProperty.Name, opt => opt.Ignore());
-                }
-                foreach (var includedDerivedType in typeMap.IncludedDerivedTypes)
-                {
-                    _reverseMap.Include(includedDerivedType.DestinationType, includedDerivedType.SourceType);
-                }
-            }
-        }
-
-    }
-}
-
+        private Func<IMemberAccessor, bool> _memberFilter;
+
+        public MappingExpression(MemberList memberList)
+        {
+            MemberList = memberList;
+            Types = new TypePair(typeof(TSource), typeof(TDestination));
+        }
+
+        public MappingExpression(MemberList memberList, Type sourceType, Type destinationType)
+        {
+            MemberList = memberList;
+            Types = new TypePair(sourceType, destinationType);
+        }
+
+        public MemberList MemberList { get; }
+        public TypePair Types { get; }
+        public Type SourceType => Types.SourceType;
+        public Type DestinationType => Types.DestinationType;
+        public ITypeMapConfiguration ReverseTypeMap => _reverseMap;
+        protected List<Action<TypeMap>> TypeMapActions { get; } = new List<Action<TypeMap>>();
+
+        protected virtual IMemberConfiguration CreateMemberConfigurationExpression<TMember>(IMemberAccessor member, Type sourceType)
+        {
+            return new MemberConfigurationExpression<TSource, TMember>(member, sourceType);
+        }
+
+        protected virtual MappingExpression<TDestination, TSource> CreateReverseMapExpression()
+        {
+            return new MappingExpression<TDestination, TSource>(MemberList.Source, DestinationType, SourceType);
+        }
+
+        public IMappingExpression<TSource, TDestination> ForMember<TMember>(Expression<Func<TDestination, TMember>> destinationMember,
+                                                                   Action<IMemberConfigurationExpression<TSource, TMember>> memberOptions)
+        {
+            var memberInfo = ReflectionHelper.FindProperty(destinationMember);
+            IMemberAccessor destProperty = memberInfo.ToMemberAccessor();
+
+            ForDestinationMember(destProperty, memberOptions);
+
+            return this;
+        }
+
+        public IMappingExpression<TSource, TDestination> ForMember(string name,
+                                                                   Action<IMemberConfigurationExpression<TSource, object>> memberOptions)
+        {
+            IMemberAccessor destMember = null;
+            var propertyInfo = DestinationType.GetProperty(name);
+            if (propertyInfo != null)
+            {
+                destMember = new PropertyAccessor(propertyInfo);
+            }
+            if (destMember == null)
+            {
+                var fieldInfo = DestinationType.GetField(name);
+                if(fieldInfo == null)
+                {
+                    throw new ArgumentOutOfRangeException(nameof(name), "Cannot find a field or property named " + name);
+                }
+                destMember = new FieldAccessor(fieldInfo);
+            }
+            ForDestinationMember(destMember, memberOptions);
+            return this;
+        }
+
+        public void ForAllOtherMembers(Action<IMemberConfigurationExpression<TSource, object>> memberOptions)
+        {
+            _allMemberOptions = memberOptions;
+            _memberFilter = m => _memberConfigurations.All(c=>c.DestinationMember.MemberInfo != m.MemberInfo);
+        }
+
+        public void ForAllMembers(Action<IMemberConfigurationExpression<TSource, object>> memberOptions)
+        {
+            _allMemberOptions = memberOptions;
+            _memberFilter = _ => true;
+        }
+
+        public IMappingExpression<TSource, TDestination> IgnoreAllPropertiesWithAnInaccessibleSetter()
+        {
+            var properties = DestinationType.GetDeclaredProperties().Where(pm => pm.HasAnInaccessibleSetter());
+            foreach (var property in properties)
+                ForMember(property.Name, opt => opt.Ignore());
+            return this;
+        }
+
+        public IMappingExpression<TSource, TDestination> IgnoreAllSourcePropertiesWithAnInaccessibleSetter()
+        {
+            var properties = SourceType.GetDeclaredProperties().Where(pm => pm.HasAnInaccessibleSetter());
+            foreach (var property in properties)
+                ForSourceMember(property.Name, opt => opt.Ignore());
+            return this;
+        }
+
+        public IMappingExpression<TSource, TDestination> Include<TOtherSource, TOtherDestination>()
+            where TOtherSource : TSource
+            where TOtherDestination : TDestination
+        {
+            return Include(typeof(TOtherSource), typeof(TOtherDestination));
+        }
+
+        public IMappingExpression<TSource, TDestination> Include(Type otherSourceType, Type otherDestinationType)
+        {
+            TypeMapActions.Add(tm => tm.IncludeDerivedTypes(otherSourceType, otherDestinationType));
+
+            return this;
+        }
+
+        public IMappingExpression<TSource, TDestination> IncludeBase<TSourceBase, TDestinationBase>()
+        {
+            return IncludeBase(typeof(TSourceBase), typeof(TDestinationBase));
+        }
+
+        public IMappingExpression<TSource, TDestination> IncludeBase(Type sourceBase, Type destinationBase)
+        {
+            TypeMapActions.Add(tm => tm.IncludeBaseTypes(sourceBase, destinationBase));
+
+            return this;
+        }
+
+        public void ProjectUsing(Expression<Func<TSource, TDestination>> projectionExpression)
+        {
+            TypeMapActions.Add(tm => tm.UseCustomProjection(projectionExpression));
+
+            ConvertUsing(projectionExpression.Compile());
+        }
+
+        public IMappingExpression<TSource, TDestination> MaxDepth(int depth)
+        {
+            TypeMapActions.Add(tm => tm.MaxDepth = depth);
+
+            return this;
+        }
+
+        public IMappingExpression<TSource, TDestination> ConstructUsingServiceLocator()
+        {
+            TypeMapActions.Add(tm => tm.ConstructDestinationUsingServiceLocator = true);
+
+            return this;
+        }
+
+        public IMappingExpression<TDestination, TSource> ReverseMap()
+        {
+            var mappingExpression = CreateReverseMapExpression();
+
+            _reverseMap = mappingExpression;
+
+            return mappingExpression;
+        }
+
+        public IMappingExpression<TSource, TDestination> ForSourceMember(Expression<Func<TSource, object>> sourceMember, Action<ISourceMemberConfigurationExpression> memberOptions)
+        {
+            var memberInfo = ReflectionHelper.FindProperty(sourceMember);
+
+            var srcConfig = new SourceMappingExpression(memberInfo);
+
+            memberOptions(srcConfig);
+
+            _sourceMemberConfigurations.Add(srcConfig);
+
+            return this;
+        }
+
+        public IMappingExpression<TSource, TDestination> ForSourceMember(string sourceMemberName, Action<ISourceMemberConfigurationExpression> memberOptions)
+        {
+            var memberInfo = SourceType.GetMember(sourceMemberName).First();
+
+            var srcConfig = new SourceMappingExpression(memberInfo);
+
+            memberOptions(srcConfig);
+
+            _sourceMemberConfigurations.Add(srcConfig);
+
+            return this;
+        }
+
+        public IMappingExpression<TSource, TDestination> Substitute(Func<TSource, object> substituteFunc)
+        {
+            TypeMapActions.Add(tm => tm.Substitution = src => substituteFunc((TSource) src));
+
+            return this;
+        }
+
+        public void ConvertUsing(Func<TSource, TDestination> mappingFunction)
+        {
+            TypeMapActions.Add(tm => tm.UseCustomMapper((source, ctxt) => mappingFunction((TSource) source)));
+        }
+
+        public void ConvertUsing(Func<TSource, ResolutionContext, TDestination> mappingFunction)
+        {
+            TypeMapActions.Add(tm => tm.UseCustomMapper((source, ctxt) => mappingFunction((TSource) source, ctxt)));
+        }
+
+        public void ConvertUsing(ITypeConverter<TSource, TDestination> converter)
+        {
+            ConvertUsing(converter.Convert);
+        }
+
+        public void ConvertUsing<TTypeConverter>() where TTypeConverter : ITypeConverter<TSource, TDestination>
+        {
+            var converter = new DeferredInstantiatedConverter<TSource, TDestination>(typeof(TTypeConverter).BuildCtor<ITypeConverter<TSource, TDestination>>());
+
+            ConvertUsing(converter.Convert);
+        }
+
+        public IMappingExpression<TSource, TDestination> BeforeMap(Action<TSource, TDestination> beforeFunction)
+        {
+            TypeMapActions.Add(tm => tm.AddBeforeMapAction((src, dest, ctxt) => beforeFunction((TSource)src, (TDestination)dest)));
+
+            return this;
+        }
+
+        public IMappingExpression<TSource, TDestination> BeforeMap(Action<TSource, TDestination, ResolutionContext> beforeFunction)
+        {
+            TypeMapActions.Add(tm => tm.AddBeforeMapAction((src, dest, ctxt) => beforeFunction((TSource)src, (TDestination)dest, ctxt)));
+
+            return this;
+        }
+
+        public IMappingExpression<TSource, TDestination> BeforeMap<TMappingAction>() where TMappingAction : IMappingAction<TSource, TDestination>
+        {
+            Action<TSource, TDestination, ResolutionContext> beforeFunction = (src, dest, ctxt) =>
+                ((TMappingAction)ctxt.Options.ServiceCtor(typeof(TMappingAction))).Process(src, dest);
+
+            return BeforeMap(beforeFunction);
+        }
+
+        public IMappingExpression<TSource, TDestination> AfterMap(Action<TSource, TDestination> afterFunction)
+        {
+            TypeMapActions.Add(tm => tm.AddAfterMapAction((src, dest, ctxt) => afterFunction((TSource)src, (TDestination)dest)));
+
+            return this;
+        }
+
+        public IMappingExpression<TSource, TDestination> AfterMap(Action<TSource, TDestination, ResolutionContext> afterFunction)
+        {
+            TypeMapActions.Add(tm => tm.AddAfterMapAction((src, dest, ctxt) => afterFunction((TSource)src, (TDestination)dest, ctxt)));
+
+            return this;
+        }
+
+        public IMappingExpression<TSource, TDestination> AfterMap<TMappingAction>() where TMappingAction : IMappingAction<TSource, TDestination>
+        {
+            Action<TSource, TDestination, ResolutionContext> afterFunction = (src, dest, ctxt)
+                => ((TMappingAction)ctxt.Options.ServiceCtor(typeof(TMappingAction))).Process(src, dest);
+
+            return AfterMap(afterFunction);
+        }
+
+        public IMappingExpression<TSource, TDestination> ConstructUsing(Func<TSource, TDestination> ctor)
+        {
+            return ConstructUsing(ctxt => ctor((TSource)ctxt.SourceValue));
+        }
+
+        public IMappingExpression<TSource, TDestination> ConstructUsing(Func<ResolutionContext, TDestination> ctor)
+        {
+            TypeMapActions.Add(tm => tm.DestinationCtor = ctxt => ctor(ctxt));
+
+            return this;
+        }
+
+        public IMappingExpression<TSource, TDestination> ConstructProjectionUsing(Expression<Func<TSource, TDestination>> ctor)
+        {
+            var func = ctor.Compile();
+
+            TypeMapActions.Add(tm => tm.ConstructExpression = ctor);
+
+            return ConstructUsing(ctxt => func((TSource)ctxt.SourceValue));
+        }
+
+        private void ForDestinationMember<TMember>(IMemberAccessor destinationProperty, Action<IMemberConfigurationExpression<TSource, TMember>> memberOptions)
+        {
+            var expression = (MemberConfigurationExpression<TSource, TMember>) CreateMemberConfigurationExpression<TMember>(destinationProperty, SourceType);
+
+            _memberConfigurations.Add(expression);
+
+            memberOptions(expression);
+        }
+
+        public void As<T>()
+        {
+            TypeMapActions.Add(tm => tm.DestinationTypeOverride = typeof(T));
+        }
+
+        public IMappingExpression<TSource, TDestination> ForCtorParam(string ctorParamName, Action<ICtorParamConfigurationExpression<TSource>> paramOptions)
+        {
+            var ctorParamExpression = new CtorParamConfigurationExpression<TSource>(ctorParamName);
+
+            paramOptions(ctorParamExpression);
+
+            _ctorParamConfigurations.Add(ctorParamExpression);
+
+            return this;
+        }
+
+        public void Configure(IProfileConfiguration profile, TypeMap typeMap)
+        {
+            foreach (var destProperty in typeMap.DestinationTypeDetails.PublicWriteAccessors)
+            {
+                var attrs = destProperty.GetCustomAttributes(true);
+                if (attrs.Any(x => x is IgnoreMapAttribute))
+                {
+                    ForMember(destProperty.Name, y => y.Ignore());
+                    _reverseMap?.ForMember(destProperty.Name, opt => opt.Ignore());
+                }
+                if (profile.GlobalIgnores.Contains(destProperty.Name))
+                {
+                    ForMember(destProperty.Name, y => y.Ignore());
+                }
+            }
+
+            if (_allMemberOptions != null)
+            {
+                foreach (var accessor in typeMap.DestinationTypeDetails.PublicReadAccessors.Select(m=>m.ToMemberAccessor()).Where(_memberFilter))
+                {
+                    ForDestinationMember(accessor, _allMemberOptions);
+                }
+            }
+
+            foreach (var action in TypeMapActions)
+            {
+                action(typeMap);
+            }
+            foreach (var memberConfig in _memberConfigurations)
+            {
+                memberConfig.Configure(typeMap);
+            }
+            foreach (var memberConfig in _sourceMemberConfigurations)
+            {
+                memberConfig.Configure(typeMap);
+            }
+            foreach (var paramConfig in _ctorParamConfigurations)
+            {
+                paramConfig.Configure(typeMap);
+            }
+
+            if (_reverseMap != null)
+            {
+                foreach (var destProperty in typeMap.GetPropertyMaps().Where(pm => pm.IsIgnored()))
+                {
+                    _reverseMap.ForSourceMember(destProperty.DestinationProperty.Name, opt => opt.Ignore());
+                }
+                foreach (var includedDerivedType in typeMap.IncludedDerivedTypes)
+                {
+                    _reverseMap.Include(includedDerivedType.DestinationType, includedDerivedType.SourceType);
+                }
+            }
+        }
+
+    }
+}
+


Small improvement to the generated graphic pack

--- src/Budford/Control/CemuSettings.cs
+++ src/Budford/Control/CemuSettings.cs
@@ -716,8 +716,10 @@
             sb.Append("$height = " + height + "\r\n");
             sb.Append("$gameWidth = " + gameWidth + "\r\n");
             sb.Append("$gameHeight = " + gameHeight + "\r\n");
+            sb.Append("\r\n");

             sb.Append("[TextureRedefine]\r\n");
+            sb.Append("tileModesExcluded = 0x001\r\n");
             sb.Append("width = " + gameWidth + "\r\n");
             sb.Append("height = " + gameHeight + "\r\n");
             sb.Append("overwriteWidth = ($width/$gameWidth) * " + gameWidth + "\r\n");
@@ -827,10 +829,24 @@
             {
                 if (pack.Active)
                 {
-                    FileManager.CopyFilesRecursively(new DirectoryInfo(Path.Combine("graphicsPacks", model.Settings.GraphicsPackRevision, pack.Folder)),
-                        new DirectoryInfo(Path.Combine(version.Folder, "graphicPacks", "Budford_" + packs)), false, true);
-                    pack.PackId = packs;
-                    packs++;
+                    DirectoryInfo src = new DirectoryInfo(Path.Combine("graphicsPacks", model.Settings.GraphicsPackRevision, pack.Folder));
+                    if (!src.Exists)
+                    {
+                        foreach (var dir in Directory.EnumerateDirectories("graphicsPacks"))
+                        {
+                            src = new DirectoryInfo(Path.Combine(dir, pack.Folder));
+                            if (src.Exists)
+                            {
+                                break;
+                            }
+                        }
+                    }
+                    if (src.Exists)
+                    {
+                        FileManager.CopyFilesRecursively(src, new DirectoryInfo(Path.Combine(version.Folder, "graphicPacks", "Budford_" + packs)), false, true);
+                        pack.PackId = packs;
+                        packs++;
+                    }
                 }
             }
             return packs;


Update Package Visualizer to use display name

Work Item: 1164

--- src/Dialog/Visualizer/Visualizer.cs
+++ src/Dialog/Visualizer/Visualizer.cs
@@ -42,7 +42,7 @@
                     continue;
                 }
                 // Project has packages. Add a node for it
-                nodes.Add(new DGMLNode { Name = project.GetCustomUniqueName(), Label = project.Name, Category = "Project" });
+                nodes.Add(new DGMLNode { Name = project.GetCustomUniqueName(), Label = project.GetDisplayName(), Category = "Project" });

                 var dependencies = VisitProjectPackages(nodes, links, repo);
                 var installedPackages = repo.GetPackages().Except(dependencies);


Create the strings at runtime

Create the strings at runtime

--- Iced/Intel/FormatterUtils.cs
+++ Iced/Intel/FormatterUtils.cs
@@ -38,36 +38,15 @@
 	}

 	static class FormatterUtils {
-		static readonly string[] spaceStrings = new string[] {
-			" ",
-			"  ",
-			"   ",
-			"    ",
-			"     ",
-			"      ",
-			"       ",
-			"        ",
-			"         ",
-			"          ",
-			"           ",
-			"            ",
-			"             ",
-			"              ",
-			"               ",
-			"                ",
-			"                 ",
-			"                  ",
-			"                   ",
-			"                    ",
-		};
-		static readonly string[] tabStrings = new string[] {
-			"\t",
-			"\t\t",
-			"\t\t\t",
-			"\t\t\t\t",
-			"\t\t\t\t\t",
-			"\t\t\t\t\t\t",
-		};
+		static readonly string[] spaceStrings = CreateStrings(' ', 20);
+		static readonly string[] tabStrings = CreateStrings('\t', 6);
+
+		static string[] CreateStrings(char c, int max) {
+			var strings = new string[max];
+			for (int i = 0; i < strings.Length; i++)
+				strings[i] = new string(c, i + 1);
+			return strings;
+		}

 		public static void AddTabs(FormatterOutput output, int column, int firstOperandCharIndex, int tabSize) {
 #if DEBUG


UI tweaks

UI tweaks

--- Source/CapComWindow.cs
+++ Source/CapComWindow.cs
@@ -52,22 +52,23 @@

 		protected override void Start()
 		{
-			WindowRect.x = CapCom.Instance.Settings.windowPosX;
-			WindowRect.y = CapCom.Instance.Settings.windowPosY;
+			WindowRect.x = CapCom.Settings.windowPosX;
+			WindowRect.y = CapCom.Settings.windowPosY;
+			WindowRect.yMax = WindowRect.y + CapCom.Settings.windowHeight;
 		}

 		protected override void OnDestroy()
 		{
-			CapCom.Instance.Settings.windowPosX = WindowRect.x;
-			CapCom.Instance.Settings.windowPosY = WindowRect.y;
-			CapCom.Instance.Settings.Save();
+			CapCom.Settings.windowPosX = WindowRect.x;
+			CapCom.Settings.windowPosY = WindowRect.y;
+			CapCom.Settings.Save();
 		}

 		protected override void Update()
 		{
 			if (WindowRect.Contains(Input.mousePosition))
 			{
-				if (Input.GetKeyDown(CapCom.Instance.Settings.scrollUp))
+				if (Input.GetKeyDown(CapCom.Settings.scrollUp))
 				{
 					if (currentContracts.Count > 0)
 					{
@@ -89,7 +90,7 @@
 						showAgency = false;
 					}
 				}
-				if (Input.GetKeyDown(CapCom.Instance.Settings.scrollDown))
+				if (Input.GetKeyDown(CapCom.Settings.scrollDown))
 				{
 					if (currentContracts.Count > 0)
 					{
@@ -111,7 +112,7 @@
 						showAgency = false;
 					}
 				}
-				if (Input.GetKeyDown(CapCom.Instance.Settings.listRight))
+				if (Input.GetKeyDown(CapCom.Settings.listRight))
 				{
 					if (currentList < 2)
 						currentList += 1;
@@ -133,7 +134,7 @@
 						showAgency = false;
 					}
 				}
-				if (Input.GetKeyDown(CapCom.Instance.Settings.listLeft))
+				if (Input.GetKeyDown(CapCom.Settings.listLeft))
 				{
 					if (currentList > 0)
 						currentList -= 1;
@@ -155,7 +156,7 @@
 						showAgency = false;
 					}
 				}
-				if (Input.GetKeyDown(CapCom.Instance.Settings.accept))
+				if (Input.GetKeyDown(CapCom.Settings.accept))
 				{
 					if (currentContract == null)
 						return;
@@ -165,14 +166,14 @@

 					currentContract.Root.Accept();
 				}
-				if (Input.GetKeyDown(CapCom.Instance.Settings.cancel))
+				if (Input.GetKeyDown(CapCom.Settings.cancel))
 				{
 					if (currentContract == null)
 						return;

 					if (currentContract.Root.ContractState == Contract.State.Offered)
 					{
-						if (CapCom.Instance.Settings.showDeclineWarning)
+						if (CapCom.Settings.showDeclineWarning)
 						{
 							dropdown = true;
 							warnDecline = true;
@@ -182,7 +183,7 @@
 					}
 					else if (currentContract.Root.ContractState == Contract.State.Active)
 					{
-						if (CapCom.Instance.Settings.showCancelWarning)
+						if (CapCom.Settings.showCancelWarning)
 						{
 							dropdown = true;
 							warnCancel = true;
@@ -227,25 +228,25 @@

 		private void sortContracts(List<CapComContract> ccList)
 		{
-			switch (CapCom.Instance.Settings.sortMode)
+			switch (CapCom.Settings.sortMode)
 			{
 				case 0:
-					ccList.Sort((a, b) => RUIutils.SortAscDescPrimarySecondary(CapCom.Instance.Settings.ascending, a.Root.Prestige.CompareTo(b.Root.Prestige), a.Name.CompareTo(b.Name)));
+					ccList.Sort((a, b) => RUIutils.SortAscDescPrimarySecondary(CapCom.Settings.ascending, a.Root.Prestige.CompareTo(b.Root.Prestige), a.Name.CompareTo(b.Name)));
 					break;
 				case 1:
-					ccList.Sort((a, b) => RUIutils.SortAscDescPrimarySecondary(CapCom.Instance.Settings.ascending, a.TotalReward.CompareTo(b.TotalReward), a.Name.CompareTo(b.Name)));
+					ccList.Sort((a, b) => RUIutils.SortAscDescPrimarySecondary(CapCom.Settings.ascending, a.TotalReward.CompareTo(b.TotalReward), a.Name.CompareTo(b.Name)));
 					break;
 				case 2:
-					ccList.Sort((a, b) => RUIutils.SortAscDescPrimarySecondary(CapCom.Instance.Settings.ascending, a.TotalSciReward.CompareTo(b.TotalSciReward), a.Name.CompareTo(b.Name)));
+					ccList.Sort((a, b) => RUIutils.SortAscDescPrimarySecondary(CapCom.Settings.ascending, a.TotalSciReward.CompareTo(b.TotalSciReward), a.Name.CompareTo(b.Name)));
 					break;
 				case 3:
-					ccList.Sort((a, b) => RUIutils.SortAscDescPrimarySecondary(CapCom.Instance.Settings.ascending, a.TotalRepReward.CompareTo(b.TotalRepReward), a.Name.CompareTo(b.Name)));
+					ccList.Sort((a, b) => RUIutils.SortAscDescPrimarySecondary(CapCom.Settings.ascending, a.TotalRepReward.CompareTo(b.TotalRepReward), a.Name.CompareTo(b.Name)));
 					break;
 				case 4:
-					ccList.Sort((a, b) => RUIutils.SortAscDescPrimarySecondary(CapCom.Instance.Settings.ascending, a.TotalPenalty.CompareTo(b.TotalPenalty), a.Name.CompareTo(b.Name)));
+					ccList.Sort((a, b) => RUIutils.SortAscDescPrimarySecondary(CapCom.Settings.ascending, a.TotalPenalty.CompareTo(b.TotalPenalty), a.Name.CompareTo(b.Name)));
 					break;
 				default:
-					ccList.Sort((a, b) => RUIutils.SortAscDescPrimarySecondary(CapCom.Instance.Settings.ascending, a.Root.Prestige.CompareTo(b.Root.Prestige), a.Name.CompareTo(b.Name)));
+					ccList.Sort((a, b) => RUIutils.SortAscDescPrimarySecondary(CapCom.Settings.ascending, a.Root.Prestige.CompareTo(b.Root.Prestige), a.Name.CompareTo(b.Name)));
 					break;
 			}

@@ -379,7 +380,7 @@

 		private void closeButton(int id)
 		{
-			Rect r = new Rect(WindowRect.width - 50, 1, 18, 18);
+			Rect r = new Rect(WindowRect.width - 50, 1, 20, 20);
 			if (GUI.Button(r, CapComSkins.settingsIcon, CapComSkins.textureButton))
 			{
 				if (settings == null)
@@ -408,8 +409,8 @@
 				GUILayout.Space(10);
 				if (GUILayout.Button("Asc/Desc", CapComSkins.tabButton, GUILayout.Width(70)))
 				{
-					CapCom.Instance.Settings.ascending = !CapCom.Instance.Settings.ascending;
-					CapCom.Instance.Settings.Save();
+					CapCom.Settings.ascending = !CapCom.Settings.ascending;
+					CapCom.Settings.Save();
 					sortContracts();
 				}
 				GUILayout.FlexibleSpace();
@@ -517,7 +518,7 @@
 					GUILayout.FlexibleSpace();
 					if (GUILayout.Button("Decline", CapComSkins.tabButton, GUILayout.Width(90)))
 					{
-						if (CapCom.Instance.Settings.showDeclineWarning)
+						if (CapCom.Settings.showDeclineWarning)
 						{
 							dropdown = true;
 							warnDecline = true;
@@ -535,7 +536,7 @@
 					GUILayout.FlexibleSpace();
 					if (GUILayout.Button("Cancel", CapComSkins.tabButton, GUILayout.Width(90)))
 					{
-						if (CapCom.Instance.Settings.showCancelWarning)
+						if (CapCom.Settings.showCancelWarning)
 						{
 							dropdown = true;
 							warnCancel = true;
@@ -618,7 +619,7 @@
 			GUILayout.Label("Briefing:", CapComSkins.headerText, GUILayout.Width(80));

 			//Display current contract info
-			if (!CapCom.Instance.Settings.hideBriefing)
+			if (!CapCom.Settings.hideBriefing)
 			{
 				GUILayout.Label(currentContract.Briefing, CapComSkins.briefingText);
 			}
@@ -657,17 +658,17 @@
 			{
 				GUILayout.Label("Mission Notes: ", CapComSkins.headerText, GUILayout.Width(100));

-				if (CapCom.Instance.Settings.hideNotes)
+				if (CapCom.Settings.hideNotes)
 				{
 					Rect r = GUILayoutUtility.GetLastRect();
 					r.x += 120;
-					r.width = 12;
-					r.height = 14;
+					r.width = 13;
+					r.height = 16;
 					if (GUI.Button(r, currentContract.ShowNotes ? CapComSkins.notesMinusIcon : CapComSkins.notesPlusIcon, CapComSkins.textureButton))
 						currentContract.ShowNotes = !currentContract.ShowNotes;
 				}

-				if (!CapCom.Instance.Settings.hideNotes || currentContract.ShowNotes)
+				if (!CapCom.Settings.hideNotes || currentContract.ShowNotes)
 					GUILayout.Label(currentContract.Notes, CapComSkins.noteText);
 			}

@@ -743,37 +744,41 @@
 			bool notes = !string.IsNullOrEmpty(cp.Notes);

 			GUILayout.BeginHorizontal();
-				if (notes && CapCom.Instance.Settings.hideNotes)
-					GUILayout.Space(28 + cp.Level * 3);
+				if (notes && CapCom.Settings.hideNotes)
+					GUILayout.Space(30 + cp.Level * 3);
 				else
 					GUILayout.Space(16 + cp.Level * 3);

 				GUILayout.BeginVertical();
 					GUILayout.Label(cp.Name, CapComSkins.parameterText);
 					Rect b = GUILayoutUtility.GetLastRect();
-					b.y += 4;
-					b.height = 10;
-					if (notes && CapCom.Instance.Settings.hideNotes)
-					{
-						b.x -= 26;
-						b.width = 8;
+
+					if (notes && CapCom.Settings.hideNotes)
+					{
+						b.x -= 28;
+						b.height = 16;
+						b.width = 13;
 						if (GUI.Button(b, cp.ShowNotes ? CapComSkins.notesMinusIcon :CapComSkins.notesPlusIcon, CapComSkins.textureButton))
 							cp.ShowNotes = !cp.ShowNotes;

-						b.x += 14;
+						b.y += 4;
+						b.x += 16;
+						b.height = 10;
 						b.width = 10;
 						GUI.DrawTexture(b, parameterStateIcon(cp.Param));
 					}
 					else
 					{
 						b.x -= 14;
+						b.y += 4;
+						b.height = 10;
 						b.width = 10;
 						GUI.DrawTexture(b, parameterStateIcon(cp.Param));
 					}

 					if (notes)
 					{
-						if (!CapCom.Instance.Settings.hideNotes || cp.ShowNotes)
+						if (!CapCom.Settings.hideNotes || cp.ShowNotes)
 							GUILayout.Label(cp.Notes, CapComSkins.noteText);
 					}

@@ -883,8 +888,8 @@
 				{
 					resizing = false;
 					WindowRect.yMax = WindowRect.y + dH;
-					CapCom.Instance.Settings.windowHeight = WindowRect.height;
-					CapCom.Instance.Settings.Save();
+					CapCom.Settings.windowHeight = WindowRect.height;
+					CapCom.Settings.Save();
 				}
 				else
 				{
@@ -920,8 +925,8 @@
 						r.y += 22;
 						if (GUI.Button(r, sortName(i), CapComSkins.menuButton))
 						{
-							CapCom.Instance.Settings.sortMode = i;
-							CapCom.Instance.Settings.Save();
+							CapCom.Settings.sortMode = i;
+							CapCom.Settings.Save();
 							sortContracts();
 							sortMenu = false;
 							dropdown = false;
@@ -931,12 +936,12 @@
 				}
 				else if (warnCancel)
 				{
-					ddRect = new Rect(WindowRect.width - 155, 45, 150, 70);
+					ddRect = new Rect(WindowRect.width - 165, 45, 160, 70);
 					GUI.Box(ddRect, "");
-					Rect r = new Rect(ddRect.x + 10, ddRect.y + 5, 130, 30);
-					GUI.Label(r, "Cancel this contract?");
-					r = new Rect(ddRect.x + 35, ddRect.y + 30, 80, 30);
-					if (GUI.Button(r, "Confirm"))
+					Rect r = new Rect(ddRect.x + 10, ddRect.y + 5, 140, 30);
+					GUI.Label(r, "Cancel this contract?", CapComSkins.warningText);
+					r = new Rect(ddRect.x + 40, ddRect.y + 30, 80, 30);
+					if (GUI.Button(r, "Confirm", CapComSkins.warningButton))
 					{
 						currentContract.Root.Cancel();
 						warnCancel = false;
@@ -945,12 +950,12 @@
 				}
 				else if (warnDecline)
 				{
-					ddRect = new Rect(WindowRect.width - 155, 45, 150, 70);
+					ddRect = new Rect(WindowRect.width - 165, 45, 160, 70);
 					GUI.Box(ddRect, "");
-					Rect r = new Rect(ddRect.x + 10, ddRect.y + 5, 130, 30);
-					GUI.Label(r, "Decline this contract?");
-					r = new Rect(ddRect.x + 35, ddRect.y + 30, 80, 30);
-					if (GUI.Button(r, "Confirm"))
+					Rect r = new Rect(ddRect.x + 10, ddRect.y + 5, 140, 30);
+					GUI.Label(r, "Decline this contract?", CapComSkins.warningText);
+					r = new Rect(ddRect.x + 40, ddRect.y + 30, 80, 30);
+					if (GUI.Button(r, "Confirm", CapComSkins.warningButton))
 					{
 						currentContract.Root.Decline();
 						warnDecline = false;
@@ -1033,7 +1038,7 @@
 				case ParameterState.Complete:
 					return CapComSkins.checkBox;
 				case ParameterState.Incomplete:
-					return CapComSkins.checkBox;
+					return CapComSkins.emptyBox;
 				default:
 					return CapComSkins.failBox;
 			}


unreachable code leftover

unreachable code leftover

--- Source/SODA/SodaUri.cs
+++ Source/SODA/SodaUri.cs
@@ -62,8 +62,6 @@
             string url = String.Format("{0}?page={1}", metadataUrl(socrataHost), page);

             return new Uri(url);
-
-            return default(Uri);
         }

         /// <summary>


Fix issue #39

Fix issue #39

--- Source/fsSerializer.cs
+++ Source/fsSerializer.cs
@@ -447,7 +447,7 @@
         /// <param name="data">The serialized state of the object.</param>
         /// <returns>If serialization was successful.</returns>
         public fsResult TrySerialize(Type storageType, object instance, out fsData data) {
-            var processors = GetProcessors(storageType);
+            var processors = GetProcessors(instance == null ? storageType : instance.GetType());

             Invoke_OnBeforeSerialize(processors, storageType, instance);

@@ -566,11 +566,10 @@
         /// <param name="result"></param>
         /// <returns></returns>
         public fsResult TryDeserialize(fsData data, Type storageType, ref object result) {
-            var processors = GetProcessors(storageType);
-            Invoke_OnBeforeDeserialize(processors, storageType, ref data);
-
             if (data.IsNull) {
                 result = null;
+                var processors = GetProcessors(storageType);
+                Invoke_OnBeforeDeserialize(processors, storageType, ref data);
                 Invoke_OnAfterDeserialize(processors, storageType, null);
                 return fsResult.Success;
             }
@@ -584,15 +583,19 @@
                 // w.r.t. the list
                 _references.Enter();

-                return InternalDeserialize_1_CycleReference(data, storageType, ref result, processors);
+                List<fsObjectProcessor> processors;
+                var r = InternalDeserialize_1_CycleReference(data, storageType, ref result, out processors);
+                if (r.Succeeded) {
+                    Invoke_OnAfterDeserialize(processors, storageType, result);
+                }
+                return r;
             }
             finally {
                 _references.Exit();
-                Invoke_OnAfterDeserialize(processors, storageType, result);
-            }
-        }
-
-        private fsResult InternalDeserialize_1_CycleReference(fsData data, Type storageType, ref object result, List<fsObjectProcessor> processors) {
+            }
+        }
+
+        private fsResult InternalDeserialize_1_CycleReference(fsData data, Type storageType, ref object result, out List<fsObjectProcessor> processors) {
             // We handle object references first because we could be deserializing a cyclic type that is
             // inherited. If that is the case, then if we handle references after inheritances we will try
             // to create an object instance for an abstract/interface type.
@@ -606,13 +609,14 @@
             if (IsObjectReference(data)) {
                 int refId = int.Parse(data.AsDictionary[Key_ObjectReference].AsString);
                 result = _references.GetReferenceObject(refId);
+                processors = GetProcessors(result.GetType());
                 return fsResult.Success;
             }

-            return InternalDeserialize_2_Version(data, storageType, ref result, processors);
-        }
-
-        private fsResult InternalDeserialize_2_Version(fsData data, Type storageType, ref object result, List<fsObjectProcessor> processors) {
+            return InternalDeserialize_2_Version(data, storageType, ref result, out processors);
+        }
+
+        private fsResult InternalDeserialize_2_Version(fsData data, Type storageType, ref object result, out List<fsObjectProcessor> processors) {
             if (IsVersioned(data)) {
                 // data is versioned, but we might not need to do a migration
                 string version = data.AsDictionary[Key_Version].AsString;
@@ -626,24 +630,29 @@

                     List<fsVersionedType> path;
                     deserializeResult += fsVersionManager.GetVersionImportPath(version, versionedType.Value, out path);
+                    if (deserializeResult.Failed) {
+                        processors = GetProcessors(storageType);
+                        return deserializeResult;
+                    }
+
+                    // deserialize as the original type
+                    deserializeResult += InternalDeserialize_3_Inheritance(data, path[0].ModelType, ref result, out processors);
                     if (deserializeResult.Failed) return deserializeResult;

-                    // deserialize as the original type
-                    deserializeResult += InternalDeserialize_3_Inheritance(data, path[0].ModelType, ref result, processors);
-                    if (deserializeResult.Failed) return deserializeResult;
-
+                    // TODO: we probably should be invoking object processors all along this pipeline
                     for (int i = 1; i < path.Count; ++i) {
                         result = path[i].Migrate(result);
                     }

+                    processors = GetProcessors(deserializeResult.GetType());
                     return deserializeResult;
                 }
             }

-            return InternalDeserialize_3_Inheritance(data, storageType, ref result, processors);
-        }
-
-        private fsResult InternalDeserialize_3_Inheritance(fsData data, Type storageType, ref object result, List<fsObjectProcessor> processors) {
+            return InternalDeserialize_3_Inheritance(data, storageType, ref result, out processors);
+        }
+
+        private fsResult InternalDeserialize_3_Inheritance(fsData data, Type storageType, ref object result, out List<fsObjectProcessor> processors) {
             var deserializeResult = fsResult.Success;

             Type objectType = storageType;
@@ -677,6 +686,12 @@
                 } while (false);
             }

+            // We wait until here to actually Invoke_OnBeforeDeserialize because we do not
+            // have the correct set of processors to invoke until *after* we have resolved
+            // the proper type to use for deserialization.
+            processors = GetProcessors(storageType);
+            Invoke_OnBeforeDeserialize(processors, storageType, ref data);
+
             // Construct an object instance if we don't have one already. We also need to construct
             // an instance if the result type is of the wrong type, which may be the case when we
             // have a versioned import graph.


完善递增(减)的步长结构。 :ribbon:

完善递增(减)的步长结构。 :ribbon:

--- src/Data/Interval.cs
+++ src/Data/Interval.cs
@@ -32,36 +32,43 @@
  */

 using System;
-using System.Collections.Generic;

 namespace Zongsoft.Data
 {
 	///
-	/// 表示数据写入的递增(减)的数据量。
+	/// 表示数据写入的递增(减)的步长值。
 	///
-	public struct Interval : IEquatable<Interval>
+	public struct Interval : IConvertible, IComparable<Interval>, IEquatable<Interval>
 	{
+		#region 静态字段
+		/// 表示递增一的步长。
+		public static readonly Interval Increment = new Interval(1);
+
+		/// 表示递减一的步长。
+		public static readonly Interval Decrement = new Interval(-1);
+		#endregion
+
 		#region 公共字段
 		/// 递增(减)的步长值。
 		public readonly int Value;
-
-		/// 递增(减)的初始值。
-		public readonly int Seed;
 		#endregion

 		#region 构造函数
-		public Interval(int value = 1, int seed = 0)
+		public Interval(int value)
 		{
 			this.Value = value;
-			this.Seed = seed;
 		}
 		#endregion

 		#region 重写方法
+		public int CompareTo(Interval other)
+		{
+			return this.Value.CompareTo(other.Value);
+		}
+
 		public bool Equals(Interval other)
 		{
-			return this.Value == other.Value &&
-			       this.Seed == other.Seed;
+			return this.Value == other.Value;
 		}

 		public override bool Equals(object obj)
@@ -74,12 +81,106 @@

 		public override int GetHashCode()
 		{
-			return EqualityComparer<Interval>.Default.GetHashCode(this);
+			return this.Value.GetHashCode();
+		}
+		#endregion
+
+		#region 转换方法
+		public TypeCode GetTypeCode()
+		{
+			return this.Value.GetTypeCode();
 		}

-		public override string ToString()
+		object IConvertible.ToType(Type conversionType, IFormatProvider provider)
 		{
-			return this.Value.ToString() + "/" + this.Seed.ToString();
+			return ((IConvertible)Value).ToType(conversionType, provider);
+		}
+
+		bool IConvertible.ToBoolean(IFormatProvider provider)
+		{
+			return ((IConvertible)Value).ToBoolean(provider);
+		}
+
+		byte IConvertible.ToByte(IFormatProvider provider)
+		{
+			return ((IConvertible)Value).ToByte(provider);
+		}
+
+		char IConvertible.ToChar(IFormatProvider provider)
+		{
+			return ((IConvertible)Value).ToChar(provider);
+		}
+
+		DateTime IConvertible.ToDateTime(IFormatProvider provider)
+		{
+			return ((IConvertible)Value).ToDateTime(provider);
+		}
+
+		decimal IConvertible.ToDecimal(IFormatProvider provider)
+		{
+			return ((IConvertible)Value).ToDecimal(provider);
+		}
+
+		double IConvertible.ToDouble(IFormatProvider provider)
+		{
+			return ((IConvertible)Value).ToDouble(provider);
+		}
+
+		short IConvertible.ToInt16(IFormatProvider provider)
+		{
+			return ((IConvertible)Value).ToInt16(provider);
+		}
+
+		int IConvertible.ToInt32(IFormatProvider provider)
+		{
+			return ((IConvertible)Value).ToInt32(provider);
+		}
+
+		long IConvertible.ToInt64(IFormatProvider provider)
+		{
+			return ((IConvertible)Value).ToInt64(provider);
+		}
+
+		sbyte IConvertible.ToSByte(IFormatProvider provider)
+		{
+			return ((IConvertible)Value).ToSByte(provider);
+		}
+
+		float IConvertible.ToSingle(IFormatProvider provider)
+		{
+			return ((IConvertible)Value).ToSingle(provider);
+		}
+
+		string IConvertible.ToString(IFormatProvider provider)
+		{
+			return Value.ToString(provider);
+		}
+
+		ushort IConvertible.ToUInt16(IFormatProvider provider)
+		{
+			return ((IConvertible)Value).ToUInt16(provider);
+		}
+
+		uint IConvertible.ToUInt32(IFormatProvider provider)
+		{
+			return ((IConvertible)Value).ToUInt32(provider);
+		}
+
+		ulong IConvertible.ToUInt64(IFormatProvider provider)
+		{
+			return ((IConvertible)Value).ToUInt64(provider);
+		}
+		#endregion
+
+		#region 类型转换
+		public static implicit operator int(Interval interval)
+		{
+			return interval.Value;
+		}
+
+		public static implicit operator Interval(int value)
+		{
+			return new Interval(value);
 		}
 		#endregion
 	}


EILib: remove trash from MprFile

EILib: remove trash from MprFile

--- src/EILib/MprFile.cs
+++ src/EILib/MprFile.cs
@@ -82,15 +82,7 @@
             {
                 using (var res = new ResFile(f))
                 {
-                    string zoneName = Path.GetFileNameWithoutExtension(path);
-
-                    Materials[1].A = 1;
-                    Materials[1].R = 1;
-                    Materials[1].G = 1;
-                    Materials[1].B = 1;
-
                     var mpFile = new MpFile();
-
                     mpFile.Materials = new MpMaterial[Materials.Length];
                     for (int i = 0; i < Materials.Length; i++)
                         mpFile.Materials[i] = Materials[i].ToMpMaterial();
@@ -115,6 +107,7 @@
                         AnimTilesCount = (uint)this.AnimTiles.Length
                     };

+                    string zoneName = Path.GetFileNameWithoutExtension(path);
                     res.AddFile(zoneName + ".mp", DateTime.Now);
                     SaveMpFile(f, mpFile);


Remove `ArchiveFileModel.Files` because it does not contain all files.

--- shared/SevenZip/ArchiveFileModel.cs
+++ shared/SevenZip/ArchiveFileModel.cs
@@ -15,10 +15,10 @@
         /// The metadata of the archive.
         public ArchiveMetadata Metadata { get; }

+        /// The hierarchic structure of files and folders within the archive.
         public ArchivedFolder RootFolder { get; }

-        public ImmutableList<ArchivedFile> Files { get; }
-
+        private readonly ImmutableList<ArchivedFile> mSectionFiles;
         private readonly ImmutableArray<int> mSections;

         internal ArchiveFileModel(ArchiveMetadata metadata, ArchivedFolder rootFolder, ImmutableArray<int> sections, ImmutableList<ArchivedFile> files)
@@ -40,10 +40,15 @@

             this.Metadata = metadata;
             this.RootFolder = rootFolder;
-            this.Files = files;
+            this.mSectionFiles = files;
             this.mSections = sections;
         }

+        ///
+        /// Returns file metadata for the given decoder section.
+        /// The returned list may contain null entries when the corresponding stream should not be written to a file.
+        ///
+        /// <param name="sectionIndex">The decoder section for which files should be returned.</param>
         public ImmutableList<ArchivedFile> GetFilesInSection(int sectionIndex)
         {
             if (sectionIndex < 0 || sectionIndex >= Metadata.DecoderSections.Length)
@@ -51,7 +56,7 @@

             var offset = mSections[sectionIndex];
             var length = mSections[sectionIndex + 1] - offset;
-            return Files.GetRange(offset, length);
+            return mSectionFiles.GetRange(offset, length);
         }
     }


Small cleanups on formatting.

Small cleanups on formatting.

svn path=/trunk/; revision=3165

--- src/Preferences.cs
+++ src/Preferences.cs
@@ -18,9 +18,9 @@
 		public const string VIEWER_MAXIMIZED = "/apps/f-spot/ui/viewer_maximized";
 		public const string VIEWER_SHOW_TOOLBAR = "/apps/f-spot/ui/viewer_show_toolbar";
 		public const string VIEWER_SHOW_FILENAMES = "/apps/f-spot/ui/viewer_show_filenames";
- 		public const string VIEWER_INTERPOLATION = "/apps/f-spot/viewer/interpolation";
- 		public const string VIEWER_TRANS_COLOR = "/apps/f-spot/viewer/trans_color";
- 		public const string VIEWER_TRANSPARENCY = "/apps/f-spot/viewer/transparency";
+		public const string VIEWER_INTERPOLATION = "/apps/f-spot/viewer/interpolation";
+		public const string VIEWER_TRANS_COLOR = "/apps/f-spot/viewer/trans_color";
+		public const string VIEWER_TRANSPARENCY = "/apps/f-spot/viewer/transparency";

 		public const string SHOW_TOOLBAR = "/apps/f-spot/ui/show_toolbar";
 		public const string SHOW_SIDEBAR = "/apps/f-spot/ui/show_sidebar";
@@ -47,9 +47,9 @@
 		public const string EXPORT_FLICKR_FRIENDS = "/apps/f-spot/export/flickr/friends";
 		public const string EXPORT_FLICKR_FAMILY = "/apps/f-spot/export/flickr/family";

-		public const string EXPORT_TOKEN_FLICKR ="/apps/f-spot/export/tokens/flickr";
-		public const string EXPORT_TOKEN_23HQ ="/apps/f-spot/export/tokens/23hq";
-		public const string EXPORT_TOKEN_ZOOOMR ="/apps/f-spot/export/tokens/zooomr";
+		public const string EXPORT_TOKEN_FLICKR = "/apps/f-spot/export/tokens/flickr";
+		public const string EXPORT_TOKEN_23HQ = "/apps/f-spot/export/tokens/23hq";
+		public const string EXPORT_TOKEN_ZOOOMR = "/apps/f-spot/export/tokens/zooomr";

 		public const string EXPORT_GALLERY_SCALE = "/apps/f-spot/export/gallery/scale";
 		public const string EXPORT_GALLERY_SIZE = "/apps/f-spot/export/gallery/size";
@@ -76,9 +76,9 @@
 		public const string EXPORT_FOLDER_SHARPEN = "/apps/f-spot/export/folder/sharpen";
 		public const string EXPORT_FOLDER_INCLUDE_TARBALLS = "/apps/f-spot/export/folder/include_tarballs";

- 		public const string EXPORT_EMAIL_SIZE = "/apps/f-spot/export/email/size";
- 		public const string EXPORT_EMAIL_ROTATE = "/apps/f-spot/export/email/auto_rotate";
- 		public const string EXPORT_EMAIL_DELETE_TIMEOUT_SEC = "/apps/f-spot/export/email/delete_timeout_seconds";
+		public const string EXPORT_EMAIL_SIZE = "/apps/f-spot/export/email/size";
+		public const string EXPORT_EMAIL_ROTATE = "/apps/f-spot/export/email/auto_rotate";
+		public const string EXPORT_EMAIL_DELETE_TIMEOUT_SEC = "/apps/f-spot/export/email/delete_timeout_seconds";

 		public const string IMPORT_GUI_ROLL_HISTORY = "/apps/f-spot/import/gui_roll_history";


AppKitConstants seems to be missing in Xamarin.Mac Latest?

--- Splat/Cocoa/Bitmaps.cs
+++ Splat/Cocoa/Bitmaps.cs
@@ -2,6 +2,7 @@
 using System.IO;
 using System.Threading;
 using System.Threading.Tasks;
+using System.Drawing;

 #if UIKIT
 using MonoTouch.UIKit;
@@ -76,7 +77,7 @@

                 var props = format == CompressedBitmapFormat.Png ?
                     new NSDictionary() :
-                    new NSDictionary(new NSNumber(quality), AppKitConstants.NSImageCompressionFactor);
+                    new NSDictionary(new NSNumber(quality), new NSString("NSImageCompressionFactor"));

                 var type = format == CompressedBitmapFormat.Png ? NSBitmapImageFileType.Png : NSBitmapImageFileType.Jpeg;


:shirt: WaveWriterのコンストラクタをprotectedに変更

:shirt: WaveWriterのコンストラクタをprotectedに変更

--- src/IO/WaveWriter.cs
+++ src/IO/WaveWriter.cs
@@ -82,7 +82,7 @@
         /// <param name="bitPerSample">サンプルあたりのビット数。</param>
         /// <param name="channelCount">チャネルの数。</param>
         /// <param name="entryOffset">書き込みを開始するバイトオフセット。</param>
-        public WaveWriter(Stream stream, int samplingRate, int bitPerSample, int channelCount, long entryOffset = 0L)
+        protected WaveWriter(Stream stream, int samplingRate, int bitPerSample, int channelCount, long entryOffset = 0L)
         {
             if (stream == null)
                 throw new ArgumentNullException(nameof(stream));


Fixed invalid invocation of GetFolder property

--- src/ShellHelper.cs
+++ src/ShellHelper.cs
@@ -211,7 +211,7 @@
                 {
                     if (IsFolder)
                     {
-                        return new Folder(InvokeMethod("GetFolder"), Path);
+                        return new Folder(GetProperty<object>("GetFolder"), Path);
                     }

                     return null;


Document GreaterThan method

Document GreaterThan method

--- src/Library/Match.cs
+++ src/Library/Match.cs
@@ -192,6 +192,21 @@
             return Match<T>.Create(new NotEqual<T>(reference));
         }

+        /// <summary>
+        /// Creates a <see cref="Match{T}"/> instance that matches successfully when the value to match is greater than the specified <paramref name="reference"/>.
+        /// </summary>
+        /// <param name="reference">
+        /// The instance a value to match must be greater than to match successfully.
+        /// </param>
+        /// <typeparam name="T">
+        /// The type of the value to match. This type must implement the <see cref="IComparable{T}"/> interface.
+        /// </typeparam>
+        /// <returns>
+        /// A new <see cref="Match{T}"/> instance that determines whether the value to match is greater than the specified <paramref name="reference"/>.
+        /// </returns>
+        /// <exception cref="ArgumentNullException">
+        /// <paramref name="reference"/> is <c>null</c>.
+        /// </exception>
         public static Match<T> GreaterThan<T>(T reference)
             where T : IComparable<T>
         {


Implement fast path for byte[] reading

Implement fast path for byte[] reading

--- src/MessageReader.cs
+++ src/MessageReader.cs
@@ -400,6 +400,14 @@
 			uint ln;
 			GetValue (out ln);

+			//TODO: more fast paths for primitive arrays
+			if (elemType == typeof (byte)) {
+				byte[] valb = new byte[ln];
+				Array.Copy (data, pos, valb, 0, (int)ln);
+				val = valb;
+				return;
+			}
+
 			//advance to the alignment of the element
 			ReadPad (Protocol.GetAlignment (Signature.TypeToDType (elemType)));


If exceptions arent handled they are rethrown.

--- src/Zip/FastZip.cs
+++ src/Zip/FastZip.cs
@@ -570,7 +570,8 @@
 							continueRunning_ = events_.OnFileFailure(targetName, ex);
 						}
 						else {
-							continueRunning_ = false;
+                            continueRunning_ = false;
+                            throw;
 						}
 					}
 				}
@@ -593,7 +594,7 @@
 				doExtraction = !((targetName == null) || (targetName.Length == 0));
 			}

-			// TODO: Fire delegate were compression method not supported, or name is invalid?
+			// TODO: Fire delegate/throw exception were compression method not supported, or name is invalid?

 			string dirName = null;

@@ -623,6 +624,7 @@
 						}
 						else {
 							continueRunning_ = false;
+                            throw;
 						}
 					}
 				}


Change the SortBy in graphql query to be based on Title

--- webapp-net/TridionDocsMashup/Client/PublicContentApiClient.cs
+++ webapp-net/TridionDocsMashup/Client/PublicContentApiClient.cs
@@ -101,7 +101,7 @@

             var results = _publicContentApi.ExecuteItemQuery(
                 filter,
-                new InputSortParam { Order = SortOrderType.Descending, SortBy = SortFieldType.LAST_PUBLISH_DATE },
+                new InputSortParam { Order = SortOrderType.Descending, SortBy = SortFieldType.TITLE },
                 new Pagination { First = maxItems },
                 null,
                 ContentIncludeMode.IncludeJsonAndRender,


make static

--- src/Umbraco.Core/Persistence/Factories/ExternalLoginFactory.cs
+++ src/Umbraco.Core/Persistence/Factories/ExternalLoginFactory.cs
@@ -3,9 +3,9 @@

 namespace Umbraco.Core.Persistence.Factories
 {
-    internal class ExternalLoginFactory
+    internal static class ExternalLoginFactory
     {
-        public IIdentityUserLogin BuildEntity(ExternalLoginDto dto)
+        public static IIdentityUserLogin BuildEntity(ExternalLoginDto dto)
         {
             var entity = new IdentityUserLogin(dto.Id, dto.LoginProvider, dto.ProviderKey, dto.UserId, dto.CreateDate);

@@ -14,7 +14,7 @@
             return entity;
         }

-        public ExternalLoginDto BuildDto(IIdentityUserLogin entity)
+        public static ExternalLoginDto BuildDto(IIdentityUserLogin entity)
         {
             var dto = new ExternalLoginDto
             {


Read alchemyapikey from configuration manager

--- BusinessInsights/Controllers/FacebookController.cs
+++ BusinessInsights/Controllers/FacebookController.cs
@@ -1,5 +1,6 @@
 using System;
 using System.Collections.Generic;
+using System.Configuration;
 using System.Linq;
 using System.Threading.Tasks;
 using System.Web.Mvc;
@@ -25,7 +26,7 @@
         /// new AlchemyLanguageClient("0ea4a12f30bf7745d366f69a95deff2c478d6257")
         /// </summary>
         public FacebookController()
-            : this(new FacebookServiceFactory(), new MockAlchemyClient())
+            : this(new FacebookServiceFactory(), new AlchemyLanguageClient(ConfigurationManager.AppSettings["AlchemyApiKey"]))
         {

         }


Objects shared across threads are written with Interlocked.Exchange SendAsync returns exceptions wrapped in HttpRequestException instances

--- src/Brokers/RabbitMQ/RestBus.RabbitMQ/Client/RestBusClient.cs
+++ src/Brokers/RabbitMQ/RestBus.RabbitMQ/Client/RestBusClient.cs
@@ -175,9 +175,11 @@
                 //TODO: test if conn or pooler is null, then leave
                 if (conn == null || pooler == null)
                 {
-                    //TODO: This means a connection could not be created most likely because the server was Unreachable
-                    //TODO: Throw some kind of HTTP 500 (Unreachable) exception
-                    throw new ApplicationException("This is Bad");
+                    // This means a connection could not be created most likely because the server was Unreachable
+                    // and shouldn't happen because StartCallbackQueueConsumer should have thrown the exception
+
+                    //TODO: The inner exception here is a good candidate for a RestBusException
+                    throw GetWrappedException("Unable to establish a connection.", new ApplicationException("Unable to establish a connection."));
                 }

                 //TODO: Check if cancellation token was set before operation even began
@@ -221,29 +223,32 @@

                     //Message arrival event
                     HttpResponsePacket responsePacket = null;
-                    bool deserializationError = false;
+                    Exception deserializationException = null;
                     receivedEvent = new ManualResetEventSlim(false);

                     arrival = a =>
                     {
                         if (a.BasicProperties.CorrelationId == correlationId)
                         {
-                            //TODO: If deserialization failed then set exception
                             HttpResponsePacket res = null;
                             try
                             {
                                 res = HttpResponsePacket.Deserialize(a.Body);
                             }
-                            catch
+                            catch (Exception ex)
                             {
-                                deserializationError = true;
+                                Interlocked.Exchange(ref deserializationException, ex);
                             }

-                            //Add/Update Content-Length Header
-                            res.Headers["Content-Length"] = new string[]{(res.Content == null ? 0 : res.Content.Length).ToString()};;
-
-                            if (!deserializationError)
+                            if (deserializationException == null)
                             {
+                                if (res != null)
+                                {
+                                    //Add/Update Content-Length Header
+                                    res.Headers["Content-Length"] = new string[] { (res.Content == null ? 0 : res.Content.Length).ToString() }; ;
+                                }
+
+                                Interlocked.Exchange(ref responsePacket, res);
                                 responsePacket = res;
                             }
                             receivedEvent.Set();
@@ -273,25 +278,29 @@
                                     //TODO: Check Cancelation Token when it's implemented
                                     if (timedOut)
                                     {
-                                        //TODO: This should be a HTTP timed out exception;
-                                        taskSource.SetException(new ApplicationException());
+                                        //NOTE: This really ought to return an "Operation Timed Out" WebException and not a Cancellation as noted in the following posts
+                                        // http://social.msdn.microsoft.com/Forums/en-US/d8d87789-0ac9-4294-84a0-91c9fa27e353/bug-in-httpclientgetasync-should-throw-webexception-not-taskcanceledexception?forum=netfxnetcom&prof=required
+                                        // http://stackoverflow.com/questions/10547895/how-can-i-tell-when-httpclient-has-timed-out
+                                        // and http://stackoverflow.com/questions/12666922/distinguish-timeout-from-user-cancellation
+                                        //
+                                        // However, for compatibility with the HttpCLient, it returns a cancellation
+                                        //
+
+                                        taskSource.SetCanceled();
                                     }
                                     else
                                     {

-                                        //TODO: How do we ensure that response (and deserializationError) is properly seen across different threads
                                         HttpResponseMessage msg;
-                                        if (!deserializationError && responsePacket.TryGetHttpResponseMessage(out msg))
+                                        if (deserializationException == null && responsePacket.TryGetHttpResponseMessage(out msg))
                                         {
                                             msg.RequestMessage = request;
                                             taskSource.SetResult(msg);
                                         }
                                         else
                                         {
-                                            //TODO: This should be one that translates to a bad response message error
-                                            taskSource.SetException(new ApplicationException());
+                                            taskSource.SetException(GetWrappedException("An error occurred while reading the response.", deserializationException));
                                         }
-
                                     }

                                     lock (localVariableInitLock)
@@ -326,7 +335,7 @@

                 if (requestTimeout == TimeSpan.Zero)
                 {
-                    //TODO: Investigate adding a publisher confirm for zero timeout messages so we know that RabbitMQ did pick up the message before relying OK.
+                    //TODO: Investigate adding a publisher confirm for zero timeout messages so we know that RabbitMQ did pick up the message before replying OK.

                     //Zero timespan means the client isn't interested in a response
                     taskSource.SetResult(new HttpResponseMessage(System.Net.HttpStatusCode.OK) { Content = new ByteArrayContent(new byte[0]) });
@@ -339,7 +348,7 @@
                 return taskSource.Task;

             }
-            catch
+            catch (Exception ex)
             {
                 //TODO: Log this

@@ -349,8 +358,7 @@
                 }
                 CleanupMessagingResources(arrival, receivedEvent);

-                //TODO: Encapsulate this error in a HttpException
-                throw;
+                throw GetWrappedException("An error occurred while sending the request.", ex);

             }

@@ -680,17 +688,12 @@

         protected override void Dispose(bool disposing)
         {
-
-            //TODO: Work on this method
-
             //TODO: Confirm that this does in fact kill all background threads

             disposed = true;
             DisposeConnection();

             if (_clientPool != null) _clientPool.Dispose();
-
-            //TODO: Kill all channels in channel pool (if implemented)

             base.Dispose(disposing);

@@ -761,6 +764,7 @@

                     //This method waits on this signal to make sure the callbackprocessor thread either started successfully or failed.
                     ManualResetEventSlim consumerSignal = new ManualResetEventSlim(false);
+                    Exception consumerSignalException = null;

                     Thread callBackProcessor = new Thread(p =>
                     {
@@ -774,7 +778,7 @@

                             AmqpChannelPooler oldpool = _clientPool;

-                            //TODO: Is it necessary to do a CompareExchange since this is within a lock? //Yes, cos this is in a brand new thread
+                            //TODO: Is it necessary to do a CompareExchange since this is within a lock? //Yes, cos this is in a brand new thread (do this for conn object too)
                             _clientPool = new AmqpChannelPooler(conn);

                             //Dispose old pool -- after making sure new pool was assigned.
@@ -843,10 +847,12 @@

                             }
                         }
-                        catch
+                        catch (Exception ex)
                         {
                             //TODO: Log error (Except it's object disposed exception)
-                            //TODO: Set Exception object which will be throw by signal waiter
+
+                            //Set Exception object which will be throw by signal waiter
+                            Interlocked.Exchange(ref consumerSignalException, ex);

                             //Notify outer thread to move on, in case it's still waiting
                             try
@@ -877,7 +883,13 @@
                     consumerSignal.Wait();
                     consumerSignal.Dispose();

-                    //TODO: Examine exception if it were set and rethrow it
+                    //Examine exception if it were set and rethrow it
+                    if (consumerSignalException != null)
+                    {
+                        throw GetWrappedException("An error occurred while sending the request.", consumerSignalException);
+                    }
+
+                    //No more code from this point in this method

                 }
             }
@@ -961,6 +973,10 @@
             }
         }

+        private HttpRequestException GetWrappedException(string message, Exception innerException)
+        {
+            return new HttpRequestException(message, innerException);
+        }
     }


fix cloud tests

fix cloud tests

--- src/Cassandra.IntegrationTests/Cloud/CloudIntegrationTests.cs
+++ src/Cassandra.IntegrationTests/Cloud/CloudIntegrationTests.cs
@@ -150,7 +150,7 @@
             Assert.IsNotNull(Session.Cluster.Configuration.AuthProvider.GetType());
             Assert.AreEqual(typeof(PlainTextAuthProvider), Session.Cluster.Configuration.AuthProvider.GetType());
             var provider = (PlainTextAuthProvider)Session.Cluster.Configuration.AuthProvider;
-            Assert.AreEqual("cassandra", provider.Username);
+            Assert.AreEqual("user1", provider.Username);
         }

         [Test]
@@ -286,8 +286,8 @@
             Assert.IsFalse(string.IsNullOrWhiteSpace(scb.Config.CertificatePassword));
             Assert.IsTrue(scb.ClientCert.HasPrivateKey);
             Assert.AreEqual(30443, scb.Config.Port);
-            Assert.AreEqual("cassandra", scb.Config.Password);
-            Assert.AreEqual("cassandra", scb.Config.Username);
+            Assert.AreEqual("user1", scb.Config.Password);
+            Assert.AreEqual("user1", scb.Config.Username);
             Assert.AreEqual("localhost", scb.Config.Host);
         }

@@ -297,7 +297,7 @@
             var session = await CreateSessionAsync(act: b => b
                 .WithExecutionProfiles(opt => opt
                     .WithProfile("default", profile =>
-                        profile.WithConsistencyLevel(ConsistencyLevel.All))
+                        profile.WithConsistencyLevel(ConsistencyLevel.Any))
                     .WithProfile("profile", profile =>
                         profile.WithSerialConsistencyLevel(ConsistencyLevel.LocalSerial))
                     .WithDerivedProfile("derived", "profile", profile =>


Simplify nested lambda

Simplify nested lambda

--- src/Compilers/CSharp/Portable/Binder/SwitchBinder_Patterns.cs
+++ src/Compilers/CSharp/Portable/Binder/SwitchBinder_Patterns.cs
@@ -83,7 +83,7 @@
             }

             // If no switch sections are subsumed, just return
-            if (!switchSections.Any(static (s, reachableLabels) => s.SwitchLabels.Any(static (l, reachableLabels) => isSubsumed(l, reachableLabels), reachableLabels), reachableLabels))
+            if (!switchSections.Any(static (s, reachableLabels) => s.SwitchLabels.Any(isSubsumed, reachableLabels), reachableLabels))
             {
                 return;
             }


gs error type log

gs error type log

--- PrinterAgent/PrintingHandler/GhostScriptPrintingHandler.cs
+++ PrinterAgent/PrintingHandler/GhostScriptPrintingHandler.cs
@@ -45,7 +45,7 @@

                 Logger.LogInfo("GS StdOut:\n" + callback.OutLog);
                 if (!string.IsNullOrEmpty(callback.ErrorLog))
-                    Logger.LogInfo("GS StdError:\n" + callback.ErrorLog);
+                    Logger.LogError("GS StdError:\n" + callback.ErrorLog);

                 Logger.LogInfo(string.Join(" ", switches));
             }


More useful integration test features.

More useful integration test features.

--- Content.IntegrationTests/ContentIntegrationTest.cs
+++ Content.IntegrationTests/ContentIntegrationTest.cs
@@ -1,10 +1,11 @@
+using System;
+using System.Threading.Tasks;
 using Content.Client;
 using Content.Client.Interfaces.Parallax;
 using Content.Server;
-using Content.Server.GameTicking;
 using Content.Server.Interfaces.GameTicking;
 using Robust.Shared.ContentPack;
-using Robust.Shared.Interfaces.Configuration;
+using Robust.Shared.Interfaces.Network;
 using Robust.Shared.IoC;
 using Robust.UnitTesting;
 using EntryPoint = Content.Client.EntryPoint;
@@ -13,25 +14,33 @@
 {
     public abstract class ContentIntegrationTest : RobustIntegrationTest
     {
-        protected override ClientIntegrationInstance StartClient(ClientIntegrationOptions options = null)
+        protected sealed override ClientIntegrationInstance StartClient(ClientIntegrationOptions options = null)
         {
             options ??= new ClientIntegrationOptions();
+
             // ReSharper disable once RedundantNameQualifier
             options.ClientContentAssembly = typeof(EntryPoint).Assembly;
             options.SharedContentAssembly = typeof(Shared.EntryPoint).Assembly;
             options.BeforeStart += () =>
             {
-                // Connecting to Discord is a massive waste of time.
-                // Basically just makes the CI logs a mess.
-                IoCManager.Resolve<IConfigurationManager>().SetCVar("discord.enabled", false);
                 IoCManager.Resolve<IModLoader>().SetModuleBaseCallbacks(new ClientModuleTestingCallbacks
                 {
                     ClientBeforeIoC = () =>
                     {
+                        if (options is ClientContentIntegrationOption contentOptions)
+                        {
+                            contentOptions.ContentBeforeIoC?.Invoke();
+                        }
+
                         IoCManager.Register<IParallaxManager, DummyParallaxManager>(true);
                     }
                 });
             };
+
+            // Connecting to Discord is a massive waste of time.
+            // Basically just makes the CI logs a mess.
+            options.CVarOverrides["discord.enabled"] = "true";
+
             return base.StartClient(options);
         }

@@ -52,6 +61,11 @@
                 {
                     ServerBeforeIoC = () =>
                     {
+                        if (options is ServerContentIntegrationOption contentOptions)
+                        {
+                            contentOptions.ContentBeforeIoC?.Invoke();
+                        }
+
                         IoCManager.Register<IGameTicker, DummyGameTicker>(true);
                     }
                 });
@@ -59,5 +73,43 @@

             return StartServer(options);
         }
+
+        protected async Task<(ClientIntegrationInstance client, ServerIntegrationInstance server)> StartConnectedServerClientPair(ClientIntegrationOptions clientOptions = null, ServerIntegrationOptions serverOptions = null)
+        {
+            var client = StartClient(clientOptions);
+            var server = StartServerDummyTicker(serverOptions);
+
+            await Task.WhenAll(client.WaitIdleAsync(), server.WaitIdleAsync());
+
+            client.SetConnectTarget(server);
+
+            client.Post(() => IoCManager.Resolve<IClientNetManager>().ClientConnect(null, 0, null));
+
+            await RunTicksSync(client, server, 10);
+
+            return (client, server);
+        }
+
+        /// <summary>
+        ///     Runs <paramref name="ticks"/> ticks on both server and client while keeping their main loop in sync.
+        /// </summary>
+        protected static async Task RunTicksSync(ClientIntegrationInstance client, ServerIntegrationInstance server, int ticks)
+        {
+            for (var i = 0; i < ticks; i++)
+            {
+                await server.WaitRunTicks(1);
+                await client.WaitRunTicks(1);
+            }
+        }
+
+        protected sealed class ClientContentIntegrationOption : ClientIntegrationOptions
+        {
+            public Action ContentBeforeIoC { get; set; }
+        }
+
+        protected sealed class ServerContentIntegrationOption : ServerIntegrationOptions
+        {
+            public Action ContentBeforeIoC { get; set; }
+        }
     }
 }


Erroring if a null custom dictionary mapping key is supplied

--- AgileMapper.UnitTests/Configuration/WhenConfiguringDictionaryMappingIncorrectly.cs
+++ AgileMapper.UnitTests/Configuration/WhenConfiguringDictionaryMappingIncorrectly.cs
@@ -7,6 +7,21 @@

     public class WhenConfiguringDictionaryMappingIncorrectly
     {
+        [Fact]
+        public void ShouldErrorIfCustomMemberKeyIsNull()
+        {
+            var configEx = Should.Throw<MappingConfigurationException>(() =>
+            {
+                Mapper.WhenMapping
+                    .FromDictionaries()
+                    .To<PublicField<string>>()
+                    .MapKey(null)
+                    .To(pf => pf.Value);
+            });
+
+            configEx.Message.ShouldContain("cannot be null");
+        }
+
         [Fact]
         public void ShouldErrorIfCustomMemberNameIsNull()
         {


Added QueryTopology_FindLargestPositionsSittable() function to DLL interface

--- Assets/HoloToolkit/SpatialUnderstanding/Scripts/SpatialUnderstandingDllTopology.cs
+++ Assets/HoloToolkit/SpatialUnderstanding/Scripts/SpatialUnderstandingDllTopology.cs
@@ -119,6 +119,25 @@
             [In] float minFacingClearance,
             [In] int locationCount,             // Pass in the space allocated in locationData
             [In, Out] IntPtr locationData);     // TopologyResult
-    }
+
+        /// <summary>
+        /// Finds only large spaces on platforms meeting the criteria specified by the parameters.
+        /// </summary>
+        /// <param name="minHeight">Minimum height above the floor for a space</param>
+        /// <param name="maxHeight">Maximum height above the floor for a space</param>
+        /// <param name="minFacingClearance">Minimum clearance for the space above the placement surface (minimum space height)</param>
+        /// <param name="minWidth">Minimum required width on placement surface</param>
+        /// <param name="locationCount">Number of location results supplied by the user in locationData</param>
+        /// <param name="locationData">Location result array of TopologyResult to be filled with the spaces found by the query</param>
+        /// <returns>Number of spaces found by the query. This value is limited by the number of results supplied by the caller (locationCount)</returns>
+        [DllImport("SpatialUnderstanding")]
+        public static extern int QueryTopology_FindLargePositionsSittable(
+            [In] float minHeight,
+            [In] float maxHeight,
+            [In] float minFacingClearance,
+            [In] float minWidth,
+            [In] int locationCount,             // Pass in the space allocated in locationData
+            [In, Out] IntPtr locationData);     // TopologyResult
+  }

 }