Commit Graph

50 Commits

Author SHA1 Message Date
agrath@gmail.com
0ea4e2f891 Added IsHelpers to DynamicXml
Added As<T>() [ return (item as T); ] to @Library
Added ToDynamicXml(string) to @Library
2011-06-12 11:50:35 -02:00
agrath@gmail.com
b367f63c1d Fixed null reference problems with new dynamicbackingitem
Fixed recursive property null reference problems
Fixed issue with node having no children and property check crashing
Made DynamicXml behave more consistently based on user feedback
Added IsNull and HasValue to PropertyResult (comes back from GetProperty but you may need to cast it)
Added new Model.IsNull(string alias, bool recursive) and Model.HasValue(string alias, bool recursive) and Model.IsNull(string alias) and Model.HasValue(string alias)
2011-06-12 11:21:44 -02:00
agrath@gmail.com
c6dd41c36a Deleted some unused class files 2011-06-12 08:23:28 -02:00
agrath@gmail.com
f2d8363556 Added IsHelper methods back into DynamicNode after I accidentally removed them while refactoring
Added new IsHelper methods for IsModZero, IsNotModZero, IsPosition, IsNotPosition, IsNotFirst, IsNotLast
Added .Count to DynamicXML
Fixed Media .Url and .NiceUrl to bring back umbracoFile
Moved MediaById and NodeById implementations to RazorLibraryCore and deprecated original methods with redirection
Fixed parsing issue with ExamineBackedMedia XPathNodeIterator cast method
2011-06-12 08:23:10 -02:00
agrath@gmail.com
9c2a9f81f4 Finished ExamineBackedMedia implementation and fixed bug with GetMedia fallback in example code (didn't add current node attributes so was inconsistent compared to examine) 2011-06-12 06:40:18 -02:00
agrath@gmail.com
d63ae05693 Got rid of DynamicMedia and DynamicMediaList implementations (still there but subclasses of DynamicNode & DynamicNodeList now) to enable navigation on Media
Started implementing ExamineBackedMedia instead of using new Media()
2011-06-11 22:15:01 -02:00
agrath@gmail.com
40099d9d22 Made DynamicNode and DynamicMedia share an intermediary base class (that inherits from DynamicObject) rather than both inheriting from DynamicObject directly
Want to share some functionality between them
2011-05-21 14:55:10 -12:00
agrath@gmail.com
cd13f8de55 Can't change the web.config for a 4.7.x release, redid implementation to not require web.config change 2011-05-21 14:47:57 -12:00
agrath@gmail.com
6a0dfc2c11 Razor @Library empty implementation 2011-05-21 14:34:46 -12:00
agrath@gmail.com
5c6e8526da Changed IsLast implementation to behave properly when the DynamicNodeList is not a parent item children list
Changed IsHelper default valueIfFalse to be string.Empty on IsHelper(Func<DynamicNode,bool> func, string valueIfTrue) implementation
2011-04-05 23:15:23 -12:00
agrath@gmail.com
3c52ac851f Slight change to handling of True/False when value isn't defined on a node but property is in DynamicNode 2011-04-05 23:06:30 -12:00
agrath@gmail.com
5bcf591a72 Fixed OrderBy for multiple properties when one or more of those properties is a real property on DynamicNode [CreateDate etc]
Fixed OrderBy so it doesn't crash when ordering by a property which doesn't exist on one of the DynamicNodes in the set
2011-03-25 10:48:03 -13:00
agrath@gmail.com
10672f02a1 Fixed .OrderBy with single properties which are implemented as actual properties (e.g. Level, CreateDate, UpdateDate) - dynamic properties should have ordered correctly 2011-03-25 09:47:00 -13:00
agrath@gmail.com
9a56886f1d Made !, != true more robust when property may not exist on a node
Fixed some cases of && breaking where the wrong number of parameters was passed to the LambdaExpression
2011-03-25 09:34:39 -13:00
agrath@gmail.com
b198edeeaa Made DynamicNodeList.Where, DynamicNodeList.OrderBy public again 2011-03-25 09:33:39 -13:00
agrath@gmail.com
76f83ddda0 Fixed RTE types in DynamicNode from still getting converted to DynamicXml due to missing return statement 2011-03-25 09:33:00 -13:00
agrath@gmail.com
23aa9e60fe Added GetProperty(string alias, bool recursive) overload to DynamicNode
Added GetPropertyValue(string alias) and GetPropertyValue(string alias, bool recursive) to DynamicNode
2011-03-22 19:01:17 -13:00
agrath@gmail.com
3d396d2b63 Added Index/Position method to DynamicNode for when it's contained within a DynamicNodeList and you're iterating
Added bool IsHelper(Func<DynamicNode,bool>), string IsHelper(Func<DynamicNode,bool>, string valueIfTrue), string IsHelper(Func<DynamicNode,bool>, string valueIfTrue, string valueIfFlase)
Added IsFirst/IsLast/IsOdd/IsEven helpers for checking position in current context/list
Added IsEqual for checking if the current node matches another by Id
Added IsDescendant/IsDescendantOrSelf/IsAncestor/IsAncestorOrSelf for checking relationships between two nodes
2011-03-22 18:48:57 -13:00
agrath@gmail.com
93d65ced40 Add IsNull and HasValue methods to Dynamic* classes
**Breaking Change: DynamicNull.HasValue and DynamicNull.IsNull have been changed from properties to methods
Rename umbraco.MacroEngines.ExtensionMethods as umbraco.MacroEngines.PrivateExtensionMethods
Implement extension method invokes for DynamicNode
2011-03-22 18:02:32 -13:00
hartvig
8833034a35 Updates to Razor snippets (WIP) 2011-03-14 11:42:41 -01:00
agrath@gmail.com
1b060dfdbf Implemented Pluck/Select to extract a given property from a DynamicNodeList and return it as a List<T>
Example:
var colours = @Model.Children.Select("colour");
//Red, Green, Blue ...
Uses the parser from .Where internally
Aliased as .Pluck
2011-03-12 16:29:02 -13:00
agrath@gmail.com
1a2bba4b2b Added data type detection for MNTP/CSV to return List<int> and fix for NodeById/MediaById to handle List<int> correctly 2011-03-12 15:19:54 -13:00
agrath@gmail.com
44bfcaf373 Changed the decimal.TryParse code slightly to replace , with . before parse attempt
This is because strings like this: "2442,5453,5366" were incorrectly parsing to be "244254535366"
2011-03-12 15:07:17 -13:00
agrath@gmail.com
b624d7479a Fixes work item: 30156, using prop.Contains(string) || !prop.Contains(string)
Added ContainsInsensitive extension method for use inside .Where (fixed method finder too)
2011-03-12 12:33:09 -13:00
hartvig
a5e2d1e107 Work items: 30152 2011-03-10 13:17:40 -01:00
agrath@gmail.com
1716b94449 Added some extra properties/functions to DynamicNull to provide a way to check to see if a child doc type actually exists.
.HasProperty will check for a property existence but because the child types are returned as DynamicNull, you couldn't check for null equality.
Use DynamicNull's .IsNull (true) or .HasValue (false) or .Count() (0) or a typeof check
2011-03-09 07:52:05 -13:00
agrath@gmail.com
f5a7001859 Fixed handling of get properties on DynamicNode when used in a BinaryExpression and neither side is a LambdaExpression 2011-03-09 07:42:43 -13:00
agrath@gmail.com
ddcf34b80c Added .Sibling to DynamicNodeWalker which is a shorthand for checking both .Next() and .Previous()
overloads are .Sibling(int) [which you can pass negative to and is equivilent to .Previous(+int) ] or .Sibling(string) which checks nodeTypeAlias
.Sibling(string) will start walking forward at the current node and then wrap back to 0 until it reaches the starting point again
2011-03-08 19:54:55 -13:00
agrath@gmail.com
a02aca0f62 Added support to DynamicNodeWalker for finding nodes that are Up/Down/Previous/Next by NodeTypeAlias
Up and down are similar to Ancestors(string nodeTypeAlias)/Descendants(string nodeTypeAlias) but return the first match
2011-03-08 19:42:59 -13:00
agrath@gmail.com
d7e83cb1ee Added support to DynamicNodeWalker so that .Next() and .Previous() can be called on nodes which did not come from a DynamicNodeList (e.g. a node you have from @Model) - assuming it has a parent 2011-03-08 19:22:41 -13:00
agrath@gmail.com
fa5b85557f Added support to DynamicNodeList for .Add and .Remove methods to support this use case:
http://our.umbraco.org/forum/developers/razor/17934-Creating-a-DynamicNodeList-with-a-'for'-loop
2011-03-08 19:06:55 -13:00
agrath@gmail.com
042e373b6a Added support for iterating over DynamicXml
e.g. @foreach(var level in @Model.someXmlProperty.Book)
2011-03-08 19:00:44 -13:00
agrath@gmail.com
150d4648c1 Added support for chaining properties if a previous property access returns DynamicNull 2011-03-08 19:00:04 -13:00
agrath@gmail.com
017ed3635a Fixed .Ancestors(int) to return ancestors where the level <= int rather than level = int to match .Descendants(int) >= behaviour 2011-03-08 18:43:59 -13:00
agrath@gmail.com
9949420c6d Change HasAccess and IsProtected to be getters so they can be used in .Where
http://umbraco.codeplex.com/workitem/30096

Add support to DynamicQueryable for accessing properties that are not dynamic and are actually defined on DynamicNode
2011-03-08 18:38:06 -13:00
agrath@gmail.com
bc8f21f92d Added implementation for .Visible which wraps umbracoNaviHide != 1 2011-03-08 18:09:06 -13:00
agrath@gmail.com
aaa90bea14 More graceful handling of missing properties in .Where - TryGetMember now returns DynamicNull
Only return DynamicNull if property truely doesn't exist - if it does exist and has no value, still return null
2011-02-27 22:55:50 -13:00
agrath@gmail.com
60c18bdff9 More graceful handling of missing properties in .Where - TryGetMember now returns DynamicNull (IEnumerable with fake .Where and .OrderBy) when the property/child type doesn't exist.
Expression Tree in DynamicQueryable explictly checks for this type and forces that portion of the predicate/expression tree to return true, bypassing the missing property
Handy when you are checking e.g. a boolean property in a .Where and that boolean doesn't exist on all nodes.
2011-02-27 21:53:45 -13:00
agrath@gmail.com
bba0fcfd5f Merge 2011-02-27 09:00:00 -13:00
agrath@gmail.com
7ca429cb61 Added overloads to AncestorsOrSelf, Ancestors, Descendants, DecendentsOrSelf to filter by Level or NodeTypeAlias
Rewrote implementations internally so a Func<DynamicNode,bool> [or Func<INode,bool>] is used so that there's only one implementation of each
2011-02-27 08:55:15 -13:00
hartvig
9729ad4d31 Work items: 30082
Properties from Richtext editor isn't encoded by razor anymore as DynamicNode will return an IHtmlString for RTE properties
Changed the lookups of Yes/no and tinmce datatypes ids to consts as these won't change anyway
2011-02-27 12:13:04 -01:00
agrath@gmail.com
cbe94ae6aa Refactored ExtensionMethod search code from DynamicNodeList (searches for extension methods e.g. .Random()) to tidy it up
Moved Extension Method searching code to seperate static class
Moved all the defined extension methods for DynamicNode into the same ExtensionMethods.cs file
Changed the way that .ContainsAny within a where is evaluated to use the ExtensionMethodFinder class - should allow extra search methods to be defined
2011-02-26 16:15:45 -13:00
agrath@gmail.com
1f05d43047 Added new overloads to MediaById and NodeById which take List<object> or params object[] and return DynamicNodeList or DynamicMediaList [new - doesn't support OrderBy,Where etc]
Added to allow retreiving multiple items by id when you know the Ids, e.g.: using MNTP to select nodes and then needing to get them in Razor
2011-02-26 11:43:23 -13:00
agrath@gmail.com
a32e8894cd Added support for calling non standard extension method style helpers within a .Where
Intended as a future extensibility point, provides a way for the parser to redirect into a static method library of helpers
Currently, only one method is available - ContainsAny
Functions like string.Contains but uses needles from a List<string>

var values = new Dictionary<string,object>();
var keywords = new List<string>();
keywords.Add("Five");
keywords.Add("Four");
values.Add("keywords",keywords);
var items = @Model.Children.Where("Name.ContainsAny(keywords)", values);
2011-02-26 11:12:06 -13:00
agrath@gmail.com
6d615e6762 Work on DynamicQueryable to support .Where("bodyText.Contains(\"string\")")
Chaining works too: .Where("Name.SubString(1,3).Contains(\"v\")");
2011-02-25 16:58:17 -13:00
agrath@gmail.com
b1ff0db8fe Work on DynamicQueryable to support .Where("shouldBeVisible && Level < 4") rather than .Where("shouldBeVisible == true && Level < 4")
Confirmed other test cases of .Where still work
2011-02-25 12:16:03 -13:00
agrath@gmail.com
3961787463 Added DynamicNode.HasProperty(string) method to check to see if a particular DynamicNode has a property 2011-02-25 00:51:41 -13:00
agrath@gmail.com
9b45a81f22 Rewrote implementation of HandleDynamicNodeLambdas in DynamicQueryable.cs to be easier to read and handle unboxing and type conversion when the output type of the lambda is convertable between the left and right side.
Allows this syntax to work now:
@Model.Children.Where("updateDate < DateTime.Now.AddDays(-2)")
This didn't work previously in 4.7beta because updateDate was still boxed as an object and object < DateTime can't be implicitly converted

@Model.Children.Where("bodyText.Contains('ipsum')") still doesn't work because the parser doesn't know how to invoke .Contains on a LambdaExpression (yet)
2011-02-25 00:39:53 -13:00
agrath@gmail.com
71c5e35443 Added DynamicNodeWalker and implementation on DynamicNode and DynamicNodeList
DynamicNodeWalker is our secret weapon in the fight against the Rebel XSLT Alliance
Navigate nodes by calling Up(), Down(), Next() and Previous() on them
Next(1) will jump two items along within the current list, whereas Next() will walk by one within the list
Previous(1) will move two items backwards within the current list
Up() is a special wrapper around .Parent which has an overload .Up(int) to replace @Model.Parent.Parent.Parent... [.Up(2)]
Down() will take you to the first Child item and is equivilent to .Children.First(), use .Down(1) to replace .Children.First().Children
If one of the NodeWalker functions fails to find a node at the requested position, it will return null
2011-02-24 17:19:50 -13:00
agrath@gmail.com
603a12c5a0 Split umbraco.MacroEngines.Juno into two subfolders (namespaces remain the same)
RazorCore contains all the core razor engine implementation
RazorDynamicNode contains all the DynamicNode functionality and associated support files
2011-02-24 16:05:54 -13:00