2019-07-27 14:36:41 +08:00
|
|
|
//
|
|
|
|
// DoricRegistry.m
|
|
|
|
// Doric
|
|
|
|
//
|
|
|
|
// Created by pengfei.zhou on 2019/7/27.
|
|
|
|
//
|
|
|
|
|
|
|
|
#import "DoricRegistry.h"
|
2019-07-29 20:23:00 +08:00
|
|
|
#import "DoricModalPlugin.h"
|
2019-07-30 11:25:05 +08:00
|
|
|
#import "DoricShaderPlugin.h"
|
2019-07-30 21:05:27 +08:00
|
|
|
#import "DoricStackNode.h"
|
|
|
|
#import "DoricVLayoutNode.h"
|
|
|
|
#import "DoricHLayoutNode.h"
|
2019-07-31 14:18:20 +08:00
|
|
|
#import "DoricTextNode.h"
|
2019-07-29 20:23:00 +08:00
|
|
|
|
|
|
|
@interface DoricRegistry ()
|
|
|
|
|
|
|
|
@property (nonatomic,strong) NSMutableDictionary *bundles;
|
|
|
|
@property (nonatomic,strong) NSMutableDictionary *plugins;
|
2019-07-30 21:05:27 +08:00
|
|
|
@property (nonatomic,strong) NSMutableDictionary *nodes;
|
2019-07-29 20:23:00 +08:00
|
|
|
|
|
|
|
@end
|
2019-07-27 14:36:41 +08:00
|
|
|
|
|
|
|
@implementation DoricRegistry
|
|
|
|
|
2019-07-29 20:23:00 +08:00
|
|
|
- (instancetype)init {
|
|
|
|
if(self = [super init]){
|
|
|
|
_bundles = [[NSMutableDictionary alloc] init];
|
|
|
|
_plugins = [[NSMutableDictionary alloc] init];
|
2019-07-30 21:05:27 +08:00
|
|
|
_nodes = [[NSMutableDictionary alloc] init];
|
2019-07-29 20:23:00 +08:00
|
|
|
[self innerRegister];
|
|
|
|
}
|
|
|
|
return self;
|
|
|
|
}
|
|
|
|
|
|
|
|
- (void)innerRegister {
|
|
|
|
[self registerNativePlugin:DoricModalPlugin.class withName:@"modal"];
|
2019-07-30 11:25:05 +08:00
|
|
|
[self registerNativePlugin:DoricShaderPlugin.class withName:@"shader"];
|
2019-07-30 21:05:27 +08:00
|
|
|
|
|
|
|
[self registerViewNode:DoricStackNode.class withName:@"Stack"];
|
|
|
|
[self registerViewNode:DoricVLayoutNode.class withName:@"VLayout"];
|
|
|
|
[self registerViewNode:DoricHLayoutNode.class withName:@"HLayout"];
|
2019-07-31 14:18:20 +08:00
|
|
|
[self registerViewNode:DoricTextNode.class withName:@"Text"];
|
|
|
|
|
2019-07-29 20:23:00 +08:00
|
|
|
}
|
|
|
|
|
|
|
|
- (void)registerJSBundle:(NSString *)bundle withName:(NSString *)name {
|
|
|
|
[self.bundles setObject:bundle forKey:name];
|
|
|
|
}
|
|
|
|
|
|
|
|
- (NSString *)acquireJSBundle:(NSString *)name {
|
|
|
|
return [self.bundles objectForKey:name];
|
|
|
|
}
|
|
|
|
|
|
|
|
- (void)registerNativePlugin:(Class)pluginClass withName:(NSString *)name {
|
|
|
|
[self.plugins setObject:pluginClass forKey:name];
|
|
|
|
}
|
|
|
|
|
|
|
|
- (Class)acquireNativePlugin:(NSString *)name {
|
|
|
|
return [self.plugins objectForKey:name];
|
|
|
|
}
|
|
|
|
|
2019-07-30 21:05:27 +08:00
|
|
|
- (void)registerViewNode:(Class)nodeClass withName:(NSString *)name {
|
|
|
|
[self.nodes setObject:nodeClass forKey:name];
|
|
|
|
}
|
|
|
|
|
|
|
|
- (Class)acquireViewNode:(NSString *)name {
|
|
|
|
return [self.nodes objectForKey:name];
|
|
|
|
}
|
|
|
|
|
2019-07-27 14:36:41 +08:00
|
|
|
@end
|