public void Save(BaseAssemblyModel _object, string path) { ClearDB(); using (TPADBContext context = new TPADBContext()) { DBAssemblyModel assemblyModel = (DBAssemblyModel)_object; context.AssemblyModel.Add(assemblyModel); context.SaveChanges(); } }
public void Save(BaseAssemblyModel _object, string path) { XMLAssemblyModel assembly = (XMLAssemblyModel)_object; string name = JsonConvert.SerializeObject(assembly, Formatting.Indented, new JsonSerializerSettings { PreserveReferencesHandling = PreserveReferencesHandling.Objects }); using (System.IO.StreamWriter file = new System.IO.StreamWriter(path, true)) { file.Write(name); } }
public static AssemblyModel MapUp(BaseAssemblyModel model) { AssemblyModel assemblyModel = new AssemblyModel(); Type type = model.GetType(); assemblyModel.Name = model.Name; PropertyInfo namespaceModelsProperty = type.GetProperty("NamespaceModels", BindingFlags.Instance | BindingFlags.Public | BindingFlags.DeclaredOnly); List <BaseNamespaceModel> namespaceModels = (List <BaseNamespaceModel>)HelperClass.ConvertList(typeof(BaseNamespaceModel), (IList)namespaceModelsProperty?.GetValue(model)); if (namespaceModels != null) { assemblyModel.NamespaceModels = namespaceModels.Select(n => new NamespaceModelMapper().MapUp(n)).ToList(); } return(assemblyModel); }