From eed3340e89f9a935ae0b47392dcc8c075fc724d9 Mon Sep 17 00:00:00 2001 From: Dave Reed Date: Wed, 18 May 2011 10:51:52 -0700 Subject: [PATCH 1/3] MediaPicker: refactor --HG-- branch : 1.x --- .../Orchard.MediaPicker/Scripts/MediaBrowser.js | 10 +--------- 1 file changed, 1 insertion(+), 9 deletions(-) diff --git a/src/Orchard.Web/Modules/Orchard.MediaPicker/Scripts/MediaBrowser.js b/src/Orchard.Web/Modules/Orchard.MediaPicker/Scripts/MediaBrowser.js index b46dd5f0a..a9256413e 100644 --- a/src/Orchard.Web/Modules/Orchard.MediaPicker/Scripts/MediaBrowser.js +++ b/src/Orchard.Web/Modules/Orchard.MediaPicker/Scripts/MediaBrowser.js @@ -122,15 +122,7 @@ .attr("src", src); $(prefix + "loader").attr("src", src); $(prefix + "src").val(src); - - var insertButton = $(prefix + "insert"); - if (src) { - insertButton.removeAttr("disabled"); - } - else { - insertButton.attr("disabled", "disabled"); - } - insertButton.toggleClass("disabled", !src); + $(prefix + "insert").attr("disabled", !src).toggleClass("disabled", !src); } function getIdPrefix(e) { From 6a88f44e735c113bd77fe426e8cb30e1908acc0b Mon Sep 17 00:00:00 2001 From: Andre Rodrigues Date: Wed, 18 May 2011 13:25:57 -0700 Subject: [PATCH 2/3] #17830: Registering ServiceRoutes after MVCRoutes. Using existing WorkContext in OrchardFactory in case of aspnetcompatibilitymode. --HG-- branch : 1.x --- src/Orchard/Mvc/Routes/RoutePublisher.cs | 6 +++- src/Orchard/Wcf/OrchardInstanceContext.cs | 14 +++++++-- src/Orchard/Wcf/OrchardServiceHostFactory.cs | 30 ++++++++++++++------ 3 files changed, 37 insertions(+), 13 deletions(-) diff --git a/src/Orchard/Mvc/Routes/RoutePublisher.cs b/src/Orchard/Mvc/Routes/RoutePublisher.cs index cab791a8d..591723012 100644 --- a/src/Orchard/Mvc/Routes/RoutePublisher.cs +++ b/src/Orchard/Mvc/Routes/RoutePublisher.cs @@ -1,5 +1,6 @@ using System.Collections.Generic; using System.Linq; +using System.ServiceModel.Activation; using System.Web.Routing; using Autofac; using Orchard.Environment; @@ -24,7 +25,10 @@ namespace Orchard.Mvc.Routes { } public void Publish(IEnumerable routes) { - var routesArray = routes.OrderByDescending(r => r.Priority).ToArray(); + var routesArray = routes + .OrderByDescending(r => r.Route is ServiceRoute ? -1 : 1) + .ThenByDescending(r => r.Priority) + .ToArray(); // this is not called often, but is intended to surface problems before // the actual collection is modified diff --git a/src/Orchard/Wcf/OrchardInstanceContext.cs b/src/Orchard/Wcf/OrchardInstanceContext.cs index 19fd96800..90a6257f1 100644 --- a/src/Orchard/Wcf/OrchardInstanceContext.cs +++ b/src/Orchard/Wcf/OrchardInstanceContext.cs @@ -7,9 +7,15 @@ using Autofac.Core; namespace Orchard.Wcf { public class OrchardInstanceContext : IExtension, IDisposable { private readonly IWorkContextScope _workContextScope; + private readonly WorkContext _workContext; public OrchardInstanceContext(IWorkContextAccessor workContextAccessor) { - _workContextScope = workContextAccessor.CreateWorkContextScope(); + _workContext = workContextAccessor.GetContext(); + + if (_workContext == null) { + _workContextScope = workContextAccessor.CreateWorkContextScope(); + _workContext = _workContextScope.WorkContext; + } } public void Attach(InstanceContext owner) {} @@ -17,7 +23,9 @@ namespace Orchard.Wcf { public void Detach(InstanceContext owner) {} public void Dispose() { - _workContextScope.Dispose(); + if (_workContextScope != null) { + _workContextScope.Dispose(); + } } public object Resolve(IComponentRegistration registration) { @@ -25,7 +33,7 @@ namespace Orchard.Wcf { throw new ArgumentNullException("registration"); } - return _workContextScope.Resolve().Resolve(registration, Enumerable.Empty()); + return _workContext.Resolve().Resolve(registration, Enumerable.Empty()); } } } diff --git a/src/Orchard/Wcf/OrchardServiceHostFactory.cs b/src/Orchard/Wcf/OrchardServiceHostFactory.cs index 52eccb3b4..f91d255e7 100644 --- a/src/Orchard/Wcf/OrchardServiceHostFactory.cs +++ b/src/Orchard/Wcf/OrchardServiceHostFactory.cs @@ -37,17 +37,17 @@ namespace Orchard.Wcf { IOrchardHost orchardHost = HostContainer.Resolve(); ShellContext shellContext = orchardHost.GetShellContext(shellSettings); IWorkContextAccessor workContextAccessor = shellContext.LifetimeScope.Resolve(); - - using (IWorkContextScope workContext = workContextAccessor.CreateWorkContextScope()) { - - ILifetimeScope lifetimeScope = workContext.Resolve(); - if (!lifetimeScope.ComponentRegistry.TryGetRegistration(new KeyedService(constructorString, typeof (object)), out registration)) { - Type serviceType = Type.GetType(constructorString, false); - if (serviceType != null) { - lifetimeScope.ComponentRegistry.TryGetRegistration(new TypedService(serviceType), out registration); - } + WorkContext workContext = workContextAccessor.GetContext(); + if (workContext == null) { + using (IWorkContextScope workContextScope = workContextAccessor.CreateWorkContextScope()) { + ILifetimeScope lifetimeScope = workContextScope.Resolve(); + registration = GetRegistration(lifetimeScope, constructorString); } } + else { + ILifetimeScope lifetimeScope = workContext.Resolve(); + registration = GetRegistration(lifetimeScope, constructorString); + } if (registration == null) { throw new InvalidOperationException(); @@ -69,5 +69,17 @@ namespace Orchard.Wcf { return host; } + + private IComponentRegistration GetRegistration(ILifetimeScope lifetimeScope, string constructorString) { + IComponentRegistration registration; + if (!lifetimeScope.ComponentRegistry.TryGetRegistration(new KeyedService(constructorString, typeof(object)), out registration)) { + Type serviceType = Type.GetType(constructorString, false); + if (serviceType != null) { + lifetimeScope.ComponentRegistry.TryGetRegistration(new TypedService(serviceType), out registration); + } + } + + return registration; + } } } From a6bee4cdab0f01a91e04070293fb7c10e6d423ea Mon Sep 17 00:00:00 2001 From: Andre Rodrigues Date: Wed, 18 May 2011 14:47:33 -0700 Subject: [PATCH 3/3] Addinf fluentnhibernate patches. --HG-- branch : 1.x --- .../fluent-nhibernate_ClasslikeMapBase.patch | 84 +++++++++++++++++++ .../fluent-nhibernate_GenericEnumMapper.patch | 21 +++++ 2 files changed, 105 insertions(+) create mode 100644 lib/fluentnhibernate/fluent-nhibernate_ClasslikeMapBase.patch create mode 100644 lib/fluentnhibernate/fluent-nhibernate_GenericEnumMapper.patch diff --git a/lib/fluentnhibernate/fluent-nhibernate_ClasslikeMapBase.patch b/lib/fluentnhibernate/fluent-nhibernate_ClasslikeMapBase.patch new file mode 100644 index 000000000..759ba3b74 --- /dev/null +++ b/lib/fluentnhibernate/fluent-nhibernate_ClasslikeMapBase.patch @@ -0,0 +1,84 @@ +# HG changeset patch +# User Andre Rodrigues +# Date 1305755030 25200 +# Node ID 9cd8564ec960ed8b634f87249da62a69b506b60f +# Parent 82d19d966b63b14bc6b7e1d76404c0fb0aacf4e0 +Exposing References method to avoid the usage of propertyinfo. + +diff -r 82d19d966b63 -r 9cd8564ec960 src/FluentNHibernate/Mapping/ClasslikeMapBase.cs +--- a/src/FluentNHibernate/Mapping/ClasslikeMapBase.cs Wed May 18 14:42:42 2011 -0700 ++++ b/src/FluentNHibernate/Mapping/ClasslikeMapBase.cs Wed May 18 14:43:50 2011 -0700 +@@ -64,7 +64,11 @@ + + protected virtual ManyToOnePart References(PropertyInfo property, string columnName) + { +- var part = new ManyToOnePart(EntityType, property); ++ return References(property.DeclaringType, property.Name, columnName); ++ } ++ ++ public ManyToOnePart References(Type declaringType, string propertyName, string columnName) { ++ var part = new ManyToOnePart(EntityType, propertyName, declaringType.Name); + + if (columnName != null) + part.Column(columnName); +diff -r 82d19d966b63 -r 9cd8564ec960 src/FluentNHibernate/Mapping/CompositeElementPart.cs +--- a/src/FluentNHibernate/Mapping/CompositeElementPart.cs Wed May 18 14:42:42 2011 -0700 ++++ b/src/FluentNHibernate/Mapping/CompositeElementPart.cs Wed May 18 14:43:50 2011 -0700 +@@ -59,7 +59,7 @@ + + protected virtual ManyToOnePart References(PropertyInfo property, string columnName) + { +- var part = new ManyToOnePart(typeof(T), property); ++ var part = new ManyToOnePart(typeof(T), property.Name, property.DeclaringType.Name); + + if (columnName != null) + part.Column(columnName); +diff -r 82d19d966b63 -r 9cd8564ec960 src/FluentNHibernate/Mapping/ManyToOnePart.cs +--- a/src/FluentNHibernate/Mapping/ManyToOnePart.cs Wed May 18 14:42:42 2011 -0700 ++++ b/src/FluentNHibernate/Mapping/ManyToOnePart.cs Wed May 18 14:43:50 2011 -0700 +@@ -20,12 +20,14 @@ + private readonly AttributeStore attributes = new AttributeStore(); + private readonly AttributeStore columnAttributes = new AttributeStore(); + private readonly Type entity; +- private readonly PropertyInfo property; ++ private readonly string name; ++ private readonly string declaringTypeName; + +- public ManyToOnePart(Type entity, PropertyInfo property) ++ public ManyToOnePart(Type entity, string name, string declaringTypeName) + { + this.entity = entity; +- this.property = property; ++ this.name = name; ++ this.declaringTypeName = declaringTypeName; + access = new AccessStrategyBuilder>(this, value => attributes.Set(x => x.Access, value)); + fetch = new FetchTypeExpression>(this, value => attributes.Set(x => x.Fetch, value)); + cascade = new CascadeExpression>(this, value => attributes.Set(x => x.Cascade, value)); +@@ -37,16 +39,15 @@ + var mapping = new ManyToOneMapping(attributes.CloneInner()); + + mapping.ContainingEntityType = entity; +- mapping.PropertyInfo = property; + + if (!mapping.IsSpecified("Name")) +- mapping.Name = property.Name; ++ mapping.Name = name; + + if (!mapping.IsSpecified("Class")) + mapping.SetDefaultValue(x => x.Class, new TypeReference(typeof(TOther))); + + if (columns.Count == 0) +- mapping.AddDefaultColumn(CreateColumn(property.Name + "_id")); ++ mapping.AddDefaultColumn(CreateColumn(name + "_id")); + + foreach (var column in columns) + { +@@ -124,7 +125,7 @@ + + public ManyToOnePart ForeignKey() + { +- return ForeignKey(string.Format("FK_{0}To{1}", property.DeclaringType.Name, property.Name)); ++ return ForeignKey(string.Format("FK_{0}To{1}", declaringTypeName, name)); + } + + public ManyToOnePart ForeignKey(string foreignKeyName) diff --git a/lib/fluentnhibernate/fluent-nhibernate_GenericEnumMapper.patch b/lib/fluentnhibernate/fluent-nhibernate_GenericEnumMapper.patch new file mode 100644 index 000000000..737d9d372 --- /dev/null +++ b/lib/fluentnhibernate/fluent-nhibernate_GenericEnumMapper.patch @@ -0,0 +1,21 @@ +# HG changeset patch +# User Andre Rodrigues +# Date 1305755041 25200 +# Node ID 48d2b0560a4196a96e906a218208b69ff9db25bd +# Parent 9cd8564ec960ed8b634f87249da62a69b506b60f +Making GenericEnumMapper Serializable. + +diff -r 9cd8564ec960 -r 48d2b0560a41 src/FluentNHibernate/Mapping/GenericEnumMapper.cs +--- a/src/FluentNHibernate/Mapping/GenericEnumMapper.cs Wed May 18 14:43:50 2011 -0700 ++++ b/src/FluentNHibernate/Mapping/GenericEnumMapper.cs Wed May 18 14:44:01 2011 -0700 +@@ -1,7 +1,9 @@ +-using NHibernate.Type; ++using System; ++using NHibernate.Type; + + namespace FluentNHibernate.Mapping + { ++ [Serializable] + public class GenericEnumMapper : EnumStringType + { + public GenericEnumMapper()