/// <summary> /// Creates a XElement and adds the ID as name attribute /// </summary> /// <param name="tagName">The name of the XML tag to create</param> /// <returns></returns> public static XElement GetXML(this IIDItem item, string tagName) { var x = new XElement(tagName); x.Add(new XAttribute("Name", item.Name)); return(x); }
public CommandSender(string host, IIDItem idItem) { FRemoter = new RemotingManagerTCP(); FHost = host; FIDItem = idItem; FSerializer = idItem.Mapper.Map <Serializer>(); }
public static string GetID(this IIDItem item) { if (item.Owner != null) { return(item.Owner.GetID() + "/" + item.Name); } else { return(item.Name); } }
protected Command CreateAddCommand(IEditableIDList destination, IIDItem item) { IEditableIDList source; if (IsContained(item, out source)) { return(Command.Move(source, destination, item)); } else { return(Command.Add(destination, item)); } }
protected bool IsContained(IIDItem item, out IEditableIDList source) { source = null; var iid = item as IIDItem; if (iid.Owner is IEditableIDList) { source = iid.Owner as IEditableIDList; return(true); } return(false); }
public DefaultAddMenuEntry(ModelMapper mapper, IIDItem model) : base(model.Mapper.Map <ICommandHistory>()) { if (mapper.CanMap <IAddMenuProvider>()) { foreach (var a in mapper.Map <IAddMenuProvider>().GetEnumerator()) { Add(a); } } FMapper = mapper; FModel = model; }
public static IIDItem GetIDItem(this IIDItem item, IEnumerable <string> relPath, List <string> donePath) { if (relPath.Count() == 0) { return(item); } if (item is IIDContainer) { return(((IIDContainer)item).GetIDItem(relPath, donePath)); } throw new Exception( String.Format("could not find ID {0}. made it up to {1}, which is no container.", donePath.Concat(relPath).Aggregate((acc, next) => acc + "/" + next), donePath.Aggregate((acc, next) => acc + "/" + next) )); }
public DefaultDragDropProvider(ModelMapper mapper) { var model = mapper.Model; if (model is IIDItem) { FIdItem = model as IIDItem; } if (model is IDraggable) { FDraggable = model as IDraggable; } if (model is IDroppable) { FDroppable = model as IDroppable; } }
public void TestEditableCollectionAndEditableIDList() { var sampleData = new IIDItem[] { new IDItem("item1"), new IDItem("item2"), new IDItem("item3"), new IDItem("item4"), new IDItem("item5"), new IDItem("item6") }; var sourceCollection = new EditableIDList <IIDItem>("source"); var targetCollection = new EditableCollection <IIDItem>(); var syncer = targetCollection.SyncWith(sourceCollection, (itemB) => itemB); sourceCollection.AddRange(sampleData); CollectionAssert.AreEqual(sourceCollection, targetCollection); sourceCollection.Remove(sampleData[0]); CollectionAssert.AreEqual(sourceCollection, targetCollection); sourceCollection.Clear(); CollectionAssert.AreEqual(sourceCollection, targetCollection, "Clear() on EditableIDList failed."); }
public void Visit(IIDItem idItem) { Contract.Assume(false); }
/// <summary> /// gets the ID Item in the model, starting from another ID item. a relpath of "" return the relToItem /// </summary> public static IIDItem GetIDItem(this IIDItem relToItem, string relPath) { return(relToItem.GetIDItem(relPath.Split('/'), new List <string>())); }
public static Serializer GetSerializer(this IIDItem item) { return(item.Mapper.Map <Serializer>()); }
public static ICommandHistory GetCommandHistory(this IIDItem item) { return(item.Mapper.Map <ICommandHistory>()); }
public static string GetIDRelativeTo(this IIDItem item, IIDItem other) { return(item.GetID().Replace(other.GetID() + "/", "")); }
public ClientCommandHistory(IIDItem idItem) : base(idItem.Mapper.Map <Serializer>()) { FCommandSender = new CommandSender("localhost", idItem); FIdItem = idItem; }