public Model() : base() { this.classes = new MetaList <MetaClass>(); this.types = new MetaList <MetaType>(); foreach (string name in Constants.TYPES_VOID) { this.types.Add(new MetaType(name)); } foreach (string name in Constants.TYPES_INT) { this.types.Add(new MetaType(name)); } foreach (string name in Constants.TYPES_FLOAT) { this.types.Add(new MetaType(name)); } foreach (string name in Constants.TYPES_BOOL) { this.types.Add(new MetaType(name)); } foreach (string name in Constants.TYPES_CHAR) { this.types.Add(new MetaType(name)); } foreach (string name in Constants.TYPES_STRING) { this.types.Add(new MetaType(name)); } }
public override bool Update(Model model) { if (!base.Update(model)) { return(false); } MetaClass oldClass = (MetaClass)this.type; MetaType metaType = model.FindMatchingType(this.type); if (metaType == null) { return(false); } this.type = metaType; MetaClass newClass = (MetaClass)this.type; MetaInstanceVariable instanceVariable; MetaList <MetaInstanceVariable> metaInstanceVariables = new MetaList <MetaInstanceVariable>(this.instanceVariables); this.instanceVariables.Clear(); foreach (MetaVariable metaVariable in newClass.AllVariables) { instanceVariable = metaInstanceVariables.Find(iv => iv.Variable.Equals(metaVariable)); if (instanceVariable != null) { this.instanceVariables.Add(instanceVariable); } else { instanceVariable = metaInstanceVariables.Find(iv => iv.Variable.Equals(metaVariable)); this.instanceVariables.Add(new MetaInstanceVariable(metaVariable)); } } return(true); }
private void tryDeleteType() { if (this.lbTypes.SelectedIndex >= 0) { MetaList <MetaType> types = this.model.Types; if (types.Count == 1) { MetaType metaType = (MetaType)this.lbTypes.SelectedItem; MessageBox.Show(string.Format(errorLastTypeDelete, metaType.Name), "Error!", MessageBoxButtons.OK, MessageBoxIcon.Error); } else { MetaType metaType = (MetaType)this.lbTypes.SelectedItem; if (!types.Contains(metaType)) { MessageBox.Show(string.Format(errorClassDelete, metaType.Name), "Error!", MessageBoxButtons.OK, MessageBoxIcon.Error); } else { this.model.DeleteTypeAt(this.lbTypes.SelectedIndex); this.RefreshData(); } } } }
public override void UpdateType(MetaType oldType, MetaType newType) { this.model.UpdateType(oldType, newType); if (oldType.CategoryType == ECategoryType.Class && newType.CategoryType == ECategoryType.Class) { MetaClass oldClass = (MetaClass)oldType; MetaClass newClass = (MetaClass)newType; if (this.values.GetKeys().Contains(oldClass)) { MetaList <MetaValue> values = this.values[oldClass]; this.values.Remove(oldClass); this.values[newClass] = values; if (this.visibleClasses.Contains(oldClass)) { this.visibleClasses.Remove(oldClass); this.visibleClasses.Add(newClass); } } } foreach (KeyValuePair <MetaClass, MetaList <MetaValue> > pair in this.values) { foreach (MetaValue value in pair.Value) { value.UpdateType(oldType, newType); } } }
public SpListItemsProvider(ClientContext clientContext, MetaList list) : base(list) { _clientContext = clientContext; _spList = clientContext.GetListByUrl(list.Url, list.WebUrl); }
public void SetDictionaryValues(MetaDictionary <MetaValue, MetaValue> metaValues) { this.dictionaryKeys = metaValues.GetKeys(); this.dictionaryValues = metaValues.GetValues(this.dictionaryKeys); this.Enabled = (this.dictionaryValues.Count > 0); this.RefreshData(); }
public MetaList <MetaType> FindTypeMismatches(Model other) { MetaList <MetaType> result = new MetaList <MetaType>(); result.AddRange(this.types.FindAll(t => !other.types.Contains(t))); result.AddRange(this.classes.FindAll(c => !other.classes.Contains(c)).ToArray()); return(result); }
private void dump(MetaList <MetaValue> metaValues) { this.dump(metaValues.Count); foreach (MetaValue metaValue in metaValues) { this.dump(metaValue); } }
/// <summary> /// Gets <see cref="ISpList{T}"/> instance for the specified <see cref="MetaList"/>. /// </summary> /// <typeparam name="TEntity">Type of element.</typeparam> /// <param name="list">SP list metadata.</param> /// <param name="options">List options.</param> /// <returns>Instance of the <see cref="ISpList{T}"/>.</returns> protected ISpList <TEntity> GetList <TEntity>(MetaList list, SpListOptions options = SpListOptions.Default) { var itemsProvider = CommonService.GetItemsProvider(list); itemsProvider.FilterByContentType = (options & SpListOptions.NoFilteringByContentType) == 0; return(new SpList <TEntity>(itemsProvider)); }
private void dump(MetaDictionary <MetaValue, MetaValue> metaValues) { MetaList <MetaValue> keys = metaValues.GetKeys(); MetaList <MetaValue> values = metaValues.GetValues(keys); this.dump(keys); this.dump(values); }
private List GetList(MetaList list) { try { return(ClientContext.GetListByUrl(list.Url, list.WebUrl)); } catch (Exception e) { throw new ListNotFoundException(list, e); } }
public override void VisitList(MetaList list) { var spList = GetList(list); list.Title = spList.Title; list.IsExternal = spList.HasExternalDataSource; new ListInfoLoader(spList).VisitList(list); }
public TypeUpdate(Repository repository, Model newModel) { InitializeComponent(); this.repository = repository; this.newModel = newModel; this.mismatchedTypes = new MetaList <MetaType>(); this.lbNewTypes.DataSource = new MetaList <MetaType>(newModel.AllTypes); this.refreshing = false; this.RefreshData(); }
public ValueList() { InitializeComponent(); this.owner = null; this.repository = null; this.type = null; this.listValues = null; this.Enabled = false; this.refreshing = false; }
public void Draw() { if (IsMetaDirty) { RefreshMeta(); IsMetaDirty = false; } MetaList.DoLayoutList(); }
public TypeUpdate(Repository repository, Model newModel) { InitializeComponent(); this.repository = repository; this.newModel = newModel; this.mismatchedTypes = new MetaList<MetaType>(); this.lbNewTypes.DataSource = new MetaList<MetaType>(newModel.AllTypes); this.refreshing = false; this.RefreshData(); }
public ValueList() { InitializeComponent(); this.owner = null; this.repository = null; this.type = null; this.listValues = null; this.Enabled = false; this.refreshing = false; }
public static Hashtable Init(MetaList metaList) { logger.Info("cacheFactory..."); Hashtable factoryList = cacheFactory(metaList); logger.Info("cacheAccessor..."); cacheAccessor(metaList); return(factoryList); }
public MetaInstance(MetaClass metaClass) : base() { this.type = metaClass; this.instanceVariables = new MetaList <MetaInstanceVariable>(); foreach (MetaVariable metaVariable in metaClass.AllVariables) { this.instanceVariables.Add(new MetaInstanceVariable(metaVariable)); } }
public void RefreshData() { if (this.refreshing) { return; } this.refreshing = true; this.mismatchedVariables = this.oldClass.FindVariableMismatches(this.newClass); Utility.ApplyNewDataSource(this.lbOldVariables, new MetaList<MetaVariable>(this.mismatchedVariables), this.mismatchedVariables.Count); this.refreshing = false; }
public void RefreshData() { if (this.refreshing) { return; } this.refreshing = true; this.mismatchedTypes = this.repository.Model.FindTypeMismatches(newModel); Utility.ApplyNewDataSource(this.lbOldTypes, new MetaList <MetaType>(this.mismatchedTypes), this.mismatchedTypes.Count); this.refreshing = false; }
public override MetaList <MetaVariable> FindVariableMismatches(MetaType metaType) { MetaList <MetaVariable> result = base.FindVariableMismatches(metaType); if (metaType.CategoryType == ECategoryType.Class) { MetaClass metaClass = (MetaClass)metaType; result.AddRange(this.variables.FindAll(v => !metaClass.variables.Contains(v))); } return(result); }
public void RefreshData() { if (this.refreshing) { return; } this.refreshing = true; this.mismatchedVariables = this.oldClass.FindVariableMismatches(this.newClass); Utility.ApplyNewDataSource(this.lbOldVariables, new MetaList <MetaVariable>(this.mismatchedVariables), this.mismatchedVariables.Count); this.refreshing = false; }
public Repository(Model model) : base() { this.model = model; this.values = new MetaDictionary <MetaClass, MetaList <MetaValue> >(); this.visibleClasses = new MetaList <MetaClass>(model.LeafClasses); foreach (MetaClass metaClass in this.visibleClasses) { this.values[metaClass] = new MetaList <MetaValue>(); } }
public void RefreshData() { if (this.refreshing) { return; } this.refreshing = true; this.mismatchedTypes = this.repository.Model.FindTypeMismatches(newModel); Utility.ApplyNewDataSource(this.lbOldTypes, new MetaList<MetaType>(this.mismatchedTypes), this.mismatchedTypes.Count); this.refreshing = false; }
public ActionResult Edit(Guid id, MetaListModel model, string button) { using (DBEntities context = Settings.CreateDataContext()) { if (!ModelState.IsValid) { return(View(model)); } MetaList target = null; if (model.Id != Guid.Empty) { target = MetaListHelper.Get(model.Id, context); if (target == null) { ModelState.AddModelError("", Resources.Resource.RowNotFound); return(View(model)); } } else { target = new MetaList(); target.Id = Guid.NewGuid(); context.AddToMetaList(target); } MetaListModel.CreateMap(); Mapper.Map(model, target); try { context.SaveChanges(); } catch (Exception ex) { var sb = new StringBuilder(Resources.Resource.SaveError + ": " + ex.Message); if (ex.InnerException != null) { sb.AppendLine(ex.InnerException.Message); } ModelState.AddModelError("", sb.ToString()); return(View(model)); } if (button == "SaveAndExit") { return(RedirectToAction("Index")); } else { return(RedirectToAction("Edit", new { target.Id })); } } }
public void SetData(IRefreshable owner, Repository repository, MetaType metaType, MetaList <MetaValue> metaValues, int index = 0) { this.owner = owner; this.repository = repository; this.type = metaType; this.listValues = metaValues; this.vlVariables.ClearData(); this.vlVariables.SetData(this, this.repository, this.type); this.vlVariables.SetValue(this.listValues.Count > 0 ? this.listValues[0] : null); this.lbValues.SelectedIndex = index; }
public VariableUpdate(Repository repository, MetaClass oldClass, MetaClass newClass) { InitializeComponent(); this.repository = repository; this.oldClass = oldClass; this.newClass = newClass; this.mismatchedVariables = new MetaList <MetaVariable>(); this.lbNewVariables.DataSource = new MetaList <MetaVariable>(newClass.Variables); this.Text = string.Format("{0} : {1}", this.oldClass.GetNameWithModule(), this.newClass.GetNameWithModule()); this.refreshing = false; this.RefreshData(); }
public ValueDictionary() { InitializeComponent(); this.owner = null; this.repository = null; this.type1 = null; this.type2 = null; this.dictionaryKeys = null; this.dictionaryValues = null; this.Enabled = false; this.refreshing = false; }
public ValueDictionary() { InitializeComponent(); this.owner = null; this.repository = null; this.type1 = null; this.type2 = null; this.dictionaryKeys = null; this.dictionaryValues = null; this.Enabled = false; this.refreshing = false; }
public void SetData(IRefreshable owner, Repository repository, MetaType metaType1, MetaType metaType2, MetaDictionary <MetaValue, MetaValue> metaValues) { this.owner = owner; this.repository = repository; this.type1 = metaType1; this.type2 = metaType2; this.dictionaryKeys = metaValues.GetKeys(); this.dictionaryValues = metaValues.GetValues(this.dictionaryKeys); this.vlVariables.ClearData(); this.vlVariables.SetData(this, this.repository, this.type2); this.vlVariables.SetValue(this.dictionaryValues.Count > 0 ? this.dictionaryValues[0] : null); }
public VariableUpdate(Repository repository, MetaClass oldClass, MetaClass newClass) { InitializeComponent(); this.repository = repository; this.oldClass = oldClass; this.newClass = newClass; this.mismatchedVariables = new MetaList<MetaVariable>(); this.lbNewVariables.DataSource = new MetaList<MetaVariable>(newClass.Variables); this.Text = string.Format("{0} : {1}", this.oldClass.GetNameWithModule(), this.newClass.GetNameWithModule()); this.refreshing = false; this.RefreshData(); }
/// <summary> /// Visit <see cref="MetaList"/> /// </summary> /// <param name="list">List to visit.</param> public virtual void VisitList(MetaList list) { if (list == null) { return; } foreach (var model in (IEnumerable <MetaContentType>)list.ContentTypes) { VisitContentType(model); } }
public void RefreshData() { if (this.refreshing) { return; } this.refreshing = true; this.owner.RefreshData(); if (this.value != null) { switch (this.type.CategoryType) { case ECategoryType.Integral: this.refreshEntry(this.value, 0); break; case ECategoryType.Enum: this.refreshEntry(this.value, 0); break; case ECategoryType.Class: MetaList <MetaInstanceVariable> metaInstanceVariables = this.value.Instance.InstanceVariables; for (int i = 0; i < metaInstanceVariables.Count; i++) { this.refreshEntry(metaInstanceVariables[i].Value, i); } break; } } else { switch (this.type.CategoryType) { case ECategoryType.Integral: this.refreshEntry(this.type, 0); break; case ECategoryType.Enum: this.refreshEntry(this.type, 0); break; case ECategoryType.Class: MetaList <MetaVariable> metaVariables = ((MetaClass)this.type).AllVariables; for (int i = 0; i < metaVariables.Count; i++) { this.refreshEntry(metaVariables[i].Type, i); } break; } } this.refreshing = false; }
private void dump(MetaList <MetaValue> metaValues) { this.dump(metaValues.Count); if (metaValues.Count > 0) { this.dump((uint)1); this.dump(this._getLS2Type(metaValues[0].Type, true)); foreach (MetaValue metaValue in metaValues) { this.dump(metaValue); } } }
private void onFormClosing(object sender, FormClosingEventArgs e) { MetaList<MetaValue> keys = new MetaList<MetaValue>(); foreach (MetaValue key in this.vdValues.Keys) { if (keys.Contains(key)) { e.Cancel = true; MessageBox.Show(ERROR_DUPLICATE_KEYS, "Error!", MessageBoxButtons.OK, MessageBoxIcon.Warning); break; } keys.Add(key); } }
private static Hashtable cacheFactory(MetaList metas) { if (DbConfig.Instance.OptimizeMode == OptimizeMode.CodeDom) { CodeDomPropertyAccessor.Init(metas); return(CodeDomPropertyAccessor.GetFactoryList()); } else if (DbConfig.Instance.OptimizeMode == OptimizeMode.IL) { ILPropertyAccessor.Init(); return(null); } return(null); }
public ActionResult Edit(Guid id, MetaListModel model, string button) { using (DBEntities context = Settings.CreateDataContext()) { if (!ModelState.IsValid) { return View(model); } MetaList target = null; if (model.Id != Guid.Empty) { target = MetaListHelper.Get(model.Id, context); if (target == null) { ModelState.AddModelError("", Resources.Resource.RowNotFound); return View(model); } } else { target = new MetaList(); target.Id = Guid.NewGuid(); context.AddToMetaList(target); } MetaListModel.CreateMap(); Mapper.Map(model, target); try { context.SaveChanges(); } catch (Exception ex) { var sb = new StringBuilder(Resources.Resource.SaveError + ": " + ex.Message); if (ex.InnerException != null) sb.AppendLine(ex.InnerException.Message); ModelState.AddModelError("", sb.ToString()); return View(model); } if (button == "SaveAndExit") return RedirectToAction("Index"); else return RedirectToAction("Edit", new { target.Id }); } }
public void RefreshData() { if (this.refreshing) { return; } this.refreshing = true; this.classes = new MetaList<MetaClass>(this.repository.Model.LeafClasses); Utility.ApplyNewDataSource(this.clbClasses, this.classes, this.classes.Count); for (int i = 0; i < this.classes.Count; ++i) { if (this.repository.VisibleClasses.Contains(this.classes[i])) { this.clbClasses.SetItemChecked(i, true); } } this.refreshing = false; }
public void RefreshData() { if (this.refreshing) { return; } this.refreshing = true; MetaList<MetaType> types = new MetaList<MetaType>(this.model.Types); Utility.ApplyNewDataSource(this.lbTypes, types, types.Count); MetaList<MetaType> allTypes = new MetaList<MetaType>(this.model.AllTypes); MetaType metaType = allTypes[this.lbTypes.SelectedIndex]; allTypes.Remove(metaType); Utility.ApplyNewDataSource(this.cbSubType1, new MetaList<MetaType>(allTypes), allTypes.Count); Utility.ApplyNewDataSource(this.cbSubType2, new MetaList<MetaType>(allTypes), allTypes.Count); bool enabled = (types.Count > 1); this.bTypeDelete.Enabled = enabled; this.RefreshType(); this.refreshing = false; }
private void dump(MetaList<MetaValue> metaValues) { this.dump(metaValues.Count); foreach (MetaValue metaValue in metaValues) { this.dump(metaValue); } }
public void RefreshType() { MetaList<MetaType> allTypes = new MetaList<MetaType>(this.model.AllTypes); MetaType metaType = allTypes[this.lbTypes.SelectedIndex]; allTypes.Remove(metaType); Utility.ApplyNewDataSource(this.cbSubType1, new MetaList<MetaType>(allTypes), allTypes.Count); Utility.ApplyNewDataSource(this.cbSubType2, new MetaList<MetaType>(allTypes), allTypes.Count); this.tbTypeName.Text = metaType.Name; this.cbSubType1.SelectedItem = metaType.SubType1; this.cbSubType2.SelectedItem = metaType.SubType2; this.tbSuffix1.Text = metaType.Suffix1; this.tbSuffix2.Text = metaType.Suffix2; if (metaType.EnumValues == null) { this.tbEnumValues.Text = ""; } else { this.tbEnumValues.Text = string.Join(" ", metaType.EnumValues.ToArray()); } this.cbCategoryType.SelectedIndex = (int)metaType.CategoryType; switch (this.cbCategoryType.SelectedIndex) { case (int)ECategoryType.Integral: lSubType1.Enabled = false; cbSubType1.Enabled = false; lSuffix1.Enabled = false; tbSuffix1.Enabled = false; lSubType2.Enabled = false; cbSubType2.Enabled = false; lSuffix2.Enabled = false; tbSuffix2.Enabled = false; lEnumValues.Enabled = false; tbEnumValues.Enabled = false; break; case (int)ECategoryType.List: lSubType1.Enabled = true; cbSubType1.Enabled = true; lSuffix1.Enabled = true; tbSuffix1.Enabled = true; lSubType2.Enabled = false; cbSubType2.Enabled = false; lSuffix2.Enabled = false; tbSuffix2.Enabled = false; lEnumValues.Enabled = false; tbEnumValues.Enabled = false; break; case (int)ECategoryType.Dictionary: lSubType1.Enabled = true; cbSubType1.Enabled = true; lSuffix1.Enabled = true; tbSuffix1.Enabled = true; lSubType2.Enabled = true; cbSubType2.Enabled = true; lSuffix2.Enabled = true; tbSuffix2.Enabled = true; lEnumValues.Enabled = false; tbEnumValues.Enabled = false; break; case (int)ECategoryType.Enum: lSubType1.Enabled = false; cbSubType1.Enabled = false; lSuffix1.Enabled = false; tbSuffix1.Enabled = false; lSubType2.Enabled = false; cbSubType2.Enabled = false; lSuffix2.Enabled = false; tbSuffix2.Enabled = false; lEnumValues.Enabled = true; tbEnumValues.Enabled = true; break; } }
public void SetData(IRefreshable owner, Repository repository, MetaType metaType, MetaList<MetaValue> metaValues, int index = 0) { this.owner = owner; this.repository = repository; this.type = metaType; this.listValues = metaValues; this.vlVariables.ClearData(); this.vlVariables.SetData(this, this.repository, this.type); this.vlVariables.SetValue(this.listValues.Count > 0 ? this.listValues[0] : null); this.lbValues.SelectedIndex = index; }
public void SetDictionaryValues(MetaDictionary<MetaValue, MetaValue> metaValues) { this.dictionaryKeys = metaValues.GetKeys(); this.dictionaryValues = metaValues.GetValues(this.dictionaryKeys); this.Enabled = (this.dictionaryValues.Count > 0); this.RefreshData(); }
public void SetData(IRefreshable owner, Repository repository, MetaType metaType1, MetaType metaType2, MetaDictionary<MetaValue, MetaValue> metaValues) { this.owner = owner; this.repository = repository; this.type1 = metaType1; this.type2 = metaType2; this.dictionaryKeys = metaValues.GetKeys(); this.dictionaryValues = metaValues.GetValues(this.dictionaryKeys); this.vlVariables.ClearData(); this.vlVariables.SetData(this, this.repository, this.type2); this.vlVariables.SetValue(this.dictionaryValues.Count > 0 ? this.dictionaryValues[0] : null); }
public void SetListValues(MetaList<MetaValue> metaValues) { this.listValues = metaValues; this.Enabled = (this.listValues.Count > 0); this.RefreshData(); }