Exemplo n.º 1
0
        public void WriteProgIDTest()
        {
            const string sProgId = "My.Crazy.1";
            const string testStr = "Testing123";

            ShellRegistrar.UnregisterProgID(sProgId);

            using (var progid = ShellRegistrar.RegisterProgID(sProgId, "Testing Vanara ProgId"))
                using (var reg = Microsoft.Win32.Registry.ClassesRoot.OpenSubKey(sProgId))
                {
                    Assert.That(reg, Is.Not.Null);
                    Assert.That(reg.GetValue(null).ToString(), Is.EqualTo(progid.FriendlyName));
                    Assert.That(progid.ID, Is.EqualTo(sProgId));
                    Assert.That(progid.ReadOnly, Is.False);

                    progid.AllowSilentDefaultTakeOver = true;
                    Assert.That(progid.AllowSilentDefaultTakeOver, Is.True);
                    progid.AllowSilentDefaultTakeOver = false;
                    Assert.That(progid.AllowSilentDefaultTakeOver, Is.False);

                    progid.AppUserModelID = testStr;
                    Assert.That(progid.AppUserModelID, Is.EqualTo(testStr));
                    progid.AppUserModelID = null;
                    Assert.That(progid.AppUserModelID, Is.Null);

                    var g = Guid.NewGuid();
                    progid.CLSID = g;
                    Assert.That(progid.CLSID.Value, Is.EqualTo(g));
                    progid.CLSID = null;
                    Assert.That(progid.CLSID, Is.Null);

                    var i = new IconLocation(@"C:\Temp\dllexp.exe", -1);
                    progid.DefaultIcon = i;
                    Assert.That(progid.DefaultIcon.ToString(), Is.EqualTo(i.ToString()));
                    progid.DefaultIcon = null;
                    Assert.That(progid.DefaultIcon, Is.Null);

                    var f = PInvoke.ShlwApi.FILETYPEATTRIBUTEFLAGS.FTA_NoEditIcon | PInvoke.ShlwApi.FILETYPEATTRIBUTEFLAGS.FTA_NoEdit;
                    progid.EditFlags = f;
                    Assert.That(progid.EditFlags, Is.EqualTo(f));
                    progid.EditFlags = 0;
                    Assert.That(progid.EditFlags, Is.EqualTo(PInvoke.ShlwApi.FILETYPEATTRIBUTEFLAGS.FTA_None));

                    var fn = new IndirectString(@"C:\Temp\dllexp.exe", -1);
                    progid.FriendlyTypeName = fn;
                    Assert.That(progid.FriendlyTypeName.ToString(), Is.EqualTo(fn.ToString()));
                    progid.FriendlyTypeName = null;
                    Assert.That(progid.FriendlyTypeName, Is.Null);

                    progid.InfoTip = fn;
                    Assert.That(progid.InfoTip.ToString(), Is.EqualTo(fn.ToString()));
                    progid.InfoTip = null;
                    Assert.That(progid.InfoTip, Is.Null);

                    var vopen  = progid.Verbs.Add("Open", "&Open", "notepad.exe %1");
                    var vprint = progid.Verbs.Add("Print", "&Print", "notepad.exe %1");
                    var vend   = progid.Verbs.Add("Terminate", "&End", "notepad.exe %1");
                    progid.Verbs.Order = new[] { vend, vprint };
                }
        }
Exemplo n.º 2
0
        public void ToStream(IO.IndentedTextWriter s)
        {
            var sg = s.Owner as BSaveGame;

            s.WriteLine("{1}\t{2}\t{3}\t{4}\t{5}\t{0}", sg.Database.ProtoPowers[ProtoPowerID],
                        TimesUsed.ToString(), IconLocation.ToString(),
                        IgnoreCost.ToString(), IgnoreTechPrereqs.ToString(), IgnorePop.ToString());
            using (s.EnterIndentBookmark())
                for (int x = 0; x < Items.Length; x++)
                {
                    Items[x].ToStream(s);
                }
        }