CreatePropertyDefCommand(TypeTreeNode ownerNode, PropertyDefOptions options) { this.ownerNode = ownerNode; this.propNode = new PropertyTreeNode(options.CreatePropertyDef(ownerNode.TypeDefinition.Module)); }
PropertyDefSettingsCommand(PropertyTreeNode propNode, PropertyDefOptions options) { this.propNode = propNode; this.newOptions = options; this.origOptions = new PropertyDefOptions(propNode.PropertyDefinition); this.origParentNode = (ILSpyTreeNode)propNode.Parent; this.origParentChildIndex = this.origParentNode.Children.IndexOf(propNode); Debug.Assert(this.origParentChildIndex >= 0); if (this.origParentChildIndex < 0) throw new InvalidOperationException(); this.nameChanged = origOptions.Name != newOptions.Name; }
public void Delete(PropertyTreeNode[] nodes) { Debug.Assert(infos == null); if (infos != null) throw new InvalidOperationException(); infos = new ModelInfo[nodes.Length]; for (int i = 0; i < infos.Length; i++) { var node = nodes[i]; var info = new ModelInfo(node.PropertyDefinition); infos[i] = info; info.OwnerType.Properties.RemoveAt(info.PropertyIndex); for (int j = 0; j < info.Methods.Length; j++) { int index = info.OwnerType.Methods.IndexOf(info.Methods[j]); Debug.Assert(index >= 0); if (index < 0) throw new InvalidOperationException(); info.OwnerType.Methods.RemoveAt(index); info.MethodIndexes[j] = index; } } }
public void Restore(PropertyTreeNode[] nodes) { Debug.Assert(infos != null); if (infos == null) throw new InvalidOperationException(); Debug.Assert(infos.Length == nodes.Length); if (infos.Length != nodes.Length) throw new InvalidOperationException(); for (int i = infos.Length - 1; i >= 0; i--) { var node = nodes[i]; var info = infos[i]; info.OwnerType.Properties.Insert(info.PropertyIndex, node.PropertyDefinition); for (int j = info.Methods.Length - 1; j >= 0; j--) info.OwnerType.Methods.Insert(info.MethodIndexes[j], info.Methods[j]); } infos = null; }
DeletePropertyDefCommand(PropertyTreeNode[] propNodes) { this.nodes = new DeletableNodes<PropertyTreeNode>(propNodes); }