// #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_ = RootMetadata.Load_fromFile( filenameextendedmetadata_, false ); if (notifyBack_in != null) { notifyBack_in("... finished", true); } }
public static void SaveToFile(string path, RootMetadata metadata) { var json = JsonConvert.SerializeObject(metadata, Formatting.Indented); File.WriteAllText(path, json); }