Dynamic keyword is back for Parameters/Dictionary
This commit is contained in:
@@ -13,8 +13,8 @@ namespace umbraco.MacroEngines
|
||||
protected IParameterDictionary ParameterDictionary;
|
||||
protected ICultureDictionary CultureDictionary;
|
||||
|
||||
public IParameterDictionary Parameter { get { return ParameterDictionary; } }
|
||||
public ICultureDictionary Dictionary { get { return CultureDictionary; } }
|
||||
public dynamic Parameter { get { return ParameterDictionary; } }
|
||||
public dynamic Dictionary { get { return CultureDictionary; } }
|
||||
|
||||
public MacroModel Macro { get { return _macro; } }
|
||||
public INode Node { get { return _node; } }
|
||||
@@ -42,5 +42,13 @@ namespace umbraco.MacroEngines
|
||||
SetMembers(macroContext.Macro, macroContext.Node);
|
||||
}
|
||||
}
|
||||
|
||||
public string GetParameter(string alias) {
|
||||
return ParameterDictionary[alias];
|
||||
}
|
||||
|
||||
public string GetDictionary(string key) {
|
||||
return CultureDictionary[key];
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -15,5 +15,7 @@ namespace umbraco.MacroEngines
|
||||
return new CSharpRazorCodeLanguage();
|
||||
return base.GetCodeLanguage();
|
||||
}
|
||||
|
||||
|
||||
}
|
||||
}
|
||||
|
||||
@@ -1,10 +1,11 @@
|
||||
using System;
|
||||
using System.Dynamic;
|
||||
using umbraco.cms.businesslogic;
|
||||
using umbraco.cms.businesslogic.language;
|
||||
|
||||
namespace umbraco.MacroEngines {
|
||||
|
||||
public class UmbracoCultureDictionary : ICultureDictionary {
|
||||
public class UmbracoCultureDictionary : DynamicObject, ICultureDictionary {
|
||||
|
||||
public string this[string key] {
|
||||
get {
|
||||
@@ -19,6 +20,11 @@ namespace umbraco.MacroEngines {
|
||||
get { return Language.GetByCultureCode(System.Threading.Thread.CurrentThread.CurrentUICulture.Name); }
|
||||
}
|
||||
|
||||
public override bool TryGetMember(GetMemberBinder binder, out object result) {
|
||||
result = this[binder.Name];
|
||||
return true;
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
@@ -1,12 +1,13 @@
|
||||
using System;
|
||||
using System.Collections;
|
||||
using System.Collections.Generic;
|
||||
using System.Dynamic;
|
||||
using umbraco.cms.businesslogic.macro;
|
||||
using System.Linq;
|
||||
|
||||
namespace umbraco.MacroEngines {
|
||||
|
||||
public class UmbracoParameterDictionary : IParameterDictionary {
|
||||
public class UmbracoParameterDictionary : DynamicObject, IParameterDictionary {
|
||||
|
||||
private readonly IEnumerable<MacroPropertyModel> _paramsKeyValue;
|
||||
|
||||
@@ -28,6 +29,10 @@ namespace umbraco.MacroEngines {
|
||||
get { return _paramsKeyValue.Where(p => p.Key == alias).Select(p => p.Value).FirstOrDefault(); }
|
||||
}
|
||||
|
||||
public override bool TryGetMember(GetMemberBinder binder, out object result) {
|
||||
result = this[binder.Name];
|
||||
return true;
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
Reference in New Issue
Block a user