public void NewEntity(ICommandEntity entity) { if (entity == null) { return; } if (_entity == null) { _entity = entity; } if (_details != null) { var deleted = new List <EntityHolder>(); foreach (EntityHolder detail in _details) { if (detail._entity == null) { continue; } detail._entity.SetEntity(_entity); _entity.AddEntity(detail._entity); deleted.Add(detail); } Clear(_details, deleted); if (_details.Count == 0) { _details = null; } } if (_masters != null) { var deleted = new List <EntityHolder>(); foreach (EntityHolder master in _masters) { if (master._entity == null) { continue; } _entity.SetEntity(master._entity); master._entity.AddEntity(_entity); deleted.Add(master); } Clear(_masters, deleted); if (_masters.Count == 0) { _masters = null; } } }
protected virtual ICommandEntity CreateEntity(XmlElement contrib) { if (commandType.Equals("ModalForm")) { return(new ModalFormCommand(targetType)); } if (commandType.Equals("ModelessForm")) { return(new ModelessFormCommand(targetType)); } ICommandEntity entity = CreateTarget() as ICommandEntity; if (entity == null) { string templ = Core.resources["plugin.invalid_command_entity"].stringValue; string[] args = new string[] { commandType, targetType.Name, methodName }; throw new PluginXmlException(contrib, string.Format(templ, args)); } return(entity); }
public CommandEntityContributuion(XmlElement contrib) : base(contrib) { path = contrib.OwnerDocument.BaseURI; XmlNode cls = XmlUtil.selectSingleNode(contrib, "class"); targetType = PluginUtil.loadTypeFromManifest((XmlElement)cls); XmlNode mn = contrib.SelectSingleNode("method"); XmlNode cmd = XmlUtil.selectSingleNode(contrib, "command"); commandType = XmlUtil.getAttributeValue(cmd, "type", "entity"); if (mn != null) { methodName = XmlUtil.getAttributeValue(mn, "name", null); if (bool.Parse(XmlUtil.getAttributeValue(mn, "static", "false"))) { methodType = MethodType.Static; } else { methodType = MethodType.Instance; } if (methodName == null) { string templ = Core.resources["xml.attribute_not_found"].stringValue; throw new Exception(string.Format(templ, mn, "name", contrib.OwnerDocument.BaseURI)); } } else { methodType = MethodType.Constructor; } entity = CreateEntity(contrib); PluginUtil.RegisterCommand(id, entity, cmd); }
protected virtual void AddEntity(ICommandEntity entity) { }
void ICommandEntity.AddEntity(ICommandEntity entity) { AddEntity(entity); }
protected virtual void SetEntity(ICommandEntity item) { }
void ICommandEntity.SetEntity(ICommandEntity item) { SetEntity(item); }