Example #1
0
        /// <summary>
        /// Gets an array of objects names for a specific object container
        /// </summary>
        /// <param name="objectType">object type to get its objects</param>
        public string[] ObjectNames(ObjectType objectType)
        {
            string[] result = new string[0];
            if (tree.Nodes.Count == 0)
            {
                return(result);
            }

            Containers          containers = AccessApp.ContainersFactory(tree.Nodes[0].Text);
            ObjectTypeExtension ote        = containers.Find(objectType);

            if (ote != null)
            {
                ContainerNames names      = ote.Container;
                TreeNode[]     matchNodes = tree.Nodes[0].Nodes.Find(names.DisplayPluralName, true);
                if (matchNodes.Length == 1)
                {
                    result = new string[matchNodes[0].Nodes.Count];
                    for (int i = 0; i < matchNodes[0].Nodes.Count; i++)
                    {
                        result[i] = matchNodes[0].Nodes[i].Text;
                    }
                }
            }
            return(result);
        }
Example #2
0
 // Puts valuable containers, if any on top.
 private void MoveValuableToTop()
 {
     if (HaValuable)
     {
         var valContainer = (ValuableContainer)Containers.Find(v => v.TopStackAllowed == false);
         Containers.Remove(valContainer);
         Containers.Add(valContainer);
     }
 }
Example #3
0
 /// <summary>
 /// SetPosition make's sure that valuable containers get placed on top.
 /// </summary>
 public void SetPosition()
 {
     if (Containers.Find(x => (x.Valuable)) != null)
     {
         var valuable = Containers[0];
         Containers.RemoveAt(0);
         Containers.Add(valuable);
     }
     ;
 }
Example #4
0
 /// <summary>
 /// Add the container to the list while checking weight.
 /// </summary>
 /// <param name="model"></param>
 /// <returns></returns>
 public bool AddContainer(Container model)
 {
     if (model.Valuable && Containers.Find(x => (x.Valuable)) != null)
     {
         return(false);
     }
     if (!CheckWeight(model.Weight))
     {
         return(false);
     }
     Containers.Add(model);
     return(true);
 }
Example #5
0
 /// <summary>
 /// Add a container to the container list
 /// </summary>
 /// <param name="container">Container object to fill the list of containers</param>
 /// <returns></returns>
 public bool AddContainer(Container container)
 {
     //Check if there already is a valuable container in the list
     if (container.Valuable && Containers.Find(c => c.Valuable) != null)
     {
         return(false);
     }
     if (!CheckWeight(container.Weight))
     {
         return(false);
     }
     Containers.Add(container);
     return(true);
 }
Example #6
0
        public bool TryToAddContainer(Container model)
        {
            // if weight isnt compatible, return false
            if (!CheckWeight(model.Weight))
            {
                return(false);
            }

            //if a valuable is already in the row, return false
            if (model.Type == Container.ContainerType.Valuable && Containers.Find(c => c.GetType() == typeof(Container.ContainerType.valuable)))
            {
                return(false);
            }

            //adds the given container to the list for this row
            Containers.Add(model);
            return(true);
        }
        private void ProcessAccessObject(string accessObjectName)
        {
            Regex regex = new Regex(@"([a-z]{3})\.(.+)", RegexOptions.IgnoreCase);
            Match match = regex.Match(accessObjectName);

            if (!match.Success)
            {
                throw new CommandLineException(Properties.Resources.InvalidObjectName);
            }

            AccessIO.FileExtensions fileExtension;
            if (!Enum.TryParse <AccessIO.FileExtensions>(match.Groups[1].Value, out fileExtension))
            {
                throw new CommandLineException(Properties.Resources.InvalidObjectName);
            }

            Containers containers = AccessApp.ContainersFactory(DatabaseFile);

            Objects.Add(new AccessIO.ObjectOptions(match.Groups[2].Value, containers.Find(fileExtension).ObjectType));
        }
        private IObjecOptions ProcessSingleFile(string fileName)
        {
            CheckFile(fileName);
            FileExtensions fileExtension = Containers.GetFileExtension(fileName);
            IObjecOptions  objectOptions = new ObjectOptions(fileName, containers.Find(fileExtension).ObjectType);

            foreach (var item in optionParams)
            {
                if (item.Value)
                {
                    try {
                        objectOptions.Options.SetProperty(item.Key);
                    } catch (ArgumentException ex) {
                        string message = String.Format(Properties.Resources.InvalidOption, item.Key);
                        throw new CommandLineException(String.Format("{0} {1}",
                                                                     message,
                                                                     Properties.Resources.ForThisObjectType),
                                                       ex);
                    }
                }
            }
            return(objectOptions);
        }