Example #1
0
 public VSNetCSharpProject AddWinServiceProject(string name)
 {
     VSNetCSharpProject project = new VSNetCSharpProject(ProjectType.WinService, name, this);
       Projects.Add(project.ProjectName, project);
       ProjectConfig.AddConfigItem(project.ProjectID + ".Debug.ActiveCfg", "Debug|.NET");
       ProjectConfig.AddConfigItem(project.ProjectID + ".Debug.Build.0", "Debug|.NET");
       ProjectConfig.AddConfigItem(project.ProjectID + ".Release.ActiveCfg", "Release|.NET");
       ProjectConfig.AddConfigItem(project.ProjectID + ".Release.Build.0", "Release|.NET");
       project.AddAsmReference("System", @"C:\WINDOWS\Microsoft.NET\Framework\v1.1.4322\System.dll");
       project.AddAsmReference("System.Data", @"C:\WINDOWS\Microsoft.NET\Framework\v1.1.4322\System.Data.dll");
       project.AddAsmReference("System.Xml", @"C:\WINDOWS\Microsoft.NET\Framework\v1.1.4322\System.Xml.dll");
       project.AddAsmReference("System.Configuration.Install",                              @"C:\WINDOWS\Microsoft.NET\Framework\v1.1.4322\System.Configuration.Install.dll");
       project.AddAsmReference("System.Management", @"C:\WINDOWS\Microsoft.NET\Framework\v1.1.4322\System.Management.dll");
       project.AddAsmReference("System.ServiceProcess",                              @"C:\WINDOWS\Microsoft.NET\Framework\v1.1.4322\System.ServiceProcess.dll");
       return project;
 }
Example #2
0
 public ProjectReference AddProjectReference(VSNetCSharpProject project)
 {
     ProjectReference reference = new ProjectReference(this, project);
       References.Add(reference);
       return reference;
 }
Example #3
0
 public VSNetCSharpProject AddClassLibProject(string name)
 {
     VSNetCSharpProject project = new VSNetCSharpProject(ProjectType.ClassLib, name, this);
       Projects.Add(project.ProjectName, project);
       ProjectConfig.AddConfigItem(project.ProjectID + ".Debug.ActiveCfg", "Debug|.NET");
       ProjectConfig.AddConfigItem(project.ProjectID + ".Debug.Build.0", "Debug|.NET");
       ProjectConfig.AddConfigItem(project.ProjectID + ".Release.ActiveCfg", "Release|.NET");
       ProjectConfig.AddConfigItem(project.ProjectID + ".Release.Build.0", "Release|.NET");
       project.AddAsmReference("System", @"C:\WINDOWS\Microsoft.NET\Framework\v1.1.4322\System.dll");
       project.AddAsmReference("System.Data", @"C:\WINDOWS\Microsoft.NET\Framework\v1.1.4322\System.Data.dll");
       project.AddAsmReference("System.XML", @"C:\WINDOWS\Microsoft.NET\Framework\v1.1.4322\System.XML.dll");
       return project;
 }
Example #4
0
 public void GenerateConfigurationClass(VSNetCSharpProject utProj)
 {
     TraceInfoEvent.Raise("Adding configuration class.");
       utProj.AddFile(GenerationHelper.GetConfigClassFileName());
       CSharpFile file =
     CSharpFilePool.Obtain(Path.Combine(m_Arch.UtilityLayer.FullPath, GenerationHelper.GetConfigClassFileName()));
       file.NameSpace = m_Arch.UtilityLayer.NameSpace;
       file.Description = "Class handling configuration";
       file.Usings.Add("System.Data");
       file.Usings.Add("Grepton.Runtime");
       file.Usings.Add("Grepton.Runtime.BusinessHosting");
       CSharpTypeDef typeDef = new CSharpTypeDef();
       file.InnerTypes.Add(typeDef);
       typeDef.Comment.Summary = file.Description;
       typeDef.HeaderLine = "public class Configuration: ConfigurationBase";
       foreach (DataAccessModel model in m_Arch.DataLayers)
       {
     if ((model.UsingClause != string.Empty) && !file.Usings.Contains(model.UsingClause))
     {
       file.Usings.Add(model.UsingClause);
     }
     CSharpPropertyDef def2 = new CSharpPropertyDef();
     typeDef.Properties.Add(def2);
     def2.HeaderLine = string.Format("public static string {0}ConnStr", model.ConfigKeyName);
     def2.Comment.Summary = string.Format("Get connection string for '{0}'", model.LayerName);
     TextWriter getWriter = def2.GetWriter;
     getWriter.WriteLine("try");
     getWriter.WriteLine("{");
     getWriter.WriteLine("  return GetConfigString(CONFIG_SECTION, \"{0}\");", model.ConfigKeyName);
     getWriter.WriteLine("}");
     getWriter.WriteLine("catch");
     getWriter.WriteLine("{");
     getWriter.WriteLine("  return String.Empty;");
     getWriter.WriteLine("}");
     CSharpPropertyDef def3 = new CSharpPropertyDef();
     typeDef.Properties.Add(def3);
     def3.HeaderLine = string.Format("public static {0} {1}Connection", model.ConnectionClass, model.ConfigKeyName);
     def3.Comment.Summary = string.Format("Get connection instance for '{0}'", model.LayerName);
     getWriter = def3.GetWriter;
     getWriter.WriteLine("if ({0}ConnStr == String.Empty)", model.ConfigKeyName);
     getWriter.WriteLine("  return new {0}(@\"{1}\");", model.ConnectionClass, model.ConnectionString);
     getWriter.WriteLine("else");
     getWriter.WriteLine("  return new {0}({1}ConnStr);", model.ConnectionClass, model.ConfigKeyName);
       }
 }
Example #5
0
 // Methods
 public ProjectReference(VSNetCSharpProject parent, VSNetCSharpProject project)
 {
     base.Parent = parent;
       RefProject = project;
       base.Name = project.ProjectName;
 }
Example #6
0
 public void GenerateLocalServiceFactory(VSNetCSharpProject bsProj, ServiceLayerModel svLayer)
 {
     string localSFClassFileName = GenerationHelper.GetLocalSFClassFileName();
       string str2 = svLayer.FullPath + localSFClassFileName;
       bsProj.AddFile(localSFClassFileName);
       CSharpFile file = CSharpFilePool.Obtain(str2);
       TraceInfoEvent.Raise("Adding local service factory class.");
       file.Description = "Local service factory class.";
       file.NameSpace = bsProj.ProjectName;
       file.Usings.Add("Grepton.Runtime");
       file.Usings.Add("Grepton.Runtime.DBTypes");
       file.Usings.Add("Grepton.Runtime.BusinessHosting");
       file.Usings.Add(m_Arch.BusinessDocsLayer.NameSpace);
       CSharpTypeDef typeDef = new CSharpTypeDef();
       file.InnerTypes.Add(typeDef);
       typeDef.Comment.Summary = file.Description;
       typeDef.HeaderLine = "public class LocalServiceFactory: IServiceFactory";
       foreach (ServiceModel model in svLayer.Services)
       {
     CSharpMethodDef def2 = new CSharpMethodDef();
     def2.Comment.Summary = string.Format("Gets the service interface for '{0}'.", model.MappingName);
     def2.HeaderLine = string.Format("public I{0} Get{0}", model.MappingName);
     def2.Writer.WriteLine("return new {0}();", model.MappingName);
     typeDef.Methods.Add(def2);
       }
 }
Example #7
0
 public void GenerateServiceSnippets(VSNetCSharpProject bsProj, ServiceLayerModel svLayer)
 {
     foreach (ServiceModel model in svLayer.Services)
       {
     string serviceFileName = GenerationHelper.GetServiceFileName(model);
     string str2 = svLayer.FullPath + serviceFileName;
     bsProj.AddFile(serviceFileName);
     CSharpFile docFile = CSharpFilePool.Obtain(str2);
     docFile.NameSpace = bsProj.ProjectName;
     TraceInfoEvent.Raise(string.Format("Adding service snippet for '{0}'.", model.MappingName));
     GenerateSnippetService(docFile, model);
       }
 }
Example #8
0
 public void GenerateRemoteServiceConfig(VSNetCSharpProject bdProj)
 {
     string hostingConfigFileName = GenerationHelper.GetHostingConfigFileName();
       string path = m_Arch.BusinessDocsLayer.FullPath + hostingConfigFileName;
       bdProj.AddSimpleFile(hostingConfigFileName);
       TextWriter writer = File.CreateText(path);
       writer.WriteLine("<?xml version=\"1.0\" encoding=\"utf-8\"?>");
       writer.WriteLine("<configuration>");
       writer.WriteLine();
       writer.WriteLine("  <configSections>");
       writer.WriteLine(
     "    <section name=\"DbConnections\" type=\"System.Configuration.NameValueFileSectionHandler\" />");
       writer.WriteLine("  </configSections>");
       writer.WriteLine();
       writer.WriteLine("  <system.runtime.remoting>");
       writer.WriteLine("    <application>");
       writer.WriteLine("      <!--");
       writer.WriteLine("        Configures the channel that the application uses to communicate with remote objects");
       writer.WriteLine("        Formatter come first so that the message can be reconstituted before we try to");
       writer.WriteLine("        examine it to get our data out of the call context.");
       writer.WriteLine("      -->");
       writer.WriteLine("      <channels>");
       writer.WriteLine("      </channels>");
       writer.WriteLine("      <!--");
       writer.WriteLine("        Configures the channel that the application uses to communicate with remote objects");
       writer.WriteLine("      -->");
       writer.WriteLine();
       foreach (ServiceLayerModel model in m_Arch.ServiceLayers)
       {
     foreach (ServiceModel model2 in model.Services)
     {
       writer.WriteLine("      <service>");
       writer.WriteLine("        <wellknown mode=\"SingleCall\"");
       writer.WriteLine(string.Format("          type=\"{0}.{1}, {0}\"", model.NameSpace, model2.MappingName));
       writer.WriteLine(string.Format("          objectUri=\"{0}/{1}\" />", model.NameSpace, model2.MappingName));
       writer.WriteLine("      </service>");
     }
       }
       writer.WriteLine("    </application>");
       writer.WriteLine("  </system.runtime.remoting>");
       writer.WriteLine("  <DbConnections>");
       foreach (DataAccessModel model3 in m_Arch.DataLayers)
       {
     writer.WriteLine(string.Format("    <add key=\"{0}\" value=\"{1}\" />", model3.ConfigKeyName,                                       model3.ConnectionString));
       }
       writer.WriteLine("  </DbConnections>");
       writer.WriteLine("</configuration>");
       writer.Close();
 }
Example #9
0
 public void GenerateServiceInstaller(VSNetCSharpProject bdProj)
 {
     string hostingInstallerFileName = GenerationHelper.GetHostingInstallerFileName();
       string path = m_Arch.BusinessDocsLayer.FullPath + hostingInstallerFileName;
       bdProj.AddSimpleFile(hostingInstallerFileName);
       TextWriter writer = File.CreateText(path);
       string str3 = CSharpGenerator.CodeBlock("CSharpServiceInstaller");
       string newValue = string.Format("{0}.{1}", m_Arch.SolutionName, GenerationHelper.HostingServiceName);
       str3 =
     str3.Replace("%timestamp%", DateTime.Now.ToString()).Replace("%namespace%", newValue).Replace("%solutionname%",                                                                                                      m_Arch.
                                                                                                 SolutionName).
       Replace("%description%", string.Format("Business hosting service for {0}.", newValue)).Replace(
       "%displayname%", newValue).Replace("%servicename%", newValue);
       writer.WriteLine(str3);
       writer.Close();
 }
Example #10
0
 public void GenerateSnippetInterfaces(VSNetCSharpProject bdProj)
 {
     string projectName = bdProj.ProjectName;
       foreach (ServiceLayerModel model in m_Arch.ServiceLayers)
       {
     foreach (ServiceModel model2 in model.Services)
     {
       string interfaceFileName = GenerationHelper.GetInterfaceFileName(model2);
       string str3 = m_Arch.BusinessDocsLayer.FullPath + interfaceFileName;
       bdProj.AddFile(interfaceFileName);
       CSharpFile docFile = CSharpFilePool.Obtain(str3);
       docFile.NameSpace = projectName;
       TraceInfoEvent.Raise(string.Format("Adding snippet interface for '{0}'.", model2.MappingName));
       GenerateSnippetInterface(docFile, model2);
     }
       }
 }
Example #11
0
 public void GenerateReadMe(VSNetCSharpProject bdProj)
 {
     string hostReadMeFileName = GenerationHelper.GetHostReadMeFileName();
       string path = m_Arch.BusinessDocsLayer.FullPath + hostReadMeFileName;
       bdProj.AddSimpleFile(hostReadMeFileName);
       TextWriter writer = File.CreateText(path);
       string str3 = CSharpGenerator.CodeBlock("HostServiceReadme");
       string newValue = string.Format("{0}.{1}", m_Arch.SolutionName, GenerationHelper.HostingServiceName);
       str3 = str3.Replace("%servicename%", newValue);
       writer.WriteLine(str3);
       writer.Close();
 }
Example #12
0
 public void GenerateSnippetDocs(VSNetCSharpProject bdProj)
 {
     string projectName = bdProj.ProjectName;
       foreach (BusinessDocModel model in m_Arch.BusinessDocsLayer.Documents)
       {
     DataEntityModel rootEntity = model.RootEntity;
     if (model.IsSimple)
     {
       string snippetDocumentFileName = GenerationHelper.GetSnippetDocumentFileName(rootEntity);
       string str3 = m_Arch.BusinessDocsLayer.FullPath + snippetDocumentFileName;
       bdProj.AddFile(snippetDocumentFileName);
       CSharpFile docFile = CSharpFilePool.Obtain(str3);
       docFile.NameSpace = projectName;
       TraceInfoEvent.Raise(string.Format("Adding document snippet for '{0}'.", rootEntity.MappingName));
       GenerateSnippetDocument(docFile, rootEntity, rootEntity.MappingName);
       TraceInfoEvent.Raise(string.Format("Adding document container snippet for '{0}'.", rootEntity.MappingName));
       GenerateContainerClass(docFile, rootEntity, rootEntity.MappingName,                                 string.Format("{0}Container", rootEntity.MappingName),                                 string.Format("{0}ContainerBase", rootEntity.MappingName));
     }
     else
     {
       string file = GenerationHelper.GetSnippetDocumentFileName(model);
       string str5 = m_Arch.BusinessDocsLayer.FullPath + file;
       bdProj.AddFile(file);
       CSharpFile file2 = CSharpFilePool.Obtain(str5);
       file2.NameSpace = projectName;
       TraceInfoEvent.Raise(string.Format("Adding document snippet for '{0}'.", model.Name));
       GenerateSnippetDocument(file2, model.RootEntity, model.Name, model.RootEntity.MappingName);
       TraceInfoEvent.Raise(string.Format("Adding document container snippet for '{0}'.", model.Name));
       GenerateContainerClass(file2, model.RootEntity, model.Name, string.Format("{0}Container", model.Name),                                 string.Format("{0}ContainerBase", model.Name));
     }
       }
 }
Example #13
0
 public void GenerateServiceFactoryInterface(VSNetCSharpProject bdProj)
 {
     string projectName = bdProj.ProjectName;
       string sFIntFileName = GenerationHelper.GetSFIntFileName();
       string str3 = m_Arch.BusinessDocsLayer.FullPath + sFIntFileName;
       bdProj.AddFile(sFIntFileName);
       CSharpFile file = CSharpFilePool.Obtain(str3);
       file.NameSpace = bdProj.ProjectName;
       TraceInfoEvent.Raise("Adding service factory interface.");
       file.Description = "Service factory interface.";
       CSharpInterfaceDef typeDef = new CSharpInterfaceDef();
       file.InnerTypes.Add(typeDef);
       typeDef.Comment.Summary = file.Description;
       typeDef.HeaderLine = "public interface IServiceFactory";
       foreach (ServiceLayerModel model in m_Arch.ServiceLayers)
       {
     foreach (ServiceModel model2 in model.Services)
     {
       CSharpMethodDef def2 = new CSharpMethodDef();
       def2.Comment.Summary = string.Format("Gets the service interface for '{0}'.", model2.MappingName);
       def2.HeaderLine = string.Format("I{0} Get{0}", model2.MappingName);
       typeDef.Methods.Add(def2);
     }
       }
 }
Example #14
0
 public void GenerateServiceFactoryClass(VSNetCSharpProject bdProj)
 {
     string projectName = bdProj.ProjectName;
       string sFClassFileName = GenerationHelper.GetSFClassFileName();
       string str3 = m_Arch.BusinessDocsLayer.FullPath + sFClassFileName;
       bdProj.AddFile(sFClassFileName);
       CSharpFile file = CSharpFilePool.Obtain(str3);
       file.NameSpace = bdProj.ProjectName;
       TraceInfoEvent.Raise("Adding service factory class.");
       file.Description = "Service factory class.";
       file.Usings.Add("System.Collections.Specialized");
       file.Usings.Add("System.Configuration");
       file.Usings.Add("Grepton.Helpers");
       file.Usings.Add("Grepton.Runtime");
       file.Usings.Add("Grepton.Runtime.BusinessHosting");
       file.Usings.Add("Grepton.Diagnostics.Exceptions");
       CSharpTypeDef typeDef = new CSharpTypeDef();
       file.InnerTypes.Add(typeDef);
       typeDef.Comment.Summary = file.Description;
       typeDef.HeaderLine = "public class ServiceFactory";
       CSharpFieldDef def2 = new CSharpFieldDef();
       def2.DefLine = "static IServiceFactory m_ServiceFactory;";
       typeDef.Fields.Add(def2);
       CSharpMethodDef def3 = new CSharpMethodDef();
       typeDef.Ctors.Add(def3);
       def3.Comment.Summary = "Initializes the service factory";
       def3.HeaderLine = "static ServiceFactory";
       TextWriter writer = def3.Writer;
       writer.WriteLine("try");
       writer.WriteLine("{");
       writer.WriteLine("  SetFactory(null);");
       writer.WriteLine("}");
       writer.WriteLine("catch (Exception ex)");
       writer.WriteLine("{");
       writer.WriteLine("  ExceptionManager.Publish(ex);");
       writer.WriteLine("}");
       CSharpMethodDef def4 = new CSharpMethodDef();
       typeDef.Methods.Add(def4);
       def4.Comment.Summary = "Initializes the service factory dispatcher";
       def4.HeaderLine = "public static void SetFactory";
       def4.AddParam("className", "string", "Service factory class name.");
       writer = def4.Writer;
       writer.WriteLine("try");
       writer.WriteLine("{");
       writer.WriteLine("  if (className == null || className == String.Empty)");
       writer.WriteLine("  {");
       writer.WriteLine("    className = ((NameValueCollection)ConfigurationSettings.");
       writer.WriteLine("      GetConfig(\"ServiceFactory\"))[\"class\"];");
       writer.WriteLine("  }");
       writer.WriteLine("  DynamicType plugIn = new DynamicType(className);");
       writer.WriteLine("  m_ServiceFactory = (IServiceFactory)plugIn.CreateInstance();");
       writer.WriteLine("}");
       writer.WriteLine("catch (Exception ex)");
       writer.WriteLine("{");
       writer.WriteLine("  ExceptionManager.Publish(ex);");
       writer.WriteLine("  throw ex;");
       writer.WriteLine("}");
       foreach (ServiceLayerModel model in m_Arch.ServiceLayers)
       {
     foreach (ServiceModel model2 in model.Services)
     {
       CSharpMethodDef def5 = new CSharpMethodDef();
       def5.Comment.Summary = string.Format("Gets the service interface for '{0}'.", model2.MappingName);
       def5.HeaderLine = string.Format("public static I{0} Get{0}", model2.MappingName);
       def5.Writer.WriteLine("return m_ServiceFactory.Get{0}();", model2.MappingName);
       typeDef.Methods.Add(def5);
     }
       }
 }
Example #15
0
 public void GenerateRemoteServiceFactory(VSNetCSharpProject bdProj)
 {
     string projectName = bdProj.ProjectName;
       string remoteSFClassFileName = GenerationHelper.GetRemoteSFClassFileName();
       string str3 = m_Arch.BusinessDocsLayer.FullPath + remoteSFClassFileName;
       bdProj.AddFile(remoteSFClassFileName);
       CSharpFile file = CSharpFilePool.Obtain(str3);
       file.NameSpace = bdProj.ProjectName;
       TraceInfoEvent.Raise("Adding remotes service factory class.");
       file.Description = "Remote service factory class.";
       file.Usings.Add("System.Collections.Specialized");
       file.Usings.Add("System.Configuration");
       file.Usings.Add("Grepton.Helpers");
       file.Usings.Add("Grepton.Runtime");
       file.Usings.Add("Grepton.Runtime.BusinessHosting");
       file.Usings.Add("Grepton.Diagnostics.Exceptions");
       file.Usings.Add(m_Arch.BusinessDocsLayer.NameSpace);
       CSharpTypeDef typeDef = new CSharpTypeDef();
       file.InnerTypes.Add(typeDef);
       typeDef.Comment.Summary = file.Description;
       typeDef.HeaderLine = "public class RemoteServiceFactory: IServiceFactory";
       CSharpMethodDef def2 = new CSharpMethodDef();
       typeDef.Ctors.Add(def2);
       def2.Comment.Summary = "Initializes the service factory with URIs.";
       def2.HeaderLine = "static RemoteServiceFactory";
       foreach (ServiceLayerModel model in m_Arch.ServiceLayers)
       {
     foreach (ServiceModel model2 in model.Services)
     {
       CSharpFieldDef def3 = new CSharpFieldDef();
       def3.CommentLine = string.Format("URI for '{0}'", model2.MappingName);
       def3.DefLine = string.Format("private static string m_{0}Uri;", model2.MappingName);
       typeDef.Fields.Add(def3);
       CSharpMethodDef def4 = new CSharpMethodDef();
       def4.Comment.Summary = string.Format("Gets the service interface for '{0}'.", model2.MappingName);
       def4.HeaderLine = string.Format("public I{0} Get{0}", model2.MappingName);
       def4.Writer.WriteLine("return (I{0})Activator.GetObject(typeof(I{0}), m_{0}Uri);", model2.MappingName);
       typeDef.Methods.Add(def4);
       def2.Writer.WriteLine("m_{0}Uri = RemoteFactory.GetUri(\"{1}/{0}\");", model2.MappingName,                                model2.Parent.NameSpace);
     }
       }
 }
Example #16
0
 // Methods
 public AsmReference(VSNetCSharpProject parent, string name, string hintPath)
 {
     base.Parent = parent;
       base.Name = name;
       this.HintPath = hintPath;
 }