Created
November 16, 2012 09:08
-
-
Save cvasilak/4085708 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#import <Foundation/Foundation.h> | |
@protocol AGEntity <NSObject> | |
@optional | |
-(NSDictionary*) mapping; | |
@end | |
@inteface Customer: NSOBject<AGEntity> | |
@property(nonatomic, copy) NSString *name | |
-(NSDictionary)mapping { | |
// user describes ANY relations and Array types | |
} | |
-(id) initWithConfig:(id<AGPipeConfig>) pipeConfig entity:(id<AGEntity>)entity { | |
... | |
NSDictionary *mapping = [entity mapping]; | |
if (mapping == nil) { // no mapping | |
_parser = [DCKeyValueObjectMapping mapperForClass: [_entity class]]; | |
} else { | |
for (NSString* name in [mapping allKeys]) { | |
DCArrayMapping *mapper = [DCArrayMapping mapperForClassElements: :[mapping objectForkey:name] forAttribute:name] | |
onClass:[_entity class]]; | |
DCParserConfiguration *config = [DCParserConfiguration configuration]; | |
[config addArrayMapper:mapper]; | |
} | |
_parser = [[DCKeyValueObjectMapping mapperForClass:[_entity class] andConfiguration:configuration]; | |
} | |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment