private void btnManageAttributes_Click(object sender, EventArgs e) { var optionalProps = GetCurrentOptionalProperties(); var frm = new AddOrRemoveAttributes(_objectClass, optionalProps, _serverDTO); if (frm.ShowDialog() == DialogResult.OK) { var retainList = frm.NewOptionalAttributes.Intersect(optionalProps); var removeList = optionalProps.Except(retainList).ToList(); foreach (var item in removeList) { _properties.Remove(item.Key); } var addList = frm.NewOptionalAttributes.Except(retainList); foreach (var item in addList) { var dto = _serverDTO.Connection.SchemaManager.GetAttributeType(item.Key); var val = MiscUtilsService.GetInstanceFromType(dto.Type); _properties.Add(item.Key, new VMDirBagItem { Description = dto.Description, IsReadOnly = dto.ReadOnly, Value = val }); } props.Refresh(); } }
private void btnManageAttributes_Click(object sender, EventArgs e) { MiscUtilsService.CheckedExec(delegate { var optionalProps = GetCurrentOptionalProperties(); if (!_properties.ContainsKey("objectClass")) { throw new Exception(VMDirConstants.UNABLE_TO_FETCH_DATA); } var oc = _properties["objectClass"].Value; string cn = ""; if (oc is string) { cn = oc.ToString(); } else if (oc is LdapValue[]) { LdapValue[] val = oc as LdapValue[]; cn = val[(val.Count() - 1)].StringValue; } var frm = new AddOrRemoveAttributes(cn, optionalProps, ServerDTO); if (frm.ShowDialog() == DialogResult.OK) { foreach (var item in frm.NewOptionalAttributes) { _kvData.Add(new KeyValuePair <string, string>(item.Key, null)); } RefreshView(); } }); }