/// <summary>
        /// Reads the indicated item <paramref name="type"/> from the Xml reader's
        /// data stream, advances the Xml reader, and returns the new item.
        /// </summary>
        /// <param name="type"></param>
        /// <param name="reader"></param>
        /// <returns></returns>
        internal static IItemModel ReadItem(SolutionModelItemType type
                                            , XmlReader reader)
        {
            IItemModel             newItem = null;
            DataContractSerializer itemSer = null;

            switch (type)
            {
            case SolutionModelItemType.File:
                itemSer = new DataContractSerializer(typeof(FileItemModel));
                newItem = (FileItemModel)itemSer.ReadObject(reader);
                break;

            case SolutionModelItemType.Folder:
                itemSer = new DataContractSerializer(typeof(FolderItemModel));
                newItem = (FolderItemModel)itemSer.ReadObject(reader);
                break;

            case SolutionModelItemType.Project:
                itemSer = new DataContractSerializer(typeof(ProjectItemModel));
                newItem = (ProjectItemModel)itemSer.ReadObject(reader);
                break;

            case SolutionModelItemType.SolutionRootItem:
                itemSer = new DataContractSerializer(typeof(SolutionRootItemModel));
                newItem = (SolutionRootItemModel)itemSer.ReadObject(reader);
                break;

            default:
                throw new ArgumentException(type.ToString());
            }

            return(newItem);
        }
        /// <summary>
        /// Adds a child item with the given type
        /// (<see cref="SolutionItemType.SolutionRootItem"/> cannot be added here).
        /// </summary>
        /// <param name="displayName"></param>
        /// <param name="type"></param>
        /// <returns></returns>
        public static IItemModel AddStaticChild(string displayName
                                                , SolutionModelItemType type
                                                , IItemChildrenModel parent)
        {
            if (parent.FindChild(displayName) != null)
            {
                throw new ArgumentException("Item '" + displayName + "' already exists.");
            }

            IItemModel newItem = null;

            switch (type)
            {
            case SolutionModelItemType.File:
                newItem = new FileItemModel(parent, displayName);
                break;

            case SolutionModelItemType.Folder:
                newItem = new FolderItemModel(parent, displayName);
                break;

            case SolutionModelItemType.Project:
                newItem = new ProjectItemModel(parent, displayName);
                break;

            // This should be created via AddSolutionRootItem() method
            case SolutionModelItemType.SolutionRootItem:
            default:
                throw new ArgumentException(type.ToString());
            }

            parent.AddChild(newItem);

            return(newItem);
        }
Exemplo n.º 3
0
 /// <summary>
 /// Class constructor
 /// </summary>
 protected ItemModel(IItemModel parent
                     , string displayName
                     , SolutionModelItemType itemType)
     : this()
 {
     Parent      = parent;
     DisplayName = displayName;
     ItemType    = itemType;
 }
        /// <summary>
        /// Adds a child item with the given type
        /// (<see cref="SolutionItemType.SolutionRootItem"/> cannot be added here).
        ///
        /// This wrapper uses a long input for conversion when reading from file.
        /// </summary>
        /// <param name="displayName"></param>
        /// <param name="type"></param>
        /// <returns></returns>
        public IItemModel AddChild(string displayName
                                   , long longType
                                   , IItemChildrenModel parent)
        {
            if (parent.FindChild(displayName) != null)
            {
                throw new ArgumentException("Item '" + displayName + "' already exists.");
            }

            SolutionModelItemType type = (SolutionModelItemType)longType;

            return(AddChild(displayName, type, parent));
        }
        /// <summary>
        /// Gets the name of the corresponding XML for each type of model
        /// based on an enumerated value.
        /// </summary>
        /// <param name="type"></param>
        /// <returns></returns>
        internal static string GetXmlName(SolutionModelItemType type)
        {
            switch (type)
            {
            case SolutionModelItemType.SolutionRootItem:
                return("RootItem");

            case SolutionModelItemType.File:
                return("File");

            case SolutionModelItemType.Folder:
                return("Folder");

            case SolutionModelItemType.Project:
                return("Project");

            default:
                throw new System.NotImplementedException(type.ToString());
            }
        }
Exemplo n.º 6
0
 /// <summary>
 /// Class constructor
 /// </summary>
 protected ItemModel(SolutionModelItemType itemType)
     : this()
 {
     ItemType = itemType;
 }
 /// <summary>
 /// Adds a child item with the given type
 /// (<see cref="SolutionItemType.SolutionRootItem"/> cannot be added here).
 /// </summary>
 /// <param name="displayName"></param>
 /// <param name="type"></param>
 /// <returns></returns>
 public IItemModel AddChild(string displayName
                            , SolutionModelItemType type
                            , IItemChildrenModel parent)
 {
     return(AddItem(displayName, type, parent));
 }
Exemplo n.º 8
0
 /// <summary>
 /// Class constructor
 /// </summary>
 protected ItemChildrenModel(SolutionModelItemType itemType)
     : base(itemType)
 {
 }
Exemplo n.º 9
0
 /// <summary>
 /// Class constructor
 /// </summary>
 protected ItemChildrenModel(IItemModel parent
                             , string displayName
                             , SolutionModelItemType itemType)
     : base(parent, displayName, itemType)
 {
 }