protected void OnGenerateEvent(GenerateTypes type, object obj) { if (GenerateEvent != null) { GenerateEvent(this, new GenerateEventArgs(obj, type)); } }
public void Parse(IList <string> args) { Options = new OptionSet() { // SQLMetal compatible { "c|conn=", "Database {CONNECTION STRING}. Cannot be used with /server, " + "/user or /password options.", conn => Conn = conn }, // SQLMetal compatible { "u|user="******"Login user {NAME}.", name => User = name }, // SQLMetal compatible { "p|password="******"Login {PASSWORD}.", password => Password = password }, // SQLMetal compatible { "s|server=", "Database server {NAME}.", name => Server = name }, // SQLMetal compatible { "d|database=", "Database catalog {NAME} on server.", name => Database = name }, { "provider=", "Specify {PROVIDER}. May be Ingres, MySql, Oracle, OracleODP, PostgreSql or Sqlite.", provider => Provider = provider }, { "with-schema-loader=", "ISchemaLoader implementation {TYPE}.", type => DbLinqSchemaLoaderProvider = type }, { "with-dbconnection=", "IDbConnection implementation {TYPE}.", type => DatabaseConnectionProvider = type }, { "with-sql-dialect=", "IVendor implementation {TYPE}.", type => SqlDialectType = type }, // SQLMetal compatible { "code=", "Output as source code to {FILE}. Cannot be used with /dbml option.", file => Code = file }, // SQLMetal compatible { "dbml=", "Output as dbml to {FILE}. Cannot be used with /map option.", file => Dbml = file }, // SQLMetal compatible { "language=", "Language {NAME} for source code: C#, C#2 or VB " + "(default: derived from extension on code file name).", name => Language = name }, { "aliases=", "Use mapping {FILE}.", file => Aliases = file }, { "schema", "Generate schema in code files (default: enabled).", v => Schema = v != null }, // SQLMetal compatible { "namespace=", "Namespace {NAME} of generated code (default: no namespace).", name => Namespace = name }, // SQLMetal compatible { "entitybase=", "Base {TYPE} of entity classes in the generated code " + "(default: entities have no base class).", type => EntityBase = type }, { "member-attribute=", "{ATTRIBUTE} for entity members in the generated code, " + "can be specified multiple times.", attribute => MemberAttributes.Add(attribute) }, { "generate-type=", "Generate only the {TYPE} selected, can be specified multiple times " + "and does not prevent references from being generated (default: " + "generate a DataContex subclass and all the entities in the schema).", type => GenerateTypes.Add(type) }, { "generate-equals-hash", "Generates overrides for Equals() and GetHashCode() methods.", v => GenerateEqualsHash = v != null }, // SQLMetal compatible { "sprocs", "Extract stored procedures.", v => Sprocs = v != null }, // SQLMetal compatible { "pluralize", "Automatically pluralize or singularize class and member names " + "using specified culture rules.", v => Pluralize = v != null }, { "culture=", "Specify {CULTURE} for word recognition and pluralization (default: \"en\").", culture => Culture = culture }, { "case=", "Transform names with the indicated {STYLE} " + "(default: net; may be: leave, pascal, camel, net).", style => Case = style }, { "generate-timestamps", "Generate timestampes in the generated code (default: enabled).", v => GenerateTimestamps = v != null }, { "readline", "Wait for a key to be pressed after processing.", v => Readline = v != null }, { "debug", "Enables additional information to help with debugging, " + "such as full stack traces in error messages.", v => Debug = v != null }, { "h|?|help", "Show this help", v => Help = v != null } }; Extra = Options.Parse(args); }
public GenerateEventArgs(object Object, GenerateTypes Type) { this.Object = Object; this.Type = Type; }
static void Main(string[] args) { InitParams(args); ReadandValidateGEN_XML(); if (isGEN_XMLValid) { string l_ns = "http://www.hafsjold.dk/schema/hafsjold.xsd"; XmlNamespaceManager l_nsMgr = new XmlNamespaceManager(docGEN_XML.NameTable); l_nsMgr.AddNamespace("mha", l_ns); System.Xml.XmlNode propertySets = docGEN_XML.SelectSingleNode("//mha:hafsjold/mha:propertySets", l_nsMgr); string SVNRootPath; if (SVN == "Empty") { SVNRootPath = propertySets.Attributes["SVNRootPath"].Value; } else { SVNRootPath = SVN; } string ProjectPath = propertySets.Attributes["ProjectPath"].Value; string ProjectName = propertySets.Attributes["ProjectName"].Value; System.Xml.XmlNodeList propertySetList = docGEN_XML.SelectNodes("//mha:hafsjold/mha:propertySets/mha:propertySet", l_nsMgr); foreach (XmlNode propertySet in propertySetList) { XmlNode ClonepropertySet = propertySet.CloneNode(true); string ClonepropertySetXML = ClonepropertySet.OuterXml; string CloneDocument = string.Format(@"<?xml version='1.0' encoding='utf-8'?> <hafsjold xmlns='http://www.hafsjold.dk/schema/hafsjold.xsd'> <propertySets SVNRootPath='{0}' ProjectPath='{1}' ProjectName='{2}'> {3} </propertySets> </hafsjold>", SVNRootPath, ProjectPath, ProjectName, ClonepropertySetXML); System.Xml.XmlDocument CloneXmlDocument = new System.Xml.XmlDocument(); CloneXmlDocument.LoadXml(CloneDocument); MemoryStream sXML = new MemoryStream(); CloneXmlDocument.Save(sXML); string Function = propertySet.Attributes["Function"].Value; string ProgPath = propertySet.Attributes["ProgPath"].Value; string ProgName = propertySet.Attributes["ProgName"].Value; switch (Function) { case "SaveMetadata": GenerateMetadata.GenerateMetadataMain(sXML); break; case "Column": GenerateColumns.MainGenerateColumns(sXML); break; case "Type": GenerateTypes.GenerateTypesMain(sXML); break; case "List": GenerateList.MainGenerateList(sXML); break; } } } }
protected void OnGenerateEvent(GenerateTypes type, object obj) { if (GenerateEvent != null) { GenerateEvent(this, new GenerateEventArgs(obj,type)); } }