mirror of
https://github.com/OrchardCMS/Orchard.git
synced 2026-02-09 09:16:41 +08:00
Merge
--HG-- branch : 1.x
This commit is contained in:
@@ -0,0 +1,84 @@
|
||||
# HG changeset patch
|
||||
# User Andre Rodrigues <andrerod@microsoft.com>
|
||||
# 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<TOther> References<TOther>(PropertyInfo property, string columnName)
|
||||
{
|
||||
- var part = new ManyToOnePart<TOther>(EntityType, property);
|
||||
+ return References<TOther>(property.DeclaringType, property.Name, columnName);
|
||||
+ }
|
||||
+
|
||||
+ public ManyToOnePart<TOther> References<TOther>(Type declaringType, string propertyName, string columnName) {
|
||||
+ var part = new ManyToOnePart<TOther>(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<TOther> References<TOther>(PropertyInfo property, string columnName)
|
||||
{
|
||||
- var part = new ManyToOnePart<TOther>(typeof(T), property);
|
||||
+ var part = new ManyToOnePart<TOther>(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<ManyToOneMapping> attributes = new AttributeStore<ManyToOneMapping>();
|
||||
private readonly AttributeStore<ColumnMapping> columnAttributes = new AttributeStore<ColumnMapping>();
|
||||
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<ManyToOnePart<TOther>>(this, value => attributes.Set(x => x.Access, value));
|
||||
fetch = new FetchTypeExpression<ManyToOnePart<TOther>>(this, value => attributes.Set(x => x.Fetch, value));
|
||||
cascade = new CascadeExpression<ManyToOnePart<TOther>>(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<TOther> 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<TOther> ForeignKey(string foreignKeyName)
|
||||
@@ -0,0 +1,21 @@
|
||||
# HG changeset patch
|
||||
# User Andre Rodrigues <andrerod@microsoft.com>
|
||||
# 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<TEnum> : EnumStringType
|
||||
{
|
||||
public GenericEnumMapper()
|
||||
@@ -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) {
|
||||
|
||||
@@ -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<RouteDescriptor> 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
|
||||
|
||||
@@ -7,9 +7,15 @@ using Autofac.Core;
|
||||
namespace Orchard.Wcf {
|
||||
public class OrchardInstanceContext : IExtension<InstanceContext>, 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<ILifetimeScope>().Resolve(registration, Enumerable.Empty<Parameter>());
|
||||
return _workContext.Resolve<ILifetimeScope>().Resolve(registration, Enumerable.Empty<Parameter>());
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -37,17 +37,17 @@ namespace Orchard.Wcf {
|
||||
IOrchardHost orchardHost = HostContainer.Resolve<IOrchardHost>();
|
||||
ShellContext shellContext = orchardHost.GetShellContext(shellSettings);
|
||||
IWorkContextAccessor workContextAccessor = shellContext.LifetimeScope.Resolve<IWorkContextAccessor>();
|
||||
|
||||
using (IWorkContextScope workContext = workContextAccessor.CreateWorkContextScope()) {
|
||||
|
||||
ILifetimeScope lifetimeScope = workContext.Resolve<ILifetimeScope>();
|
||||
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<ILifetimeScope>();
|
||||
registration = GetRegistration(lifetimeScope, constructorString);
|
||||
}
|
||||
}
|
||||
else {
|
||||
ILifetimeScope lifetimeScope = workContext.Resolve<ILifetimeScope>();
|
||||
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;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user