示例#1
0
        private void btnAddToClass_Click(object sender, EventArgs e)
        {
            // Connect to the vault and continue if successful.
            if (!ConnectToSelectedVault())
            {
                return;
            }

            ObjectClasses classes = vault.ClassOperations.GetAllObjectClasses();

            foreach (ObjectClass cl in classes)
            {
                if (cl.ObjectType == 0)
                {
                    ObjectClassAdmin cla = vault.ClassOperations.GetObjectClassAdmin(cl.ID);
                    // Need to get the AssociatedPropertyDefs from the underlying ObjectClass (except
                    // for a few built-in properties), otherwise UpdateObjectClassAdmin() will fail.
                    CopyPropertiesToObjectClassAdmin(cla, cl);
                    AssociatedPropertyDef apd = new AssociatedPropertyDef();
                    apd.PropertyDef = ((PropertyComboBoxItem)propertyComboBox.SelectedItem).propID;
                    cla.AssociatedPropertyDefs.Add(-1, apd);
                    vault.ClassOperations.UpdateObjectClassAdmin(cla);
                }
            }
            MessageBox.Show("Done");
        }
        public void Add(int index, AssociatedPropertyDef associatedPropertyDef)
        {
            TestAssociatedPropertyDef newState = (associatedPropertyDef as TestAssociatedPropertyDef) ?? new TestAssociatedPropertyDef(associatedPropertyDef);

            if (index == -1 || index == tapd.Count + 1)
            {
                tapd.Add(newState);
            }
            else if (index > tapd.Count)
            {
                throw new Exception("Index out of range: " + index);
            }
            else
            {
                // I hate 1 indexing
                tapd[index - 1] = newState;
            }
        }
示例#3
0
 public TestAssociatedPropertyDef(AssociatedPropertyDef apd)
 {
     this.PropertyDef = apd.PropertyDef;
     this.Required    = apd.Required;
 }