private SelectedLists GetSelecetedLists() { SelectedLists allItems = new SelectedLists(); allItems.SelectedListCollection = new List <SelectedList>(); foreach (CheckListItem checkedItems in CheckListSpLists.CheckedItems) { var selectedList = new SelectedList(); selectedList.CheckedField = new List <Field>(); List list = (List)checkedItems.Value; var checkedFields = SpContext .SelectedListItems .Where(a => a.SpList == list) .FirstOrDefault() .Fields.Where(a => a.Selected) .ToList(); selectedList.List = list; foreach (var checkedField in checkedFields) { selectedList.CheckedField.Add(checkedField.Field); } allItems.SelectedListCollection.Add(selectedList); } return(allItems); }
internal CreateCs(SelectedLists selectedLists) { InitializeComponent(); this.SelectedLists = selectedLists; textNamespace.Text = SpContext.NamespaceString; textProjectFolder.Text = SpContext.ModelFolder; textContextName.Text = SpContext.ContextName; }
public void Create(SelectedLists selectedLists, string nameSpaceString, string path, string contextName) { //Create Context var contextFileName = path + "\\" + contextName + ".cs"; var contextString = CreateContextUsingDeclerations; contextString += CreateNamespace(nameSpaceString); contextString += CreateContextClass(contextName); foreach (var list in selectedLists.SelectedListCollection) { //Create Entity Files var classString = CreateEntityClass(list, nameSpaceString); string fileName = path + "\\" + list.List.Title.CleanName() + ".cs"; if (System.IO.File.Exists(fileName)) { string newFileName = fileName + "-bak"; var counter = 0; while (System.IO.File.Exists(newFileName)) { newFileName = string.Format("{0}{1}", newFileName, counter++); } System.IO.File.Move(fileName, newFileName); } System.IO.File.WriteAllText(fileName, classString, Encoding.Unicode); contextString += CreateContextProperty(list.List.Title.CleanName()); } contextString += CloseClass(); if (System.IO.File.Exists(contextFileName)) { string newFileName = contextFileName + "-bak"; var counter = 0; while (System.IO.File.Exists(newFileName)) { newFileName = string.Format("{0}{1}", newFileName, counter++); } System.IO.File.Move(contextFileName, newFileName); } System.IO.File.WriteAllText(contextFileName, contextString); }
public void SaveInfo(SelectedLists saveInfo, string path) { var file = JsonConvert.SerializeObject(saveInfo); File.WriteAllText(path, file); }