public static string Convert_NType( XS__RootMetadata root_ref_in, string xsdType_in, string schemaName_in, out bool isStandardNType_out ) { isStandardNType_out = true; switch (xsdType_in) { case "xs:string": return "string"; case "xs:decimal": return "decimal"; case "xs:integer": return "int"; case "xs:boolean": return "bool"; case "xs:time": case "xs:date": return "DateTime"; default: isStandardNType_out = false; return string.Format( "{0}{1}", root_ref_in.MetadataCollection[0].Prefix, (root_ref_in == null) ? xsdType_in : root_ref_in.MetadataCollection[0].CaseTranslate( xsdType_in, schemaName_in ) ); } }
public static XS__RootMetadata Load_fromFile( string metadataFilepath_in, bool useMetacache_in ) { string _key = metadataFilepath_in; if ( useMetacache_in && (metacache__ != null) && Metacache.Contains(_key) ) { return((XS__RootMetadata)XS__RootMetadata.Metacache[_key]); } else { XS__RootMetadata _rootmetadata = new XS__RootMetadata( metadataFilepath_in ); if (useMetacache_in) { XS__RootMetadata.Metacache.Add( _key, _rootmetadata ); } return(_rootmetadata); } }
public static XS__metadataExtended[] Load_fromURI( XS__RootMetadata root_ref_in, params Uri[] filePath_in ) { XS__metadataExtended[] _output = new XS__metadataExtended[filePath_in.Length]; for (int i = 0; i < filePath_in.Length; i++) { if (filePath_in[i].IsFile) { _output[i] = XS__metadataExtended.Load_fromFile( filePath_in[i].LocalPath )[0]; // no need! everything's been taken care at: XS__metadataExtended.Load_fromFile(...) //_output[i].root_metadataextended_ = ROOT + "." + METADATAEXTENDED + "[" + i + "]"; //_output[i].parent_ref = root_ref_in; // ToDos: now! //if (root_ref_in != null) _output[i].root_ref = root_ref_in; } else { try { _output[i] = (XS__metadataExtended) new XmlSerializer(typeof(XS__metadataExtended)).Deserialize( OGen.Libraries.PresentationLayer.WebForms.Utilities.ReadURL( filePath_in[i].ToString() ) ); } catch (Exception _ex) { throw new Exception(string.Format( System.Globalization.CultureInfo.CurrentCulture, "\n---\n{0}.{1}.Load_fromURI():\nERROR READING XML:\n{2}\n---\n{3}", typeof(XS__metadataExtended).Namespace, typeof(XS__metadataExtended).Name, //(filePath_in[i].IsFile) // ? filePath_in[i].LocalPath // : filePath_in[i].ToString(), _ex.Message )); } _output[i].root_metadataextended_ = ROOT + "." + METADATAEXTENDED + "[" + i + "]"; _output[i].parent_ref = root_ref_in; // ToDos: now! if (root_ref_in != null) { _output[i].root_ref = root_ref_in; } } } return(_output); }
public static string Convert_NType( XS__RootMetadata root_ref_in, string xsdType_in, string schemaName_in ) { bool isStandardNType_out; return Convert_NType( root_ref_in, xsdType_in, schemaName_in, out isStandardNType_out ); }
public static XS__diagram[] Load_fromURI( XS__RootMetadata root_ref_in, params Uri[] filePath_in ) { XS__diagram[] _output = new XS__diagram[filePath_in.Length]; for (int i = 0; i < filePath_in.Length; i++) { if (filePath_in[i].IsFile) { _output[i] = XS__diagram.Load_fromFile( filePath_in[i].LocalPath )[0]; // no need! everything's been taken care at: XS__diagram.Load_fromFile(...) //_output[i].root_diagram_ = ROOT + "." + DIAGRAM + "[" + i + "]"; //_output[i].parent_ref = root_ref_in; // ToDos: now! //if (root_ref_in != null) _output[i].root_ref = root_ref_in; } else { try { _output[i] = (XS__diagram) new XmlSerializer(typeof(XS__diagram)).Deserialize( OGen.lib.presentationlayer.webforms.utils.ReadURL( filePath_in[i].ToString() ) ); } catch (Exception _ex) { throw new Exception(string.Format( "\n---\n{0}.{1}.Load_fromURI():\nERROR READING XML:\n{2}\n---\n{3}", typeof(XS__diagram).Namespace, typeof(XS__diagram).Name, //(filePath_in[i].IsFile) // ? filePath_in[i].LocalPath // : filePath_in[i].ToString(), _ex.Message )); } _output[i].root_diagram_ = ROOT + "." + DIAGRAM + "[" + i + "]"; _output[i].parent_ref = root_ref_in; // ToDos: now! if (root_ref_in != null) { _output[i].root_ref = root_ref_in; } } } return(_output); }
public static string Convert_NType( XS__RootMetadata root_ref_in, string xsdType_in, string schemaName_in ) { bool isStandardNType_out; return(Convert_NType( root_ref_in, xsdType_in, schemaName_in, out isStandardNType_out )); }
public static XS__metadataExtended[] Load_fromFile( XS__RootMetadata root_ref_in, params string[] filePath_in ) { FileStream _stream; XS__metadataExtended[] _output = new XS__metadataExtended[filePath_in.Length]; for (int i = 0; i < filePath_in.Length; i++) { _stream = new FileStream( filePath_in[i], FileMode.Open, FileAccess.Read, FileShare.Read ); try { _output[i] = (XS__metadataExtended) new XmlSerializer(typeof(XS__metadataExtended)).Deserialize( _stream ); _stream.Close(); #if !NET_1_1 _stream.Dispose(); #endif } catch (Exception _ex) { throw new Exception(string.Format( System.Globalization.CultureInfo.CurrentCulture, "\n---\n{0}.{1}.Load_fromFile():\nERROR READING XML:\n{2}\n---\n{3}\n---\n{4}\n---\n", typeof(XS__metadataExtended).Namespace, typeof(XS__metadataExtended).Name, filePath_in[i], _ex.Message, _ex.InnerException )); } _output[i].root_metadataextended_ = ROOT + "." + METADATAEXTENDED + "[" + i + "]"; _output[i].parent_ref = root_ref_in; // ToDos: now! if (root_ref_in != null) { _output[i].root_ref = root_ref_in; } } return(_output); }
public static XS__RootMetadata Load_fromFile( string metadataFilePath_in, bool useMetadataCache_in, bool reinitializeCache_in ) { XS__RootMetadata _output; if (!useMetadataCache_in || reinitializeCache_in) { XS__RootMetadata.MetadataCache.Clear(); OGen.Libraries.Generator.Utilities.ReflectThrough_Cache_Clear(); } if (useMetadataCache_in) { // check before lock if (!MetadataCache.Contains(metadataFilePath_in)) { lock (metadatacache_locker) { // double check, thread safer! if (!MetadataCache.Contains(metadataFilePath_in)) { // initialization... // ...attribution (last thing before unlock) XS__RootMetadata.MetadataCache.Add( metadataFilePath_in, new XS__RootMetadata( metadataFilePath_in ) ); } } } _output = (XS__RootMetadata)XS__RootMetadata.MetadataCache[metadataFilePath_in]; return(_output); } else { _output = new XS__RootMetadata( metadataFilePath_in ); return(_output); } }
public static XS__documentation[] Load_fromFile( XS__RootMetadata root_ref_in, params string[] filePath_in ) { FileStream _stream; XS__documentation[] _output = new XS__documentation[filePath_in.Length]; for (int i = 0; i < filePath_in.Length; i++) { _stream = new FileStream( filePath_in[i], FileMode.Open, FileAccess.Read, FileShare.Read ); try { _output[i] = (XS__documentation) new XmlSerializer(typeof(XS__documentation)).Deserialize( _stream ); _stream.Close(); _stream.Dispose(); } catch (Exception _ex) { throw new Exception(string.Format( "\n---\n{0}.{1}.Load_fromFile():\nERROR READING XML:\n{2}\n---\n{3}\n---\n{4}\n---\n", typeof(XS__documentation).Namespace, typeof(XS__documentation).Name, filePath_in[i], _ex.Message, _ex.InnerException )); } _output[i].root_documentation_ = ROOT + "." + DOCUMENTATION + "[" + i + "]"; _output[i].parent_ref = root_ref_in; // ToDos: now! if (root_ref_in != null) { _output[i].root_ref = root_ref_in; } } return(_output); }
public static XS__metadataBusiness[] Load_fromFile( XS__RootMetadata root_ref_in, params string[] filePath_in ) { FileStream _stream; XS__metadataBusiness[] _output = new XS__metadataBusiness[filePath_in.Length]; for (int i = 0; i < filePath_in.Length; i++) { _stream = new FileStream( filePath_in[i], FileMode.Open, FileAccess.Read, FileShare.Read ); try { _output[i] = (XS__metadataBusiness)new XmlSerializer(typeof(XS__metadataBusiness)).Deserialize( _stream ); _stream.Close(); #if !NET_1_1 _stream.Dispose(); #endif } catch (Exception _ex) { throw new Exception(string.Format( System.Globalization.CultureInfo.CurrentCulture, "\n---\n{0}.{1}.Load_fromFile():\nERROR READING XML:\n{2}\n---\n{3}\n---\n{4}\n---\n", typeof(XS__metadataBusiness).Namespace, typeof(XS__metadataBusiness).Name, filePath_in[i], _ex.Message, _ex.InnerException )); } _output[i].root_metadatabusiness_ = ROOT + "." + METADATABUSINESS + "[" + i + "]"; _output[i].parent_ref = root_ref_in; // ToDos: now! if (root_ref_in != null) _output[i].root_ref = root_ref_in; } return _output; }
//#endregion // #region Methods... #region //public void New(...); // public void New( // string applicationPath_in, //string documentationName_in, // dNotifyBack notifyBack_in // ) { // if (notifyBack_in != null) notifyBack_in("creating...", true); // #region XS_Schema _metadata_temp = new XS_Schema(); ...; // XS_Schema _metadata_temp = new XS_Schema(); // _metadata_temp.DocumentationName = documentationName_in; // #endregion // // if (notifyBack_in != null) notifyBack_in("- generating xml file", true); // #region string _xmlfile = ...; // string _xmlfile = string.Format( // System.Globalization.CultureInfo.CurrentCulture, // "{0}{1}OGenXSD-metadatas{1}MD_{2}.OGenXSD-metadata.xml", // /*0*/applicationPath_in, // /*1*/System.IO.Path.DirectorySeparatorChar, // /*2*/documentationName_in // ); // #endregion // _metadata_temp.SaveState_toFile(_xmlfile); // // if (notifyBack_in != null) notifyBack_in("... finished!", true); // if (notifyBack_in != null) notifyBack_in("", true); // // Open( // _xmlfile, // true, // notifyBack_in // ); // } #endregion // #region public void Open(...); public void Open( string fileNameExtendedMetadata_in, bool force_doNOTSave_in, OGen.XSD.Libraries.Generator.NotifyBack notifyBack_in ) { #region Checking... if (this.HasChanges) { if (!force_doNOTSave_in) { throw new Exception(string.Format( System.Globalization.CultureInfo.CurrentCulture, "{0}.{1}.Open(): - must save before open", this.GetType().Namespace, this.GetType().Name )); } } #endregion this.filenameextendedmetadata_ = fileNameExtendedMetadata_in; if (notifyBack_in != null) { notifyBack_in("opening...", true); } if (notifyBack_in != null) { notifyBack_in("- reading metadata from xml files", true); } this.rootmetadata_ = XS__RootMetadata.Load_fromFile( this.filenameextendedmetadata_, false, true ); if (notifyBack_in != null) { notifyBack_in("... finished", true); } }
public static string Convert_NType( XS__RootMetadata root_ref_in, string xsdType_in, string schemaName_in, out bool isStandardNType_out ) { isStandardNType_out = true; switch (xsdType_in) { case "xs:string": return("string"); case "xs:decimal": return("decimal"); case "xs:integer": return("int"); case "xs:boolean": return("bool"); case "xs:time": case "xs:date": return("DateTime"); default: isStandardNType_out = false; return(string.Format( System.Globalization.CultureInfo.CurrentCulture, "{0}{1}", root_ref_in.MetadataCollection[0].Prefix, (root_ref_in == null) ? xsdType_in : root_ref_in.MetadataCollection[0].CaseTranslate( xsdType_in, schemaName_in ) )); } }
// #region public void New(...); // public void New( // string applicationPath_in, // string documentationName_in, // dNotifyBack notifyBack_in // ) { // if (notifyBack_in != null) notifyBack_in("creating...", true); // #region DocMetadata _metadata_temp = new DocMetadata(); ...; // XS__documentation _metadata_temp = new XS__documentation(); // _metadata_temp.DocumentationName = documentationName_in; // #endregion // // if (notifyBack_in != null) notifyBack_in("- generating xml file", true); // #region string _xmlfile = ...; // string _xmlfile = string.Format( // "{0}{1}OGenDoc-metadatas{1}MD_{2}.OGenDoc-metadata.xml", // /*0*/applicationPath_in, // /*1*/System.IO.Path.DirectorySeparatorChar, // /*2*/documentationName_in // ); // #endregion // _metadata_temp.SaveState_toFile(_xmlfile); // // if (notifyBack_in != null) notifyBack_in("... finished!", true); // if (notifyBack_in != null) notifyBack_in("", true); // // Open( // _xmlfile, // true, // notifyBack_in // ); // } // #endregion #region public void Open(...); public void Open( string filename_in, bool force_doNOTsave_in, dNotifyBack notifyBack_in ) { #region Checking... if (this.hasChanges) { if (!force_doNOTsave_in) { throw new Exception(string.Format( "{0}.{1}.Open(): - must save before open", this.GetType().Namespace, this.GetType().Name )); } } #endregion filename_ = filename_in; if (notifyBack_in != null) { notifyBack_in("opening...", true); } if (notifyBack_in != null) { notifyBack_in("- reading metadata from xml file", true); } rootmetadata_ = XS__RootMetadata.Load_fromFile( filename_, false ); if (notifyBack_in != null) { notifyBack_in("... finished", true); } }
public static XS__documentation[] Load_fromFile( XS__RootMetadata root_ref_in, params string[] filePath_in ) { FileStream _stream; XS__documentation[] _output = new XS__documentation[filePath_in.Length]; for (int i = 0; i < filePath_in.Length; i++) { _stream = new FileStream( filePath_in[i], FileMode.Open, FileAccess.Read, FileShare.Read ); try { _output[i] = (XS__documentation)new XmlSerializer(typeof(XS__documentation)).Deserialize( _stream ); _stream.Close(); _stream.Dispose(); } catch (Exception _ex) { throw new Exception(string.Format( "\n---\n{0}.{1}.Load_fromFile():\nERROR READING XML:\n{2}\n---\n{3}\n---\n{4}\n---\n", typeof(XS__documentation).Namespace, typeof(XS__documentation).Name, filePath_in[i], _ex.Message, _ex.InnerException )); } _output[i].root_documentation_ = ROOT + "." + DOCUMENTATION + "[" + i + "]"; _output[i].parent_ref = root_ref_in; // ToDos: now! if (root_ref_in != null) _output[i].root_ref = root_ref_in; } return _output; }
public static XS__metadataExtended[] Load_fromFile( XS__RootMetadata root_ref_in, params string[] filePath_in ) { FileStream _stream; XS__metadataExtended[] _output = new XS__metadataExtended[filePath_in.Length]; for (int i = 0; i < filePath_in.Length; i++) { _stream = new FileStream( filePath_in[i], FileMode.Open, FileAccess.Read, FileShare.Read ); try { _output[i] = (XS__metadataExtended)new XmlSerializer(typeof(XS__metadataExtended)).Deserialize( _stream ); } catch (Exception _ex) { throw new Exception(string.Format( "\n---\n{0}.{1}.Load_fromFile():\nERROR READING XML:\n{2}\n---\n{3}", typeof(XS0__metadataExtended).Namespace, typeof(XS0__metadataExtended).Name, filePath_in[i], _ex.Message )); } _output[i].root_metadataextended_ = ROOT + "." + METADATAEXTENDED + "[" + i + "]"; _output[i].parent_ref = root_ref_in; // ToDos: now! if (root_ref_in != null) _output[i].root_ref = root_ref_in; } return _output; }
static void Main(string[] args) { bool _found = false; string _file1 = System.IO.Path.Combine( #if !NET_1_1 System.Configuration.ConfigurationManager.AppSettings #else System.Configuration.ConfigurationSettings.AppSettings #endif ["ogenPath"], @"..\..\OGen-NTier_UTs\OGen-metadatas\MD_OGen-NTier_UTs.OGenXSD-metadata.xml" ) ; XS__RootMetadata _root = new XS__RootMetadata( _file1 ); Console.WriteLine( "null? '{0}'", (_root.Read_fromRoot( "ROOT.metadataExtended[0].tables.table[0].tableSearches.tableSearch[0].name" ) == null) ); _root.IterateThrough_fromRoot( "ROOT.metadataExtended[n].tables.table[n].tableSearches.tableSearch[n].tableSearchUpdates.tableSearchUpdate[n]", new OGen.lib.generator.utils.IterationFoundDelegate(notifyme), ref _found ); Console.WriteLine( "found? '{0}'", _found ); return; Console.WriteLine( "TableName: '{0}' : '{1}' : '{2}' : '{3}' : '{4}'", _root.Read_fromRoot("ROOT.metadataExtended[0].tables.table[0].name"), _root.Read_fromRoot("ROOT.metadataDB[0].tables.table[0].hasPK"), _root.Read_fromRoot("ROOT.metadataDB[0].tables.table[0].parallel_ref.name"), _root.Read_fromRoot("ROOT.metadataDB[0].tables.table[0].hasPK"), _root.Read_fromRoot("ROOT.metadataExtended[0].tables.table[0].parallel_ref.hasPK") ); _root.IterateThrough_fromRoot( "ROOT.metadataExtended[n].tables.table[n]", new OGen.lib.generator.utils.IterationFoundDelegate(notifyme), ref _found ); Console.WriteLine((_found) ? "done!\n" : "nothing to do\n"); Console.WriteLine( "SearchName: '{0}'", _root.Read_fromRoot("ROOT.metadataExtended[0].tables.table[0].tableSearches.tableSearch[0].name") ); _root.IterateThrough_fromRoot( "ROOT.metadataExtended[n].tables.table[n].tableSearches.tableSearch[n]", new OGen.lib.generator.utils.IterationFoundDelegate(notifyme), ref _found ); Console.WriteLine((_found) ? "done!\n" : "nothing to do\n"); Console.WriteLine(); Console.ReadLine(); return; #region //test1... //string _file1 = // System.IO.Path.Combine( // #if !NET_1_1 // System.Configuration.ConfigurationManager.AppSettings // #else // System.Configuration.ConfigurationSettings.AppSettings // #endif // ["ogenPath"], // //@"..\..\OGen-NTier_UTs\OGen-metadatas\MD_OGen-NTier_UTs.OGen-metadata.xml" // @"..\..\OGen-NTier_UTs\OGen-metadatas\xxx_apagar.xml" // ) //; //string _file2 = // System.IO.Path.Combine( // #if !NET_1_1 // System.Configuration.ConfigurationManager.AppSettings // #else // System.Configuration.ConfigurationSettings.AppSettings // #endif // ["ogenPath"], // //@"..\..\OGen-NTier_UTs\OGen-metadatas\MD0_OGen-NTier_UTs.OGen-metadata.xml" // @"..\..\OGen-NTier_UTs\OGen-metadatas\xxx0_apagar.xml" // ) //; //DBServerTypes _aux_dbservertype = DBServerTypes.SQLServer; //cDBMetadata _aux_metadata; //_aux_metadata = new cDBMetadata(); //#region //testings... ////_aux_metadata.LoadState_fromDB( //// null, //// DBServerTypes.SQLServer, //// "server=127.0.0.1;uid=sa;pwd=passpub;database=OGen-NTier_UTs;", //// "", //// true ////); ////for (int t = 0; t < _aux_metadata.Tables.Count; t++) { //// Console.WriteLine(_aux_metadata.Tables[t].Name); ////} ////return; //#endregion //_aux_metadata.LoadState_fromFile( // _file1 //); //Console.WriteLine("--- {0}", _aux_metadata.ApplicationName); //xpto(_aux_metadata); //_aux_metadata.SaveState_toFile( // _file2 //); //_aux_metadata = new cDBMetadata(); //_aux_metadata.LoadState_fromFile( // _file2 //); //xpto(_aux_metadata); #endregion }
public static XS__metadataBusiness Load_fromAssembly( string assemblyFilePath_in, XS__RootMetadata root_ref_in, int index_in ) { #region XS__metadataBusiness _output = ...; XS__metadataBusiness _output = new XS__metadataBusiness(); _output.root_metadatabusiness_ = ROOT + "." + METADATABUSINESS + "[" + index_in.ToString() + "]"; _output.parent_ref = root_ref_in; // ToDos: now! if (root_ref_in != null) { _output.root_ref = root_ref_in; } #endregion #region Assembly _assembly = Assembly.LoadFrom(assemblyFilePath_in); Assembly _assembly //= Assembly.LoadFile(assemblyFilePath_in); = Assembly.LoadFrom(assemblyFilePath_in); //_assembly.GetFiles(true); //_assembly.GetReferencedAssemblies(); if (_assembly == null) { throw new Exception(String.Format( "can't load assembly 'assemblyName_in'\n at: {0}.{1}.Load_fromAssembly();", typeof(XS__metadataBusiness).Namespace, typeof(XS__metadataBusiness).Name, assemblyFilePath_in )); } #endregion bool _isBO = false; bool _isBDO = false; int _class_index; int _method_index; int _property_index; Type[] _types = _assembly.GetTypes(); for (int t = 0; t < _types.Length; t++) { Type _type = (Type)_types[t]; object[] _classattributes = _type.GetCustomAttributes( typeof(BOClassAttribute), true //false ); if ( (_classattributes.Length > 0) //&& //(_type.Name.IndexOf("BO0_") != 0) //&& //(_type.Name.IndexOf("BDO0_") != 0) && ( (_type.Name.IndexOf("BO_") == 0) || (_type.Name.IndexOf("BDO_") == 0) ) ) { for (int ca = 0; ca < _classattributes.Length; ca++) { BOClassAttribute _attribute = (BOClassAttribute)_classattributes[ca]; _isBO = false; _isBDO = false; _output.Classes.ClassCollection.Add( out _class_index, //_attribute.Name (_isBO = (_type.Name.IndexOf("BO_") == 0)) ? _type.Name.Substring(3) : ( (_isBDO = (_type.Name.IndexOf("BDO_") == 0)) ? _type.Name.Substring(4) : _type.Name ) ); _output.Classes.ClassCollection[_class_index].Type = ((_isBO) ? XS_BoEnumeration.BO : ((_isBDO) ? XS_BoEnumeration.BDO : XS_BoEnumeration.invalid ) ); MethodInfo[] _methods = _type.GetMethods( BindingFlags.Public | BindingFlags.Instance ); for (int m = 0; m < _methods.Length; m++) { if (Attribute.IsDefined( _methods[m], typeof(BOMethodAttribute) )) { Attribute[] _methodattributes = Attribute.GetCustomAttributes( _methods[m], typeof(BOMethodAttribute), true ); _method_index = -1; for (int ma = 0; ma < _methodattributes.Length; ma++) { if (_methodattributes[ma].GetType() == typeof(BOMethodAttribute)) { BOMethodAttribute _methodattribute = (BOMethodAttribute)_methodattributes[ma]; _output.Classes.ClassCollection[_class_index].Methods.MethodCollection.Add( out _method_index, _methods[m].Name ); _output.Classes.ClassCollection[_class_index].Methods.MethodCollection[ _method_index ].Distribute = _methodattribute.Distribute; _output.Classes.ClassCollection[_class_index].Methods.MethodCollection[ _method_index ].OutputType = translate(string.Format( "{0}.{1}", _methods[m].ReturnType.Namespace, _methods[m].ReturnType.Name )); } } ParameterInfo[] _parameterinfo = _methods[m].GetParameters(); for (int p = 0; p < _parameterinfo.Length; p++) { _output.Classes.ClassCollection[_class_index].Methods.MethodCollection[_method_index].Parameters.ParameterCollection.Add( out _property_index, _parameterinfo[p].Name ); _output.Classes.ClassCollection[_class_index].Methods.MethodCollection[_method_index].Parameters.ParameterCollection[ _property_index ].isOut = _parameterinfo[p].IsOut; _output.Classes.ClassCollection[_class_index].Methods.MethodCollection[_method_index].Parameters.ParameterCollection[ _property_index ].Type = translate(string.Format( "{0}.{1}", _parameterinfo[p].ParameterType.Namespace, (_parameterinfo[p].ParameterType.Name.IndexOf('&') >= 0) ? _parameterinfo[p].ParameterType.Name.Substring(0, _parameterinfo[p].ParameterType.Name.Length - 1) : _parameterinfo[p].ParameterType.Name )); _output.Classes.ClassCollection[_class_index].Methods.MethodCollection[_method_index].Parameters.ParameterCollection[ _property_index ].isRef = (_parameterinfo[p].ParameterType.IsByRef && !_parameterinfo[p].IsOut); _output.Classes.ClassCollection[_class_index].Methods.MethodCollection[_method_index].Parameters.ParameterCollection[ _property_index ].isParams = false; } } } } } } return(_output); }
public static XS__metadataBusiness[] Load_fromURI( XS__RootMetadata root_ref_in, params Uri[] filePath_in ) { XS__metadataBusiness[] _output = new XS__metadataBusiness[filePath_in.Length]; for (int i = 0; i < filePath_in.Length; i++) { if (filePath_in[i].IsFile) { _output[i] = XS__metadataBusiness.Load_fromFile( filePath_in[i].LocalPath )[0]; // no need! everything's been taken care at: XS__metadataBusiness.Load_fromFile(...) //_output[i].root_metadatabusiness_ = ROOT + "." + METADATABUSINESS + "[" + i + "]"; //_output[i].parent_ref = root_ref_in; // ToDos: now! //if (root_ref_in != null) _output[i].root_ref = root_ref_in; } else { try { _output[i] = (XS__metadataBusiness)new XmlSerializer(typeof(XS__metadataBusiness)).Deserialize( OGen.Libraries.PresentationLayer.WebForms.Utilities.ReadURL( filePath_in[i].ToString() ) ); } catch (Exception _ex) { throw new Exception(string.Format( System.Globalization.CultureInfo.CurrentCulture, "\n---\n{0}.{1}.Load_fromURI():\nERROR READING XML:\n{2}\n---\n{3}", typeof(XS__metadataBusiness).Namespace, typeof(XS__metadataBusiness).Name, //(filePath_in[i].IsFile) // ? filePath_in[i].LocalPath // : filePath_in[i].ToString(), _ex.Message )); } _output[i].root_metadatabusiness_ = ROOT + "." + METADATABUSINESS + "[" + i + "]"; _output[i].parent_ref = root_ref_in; // ToDos: now! if (root_ref_in != null) _output[i].root_ref = root_ref_in; } } return _output; }
public static XS__metadataBusiness Load_fromAssembly( string assemblyFilePath_in, XS__RootMetadata root_ref_in, int index_in ) { #region XS__metadataBusiness _output = ...; XS__metadataBusiness _output = new XS__metadataBusiness(); _output.root_metadatabusiness_ = string.Concat(ROOT, ".", METADATABUSINESS, "[", index_in.ToString(System.Globalization.CultureInfo.CurrentCulture), "]"); _output.parent_ref = root_ref_in; // ToDos: now! if (root_ref_in != null) _output.root_ref = root_ref_in; #endregion #region Assembly _assembly = Assembly.LoadFrom(assemblyFilePath_in); Assembly _assembly //= Assembly.LoadFile(assemblyFilePath_in); = Assembly.LoadFrom(assemblyFilePath_in); //_assembly.GetFiles(true); //_assembly.GetReferencedAssemblies(); if (_assembly == null) { throw new Exception(string.Format( System.Globalization.CultureInfo.CurrentCulture, "can't load assembly 'assemblyName_in'\n at: {0}.{1}.Load_fromAssembly();", typeof(XS__metadataBusiness).Namespace, typeof(XS__metadataBusiness).Name, assemblyFilePath_in )); } #endregion //bool _isBO = false; //bool _isBDO = false; int _class_index; int _method_index; int _property_index; Type[] _types = _assembly.GetTypes(); #if NET_2_0 Array.Sort( _types, delegate( Type arg1, Type arg2 ) { return string.Compare( arg1.Name, arg2.Name, false, System.Globalization.CultureInfo.CurrentCulture ); } ); #endif for (int t = 0; t < _types.Length; t++) { Type _type = (Type)_types[t]; object[] _classattributes = _type.GetCustomAttributes( typeof(BOClassAttribute), true//false ); if ( (_classattributes.Length > 0) && (_type.Name.IndexOf("SBO_", StringComparison.CurrentCulture) == 0) ) { for (int ca = 0; ca < _classattributes.Length; ca++) { // BOClassAttribute _attribute // = (BOClassAttribute)_classattributes[ca]; _output.Classes.ClassCollection.Add( out _class_index, //_attribute.Name (_type.Name.IndexOf("SBO_", StringComparison.CurrentCulture) == 0) ? _type.Name.Substring(4) : _type.Name ); _output.Classes.ClassCollection[_class_index].Namespace = _type.Namespace; _output.Classes.ClassCollection[_class_index].Type = XS_BoEnumeration.invalid; MethodInfo[] _methods = _type.GetMethods( BindingFlags.Public | //BindingFlags.Instance BindingFlags.Static ); #if NET_2_0 Array.Sort( _methods, delegate( MethodInfo arg1, MethodInfo arg2 ) { return string.Compare( arg1.Name, arg2.Name, false, System.Globalization.CultureInfo.CurrentCulture ); } ); #endif for (int m = 0; m < _methods.Length; m++) { if (Attribute.IsDefined( _methods[m], typeof(BOMethodAttribute) )) { Attribute[] _methodattributes = Attribute.GetCustomAttributes( _methods[m], typeof(BOMethodAttribute), true ); _method_index = -1; for (int ma = 0; ma < _methodattributes.Length; ma++) { if (_methodattributes[ma].GetType() == typeof(BOMethodAttribute)) { BOMethodAttribute _methodattribute = (BOMethodAttribute)_methodattributes[ma]; _output.Classes.ClassCollection[_class_index].Methods.MethodCollection.Add( out _method_index, _methods[m].Name ); _output.Classes.ClassCollection[_class_index].Methods.MethodCollection[ _method_index ].Distribute = _methodattribute.Distribute; _output.Classes.ClassCollection[_class_index].Methods.MethodCollection[ _method_index ].IsSearch = _methodattribute.IsSearch; _output.Classes.ClassCollection[_class_index].Methods.MethodCollection[ _method_index ].IPParamNum = _methodattribute.IPParamNum; _output.Classes.ClassCollection[_class_index].Methods.MethodCollection[ _method_index ].OutputType = OGen.Libraries.Utilities.Type_ToString(_methods[m].ReturnType); } } ParameterInfo[] _parameterinfo = _methods[m].GetParameters(); for (int p = 0; p < _parameterinfo.Length; p++) { _output.Classes.ClassCollection[_class_index].Methods.MethodCollection[_method_index].Parameters.ParameterCollection.Add( out _property_index, _parameterinfo[p].Name ); _output.Classes.ClassCollection[_class_index].Methods.MethodCollection[_method_index].Parameters.ParameterCollection[ _property_index ].IsOut = _parameterinfo[p].IsOut; _output.Classes.ClassCollection[_class_index].Methods.MethodCollection[_method_index].Parameters.ParameterCollection[ _property_index ].Type = OGen.Libraries.Utilities.Type_ToString(_parameterinfo[p].ParameterType); _output.Classes.ClassCollection[_class_index].Methods.MethodCollection[_method_index].Parameters.ParameterCollection[ _property_index ].IsRef = (_parameterinfo[p].ParameterType.IsByRef && !_parameterinfo[p].IsOut); _output.Classes.ClassCollection[_class_index].Methods.MethodCollection[_method_index].Parameters.ParameterCollection[ _property_index ].IsParams = false; } } } } } } return _output; }
public static XS__metadataDB Load_fromDB( OGen.NTier.Libraries.Metadata.MetadataDB.Load_fromDatabase notifyBack_in, string subAppName_in, XS__RootMetadata root_ref_in, int index_in, params DBSimpleConnectionstring[] dbConnectionParam_in ) { #region XS__metadataDB _output = ...; XS__metadataDB _output = new XS__metadataDB(); _output.root_metadatadb_ = string.Concat(ROOT, ".", METADATADB, "[", index_in.ToString(System.Globalization.CultureInfo.CurrentCulture), "]"); _output.parent_ref = root_ref_in; // ToDos: now! if (root_ref_in != null) _output.root_ref = root_ref_in; #endregion bool _getTables_exists; bool _getTableFields_exists; DBConnection _connection; DBTable[] _tables_aux; DBTableField[] _fields_aux; XS_tableType _table; XS_tableDBType _tabledb; XS_tableFieldType _field; XS_tableFieldDBType _fielddb; int _searchindex; const string OGEN_SP0__GETTABLEFIELDS = "OGen_sp0__getTableFields"; const string OGEN_SP0__GETTABLES = "OGen_sp0__getTables"; for (int c = 0; c < dbConnectionParam_in.Length; c++) { #region notifyBack_in(...); if (notifyBack_in != null) { notifyBack_in( string.Format( System.Globalization.CultureInfo.CurrentCulture, "#{0}/{1} - {2}", c + 1, dbConnectionParam_in.Length, dbConnectionParam_in[c].DBServerType.ToString() ), true ); } #endregion _connection = DBConnectionsupport.CreateInstance( dbConnectionParam_in[c].DBServerType, dbConnectionParam_in[c].Connectionstring ); #region _tables_aux = ...; _getTables_exists = _connection.SQLStoredProcedure_exists(OGEN_SP0__GETTABLES); _tables_aux = _connection.SchemaDatabaseTables( subAppName_in, _getTables_exists ? OGEN_SP0__GETTABLES : string.Empty ); #endregion #region _fields_aux = ...; switch ((DBServerTypes)Enum.Parse(typeof(DBServerTypes), _connection.DBServerType)) { #if PostgreSQL case DBServerTypes.PostgreSQL: _getTableFields_exists = _connection.SQLFunction_exists(OGEN_SP0__GETTABLEFIELDS); break; #endif default: _getTableFields_exists = _connection.SQLStoredProcedure_exists(OGEN_SP0__GETTABLEFIELDS); break; } _fields_aux = _connection.SchemaDatabaseTableFields( // _tables_aux[t].Name, // get's specific table fields string.Empty, // get's fields for all tables _getTableFields_exists ? OGEN_SP0__GETTABLEFIELDS : string.Empty ); #endregion for (int t = 0; t < _tables_aux.Length; t++) { #region _table = ...; _table.Name = ...; _searchindex = _output.Tables.TableCollection.Search( _tables_aux[t].Name ); if (_searchindex >= 0) { _table = _output.Tables.TableCollection[_searchindex]; } else { _table = new XS_tableType( _tables_aux[t].Name ); _output.Tables.TableCollection.Add(_table); } #endregion _table.IsVirtualTable = _tables_aux[t].IsVirtualTable; #region _tabledb = ...; _tabledb.DBServerType = ...; _searchindex = _table.TableDBs.TableDBCollection.Search( dbConnectionParam_in[c].DBServerType.ToString() ); if (_searchindex >= 0) { _tabledb = _table.TableDBs.TableDBCollection[_searchindex]; } else { _tabledb = new XS_tableDBType( dbConnectionParam_in[c].DBServerType.ToString() ); _table.TableDBs.TableDBCollection.Add(_tabledb); } #endregion _tabledb.DBTableName = _tables_aux[t].Name; _tabledb.DBDescription = _tables_aux[t].DBDescription; for (int f = 0; f < _fields_aux.Length; f++) { if ( #if MySQL ( (dbConnectionParam_in[c].DBServerType == DBServerTypes.MySQL) && (_tables_aux[t].Name.ToLower() != _fields_aux[f].TableName.ToLower()) ) || #endif (_tables_aux[t].Name != _fields_aux[f].TableName) ) { continue; } #region _field = ...; _field.Name = ...; _searchindex = _table.TableFields.TableFieldCollection.Search( _fields_aux[f].Name ); if (_searchindex >= 0) { _field = _table.TableFields.TableFieldCollection[_searchindex]; } else { _field = new XS_tableFieldType( _fields_aux[f].Name ); _table.TableFields.TableFieldCollection.Add(_field); } #endregion _field.IsPK = _fields_aux[f].IsPK; _field.IsIdentity = _fields_aux[f].IsIdentity; _field.IsNullable = _fields_aux[f].IsNullable; _field.NumericPrecision = _fields_aux[f].Numeric_Precision; _field.NumericScale = _fields_aux[f].Numeric_Scale; _field.Size = _fields_aux[f].Size; #if MySQL if ( (dbConnectionParam_in[c].DBServerType == DBServerTypes.MySQL) && (_field.FKTableName == string.Empty) ) { _field.FKTableName = _fields_aux[f].ForeignKey_TableName; } else if ( (dbConnectionParam_in[c].DBServerType != DBServerTypes.MySQL) ) { _field.FKTableName = _fields_aux[f].ForeignKey_TableName; } #else _field.FKTableName = _fields_aux[f].ForeignKey_TableName; #endif _field.FKFieldName = _fields_aux[f].ForeignKey_TableFieldName; #region _fielddb = ...; _fielddb.DBServerType = ...; _searchindex = _field.TableFieldDBs.TableFieldDBCollection.Search( dbConnectionParam_in[c].DBServerType ); if (_searchindex >= 0) { _fielddb = _field.TableFieldDBs.TableFieldDBCollection[_searchindex]; } else { _fielddb = new XS_tableFieldDBType( dbConnectionParam_in[c].DBServerType.ToString() ); _field.TableFieldDBs.TableFieldDBCollection.Add(_fielddb); } #endregion _fielddb.DBType = _fields_aux[f].DBType_inDB_name; _fielddb.DBDescription = _fields_aux[f].DBDescription; _fielddb.DBDefaultValue = _fields_aux[f].DBDefaultValue; _fielddb.DBCollationName = _fields_aux[f].DBCollationName; _fielddb.DBFieldName = _fields_aux[f].Name; } } } return _output; }
static void Main(string[] args) { XS__RootMetadata _rootmetadata = XS__RootMetadata.Load_fromFile( System.IO.Path.Combine( #if !NET_1_1 System.Configuration.ConfigurationManager.AppSettings #else System.Configuration.ConfigurationSettings.AppSettings #endif ["ogenPath"], @"..\..\OGen-NTier\OGen-NTier-Doc\OGenDoc-metadatas\MD_OGen.OGenDoc-metadata.xml" ), false ); Console.WriteLine(_rootmetadata.Read_fromRoot( //"ROOT.documentation[0].subjects.subject.Count" //"ROOT.documentation[0].documentationName" //"ROOT.documentation[0].subjects.subject[0].description" //"ROOT.documentation[0].subjects.subject[2].idSubject" //"ROOT.documentation[0].subjects.subject[18].documents.document[2].idDocument" "ROOT.documentation[0].subjects.subject[19].documents.document[1].document" )); _rootmetadata.IterateThrough_fromRoot( "ROOT.documentation[n].faqSubjects.faqSubject[n]", //"ROOT.documentation[n].subjects.subject[n]", Iteration_found ); // #region test3 - translate bug... //Console.WriteLine(OGen.Doc.lib.metadata.utils.translate( // @"---${code::1} //--- //${code::1} //--- //${code::1} //---", // rootmetadata_.DocumentationCollection[0] //)); // // return; // #endregion #region //test2 - performance tweaks... // long _begin_ticks = DateTime.Now.Ticks; // // string filename_ // = System.IO.Path.Combine( // #if !NET_1_1 // System.Configuration.ConfigurationManager.AppSettings // #else // System.Configuration.ConfigurationSettings.AppSettings // #endif // ["ogenPath"], // // @"..\..\OGen-NTier\OGen-NTier-Doc\OGenDoc-metadatas\MD_OGen.OGenDoc-metadata.xml" // ); // string _outputDir = System.IO.Directory.GetParent( // Path.GetDirectoryName(filename_) // ).FullName; // // XS__RootMetadata rootmetadata_ = XS__RootMetadata.Load_fromFile( // filename_, // false // ); // // Console.WriteLine( // "--- instance: -------------------------------\n{0}\n----------------------------------------------", // //rootmetadata_.DocumentationCollection[0].Subjects.SubjectCollection.Count // //rootmetadata_.DocumentationCollection[0].DocumentationName // //rootmetadata_.DocumentationCollection[0].Subjects.SubjectCollection[0].Description // //rootmetadata_.DocumentationCollection[0].Subjects.SubjectCollection[2].IDSubject // //rootmetadata_.DocumentationCollection[0].Subjects.SubjectCollection[18].Documents.DocumentCollection[2].IDDocument // rootmetadata_.DocumentationCollection[0].Subjects.SubjectCollection[19].Documents.DocumentCollection[1].Document // ); // Console.WriteLine( // "--- reflection: ------------------------------\n{0}\n----------------------------------------------", // rootmetadata_.Read_fromRoot( // //"ROOT.documentation[0].subjects.subject.Count" // //"ROOT.documentation[0].documentationName" // //"ROOT.documentation[0].subjects.subject[0].description" // //"ROOT.documentation[0].subjects.subject[2].idSubject" // //"ROOT.documentation[0].subjects.subject[18].documents.document[2].idDocument" // "ROOT.documentation[0].subjects.subject[19].documents.document[1].document" // ) // ); // rootmetadata_.IterateThrough_fromRoot( // "ROOT.documentation[n].subjects.subject[n]", // //"ROOT.documentation[n].subjects.subject[n].documents.document[n]", // Iteration_found // ); // // Console.WriteLine("time: {0}", new DateTime(DateTime.Now.Ticks - _begin_ticks).ToString("HH'H' mm'm' ss's' fff")); // return; #endregion #region //test1 - generator... // MetaFile[] _metafiles = new MetaFile[rootmetadata_.MetadataFiles.MetadataFiles.Count]; // for (int i = 0; i < rootmetadata_.MetadataFiles.MetadataFiles.Count; i++) { // _metafiles[i] = new MetaFile( // Path.Combine( // Path.GetDirectoryName(filename_), // rootmetadata_.MetadataFiles.MetadataFiles[i].XMLFilename // ), // XS__documentation.DOCUMENTATION // ); // } // cGenerator _generator = new cGenerator( // #if !NET_1_1 // System.Configuration.ConfigurationManager.AppSettings // #else // System.Configuration.ConfigurationSettings.AppSettings // #endif // ["Templates"], // _outputDir, // _metafiles // ); // _generator.Build( // Notify, // rootmetadata_ // ); // return; #endregion }
public static XS__metadataBusiness Load_fromAssembly( string assemblyFilePath_in, XS__RootMetadata root_ref_in, int index_in ) { #region XS__metadataBusiness _output = ...; XS__metadataBusiness _output = new XS__metadataBusiness(); _output.root_metadatabusiness_ = string.Concat(ROOT, ".", METADATABUSINESS, "[", index_in.ToString(System.Globalization.CultureInfo.CurrentCulture), "]"); _output.parent_ref = root_ref_in; // ToDos: now! if (root_ref_in != null) { _output.root_ref = root_ref_in; } #endregion #region Assembly _assembly = Assembly.LoadFrom(assemblyFilePath_in); Assembly _assembly //= Assembly.LoadFile(assemblyFilePath_in); = Assembly.LoadFrom(assemblyFilePath_in); //_assembly.GetFiles(true); //_assembly.GetReferencedAssemblies(); if (_assembly == null) { throw new Exception(string.Format( System.Globalization.CultureInfo.CurrentCulture, "can't load assembly 'assemblyName_in'\n at: {0}.{1}.Load_fromAssembly();", typeof(XS__metadataBusiness).Namespace, typeof(XS__metadataBusiness).Name, assemblyFilePath_in )); } #endregion //bool _isBO = false; //bool _isBDO = false; int _class_index; int _method_index; int _property_index; Type[] _types = _assembly.GetTypes(); #if NET_2_0 Array.Sort( _types, delegate( Type arg1, Type arg2 ) { return(string.Compare( arg1.Name, arg2.Name, false, System.Globalization.CultureInfo.CurrentCulture )); } ); #endif for (int t = 0; t < _types.Length; t++) { Type _type = (Type)_types[t]; object[] _classattributes = _type.GetCustomAttributes( typeof(BOClassAttribute), true //false ); if ( (_classattributes.Length > 0) && (_type.Name.IndexOf("SBO_", StringComparison.CurrentCulture) == 0) ) { for (int ca = 0; ca < _classattributes.Length; ca++) { // BOClassAttribute _attribute // = (BOClassAttribute)_classattributes[ca]; _output.Classes.ClassCollection.Add( out _class_index, //_attribute.Name (_type.Name.IndexOf("SBO_", StringComparison.CurrentCulture) == 0) ? _type.Name.Substring(4) : _type.Name ); _output.Classes.ClassCollection[_class_index].Namespace = _type.Namespace; _output.Classes.ClassCollection[_class_index].Type = XS_BoEnumeration.invalid; MethodInfo[] _methods = _type.GetMethods( BindingFlags.Public | //BindingFlags.Instance BindingFlags.Static ); #if NET_2_0 Array.Sort( _methods, delegate( MethodInfo arg1, MethodInfo arg2 ) { return(string.Compare( arg1.Name, arg2.Name, false, System.Globalization.CultureInfo.CurrentCulture )); } ); #endif for (int m = 0; m < _methods.Length; m++) { if (Attribute.IsDefined( _methods[m], typeof(BOMethodAttribute) )) { Attribute[] _methodattributes = Attribute.GetCustomAttributes( _methods[m], typeof(BOMethodAttribute), true ); _method_index = -1; for (int ma = 0; ma < _methodattributes.Length; ma++) { if (_methodattributes[ma].GetType() == typeof(BOMethodAttribute)) { BOMethodAttribute _methodattribute = (BOMethodAttribute)_methodattributes[ma]; _output.Classes.ClassCollection[_class_index].Methods.MethodCollection.Add( out _method_index, _methods[m].Name ); _output.Classes.ClassCollection[_class_index].Methods.MethodCollection[ _method_index ].Distribute = _methodattribute.Distribute; _output.Classes.ClassCollection[_class_index].Methods.MethodCollection[ _method_index ].IsSearch = _methodattribute.IsSearch; _output.Classes.ClassCollection[_class_index].Methods.MethodCollection[ _method_index ].IPParamNum = _methodattribute.IPParamNum; _output.Classes.ClassCollection[_class_index].Methods.MethodCollection[ _method_index ].OutputType = OGen.Libraries.Utilities.Type_ToString(_methods[m].ReturnType); } } ParameterInfo[] _parameterinfo = _methods[m].GetParameters(); for (int p = 0; p < _parameterinfo.Length; p++) { _output.Classes.ClassCollection[_class_index].Methods.MethodCollection[_method_index].Parameters.ParameterCollection.Add( out _property_index, _parameterinfo[p].Name ); _output.Classes.ClassCollection[_class_index].Methods.MethodCollection[_method_index].Parameters.ParameterCollection[ _property_index ].IsOut = _parameterinfo[p].IsOut; _output.Classes.ClassCollection[_class_index].Methods.MethodCollection[_method_index].Parameters.ParameterCollection[ _property_index ].Type = OGen.Libraries.Utilities.Type_ToString(_parameterinfo[p].ParameterType); _output.Classes.ClassCollection[_class_index].Methods.MethodCollection[_method_index].Parameters.ParameterCollection[ _property_index ].IsRef = (_parameterinfo[p].ParameterType.IsByRef && !_parameterinfo[p].IsOut); _output.Classes.ClassCollection[_class_index].Methods.MethodCollection[_method_index].Parameters.ParameterCollection[ _property_index ].IsParams = false; } } } } } } return(_output); }
//#endregion // #region public void Open(...); public void Open( string filename_in, bool force_doNOTsave_in, dNotifyBack notifyBack_in ) { #region Checking... if (this.hasChanges) { if (!force_doNOTsave_in) { throw new Exception(string.Format( "{0}.{1}.Open(): - must save before open", this.GetType().Namespace, this.GetType().Name )); } } #endregion Filename = filename_in; if (notifyBack_in != null) { notifyBack_in("opening...", true); } if (notifyBack_in != null) { notifyBack_in("- reading configuration from xml file", true); } metadata_ = XS__RootMetadata.Load_fromFile( Filename, false ); #region - reading metadata from business assembly string _debug_assembly = Path.Combine( ParentDirectoryname, businessAssembly( metadata_.MetadataExtendedCollection[0].ApplicationName, metadata_.MetadataExtendedCollection[0].ApplicationNamespace, false ) ); string _release_assembly = Path.Combine( ParentDirectoryname, businessAssembly( metadata_.MetadataExtendedCollection[0].ApplicationName, metadata_.MetadataExtendedCollection[0].ApplicationNamespace, true ) ); bool _debug_exits = File.Exists(_debug_assembly); bool _release_exits = File.Exists(_release_assembly); if (_debug_exits || _release_exits) { DateTime _debug_datetime = (_debug_exits) ? File.GetLastWriteTime(_debug_assembly) : DateTime.MinValue; DateTime _release_datetime = (_release_exits) ? File.GetLastWriteTime(_release_assembly) : DateTime.MinValue; string _assembly = (_debug_datetime > _release_datetime) ? _debug_assembly : _release_assembly; if (notifyBack_in != null) { notifyBack_in("- reading metadata from business assembly", true); } OGen.NTier.lib.metadata.metadataBusiness.XS__metadataBusiness _metadatabusiness; try { _metadatabusiness = OGen.NTier.lib.metadata.metadataBusiness.XS__metadataBusiness.Load_fromAssembly( _assembly, null, 0 ); } catch (Exception _ex) { throw new Exception(string.Format( "\n---\nfailed to load assembly: {0}\n---\n{1}\n---\n{2}\n---\n{3}\n---", _assembly, _ex.Message, _ex.InnerException, _ex.HelpLink )); //_assembly } _metadatabusiness.ApplicationName = metadata_.MetadataExtendedCollection[0].ApplicationName; _metadatabusiness.SaveState_toFile( Path.Combine( Directoryname, string.Format( "MD_{0}.OGenXSD-metadataBusiness.xml", metadata_.MetadataExtendedCollection[0].ApplicationName ) ) ); if (notifyBack_in != null) { notifyBack_in("- saving business metadata to xml file", true); } } else { if (notifyBack_in != null) { notifyBack_in("- WARNING: no metadata from business assembly to read from", true); } } #endregion #region - reading metadata from db if (notifyBack_in != null) { notifyBack_in("- reading metadata from db", true); } OGen.NTier.lib.metadata.metadataDB.XS__metadataDB _metadatadb = OGen.NTier.lib.metadata.metadataDB.XS__metadataDB.Load_fromDB( null, metadata_.MetadataExtendedCollection[0].SubAppName, metadata_, 0, metadata_dbconnectionstrings().Convert_toArray() ); // NOTE: this is very important, every parameter / information // that's not comming from the database is empty, // and needs to be filled in order to be serialized to the xml file: _metadatadb.ApplicationName = metadata_.MetadataExtendedCollection[0].ApplicationName; for (int ff, tt, t = 0; t < metadata_.MetadataExtendedCollection[0].Tables.TableCollection.Count; t++) { for (int f = 0; f < metadata_.MetadataExtendedCollection[0].Tables.TableCollection[t].TableFields.TableFieldCollection.Count; f++) { if (metadata_.MetadataExtendedCollection[0].Tables.TableCollection[t].TableFields.TableFieldCollection[f].isViewPK) { tt = _metadatadb.Tables.TableCollection.Search( metadata_.MetadataExtendedCollection[0].Tables.TableCollection[t].Name, !metadata_.MetadataExtendedCollection[0].DBs.Supports_MySQL ); if (tt < 0) { continue; } ff = _metadatadb.Tables.TableCollection[tt].TableFields.TableFieldCollection.Search( metadata_.MetadataExtendedCollection[0].Tables.TableCollection[t].TableFields.TableFieldCollection[f].Name, !metadata_.MetadataExtendedCollection[0].DBs.Supports_MySQL ); if (ff < 0) { continue; } _metadatadb.Tables.TableCollection[ tt ].TableFields.TableFieldCollection[ ff ].isPK = true; } } } for (int i = 0; i < metadata_.MetadataFiles.MetadataFiles.Count; i++) { if ( metadata_.MetadataFiles.MetadataFiles[i].XMLFileType == OGen.NTier.lib.metadata.metadataDB.XS__metadataDB.METADATADB ) { if (notifyBack_in != null) { notifyBack_in("- saving db metadata to xml file", true); } //--- BUG: using old db information //metadata_.MetadataDBCollection[0].SaveState_toFile( // Path.Combine( // Directoryname, // metadata_.MetadataFiles.MetadataFiles[i].XMLFilename // ) //); //--- DEBUG: using new db information _metadatadb.SaveState_toFile( Path.Combine( Directoryname, metadata_.MetadataFiles.MetadataFiles[i].XMLFilename ) ); break; } } #endregion if (notifyBack_in != null) { notifyBack_in("- re-reading configuration from xml file", true); } metadata_ = XS__RootMetadata.Load_fromFile( Filename, false ); if (notifyBack_in != null) { notifyBack_in("... finished", true); } }
public static XS__metadataDB Load_fromDB( XS__metadataDB.Load_fromDBDelegate notifyBack_in, string subAppName_in, XS__RootMetadata root_ref_in, int index_in, params DBSimpleConnectionstring[] dbConnectionParam_in ) { #region XS__metadataDB _output = ...; XS__metadataDB _output = new XS__metadataDB(); _output.root_metadatadb_ = ROOT + "." + METADATADB + "[" + index_in.ToString() + "]"; _output.parent_ref = root_ref_in; // ToDos: now! if (root_ref_in != null) { _output.root_ref = root_ref_in; } #endregion bool _getTables_exists; bool _getTableFields_exists; DBConnection _connection; DBTable[] _tables_aux; DBTableField[] _fields_aux; XS_tableType _table; XS_tableDBType _tabledb; XS_tableFieldType _field; XS_tableFieldDBType _fielddb; int _searchindex; const string OGEN_SP0__GETTABLEFIELDS = "OGen_sp0__getTableFields"; const string OGEN_SP0__GETTABLES = "OGen_sp0__getTables"; for (int c = 0; c < dbConnectionParam_in.Length; c++) { #region notifyBack_in(...); if (notifyBack_in != null) { notifyBack_in( string.Format( "#{0}/{1} - {2}", c + 1, dbConnectionParam_in.Length, dbConnectionParam_in[c].DBServerType.ToString() ), true ); } #endregion _connection = DBConnectionsupport.CreateInstance( dbConnectionParam_in[c].DBServerType, dbConnectionParam_in[c].Connectionstring ); #region _tables_aux = ...; _getTables_exists = _connection.SQLStoredProcedure_exists(OGEN_SP0__GETTABLES); _tables_aux = _connection.getTables( subAppName_in, _getTables_exists ? OGEN_SP0__GETTABLES : string.Empty ); #endregion #region _fields_aux = ...; switch ((DBServerTypes)Enum.Parse(typeof(DBServerTypes), _connection.DBServerType)) { #if PostgreSQL case DBServerTypes.PostgreSQL: _getTableFields_exists = _connection.SQLFunction_exists(OGEN_SP0__GETTABLEFIELDS); break; #endif default: _getTableFields_exists = _connection.SQLStoredProcedure_exists(OGEN_SP0__GETTABLEFIELDS); break; } _fields_aux = _connection.getTableFields( // _tables_aux[t].Name, // get's specific table fields string.Empty, // get's fields for all tables _getTableFields_exists ? OGEN_SP0__GETTABLEFIELDS : string.Empty ); #endregion for (int t = 0; t < _tables_aux.Length; t++) { #region _table = ...; _table.Name = ...; _searchindex = _output.Tables.TableCollection.Search( _tables_aux[t].Name ); if (_searchindex >= 0) { _table = _output.Tables.TableCollection[_searchindex]; } else { _table = new XS_tableType( _tables_aux[t].Name ); _output.Tables.TableCollection.Add(_table); } #endregion _table.isVirtualTable = _tables_aux[t].isVirtualTable; #region _tabledb = ...; _tabledb.DBServerType = ...; _searchindex = _table.TableDBs.TableDBCollection.Search( dbConnectionParam_in[c].DBServerType.ToString() ); if (_searchindex >= 0) { _tabledb = _table.TableDBs.TableDBCollection[_searchindex]; } else { _tabledb = new XS_tableDBType( dbConnectionParam_in[c].DBServerType.ToString() ); _table.TableDBs.TableDBCollection.Add(_tabledb); } #endregion _tabledb.DBTableName = _tables_aux[t].Name; _tabledb.DBDescription = _tables_aux[t].DBDescription; for (int f = 0; f < _fields_aux.Length; f++) { if ( #if MySQL ( (dbConnectionParam_in[c].DBServerType == DBServerTypes.MySQL) && (_tables_aux[t].Name.ToLower() != _fields_aux[f].TableName.ToLower()) ) || #endif (_tables_aux[t].Name != _fields_aux[f].TableName) ) { continue; } #region _field = ...; _field.Name = ...; _searchindex = _table.TableFields.TableFieldCollection.Search( _fields_aux[f].Name ); if (_searchindex >= 0) { _field = _table.TableFields.TableFieldCollection[_searchindex]; } else { _field = new XS_tableFieldType( _fields_aux[f].Name ); _table.TableFields.TableFieldCollection.Add(_field); } #endregion _field.isPK = _fields_aux[f].isPK; _field.isIdentity = _fields_aux[f].isIdentity; _field.isNullable = _fields_aux[f].isNullable; _field.NumericPrecision = _fields_aux[f].Numeric_Precision; _field.NumericScale = _fields_aux[f].Numeric_Scale; _field.Size = _fields_aux[f].Size; #if MySQL if ( (dbConnectionParam_in[c].DBServerType == DBServerTypes.MySQL) && (_field.FKTableName == string.Empty) ) { _field.FKTableName = _fields_aux[f].FK_TableName; } else if ( (dbConnectionParam_in[c].DBServerType != DBServerTypes.MySQL) ) { _field.FKTableName = _fields_aux[f].FK_TableName; } #else _field.FKTableName = _fields_aux[f].FK_TableName; #endif _field.FKFieldName = _fields_aux[f].FK_FieldName; #region _fielddb = ...; _fielddb.DBServerType = ...; _searchindex = _field.TableFieldDBs.TableFieldDBCollection.Search( dbConnectionParam_in[c].DBServerType ); if (_searchindex >= 0) { _fielddb = _field.TableFieldDBs.TableFieldDBCollection[_searchindex]; } else { _fielddb = new XS_tableFieldDBType( dbConnectionParam_in[c].DBServerType.ToString() ); _field.TableFieldDBs.TableFieldDBCollection.Add(_fielddb); } #endregion _fielddb.DBType = _fields_aux[f].DBType_inDB_name; _fielddb.DBDescription = _fields_aux[f].DBDescription; _fielddb.DBDefaultValue = _fields_aux[f].DBDefaultValue; _fielddb.DBCollationName = _fields_aux[f].DBCollationName; _fielddb.DBFieldName = _fields_aux[f].Name; } } } return(_output); }
//#endregion // #region public void Open(...); public void Open( string filename_in, bool force_doNOTSave_in, OGen.NTier.Libraries.Generator.NotifyBack notifyBack_in ) { #region Checking... if (this.HasChanges) { if (!force_doNOTSave_in) { throw new Exception(string.Format( System.Globalization.CultureInfo.CurrentCulture, "{0}.{1}.Open(): - must save before open", this.GetType().Namespace, this.GetType().Name )); } } #endregion this.FileName = filename_in; if (notifyBack_in != null) notifyBack_in("opening...", true); if (notifyBack_in != null) notifyBack_in("- reading configuration from xml file", true); this.metadata_ = XS__RootMetadata.Load_fromFile( this.FileName, false, true ); #region - reading metadata from business assembly string _debug_assembly = Path.Combine( this.ParentDirectoryname, businessAssembly( this.metadata_.MetadataExtendedCollection[0].ApplicationName, this.metadata_.MetadataExtendedCollection[0].ApplicationNamespace, false ) ); string _release_assembly = Path.Combine( this.ParentDirectoryname, businessAssembly( this.metadata_.MetadataExtendedCollection[0].ApplicationName, this.metadata_.MetadataExtendedCollection[0].ApplicationNamespace, true ) ); bool _debug_exits = File.Exists(_debug_assembly); bool _release_exits = File.Exists(_release_assembly); if (_debug_exits || _release_exits) { DateTime _debug_datetime = (_debug_exits) ? File.GetLastWriteTime(_debug_assembly) : DateTime.MinValue; DateTime _release_datetime = (_release_exits) ? File.GetLastWriteTime(_release_assembly) : DateTime.MinValue; string _assembly = (_debug_datetime > _release_datetime) ? _debug_assembly : _release_assembly; if (notifyBack_in != null) notifyBack_in("- reading metadata from business assembly", true); OGen.NTier.Libraries.Metadata.MetadataBusiness.XS__metadataBusiness _metadatabusiness; try { _metadatabusiness = OGen.NTier.Libraries.Metadata.MetadataBusiness.XS__metadataBusiness.Load_fromAssembly( _assembly, null, 0 ); } catch (Exception _ex) { throw new Exception(string.Format( System.Globalization.CultureInfo.CurrentCulture, "\n---\nfailed to load assembly: {0}\n---\n{1}\n---\n{2}\n---\n{3}\n---", _assembly, _ex.Message, _ex.InnerException, _ex.HelpLink )); //_assembly } _metadatabusiness.ApplicationName = this.metadata_.MetadataExtendedCollection[0].ApplicationName; _metadatabusiness.SaveState_toFile( Path.Combine( this.Directoryname, string.Format( System.Globalization.CultureInfo.CurrentCulture, "MD_{0}.OGenXSD-metadataBusiness.xml", this.metadata_.MetadataExtendedCollection[0].ApplicationName ) ) ); if (notifyBack_in != null) notifyBack_in("- saving business metadata to xml file", true); } else { if (notifyBack_in != null) notifyBack_in("- WARNING: no metadata from business assembly to read from", true); } #endregion #region - reading metadata from db if (notifyBack_in != null) notifyBack_in("- reading metadata from db", true); OGen.NTier.Libraries.Metadata.MetadataDB.XS__metadataDB _metadatadb = OGen.NTier.Libraries.Metadata.MetadataDB.XS__metadataDB.Load_fromDB( null, this.metadata_.MetadataExtendedCollection[0].SubAppName, this.metadata_, 0, this.metadata_dbconnectionstrings().Convert_toArray() ); // NOTE: this is very important, every parameter / information // that's not comming from the database is empty, // and needs to be filled in order to be serialized to the xml file: _metadatadb.ApplicationName = this.metadata_.MetadataExtendedCollection[0].ApplicationName; for (int ff, tt, t = 0; t < this.metadata_.MetadataExtendedCollection[0].Tables.TableCollection.Count; t++) { for (int f = 0; f < this.metadata_.MetadataExtendedCollection[0].Tables.TableCollection[t].TableFields.TableFieldCollection.Count; f++) { if (this.metadata_.MetadataExtendedCollection[0].Tables.TableCollection[t].TableFields.TableFieldCollection[f].IsViewPK) { tt = _metadatadb.Tables.TableCollection.Search( this.metadata_.MetadataExtendedCollection[0].Tables.TableCollection[t].Name, !this.metadata_.MetadataExtendedCollection[0].DBs.Supports_MySQL ); if (tt < 0) continue; ff = _metadatadb.Tables.TableCollection[tt].TableFields.TableFieldCollection.Search( this.metadata_.MetadataExtendedCollection[0].Tables.TableCollection[t].TableFields.TableFieldCollection[f].Name, !this.metadata_.MetadataExtendedCollection[0].DBs.Supports_MySQL ); if (ff < 0) continue; _metadatadb.Tables.TableCollection[ tt ].TableFields.TableFieldCollection[ ff ].IsPK = true; } } } for (int i = 0; i < this.metadata_.MetadataFiles.MetadataFiles.Count; i++) { if ( this.metadata_.MetadataFiles.MetadataFiles[i].XMLFileType == OGen.NTier.Libraries.Metadata.MetadataDB.XS__metadataDB.METADATADB ) { if (notifyBack_in != null) notifyBack_in("- saving db metadata to xml file", true); //--- BUG: using old db information //metadata_.MetadataDBCollection[0].SaveState_toFile( // Path.Combine( // Directoryname, // metadata_.MetadataFiles.MetadataFiles[i].XMLFileName // ) //); //--- DEBUG: using new db information _metadatadb.SaveState_toFile( Path.Combine( this.Directoryname, this.metadata_.MetadataFiles.MetadataFiles[i].XMLFileName ) ); break; } } #endregion if (notifyBack_in != null) notifyBack_in("- re-reading configuration from xml file", true); this.metadata_ = XS__RootMetadata.Load_fromFile( this.FileName, false, true ); if (notifyBack_in != null) notifyBack_in("... finished", true); }
// #region Methods... #region //public void New(...); // public void New( // string applicationPath_in, //string documentationName_in, // dNotifyBack notifyBack_in // ) { // if (notifyBack_in != null) notifyBack_in("creating...", true); // #region XS_Schema _metadata_temp = new XS_Schema(); ...; // XS_Schema _metadata_temp = new XS_Schema(); // _metadata_temp.DocumentationName = documentationName_in; // #endregion // // if (notifyBack_in != null) notifyBack_in("- generating xml file", true); // #region string _xmlfile = ...; // string _xmlfile = string.Format( // "{0}{1}OGenXSD-metadatas{1}MD_{2}.OGenXSD-metadata.xml", // /*0*/applicationPath_in, // /*1*/System.IO.Path.DirectorySeparatorChar, // /*2*/documentationName_in // ); // #endregion // _metadata_temp.SaveState_toFile(_xmlfile); // // if (notifyBack_in != null) notifyBack_in("... finished!", true); // if (notifyBack_in != null) notifyBack_in("", true); // // Open( // _xmlfile, // true, // notifyBack_in // ); // } #endregion // #region public void Open(...); public void Open( string filenameextendedmetadata_in, bool force_doNOTsave_in, dNotifyBack notifyBack_in ) { #region Checking... if (this.hasChanges) { if (!force_doNOTsave_in) { throw new Exception(string.Format("{0}.{1}.Open(): - must save before open", this.GetType().Namespace, this.GetType().Name)); } } #endregion filenameextendedmetadata_ = filenameextendedmetadata_in; if (notifyBack_in != null) notifyBack_in("opening...", true); if (notifyBack_in != null) notifyBack_in("- reading metadata from xml files", true); rootmetadata_ = XS__RootMetadata.Load_fromFile( filenameextendedmetadata_, false ); if (notifyBack_in != null) notifyBack_in("... finished", true); }
public static XS__metadataDB Load_fromDB( XS__metadataDB.Load_fromDBDelegate notifyBack_in, string subAppName_in, XS__RootMetadata root_ref_in, int index_in, params DBConnectionParam[] dbConnectionParam_in ) { #region XS__metadataDB _output = ...; XS__metadataDB _output = new XS__metadataDB(); _output.root_metadatadb_ = ROOT + "." + METADATADB + "[" + index_in.ToString() + "]"; _output.parent_ref = root_ref_in; // ToDos: now! if (root_ref_in != null) _output.root_ref = root_ref_in; #endregion bool _getTables_exists; bool _getTableFields_exists; DBConnection _connection; cDBTable[] _tables_aux; cDBTableField[] _fields_aux; XS_tableType _table; XS_tableDBType _tabledb; XS_tableFieldType _field; XS_tableFieldDBType _fielddb; int _searchindex; const string OGEN_SP0__GETTABLEFIELDS = "OGen_sp0__getTableFields"; const string OGEN_SP0__GETTABLES = "OGen_sp0__getTables"; for (int c = 0; c < dbConnectionParam_in.Length; c++) { #region notifyBack_in(...); if (notifyBack_in != null) { notifyBack_in( string.Format( "#{0}/{1} - {2}", c + 1, dbConnectionParam_in.Length, dbConnectionParam_in[c].DBServerType.ToString() ), true ); } #endregion _connection = DBConnectionsupport.CreateInstance( dbConnectionParam_in[c].DBServerType, dbConnectionParam_in[c].Connectionstring ); #region _tables_aux = ...; _getTables_exists = _connection.SQLStoredProcedure_exists(OGEN_SP0__GETTABLES); _tables_aux = _connection.getTables( subAppName_in, _getTables_exists ? OGEN_SP0__GETTABLES : string.Empty ); #endregion #region _fields_aux = ...; _getTableFields_exists = _connection.SQLStoredProcedure_exists(OGEN_SP0__GETTABLEFIELDS); _fields_aux = _connection.getTableFields( // _tables_aux[t].Name, // get's specific table fields string.Empty, // get's fields for all tables _getTableFields_exists ? OGEN_SP0__GETTABLEFIELDS : string.Empty ); #endregion for (int t = 0; t < _tables_aux.Length; t++) { #region _table = ...; _table.Name = ...; _searchindex = _output.Tables.TableCollection.Search( _tables_aux[t].Name, true ); if (_searchindex >= 0) { _table = _output.Tables.TableCollection[_searchindex]; } else { _table = new XS_tableType( _tables_aux[t].Name ); _output.Tables.TableCollection.Add(_table); } #endregion _table.isVirtualTable = _tables_aux[t].isVirtualTable; #region _tabledb = ...; _tabledb.DBServerType = ...; _searchindex = _table.TableDBs.TableDBCollection.Search( dbConnectionParam_in[c].DBServerType.ToString(), true ); if (_searchindex >= 0) { _tabledb = _table.TableDBs.TableDBCollection[_searchindex]; } else { _tabledb = new XS_tableDBType( dbConnectionParam_in[c].DBServerType.ToString() ); _table.TableDBs.TableDBCollection.Add(_tabledb); } #endregion _tabledb.DBTableName = _tables_aux[t].Name; _tabledb.DBDescription = _tables_aux[t].DBDescription; for (int f = 0; f < _fields_aux.Length; f++) { if (_tables_aux[t].Name != _fields_aux[f].TableName) { continue; } #region _field = ...; _field.Name = ...; _searchindex = _table.TableFields.TableFieldCollection.Search( _fields_aux[f].Name, true ); if (_searchindex >= 0) { _field = _table.TableFields.TableFieldCollection[_searchindex]; } else { _field = new XS_tableFieldType( _fields_aux[f].Name ); _table.TableFields.TableFieldCollection.Add(_field); } #endregion _field.isPK = _fields_aux[f].isPK; _field.isIdentity = _fields_aux[f].isIdentity; _field.isNullable = _fields_aux[f].isNullable; _field.NumericPrecision = _fields_aux[f].Numeric_Precision; _field.NumericScale = _fields_aux[f].Numeric_Scale; _field.Size = _fields_aux[f].Size; _field.FKTableName = _fields_aux[f].FK_TableName; _field.FKFieldName = _fields_aux[f].FK_FieldName; #region _fielddb = ...; _fielddb.DBServerType = ...; _searchindex = _field.TableFieldDBs.TableFieldDBCollection.Search( dbConnectionParam_in[c].DBServerType.ToString(), true ); if (_searchindex >= 0) { _fielddb = _field.TableFieldDBs.TableFieldDBCollection[_searchindex]; } else { _fielddb = new XS_tableFieldDBType( dbConnectionParam_in[c].DBServerType.ToString() ); } #endregion _fielddb.DBType = _fields_aux[f].DBType_inDB_name; _fielddb.DBDescription = _fields_aux[f].DBDescription; _fielddb.DBDefaultValue = _fields_aux[f].DBDefaultValue; _fielddb.DBCollationName = _fields_aux[f].DBCollationName; _fielddb.DBFieldName = _fields_aux[f].Name; } } } return _output; }
public static XS__RootMetadata Load_fromFile( string metadataFilepath_in, bool useMetacache_in ) { string _key = metadataFilepath_in; if ( useMetacache_in && (metacache__ != null) && Metacache.Contains(_key) ) { return (XS__RootMetadata)XS__RootMetadata.Metacache[_key]; } else { XS__RootMetadata _rootmetadata = new XS__RootMetadata( metadataFilepath_in ); if (useMetacache_in) { XS__RootMetadata.Metacache.Add( _key, _rootmetadata ); } return _rootmetadata; } }
public static XS__metadataExtended[] Load_fromURI( XS__RootMetadata root_ref_in, params Uri[] filePath_in ) { XS__metadataExtended[] _output = new XS__metadataExtended[filePath_in.Length]; for (int i = 0; i < filePath_in.Length; i++) { if (filePath_in[i].IsFile) { _output[i] = XS__metadataExtended.Load_fromFile( filePath_in[i].LocalPath )[0]; // no need! everything's been taken care at: XS__metadataExtended.Load_fromFile(...) //_output[i].root_metadataextended_ = ROOT + "." + METADATAEXTENDED + "[" + i + "]"; //_output[i].parent_ref = root_ref_in; // ToDos: now! //if (root_ref_in != null) _output[i].root_ref = root_ref_in; } else { try { _output[i] = (XS__metadataExtended)new XmlSerializer(typeof(XS__metadataExtended)).Deserialize( OGen.lib.presentationlayer.webforms.utils.ReadURL( filePath_in[i].ToString() ) ); } catch (Exception _ex) { throw new Exception(string.Format( "\n---\n{0}.{1}.Load_fromURI():\nERROR READING XML:\n{2}\n---\n{3}", typeof(XS__metadataExtended).Namespace, typeof(XS__metadataExtended).Name, //(filePath_in[i].IsFile) // ? filePath_in[i].LocalPath // : filePath_in[i].ToString(), _ex.Message )); } _output[i].root_metadataextended_ = ROOT + "." + METADATAEXTENDED + "[" + i + "]"; _output[i].parent_ref = root_ref_in; // ToDos: now! if (root_ref_in != null) _output[i].root_ref = root_ref_in; } } return _output; }
public static XS__metadataBusiness Load_fromAssembly( string assemblyFilePath_in, XS__RootMetadata root_ref_in, int index_in ) { #region XS__metadataBusiness _output = ...; XS__metadataBusiness _output = new XS__metadataBusiness(); _output.root_metadatabusiness_ = ROOT + "." + METADATABUSINESS + "[" + index_in.ToString() + "]"; _output.parent_ref = root_ref_in; // ToDos: now! if (root_ref_in != null) _output.root_ref = root_ref_in; #endregion #region Assembly _assembly = Assembly.LoadFrom(assemblyFilePath_in); Assembly _assembly //= Assembly.LoadFile(assemblyFilePath_in); = Assembly.LoadFrom(assemblyFilePath_in); //_assembly.GetFiles(true); //_assembly.GetReferencedAssemblies(); if (_assembly == null) { throw new Exception(String.Format( "can't load assembly 'assemblyName_in'\n at: {0}.{1}.Load_fromAssembly();", typeof(XS__metadataBusiness).Namespace, typeof(XS__metadataBusiness).Name, assemblyFilePath_in )); } #endregion bool _isBO = false; bool _isBDO = false; int _class_index; int _method_index; int _property_index; Type[] _types = _assembly.GetTypes(); for (int t = 0; t < _types.Length; t++) { Type _type = (Type)_types[t]; object[] _classattributes = _type.GetCustomAttributes( typeof(BOClassAttribute), true//false ); if ( (_classattributes.Length > 0) //&& //(_type.Name.IndexOf("BO0_") != 0) //&& //(_type.Name.IndexOf("BDO0_") != 0) && ( (_type.Name.IndexOf("BO_") == 0) || (_type.Name.IndexOf("BDO_") == 0) ) ) { for (int ca = 0; ca < _classattributes.Length; ca++) { BOClassAttribute _attribute = (BOClassAttribute)_classattributes[ca]; _isBO = false; _isBDO = false; _output.Classes.ClassCollection.Add( out _class_index, //_attribute.Name (_isBO = (_type.Name.IndexOf("BO_") == 0)) ? _type.Name.Substring(3) : ( (_isBDO = (_type.Name.IndexOf("BDO_") == 0)) ? _type.Name.Substring(4) : _type.Name ) ); _output.Classes.ClassCollection[_class_index].Type = ((_isBO) ? XS_BoEnumeration.BO : ((_isBDO) ? XS_BoEnumeration.BDO : XS_BoEnumeration.invalid ) ); MethodInfo[] _methods = _type.GetMethods( BindingFlags.Public | BindingFlags.Instance ); for (int m = 0; m < _methods.Length; m++) { if (Attribute.IsDefined( _methods[m], typeof(BOMethodAttribute) )) { Attribute[] _methodattributes = Attribute.GetCustomAttributes( _methods[m], typeof(BOMethodAttribute), true ); _method_index = -1; for (int ma = 0; ma < _methodattributes.Length; ma++) { if (_methodattributes[ma].GetType() == typeof(BOMethodAttribute)) { BOMethodAttribute _methodattribute = (BOMethodAttribute)_methodattributes[ma]; _output.Classes.ClassCollection[_class_index].Methods.MethodCollection.Add( out _method_index, _methods[m].Name ); _output.Classes.ClassCollection[_class_index].Methods.MethodCollection[ _method_index ].Distribute = _methodattribute.Distribute; _output.Classes.ClassCollection[_class_index].Methods.MethodCollection[ _method_index ].OutputType = translate(string.Format( "{0}.{1}", _methods[m].ReturnType.Namespace, _methods[m].ReturnType.Name )); } } ParameterInfo[] _parameterinfo = _methods[m].GetParameters(); for (int p = 0; p < _parameterinfo.Length; p++) { _output.Classes.ClassCollection[_class_index].Methods.MethodCollection[_method_index].Parameters.ParameterCollection.Add( out _property_index, _parameterinfo[p].Name ); _output.Classes.ClassCollection[_class_index].Methods.MethodCollection[_method_index].Parameters.ParameterCollection[ _property_index ].isOut = _parameterinfo[p].IsOut; _output.Classes.ClassCollection[_class_index].Methods.MethodCollection[_method_index].Parameters.ParameterCollection[ _property_index ].Type = translate(string.Format( "{0}.{1}", _parameterinfo[p].ParameterType.Namespace, (_parameterinfo[p].ParameterType.Name.IndexOf('&') >= 0) ? _parameterinfo[p].ParameterType.Name.Substring(0, _parameterinfo[p].ParameterType.Name.Length - 1) : _parameterinfo[p].ParameterType.Name )); _output.Classes.ClassCollection[_class_index].Methods.MethodCollection[_method_index].Parameters.ParameterCollection[ _property_index ].isRef = (_parameterinfo[p].ParameterType.IsByRef && !_parameterinfo[p].IsOut); _output.Classes.ClassCollection[_class_index].Methods.MethodCollection[_method_index].Parameters.ParameterCollection[ _property_index ].isParams = false; } } } } } } return _output; }
public static void Main(string[] args) { Console.WriteLine( System.Reflection.Assembly.GetExecutingAssembly().ImageRuntimeVersion ); Console.ReadLine(); return; Debug.Listeners.Add(new TextWriterTraceListener(System.Console.Out)); //int x = 0; //Debug.WriteLine(x++); //Console.WriteLine(x); //return; bool _found = false; string _file1 = System.IO.Path.Combine( #if !NET_1_1 System.Configuration.ConfigurationManager.AppSettings #else System.Configuration.ConfigurationSettings.AppSettings #endif ["ogenPath"], @"..\..\OGen-NTier_UTs\OGen-metadatas\MD_OGen-NTier_UTs.OGenXSD-metadata.xml" ) ; XS__RootMetadata _root = new XS__RootMetadata( _file1 ); string _aux; Console.WriteLine( "null? {0} \t\t '{1}'", ((_aux = _root.Read_fromRoot( "ROOT.metadataExtended[0].tables.table[0].tableSearches.tableSearch[0].name" )) == null), _aux ); Console.WriteLine("-------------------------------------------------------------"); _root.IterateThrough_fromRoot( "ROOT.metadataExtended[0].tables.table[n].tableSearches.tableSearch[n].tableSearchUpdates.tableSearchUpdate[n]", delegate(string message_in) { Console.WriteLine("'{0}'", message_in); }, ref _found ); Console.WriteLine("-------------------------------------------------------------"); _root.IterateThrough_fromRoot( "ROOT.metadataExtended[n].tables.table[n].tableSearches.tableSearch[n].tableSearchUpdates.tableSearchUpdate[n]", delegate(string message_in) { Console.WriteLine("'{0}'", message_in); }, ref _found ); Console.WriteLine( "found? '{0}'", _found ); Console.WriteLine("-------------------------------------------------------------"); _root.IterateThrough_fromRoot( "ROOT.metadataExtended[0].tables.table[n]", delegate(string message_in) { Console.WriteLine( "{0}.name: '{1}'", message_in, _root.Read_fromRoot( message_in + ".name" ) ); }, ref _found ); Console.WriteLine("-------------------------------------------------------------"); _root.IterateThrough_fromRoot( "ROOT.metadataExtended[0].tables.table[n].tableSearches.tableSearch[n]", delegate(string message_in) { Console.WriteLine("'{0}'", message_in); }, ref _found ); Console.WriteLine("-------------------------------------------------------------"); return; Console.WriteLine( "TableName: '{0}' : '{1}' : '{2}' : '{3}' : '{4}'", _root.Read_fromRoot("ROOT.metadataExtended[0].tables.table[0].name"), _root.Read_fromRoot("ROOT.metadataDB[0].tables.table[0].hasPK"), _root.Read_fromRoot("ROOT.metadataDB[0].tables.table[0].parallel_ref.name"), _root.Read_fromRoot("ROOT.metadataDB[0].tables.table[0].hasPK"), _root.Read_fromRoot("ROOT.metadataExtended[0].tables.table[0].parallel_ref.hasPK") ); _root.IterateThrough_fromRoot( "ROOT.metadataExtended[n].tables.table[n]", delegate(string message_in) { Console.WriteLine(message_in); }, ref _found ); Console.WriteLine((_found) ? "done!\n" : "nothing to do\n"); Console.WriteLine( "SearchName: '{0}'", _root.Read_fromRoot("ROOT.metadataExtended[0].tables.table[0].tableSearches.tableSearch[0].name") ); _root.IterateThrough_fromRoot( "ROOT.metadataExtended[n].tables.table[n].tableSearches.tableSearch[n]", delegate(string message_in) { Console.WriteLine(message_in); }, ref _found ); Console.WriteLine((_found) ? "done!\n" : "nothing to do\n"); Console.WriteLine(); Console.ReadLine(); return; #region //test1... //string _file1 = // System.IO.Path.Combine( // #if !NET_1_1 // System.Configuration.ConfigurationManager.AppSettings // #else // System.Configuration.ConfigurationSettings.AppSettings // #endif // ["ogenPath"], // //@"..\..\OGen-NTier_UTs\OGen-metadatas\MD_OGen-NTier_UTs.OGen-metadata.xml" // @"..\..\OGen-NTier_UTs\OGen-metadatas\xxx_apagar.xml" // ) //; //string _file2 = // System.IO.Path.Combine( // #if !NET_1_1 // System.Configuration.ConfigurationManager.AppSettings // #else // System.Configuration.ConfigurationSettings.AppSettings // #endif // ["ogenPath"], // //@"..\..\OGen-NTier_UTs\OGen-metadatas\MD0_OGen-NTier_UTs.OGen-metadata.xml" // @"..\..\OGen-NTier_UTs\OGen-metadatas\xxx0_apagar.xml" // ) //; //DBServerTypes _aux_dbservertype = DBServerTypes.SQLServer; //cDBMetadata _aux_metadata; //_aux_metadata = new cDBMetadata(); //#region //testings... ////_aux_metadata.LoadState_fromDB( //// null, //// DBServerTypes.SQLServer, //// "server=127.0.0.1;uid=sa;pwd=passpub;database=OGen-NTier_UTs;", //// "", //// true ////); ////for (int t = 0; t < _aux_metadata.Tables.Count; t++) { //// Console.WriteLine(_aux_metadata.Tables[t].Name); ////} ////return; //#endregion //_aux_metadata.LoadState_fromFile( // _file1 //); //Console.WriteLine("--- {0}", _aux_metadata.ApplicationName); //xpto(_aux_metadata); //_aux_metadata.SaveState_toFile( // _file2 //); //_aux_metadata = new cDBMetadata(); //_aux_metadata.LoadState_fromFile( // _file2 //); //xpto(_aux_metadata); #endregion }
//#endregion #region public Methods... // #region public void New(...); // public void New( // string applicationPath_in, // string documentationName_in, // dNotifyBack notifyBack_in // ) { // if (notifyBack_in != null) notifyBack_in("creating...", true); // #region DocMetadata _metadata_temp = new DocMetadata(); ...; // XS__documentation _metadata_temp = new XS__documentation(); // _metadata_temp.DocumentationName = documentationName_in; // #endregion // // if (notifyBack_in != null) notifyBack_in("- generating xml file", true); // #region string _xmlfile = ...; // string _xmlfile = string.Format( // System.Globalization.CultureInfo.CurrentCulture, // "{0}{1}OGenDoc-metadatas{1}MD_{2}.OGenDoc-metadata.xml", // /*0*/applicationPath_in, // /*1*/System.IO.Path.DirectorySeparatorChar, // /*2*/documentationName_in // ); // #endregion // _metadata_temp.SaveState_toFile(_xmlfile); // // if (notifyBack_in != null) notifyBack_in("... finished!", true); // if (notifyBack_in != null) notifyBack_in("", true); // // Open( // _xmlfile, // true, // notifyBack_in // ); // } // #endregion #region public void Open(...); public void Open( string filename_in, bool force_doNOTSave_in, OGen.Doc.Libraries.Generator.NotifyBack notifyBack_in ) { #region Checking... if (this.HasChanges) { if (!force_doNOTSave_in) { throw new Exception(string.Format( System.Globalization.CultureInfo.CurrentCulture, "{0}.{1}.Open(): - must save before open", this.GetType().Namespace, this.GetType().Name )); } } #endregion this.filename_ = filename_in; if (notifyBack_in != null) notifyBack_in("opening...", true); if (notifyBack_in != null) notifyBack_in("- reading metadata from xml file", true); this.rootmetadata_ = XS__RootMetadata.Load_fromFile( this.filename_, false, true ); if (notifyBack_in != null) notifyBack_in("... finished", true); }