示例#1
0
 def get_controller_code(self, controller):
     temp_path = './Templates/Controller.cs'
     with open(temp_path, 'r') as f:
         code = f.read()
     f.close()
     code = dollar_replace(code, {'area': self.area.name, 'controller': controller.name})
     action_code_regex = re.compile(r'(#region TemplateActions(.*)#endregion TemplateActions)', re.DOTALL)
     action_code_template = re.search(action_code_regex, code).group(2)
     action_code = ''
     for action in controller.actions:
         action_code += dollar_replace(action_code_template, {'action': action})
         action_code += '\n\n'
     code = re.sub(action_code_regex, action_code, code)
     return code
示例#2
0
 def get_view_code(self, action):
     temp_path = './Templates/View.cshtml'
     with open(temp_path, 'r') as f:
         code = f.read()
     f.close()
     code = dollar_replace(code, {'action': action})
     return code
示例#3
0
 def get_service_code(self):
     temp_path = './Templates/Service.cs'
     with open(temp_path, 'r') as f:
         code = f.read()
     f.close()
     code = dollar_replace(code, {'area': self.area.name})
     return code
示例#4
0
 def create_view(self, controller):
     view_path = dollar_replace(get_config('Paths', 'Views'), {'area': self.area.name, 'controller': controller.name})
     self.prepare_dir(view_path)
     for action in controller.actions:
         self.create_controller_view(view_path, action)
示例#5
0
 def create_controller(self, controller):
     controller_path = dollar_replace(get_config('Paths', 'Controllers'), {'area': self.area.name, 'controller': controller.name})
     self.prepare_dir(controller_path)
     self.create_controller_file(controller_path, controller)
示例#6
0
 def create_service(self):
     service_path = dollar_replace(get_config('Paths', 'Services'), {'area': self.area.name})
     self.prepare_dir(service_path)
     self.create_service_file(service_path)
示例#7
0
 def create_model(self):
     service_path = dollar_replace(get_config('Paths', 'Models'), {'area': self.area.name})
     self.prepare_dir(service_path)