示例#1
0
        public IReadOnlyCollection <AddressableRegion> FindDisks(SearchConstraints SearchConstraints)
        {
            List <AddressableRegion> disks = new List <AddressableRegion>();

            for (int i = 0; i < Disks.Count; i++)
            {
                var invalidConstraint = SearchConstraints.DriveConstraint != null && SearchConstraints.DriveConstraint != i;
                if (invalidConstraint)
                {
                    continue;
                }

                var region = Disks[i];
                if (region.IsExternalDrive && !region.IsMounted)
                {
                    continue;
                }

                disks.Add(region);

                //var found = region.Find(SearchConstraints, searchValue);
                //if (found == null)
                //    continue;

                //context.Variables["Index"] = found.Value.ToString();
                //return;
            }

            return(disks);
        }
示例#2
0
        public MemoryCoordinate?Find(SearchConstraints constraints, IReadOnlyCollection <string> value)
        {
            var paddedValues = value.Select(x =>
            {
                if (x.Length < 4)
                {
                    return(x.PadRight(4, ' '));
                }
                else
                {
                    return(x);
                }
            }).ToList();



            var coordinates = FilterCoordinates(constraints);

            foreach (var searchCoordinate in coordinates)
            {
                if (TestSearchCoordinate(searchCoordinate, paddedValues))
                {
                    return(searchCoordinate);
                }
            }

            return(null);
        }
示例#3
0
        public IEnumerable <MemoryCoordinate> FilterCoordinates(SearchConstraints constraints)
        {
            var allCoordinates = this.AllCoordinates.ToList();

            foreach (var coordinate in allCoordinates)
            {
                var matchCol = !constraints.ColConstraint.HasValue || constraints.ColConstraint.Value == coordinate.X;
                var matchRow = !constraints.RowConstraint.HasValue || constraints.RowConstraint.Value == coordinate.Y;
                if (!matchRow || !matchCol)
                {
                    continue;
                }

                yield return(coordinate);
            }
        }
示例#4
0
        public static SearchConstraints ResolveTarget(string from)
        {
            var expression = new SearchConstraints();

            from = from.Replace(",", "");
            from = from.Replace(" ", "");
            from = from.Replace(":", "");

            var driveConstraintRaw = from[0];

            if ('*' != driveConstraintRaw)
            {
                expression.DriveConstraint = Int32.Parse(driveConstraintRaw.ToString());
            }

            var colConstraintRaw = from[1];

            if ('*' != colConstraintRaw)
            {
                expression.ColConstraint = Int32.Parse(colConstraintRaw.ToString());
            }

            var rowConstraintRaw = from[2];

            if ('*' != rowConstraintRaw)
            {
                int yInt;
                if (char.IsLetter(rowConstraintRaw))
                {
                    yInt = (int)rowConstraintRaw - 'A';
                }
                else
                {
                    yInt = Convert.ToInt32(rowConstraintRaw.ToString());
                }

                expression.RowConstraint = yInt;
            }

            return(expression);
        }