Beispiel #1
0
        public void CheckoutTest()
        {
            this.Checkout();

            Assert.IsTrue(File.Exists(checkFile), "Should have found the check file.  file=[" +
                          checkFile + "]");

            Entries entries =
                manager.FetchEntries(rootDir);

            String moduleDir = Path.Combine(this.settings.LocalPath, this.settings.Module);

            Assert.IsTrue(entries.Contains(Path.Combine(moduleDir, checkFile)), "Build file should have a cvs entry.");
            Assert.IsTrue(entries.Contains(Path.Combine(moduleDir, "src" + Path.DirectorySeparatorChar.ToString())),
                          this.settings.Config.TargetDirectory + " directory should have a cvs entry.");
            foreach (DictionaryEntry dicEntry in entries)
            {
                Entry entry = (Entry)dicEntry.Value;
                if (!entry.IsDirectory)
                {
                    Assert.IsNotNull(entry.Date, "Should have date information.");
                }
            }
            Assert.IsTrue(!Directory.Exists(Path.Combine(this.settings.Config.LocalPath, manager.CVS)),
                          "Should not have a cvs directory above module path.");
            Assert.IsTrue(!Directory.Exists(Path.Combine(this.settings.Config.Module, manager.CVS)),
                          "Should not have a cvs directory in the current execution path.  ");
        }
Beispiel #2
0
        public void UpdateTest()
        {
            this.Checkout();
            File.Delete(checkFile);
            LOGGER.Debug("After deleted checkFile=[" + checkFile + "]");

            Assert.IsTrue(!File.Exists(checkFile));
            this.UpdateAllRecursive(rootDir);
            Assert.IsTrue(File.Exists(checkFile));

            String  moduleDir = Path.Combine(rootDir, this.settings.Module);
            Entries entries   =
                this.manager.FetchEntries(moduleDir + Path.DirectorySeparatorChar.ToString());

            String[] files =
                Directory.GetFiles(rootDir);
            String[] directories =
                Directory.GetDirectories(rootDir);
            // Minus the cvs directory
            int total = files.Length + directories.Length - 1;

            Assert.AreEqual(total, entries.Count);
            LOGGER.Debug("Before checking all file names.");

            Assert.IsTrue(entries.Contains(Path.Combine(moduleDir, this.settings.TargetFile)));

            // Had some problems with an extra module directory appearing under
            //    the main working folder.
            String doubleModuleDir = Path.Combine(rootDir, this.settings.Config.Module);

            Assert.IsTrue(!Directory.Exists(doubleModuleDir));
        }
Beispiel #3
0
 public bool Contains(IGroup <T> instance)
 {
     if (instance is null)
     {
         throw new ArgumentNullException(nameof(instance));
     }
     return(Entries.Contains(instance));
 }
        private void MenuItem_Delete_Click(object sender, RoutedEventArgs e)
        {
            var entry = listView.SelectedItem as AddressBookEntry;

            if (entry != null && Entries.Contains(entry))
            {
                Entries.Remove(entry);
            }
        }
Beispiel #5
0
        public void Remove(GumpEntry g)
        {
            if (g == null || !Entries.Contains(g))
            {
                return;
            }

            Entries.Remove(g);
            g.Parent = null;
        }
Beispiel #6
0
 public void Add(GumpEntry g)
 {
     if (g.Parent != this)
     {
         g.Parent = this;
     }
     else if (!Entries.Contains(g))
     {
         Entries.Add(g);
     }
 }
Beispiel #7
0
 public bool Contains(object instance)
 {
     if (instance is null)
     {
         throw new ArgumentNullException(nameof(instance));
     }
     if (!(instance is T || instance is IGroup <T>))
     {
         throw new ArgumentException($"{nameof(instance)} is of a type that cannot be assigned to IGroup.");
     }
     return(Entries.Contains(instance));
 }
Beispiel #8
0
        /// <summary>
        ///     Initializes a new instance of the <see cref="Pattern" /> class with the specified pattern entries.
        /// </summary>
        /// <param name="entries">The entries, which must not be <c>null</c> or contain <c>null</c>.</param>
        /// <exception cref="ArgumentException"><paramref name="entries" /> contains <c>null</c>.</exception>
        /// <exception cref="ArgumentNullException"><paramref name="entries" /> is <c>null</c>.</exception>
        public Pattern([ItemNotNull][NotNull] IEnumerable <PatternEntry> entries)
        {
            if (entries == null)
            {
                throw new ArgumentNullException(nameof(entries));
            }

            Entries = entries.ToList().AsReadOnly();
            if (Entries.Contains(null))
            {
                throw new ArgumentException("Null entries are not allowed.", nameof(entries));
            }
        }
Beispiel #9
0
        void DoBruteForceWork(object sender, System.ComponentModel.DoWorkEventArgs eventArgs)
        {
            var dlg = (Ookii.Dialogs.Wpf.ProgressDialog)sender;

            var newEntries = new Models.ModelCharaHierarchy(Entries.MainFormat, Entries.SubFormat, Entries.VariantFormat);

            for (var m = 0; m < 10000; ++m)
            {
                if (dlg.CancellationPending)
                {
                    return;
                }
                dlg.ReportProgress(m / 100, null, string.Format("Current progress: {0:P}", m / 10000.0));
                for (var b = 0; b < 10000; ++b)
                {
                    var imcPath = string.Format(ImcPathFormat, m, b);
                    SaintCoinach.IO.File imcBase;
                    if (!Parent.Realm.Packs.TryGetFile(imcPath, out imcBase))
                    {
                        continue;
                    }
                    try {
                        var imc = new SaintCoinach.Graphics.ImcFile(imcBase);
                        for (var v = 1; v < imc.Count; ++v)
                        {
                            if (Entries.Contains(m, b, v))
                            {
                                continue;
                            }

                            var any = false;
                            foreach (var p in imc.Parts)
                            {
                                if (p.Variants[v].Variant != 0)
                                {
                                    any = true;
                                    break;
                                }
                            }
                            if (any)
                            {
                                newEntries.Add(m, b, v);
                            }
                        }
                    } catch (Exception ex) {
                        Console.Error.WriteLine("Failed parsing imc file {0}:{1}{2}", imcPath, Environment.NewLine, ex);
                    }
                }
            }
            Entries = newEntries;
        }
Beispiel #10
0
        public virtual void MergeWith(IMergeable obj)
        {
            var fb = obj as IFreeBusy;

            if (fb == null)
            {
                return;
            }

            foreach (var entry in fb.Entries.Where(entry => !Entries.Contains(entry)))
            {
                Entries.Add(entry);
            }
        }
Beispiel #11
0
        /// <summary>
        ///     Merges this object with another.
        /// </summary>
        /// <param name="obj"></param>
        public void MergeWith(IMergeable obj)
        {
            var fb = obj as IFreeBusy;

            if (fb != null)
            {
                foreach (IFreeBusyEntry entry in fb.Entries)
                {
                    if (!Entries.Contains(entry))
                    {
                        Entries.Add(entry.Copy <IFreeBusyEntry>( ));
                    }
                }
            }
        }
Beispiel #12
0
        public bool RemoveEntry(Entry entry)
        {
            if (entry is null)
            {
                throw new EntityNotFoundException("User -> Entry");
            }

            if (!Entries.Contains(entry))
            {
                return(false);
            }

            Entries.Remove(entry);
            return(true);
        }
        private void MenuItem_Edit_Click(object sender, RoutedEventArgs e)
        {
            var entry = listView.SelectedItem as AddressBookEntry;

            if (entry != null && Entries.Contains(entry))
            {
                txtName.Text   = entry.Name;
                txtServer.Text = entry.Address;
                txtName.Focus();
                Dispatcher.BeginInvoke(new Action(() =>
                {
                    txtName.SelectAll();
                }));
            }
        }
Beispiel #14
0
        public void Refresh(bool recompile = true)
        {
            if (recompile)
            {
                Entries.Clear();
                Entries.TrimExcess();
                AddGumpLayout();
            }
            else if (Entries.Contains(Countdown))
            {
                Entries.Remove(Countdown);
                AddCountdown();
            }

            User.SendGump(this, false);
        }
        private void MenuItem_SetPass_Click(object sender, RoutedEventArgs e)
        {
            var entry = listView.SelectedItem as AddressBookEntry;

            if (entry != null && Entries.Contains(entry))
            {
                string serverName = string.IsNullOrWhiteSpace(entry.Name) ? string.IsNullOrWhiteSpace(entry.Address) ? "[null]" : entry.Address.ToString() : entry.Name;
                string message    = string.Format("Enter new pass for {0}", serverName);
                string pass       = entry.Password;
                if (LoginPassWindow.Prompt(ref pass, message, "Apply"))
                {
                    entry.Password = string.IsNullOrWhiteSpace(pass) ? null : pass;
                    listView.Items.Refresh();
                }
            }
        }
Beispiel #16
0
        private void RemoveValue(string key, string valueToRemove)
        {
            var pos = -1;

            if (!Entries.Contains(key))
            {
                return;
            }

            var value = Entries[key].ToString();

            do
            {
                pos = value.IndexOf(valueToRemove, StringComparison.Ordinal);
                if (pos >= 0)
                {
                    value = value.Remove(pos, valueToRemove.Length);
                }
            } while (pos >= 0);
            Entries[key] = value;
        }
 /// <summary>
 /// Determines whether the list contains a specific item.
 /// </summary>
 /// <param name="item">The item to be found.</param>
 /// <returns><c>true</c> if the item is in the list; false otherwise.</returns>
 public bool Contains(T item)
 {
     return(Entries.Contains(item));
 }
 public bool Contains(Template template)
 {
     return(template != null && Entries.Contains(template));
 }
Beispiel #19
0
        public bool TryAddSeed(Mobile from, Seed seed, int index = -1)
        {
            if (!from.Backpack.CheckHold(from, seed, true, true) || seed.Amount <= 0)
            {
                return(false);
            }
            else if (!from.InRange(this.GetWorldLocation(), 3) || from.Map != this.Map)
            {
                return(false);
            }
            else if (TotalCount + seed.Amount <= MaxSeeds)
            {
                SeedEntry entry    = GetExisting(seed);
                int       oldcount = UniqueCount;

                if (entry != null)
                {
                    entry.Seed.Amount += seed.Amount;
                    seed.Delete();
                }
                else if (UniqueCount < MaxUnique)
                {
                    entry = new SeedEntry(seed);
                    DropItem(seed);

                    seed.Movable = false;
                }
                else
                {
                    from.SendLocalizedMessage(1151839); // There is not enough room in the box.
                }

                if (entry != null)
                {
                    if (Entries.Contains(entry))
                    {
                        if (index > -1 && index < Entries.Count - 1)
                        {
                            Entries.Remove(entry);
                            AddEntry(entry, index);
                        }
                    }
                    else
                    {
                        if (index > -1 && index < Entries.Count)
                        {
                            AddEntry(entry, index);
                        }
                        else
                        {
                            AddEntry(entry);
                        }
                    }

                    from.SendLocalizedMessage(1151846); // You put the seed in the seedbox.

                    if (from is PlayerMobile)
                    {
                        var gump = new SeedBoxGump((PlayerMobile)from, this);
                        gump.CheckPage(entry);

                        BaseGump.SendGump(gump);
                    }

                    InvalidateProperties();
                    return(true);
                }
            }
            else
            {
                from.SendLocalizedMessage(1151839); // There is not enough room in the box.
            }

            return(false);
        }
        public void AddFilesTest()
        {
            this.CheckoutTestModule();

            String modulePath = Path.Combine(this.GetTempPath(),
                                             this.Settings.Config.Module);

            String[] files = Directory.GetFiles(modulePath, "*.txt");

            Assert.IsTrue(files.Length > 0);
            ArrayList copiedFiles = new ArrayList();

            foreach (String file in files)
            {
                LOGGER.Debug("file=[" + file + "]");
                // Remove the .txt when everything works, giving me bugs...
                String newFileName = Guid.NewGuid().ToString() + ".txt";
                String fullPath    = Path.Combine(modulePath, newFileName);
                File.Copy(file, fullPath);
                copiedFiles.Add(fullPath);
            }

            CvsRoot          root    = new CvsRoot(this.Settings.Config.Cvsroot);
            WorkingDirectory working =
                new WorkingDirectory(root,
                                     this.Settings.Config.LocalPath,
                                     this.Settings.Config.Module);

            CVSServerConnection connection = new CVSServerConnection();

            Assert.IsNotNull(connection);

            AddCommand command = new AddCommand(working);

            //command.Folders = this.GetFolders(modulePath);
            command.Folders = this.GetFoldersToAdd(copiedFiles);

            Assert.IsTrue(command.Folders.Count > 0);
            LOGGER.Debug("folders count=[" + command.Folders.Count + "]");
            foreach (DictionaryEntry folderDic in command.Folders)
            {
                Folder folder = (Folder)folderDic.Value;
                LOGGER.Debug("folder=[" + folder.ToString() + "]");
                LOGGER.Debug("entries count=[" + folder.Entries.Count + "]");
            }
            Assert.IsNotNull(command);

            try {
                connection.Connect(working, this.Settings.Config.ValidPassword);
            } catch (AuthenticationException) {
                // should not get here.
                Assert.IsTrue(true);
            }

            command.Execute(connection);
            connection.Close();

            try {
                connection.Connect(working, this.Settings.Config.ValidPassword);
            } catch (AuthenticationException) {
                Assert.IsTrue(true);
            }
            CommitCommand2 commitCommand = new CommitCommand2(working);

            working.Folders          = command.Folders;
            commitCommand.LogMessage = "AddCommandTest";
            commitCommand.Execute(connection);
            connection.Close();

            Manager manager = new Manager(working.WorkingPath);
            Entries entries = manager.FetchEntries(Path.Combine(modulePath, "Entries"));

            foreach (String addedFile in copiedFiles)
            {
                Assert.IsTrue(entries.Contains(Path.Combine(modulePath, addedFile)));
            }
        }
Beispiel #21
0
        public bool TryAddSeed(Mobile from, Seed seed, int index = -1)
        {
            if (!CheckAccessible(from, this))
            {
                PrivateOverheadMessage(MessageType.Regular, 946, 1010563, from.NetState); // This container is secure.
                return(false);
            }

            if (!from.Backpack.CheckHold(from, seed, true, true) || seed.Amount <= 0)
            {
                return(false);
            }

            if (!from.InRange(GetWorldLocation(), 3) || from.Map != Map)
            {
                return(false);
            }

            if (TotalCount + seed.Amount <= MaxSeeds)
            {
                SeedEntry entry = GetExisting(seed);

                if (entry != null)
                {
                    entry.Seed.Amount += seed.Amount;
                    seed.Delete();
                }
                else if (UniqueCount < MaxUnique)
                {
                    entry = new SeedEntry(seed);
                    DropItem(seed);

                    seed.Movable = false;
                }
                else
                {
                    from.SendLocalizedMessage(1151839); // There is not enough room in the box.
                }

                if (entry != null)
                {
                    InvalidateProperties();

                    if (Entries.Contains(entry))
                    {
                        if (index > -1 && index < Entries.Count - 1)
                        {
                            Entries.Remove(entry);
                            AddEntry(entry, index);
                        }
                    }
                    else
                    {
                        if (index > -1 && index < Entries.Count)
                        {
                            AddEntry(entry, index);
                        }
                        else
                        {
                            AddEntry(entry);
                        }
                    }

                    from.SendLocalizedMessage(1151846); // You put the seed in the seedbox.

                    if (from is PlayerMobile mobile)
                    {
                        var gump = mobile.FindGump <SeedBoxGump>();

                        if (gump != null)
                        {
                            gump.CheckPage(entry);
                            gump.Refresh();
                        }
                        else
                        {
                            gump = new SeedBoxGump(mobile, this);
                            gump.CheckPage(entry);

                            BaseGump.SendGump(gump);
                        }
                    }

                    return(true);
                }
            }
            else
            {
                from.SendLocalizedMessage(1151839); // There is not enough room in the box.
            }

            return(false);
        }