Comments (11)
I'm happy with removing the <T>
constraint and using properties from the PropertyDescriptor
- as you say, it makes sense!
re: Breaking changes... since we're currently following SemVer, we're still on v0.x - so completely within the realm of breaking changes. I know it is a pain in the arse for some devs to deal with these scenarios, but truth is that Ditto is still under active development (pre-release) - so until a v1.0 is released we have freedom to change APIs.
from umbraco-ditto.
👍
from umbraco-ditto.
Wizzzard! I was hoping you'd say that. 😄
from umbraco-ditto.
I need to get my head back round these as I haven't looked for a while. A couple of comments off the top of my head though.
By supporting generics, we do make this a bit easier in some places, such as using Enumerable.Empty< T>() to return an empty collection of type T, which you couldn't do if we didn't have a generic type. Also, with < T> we are requiring that T is a class, which is a requirement for the type converter to work (i think) so removing the generic type means you'll have to perform any relevant checks manually (if there are any).
Like I say, I'm not sure if any of these are a problem, I just looked through the code at where generics is being used in the current code, and how removing this will affect those.
I think the main original requirement for this was because .As< T> was the only way to use ditto originally, however with the addition of the .As(Type type) method added, it may not be as big a requirement.
from umbraco-ditto.
Those are fair points.
Enumerable.Empty
is the trickiest of those to deal with, That can be invoked though, I think I need to make an EnumerableInvocator
helper class somewhere to store the cached methods since I would have three then. Empty
, Cast
, and FirstOrDefault
.
For the constraints... Type.IsValueType
and Type.IsClass
should cover that.
from umbraco-ditto.
Hi @mattbrailsford, perhaps I misunderstand, but can't an Emtpy collection of 'myType' be returned with:
return Enumerable.Empty<object>().Cast(myType);
where Cast(Type type) is an extension:
public static IEnumerable Cast(this IEnumerable iEnumerable, Type type)
{
MethodInfo methodInfo = typeof(Enumerable).GetMethod("Cast");
MethodInfo genericMethodInfo = methodInfo.MakeGenericMethod(type);
return genericMethodInfo.Invoke(null, new[] { iEnumerable }) as IEnumerable;
}
from umbraco-ditto.
Probably. But now we need a custom Cast method, and IMO the result is less readable.
from umbraco-ditto.
arh, what @JimBobSquarePants has just said
@mattbrailsford but the end result is simpler syntax for the end consumer
from umbraco-ditto.
@Hendy fair point.
from umbraco-ditto.
We already have the Cast
and FirstOrDefault
ones. I'm happy to make the changes and I'll keep it as simple as possible.
from umbraco-ditto.
Closing this discussion thread. We can continue (if needed) on PR #55.
from umbraco-ditto.
Related Issues (20)
- DittoCache examples HOT 2
- Changes to lazy properties HOT 7
- Documentation using GitHub Pages HOT 2
- How to bind my model with an action to a DitFloView PartialView HOT 22
- UmbracoPicker returns wrong IPublishedContent in Umbraco 7.5.3 HOT 7
- Base Processor - exposing Umbraco context services HOT 5
- Custom Processor Contexts only persist a single .As() HOT 18
- Ditto Factory misusing `PluginManager.ResolveTypes`? HOT 10
- Ability to Conditionally Stop Processor Chain HOT 24
- XPath Processor? HOT 6
- Decimal mapping always 0 for negative values HOT 7
- Constructor Cache is no longer used HOT 3
- Orphaned Archetype Properties Cause Null Exception During Mapping HOT 3
- Migration to UMCO HOT 1
- Ditto-centric Stack Trace HOT 4
- Ditto processor attributes require a DittoProcessorMetaData attribute to be applied to the class but none was found. HOT 36
- Support for Umbraco v8 HOT 1
- Getting EntryPointNotFoundException on ditto objects HOT 2
- Excessive memory usage HOT 9
- Casting IPublishedContent to specific Model using Ditto mixing up property values between nodes on the same level HOT 3
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
D3
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
-
Recommend Topics
-
javascript
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
-
web
Some thing interesting about web. New door for the world.
-
server
A server is a program made to process requests and deliver data to clients.
-
Machine learning
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from umbraco-ditto.