Beispiel #1
0
        private string WriteIvyFile(string outputPath, string filename, bool savePath)
        {
            if (filename == null)
            {
                filename = "ivy.xml";
            }
            if (!Directory.Exists(outputPath))
            {
                Directory.CreateDirectory(outputPath);
            }
            string text = Path.Combine(outputPath, filename);

            if (!savePath)
            {
                this.BasePath = (this.IvyFile = null);
            }
            string value = IvyParser.Serialize(this);

            using (StreamWriter streamWriter = File.CreateText(text))
            {
                streamWriter.Write(value);
            }
            this.BasePath = outputPath;
            this.IvyFile  = filename;
            return(text);
        }
Beispiel #2
0
        public static T Parse <T>(string xml) where T : class
        {
            object obj = IvyParser.Deserialize <T>(xml);

            if (obj != null && typeof(T) == typeof(IvyModule))
            {
                ((IvyModule)obj).IvyFile = "ivy.xml";
            }
            return(obj as T);
        }
Beispiel #3
0
        public string WriteIvyFile(string outputPath, string filename)
        {
            if (filename == null)
            {
                filename = "ivy.xml";
            }
            if (!Directory.Exists(outputPath))
            {
                Directory.CreateDirectory(outputPath);
            }
            string path = Path.Combine(outputPath, filename);
            string str2 = IvyParser.Serialize(this);

            using (StreamWriter writer = File.CreateText(path))
            {
                writer.Write(str2);
            }
            return(path);
        }
Beispiel #4
0
        public static T ParseFile <T>(string path) where T : class
        {
            IvyParser.HasErrors      = false;
            IvyParser.ErrorMessage   = null;
            IvyParser.ErrorException = null;
            if (!File.Exists(path))
            {
                IvyParser.HasErrors    = true;
                IvyParser.ErrorMessage = string.Format("File does not exist: {0}", path);
                return((T)((object)null));
            }
            object obj = IvyParser.Parse <T>(File.ReadAllText(path, Encoding.UTF8));

            if (obj != null && typeof(T) == typeof(IvyModule))
            {
                ((IvyModule)obj).BasePath = Path.GetDirectoryName(path);
                ((IvyModule)obj).IvyFile  = Path.GetFileName(path);
            }
            return(obj as T);
        }
Beispiel #5
0
 public static IvyModule FromIvyFile(string fullpath)
 {
     return(IvyParser.ParseFile <IvyModule>(fullpath));
 }
Beispiel #6
0
 public override string ToString()
 {
     return(IvyParser.Serialize(this));
 }
Beispiel #7
0
 public override string ToString() =>
 IvyParser.Serialize(this);
Beispiel #8
0
 public static ModuleRepository FromIvyFile(string fullpath) =>
 IvyParser.ParseFile <ModuleRepository>(fullpath);
Beispiel #9
0
 public static ModuleRepository FromIvyFile(string fullpath)
 {
     return(IvyParser.ParseFile <ModuleRepository>(fullpath));
 }
Beispiel #10
0
 public static IvyModule FromIvyFile(string fullpath) =>
 IvyParser.ParseFile <IvyModule>(fullpath);