public ServiceLayerModel Remove(ServiceModel sm) { m_Services.Remove(sm); sm.Parent = null; return this; }
public void Remove(ServiceModel sModel) { m_Items.Remove(sModel); }
public ServiceLayerModel Add(ServiceModel sm) { m_Services.Add(sm); sm.Parent = this; return this; }
public static string GetSnippetInterfaceFileName(ServiceModel srv) { return string.Format(@"\Interfaces\I{0}.cs", srv.MappingName); }
public int Add(ServiceModel sModel) { foreach (ServiceModel model in m_Items) { if (model.Name.ToLower().Equals(sModel.Name.ToLower())) { throw new ArgumentException("There is already a ServiceModel item in the container with the same name."); } } return m_Items.Add(sModel); }
public static string GetBaseInterfaceFileName(ServiceModel srv) { return string.Format(@"\BaseInterfaces\I{0}Base.cs", srv.MappingName); }
public static string GetServiceFileName(ServiceModel srv) { return string.Format(@"\Services\{0}.cs", srv.MappingName); }
public void GenerateSnippetService(CSharpFile docFile, ServiceModel srv) { docFile.Description = string.Format("Base service for '{0}' entity.", srv.MappingName); docFile.Usings.Add("System.Data"); docFile.Usings.Add("Grepton.Runtime"); docFile.Usings.Add("Grepton.Runtime.DBTypes"); docFile.Usings.Add("Grepton.Runtime.BusinessHosting"); docFile.Usings.Add("Grepton.Diagnostics.EventSchema"); docFile.Usings.Add("Grepton.Diagnostics.Exceptions"); docFile.Usings.Add(srv.Parent.DataAccessLayer.NameSpace); docFile.Usings.Add(m_Arch.BusinessDocsLayer.NameSpace); CSharpTypeDef typeDef = new CSharpTypeDef(); docFile.InnerTypes.Add(typeDef); typeDef.Comment.Summary = docFile.Description; typeDef.HeaderLine = string.Format("public class {0}: {0}Base, I{0}", srv.MappingName); CSharpMethodDef def2 = new CSharpMethodDef(); typeDef.Ctors.Add(def2); def2.HeaderLine = string.Format("public {0}", srv.MappingName); def2.HeaderTrailer = ": base()"; def2.Comment.Summary = string.Format("Creates the {0} with a default data context.", srv.MappingName); CSharpMethodDef def3 = new CSharpMethodDef(); typeDef.Ctors.Add(def3); def3.HeaderLine = string.Format("public {0}", srv.MappingName); def3.HeaderTrailer = ": base(dataContext)"; def3.AddParam("dataContext", srv.Parent.DataAccessLayer.DataContextName, "Data context of the service."); def3.Comment.Summary = string.Format("Creates the {0} with the specified data context.", srv.MappingName); }
public void GenerateBaseService(CSharpFile docFile, ServiceModel srv) { docFile.Description = string.Format("Base service for '{0}' entity.", srv.MappingName); docFile.Usings.Add("System.Data"); docFile.Usings.Add("Grepton.Runtime"); docFile.Usings.Add("Grepton.Runtime.DBTypes"); docFile.Usings.Add("Grepton.Runtime.BusinessHosting"); docFile.Usings.Add("Grepton.Diagnostics.EventSchema"); docFile.Usings.Add("Grepton.Diagnostics.Exceptions"); docFile.Usings.Add("Grepton.Diagnostics.Pmc"); docFile.Usings.Add(srv.Parent.DataAccessLayer.NameSpace); docFile.Usings.Add(m_Arch.BusinessDocsLayer.NameSpace); CSharpTypeDef typeDef = new CSharpTypeDef(); docFile.InnerTypes.Add(typeDef); typeDef.Attributes.Add("ImplicitPmc"); typeDef.Comment.Summary = docFile.Description; typeDef.HeaderLine = string.Format("public class {0}Base: BusinessService, I{0}Base", srv.MappingName); CSharpFieldDef def2 = new CSharpFieldDef(); typeDef.Fields.Add(def2); def2.DefLine = string.Format("protected {0} m_DataContext;", srv.Parent.DataAccessLayer.DataContextName); def2.CommentLine = "Data context of this service instance."; CSharpMethodDef def3 = new CSharpMethodDef(); typeDef.Ctors.Add(def3); def3.HeaderLine = string.Format("public {0}Base", srv.MappingName); def3.Comment.Summary = string.Format("Creates the {0} with a default data context.", srv.MappingName); def3.Writer.WriteLine("m_DataContext = new {0}();", srv.Parent.DataAccessLayer.DataContextName); CSharpMethodDef def4 = new CSharpMethodDef(); typeDef.Ctors.Add(def4); def4.HeaderLine = string.Format("public {0}Base", srv.MappingName); def4.AddParam("dataContext", srv.Parent.DataAccessLayer.DataContextName, "Data context of the service."); def4.Comment.Summary = string.Format("Creates the {0} with the specified data context.", srv.MappingName); def4.Writer.WriteLine("m_DataContext = dataContext;"); foreach (OperationModel model in srv.Operations) { IOperationCodeGenerator codeGenerator = model.GetCodeGenerator(); if (codeGenerator.WantGenerateServiceMethod()) { codeGenerator.GenerateServiceMethod(typeDef); } } }
public void GenerateSnippetInterface(CSharpFile docFile, ServiceModel srv) { docFile.Description = string.Format("Interface for '{0}' entity.", srv.MappingName); docFile.Usings.Add("Grepton.Runtime"); docFile.Usings.Add("Grepton.Runtime.DBTypes"); CSharpTypeDef typeDef = new CSharpInterfaceDef(); docFile.InnerTypes.Add(typeDef); typeDef.Comment.Summary = docFile.Description; typeDef.HeaderLine = string.Format("public interface I{0}: I{0}Base", srv.MappingName); }
public void GenerateBaseInterface(CSharpFile docFile, ServiceModel srv) { docFile.Description = string.Format("Base interface for '{0}' entity.", srv.MappingName); docFile.Usings.Add("Grepton.Runtime"); docFile.Usings.Add("Grepton.Runtime.DBTypes"); CSharpTypeDef typeDef = new CSharpInterfaceDef(); docFile.InnerTypes.Add(typeDef); typeDef.Comment.Summary = docFile.Description; typeDef.HeaderLine = string.Format("public interface I{0}Base", srv.MappingName); if (!m_Arch.DisableBaseInterfaces) { foreach (OperationModel model in srv.Operations) { IOperationCodeGenerator codeGenerator = model.GetCodeGenerator(); if (codeGenerator.WantGenerateServiceMethod()) { codeGenerator.GenerateInterface(typeDef); } } } }
public void DefineNativeOperations(ServiceLayerModel srvLayer) { foreach (BusinessDocModel model in this.BusinessDocsLayer.Documents) { if ((model.ParentRelations.Count == 0) && (model.ChildRelations.Count == 0)) { DataEntityModel rootEntity = model.RootEntity; ServiceModel model3 = new ServiceModel(GenerationHelper.GetServiceName(rootEntity)); srvLayer.Add(model3); model3 += new TableOperation(TableOperationType.Select, rootEntity); TraceInfoEvent.Raise(string.Format("Select operation added for '{0}'", rootEntity.MappingName)); model3 += new TableOperation(TableOperationType.SelectAll, rootEntity); TraceInfoEvent.Raise(string.Format("SelectAll operation added for '{0}'", rootEntity.MappingName)); model3 += new TableOperation(TableOperationType.Insert, rootEntity); TraceInfoEvent.Raise(string.Format("Insert operation added for '{0}'", rootEntity.MappingName)); if (rootEntity.UpdateSetFields.Count > 0) { model3 += new TableOperation(TableOperationType.Update, rootEntity); TraceInfoEvent.Raise(string.Format("Update operation added for '{0}'", rootEntity.MappingName)); } model3 += new TableOperation(TableOperationType.Delete, rootEntity); TraceInfoEvent.Raise(string.Format("Delete operation added for '{0}'", rootEntity.MappingName)); model3 += new TableOperation(TableOperationType.SelectDispsetAll, rootEntity); TraceInfoEvent.Raise(string.Format("SelectDispSetAll operation added for '{0}'", rootEntity.MappingName)); foreach (AssocModel model4 in rootEntity.ParentAssocs) { model3 += new AssocOperation(AssocOperationType.SelectBy, model4); TraceInfoEvent.Raise(string.Format("SelectBy operation added for '{0}'", model4.Name)); model3 += new AssocOperation(AssocOperationType.DeleteBy, model4); TraceInfoEvent.Raise(string.Format("DeleteBy operation added for '{0}'", model4.Name)); } continue; } ServiceModel sm = new ServiceModel(GenerationHelper.GetServiceName(model.Name)); srvLayer.Add(sm); sm += new DocumentOperation(DocOperationType.Select, model); TraceInfoEvent.Raise(string.Format("Select operation added for '{0}'", model.Name)); sm += new DocumentOperation(DocOperationType.SelectAll, model); TraceInfoEvent.Raise(string.Format("SelectAll operation added for '{0}'", model.Name)); sm += new DocumentOperation(DocOperationType.Insert, model); TraceInfoEvent.Raise(string.Format("Insert operation added for '{0}'", model.Name)); if (model.RootEntity.UpdateSetFields.Count > 0) { sm += new DocumentOperation(DocOperationType.Update, model); TraceInfoEvent.Raise(string.Format("Update operation added for '{0}'", model.Name)); } sm += new DocumentOperation(DocOperationType.Delete, model); TraceInfoEvent.Raise(string.Format("Delete operation added for '{0}'", model.Name)); } }