Пример #1
0
        /// <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);
        }
Пример #2
0
 public CommandSender(string host, IIDItem idItem)
 {
     FRemoter    = new RemotingManagerTCP();
     FHost       = host;
     FIDItem     = idItem;
     FSerializer = idItem.Mapper.Map <Serializer>();
 }
Пример #3
0
 public static string GetID(this IIDItem item)
 {
     if (item.Owner != null)
     {
         return(item.Owner.GetID() + "/" + item.Name);
     }
     else
     {
         return(item.Name);
     }
 }
Пример #4
0
        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));
            }
        }
Пример #5
0
        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);
        }
Пример #6
0
        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;
        }
Пример #7
0
        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)
                                    ));
        }
Пример #8
0
        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;
            }
        }
Пример #9
0
        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.");
        }
Пример #10
0
 public void Visit(IIDItem idItem)
 {
     Contract.Assume(false);
 }
Пример #11
0
 /// <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>()));
 }
Пример #12
0
 public static Serializer GetSerializer(this IIDItem item)
 {
     return(item.Mapper.Map <Serializer>());
 }
Пример #13
0
 public static ICommandHistory GetCommandHistory(this IIDItem item)
 {
     return(item.Mapper.Map <ICommandHistory>());
 }
Пример #14
0
 public static string GetIDRelativeTo(this IIDItem item, IIDItem other)
 {
     return(item.GetID().Replace(other.GetID() + "/", ""));
 }
Пример #15
0
 public ClientCommandHistory(IIDItem idItem)
     : base(idItem.Mapper.Map <Serializer>())
 {
     FCommandSender = new CommandSender("localhost", idItem);
     FIdItem        = idItem;
 }