Esempio n. 1
0
        public void CombinedTest()
        {
            var c = new ExtensionCollection();

            Assert.AreEqual(0, c.Count);
            Assert.IsNull(c.Get <ExtensionCollectionTest>());
            AssertEx.ThrowsArgumentException(() => c.Set(typeof(int), 1));
            c.Set(this);
            Assert.AreEqual(1, c.Count);
            Assert.AreSame(this, c.Get <ExtensionCollectionTest>());

            c.Lock();
            AssertEx.Throws <InstanceIsLockedException>(() => c.Set(this));

            var cc = (ExtensionCollection)c.Clone();

            AssertEx.HasSameElements(c, cc);

            var o = new object();

            cc.Set(o);
            Assert.AreEqual(2, cc.Count);
            Assert.AreSame(this, cc.Get <ExtensionCollectionTest>());
            Assert.AreSame(o, cc.Get <object>());
        }
Esempio n. 2
0
    IEnumerator FeedItem_Init(Video vid)
    {
        video = vid;

        // find a textmesh for the description
        TextMesh textMesh = GetComponentInChildren <TextMesh>();

        if (textMesh)
        {
            //textMesh.text = vid.Description.Substring(0,Mathf.Min(30, vid.Description.Length));
            textMesh.text = vid.Title;
        }

        // find a thumbnail child
        Transform thumb = transform.Find("Thumbnail");

        if (thumb)
        {
            ExtensionCollection <MediaThumbnail> thumbnails = video.Thumbnails;
            MediaThumbnail thumbnail = thumbnails[0];

            string urlString = thumbnail.Url;
            WWW    req       = new WWW(urlString);
            yield return(req);

            thumb.gameObject.renderer.material.mainTexture = req.texture;
            thumb.gameObject.renderer.material.SetTextureScale("_MainTex", new Vector2(1.0f, -1.0f));
        }
    }
Esempio n. 3
0
        public static List <string> GetAgendaToLinks()
        {
            DateTime dt = new DateTime();

            dt = DateTime.Now;
            string userName        = "******";
            string password        = "******";
            string applicationName = "Agenda";

            CalendarHelper.Credentials = new GDataCredentials(userName, password);
            AtomEntryCollection feed  = CalendarHelper.GetAllEvents(CalendarHelper.GetService(applicationName), DateTime.Now, DateTime.Now.AddDays(90));
            List <string>       items = new List <string>();

            for (int x = 0; x < feed.Count; x++)
            {
                var e = feed[x];

                if (!String.IsNullOrEmpty(e.Title.Text))
                {
                    CalendarEvent ar = new CalendarEvent();

                    ar.Title       = e.Title.Text;
                    ar.URI         = e.AlternateUri.Content;
                    ar.Description = e.Content.Content;
                    ExtensionCollection <When> v = ((EventEntry)(e)).Times;
                    ar.StartTime = v[0].StartTime;
                    ar.EndTime   = v[0].EndTime;
                    items.Add(ar.ToString());
                }
            }
            return(items);
        }
Esempio n. 4
0
        /// <summary>
        /// Writes the XML file for getting infos about updates.
        /// </summary>
        /// <param name="xmlFile">is the filename where to save the infos to.</param>
        public bool WriteUpdateXml(string xmlFile)
        {
            if (String.IsNullOrEmpty(xmlFile))
            {
                Console.WriteLine("[MpeMaker] Error: Output file for Update.xml is not specified in package.");
                return(false);
            }

            if (!Path.IsPathRooted(xmlFile))
            {
                xmlFile = Path.GetFullPath(Path.Combine(Path.GetDirectoryName(this.ProjectSettings.ProjectFilename), xmlFile));
            }

            ExtensionCollection list = ExtensionCollection.Load(xmlFile);

            PackageClass pakToAdd = Clone();

            pakToAdd.GeneralInfo.OnlineLocation = ReplaceInfo(pakToAdd.GeneralInfo.OnlineLocation);
            pakToAdd.GeneralInfo.Params.Items.Remove(pakToAdd.GeneralInfo.Params[ParamNamesConst.ICON]);

            list.Add(pakToAdd);
            list.Sort(true);
            list.Save(xmlFile);

            return(true);
        }
Esempio n. 5
0
        /// <summary>
        /// Merges the specified organizations.
        /// </summary>
        /// <param name="organizations">The organizations.</param>
        /// <param name="organization">The organization.</param>
        /// <returns>True if Changed.</returns>
        public static bool Merge(this ExtensionCollection <Organization> organizations, Organization organization)
        {
            if ((!string.IsNullOrWhiteSpace(organization.Name) || !string.IsNullOrWhiteSpace(organization.Department)))
            {
                var result = false;

                if (organizations.Any(e => e.Name == organization.Name))
                {
                    var org = organizations.First(e => e.Name == organization.Name);
                    result |= org.ApplyProperty(o => o.Department, organization.Department);
                    result |= org.ApplyProperty(o => o.Title, organization.Title);
                }
                else
                {
                    organizations.Add(organization);
                    result = true;
                }

                if (organizations.Any() && !organizations.Any(e => e.Primary))
                {
                    organizations.First().Primary = true;
                }

                return(result);
            }

            return(false);
        }
Esempio n. 6
0
 private void btn_clean_Click(object sender, EventArgs e)
 {
     if (MessageBox.Show("Do you want to clear all unused data ?\nYou need to redownload update info .", "Cleanup",
                         MessageBoxButtons.YesNo,
                         MessageBoxIcon.Question) == DialogResult.Yes)
     {
         ExtensionCollection collection = new ExtensionCollection();
         foreach (PackageClass item in MpeCore.MpeInstaller.KnownExtensions.Items)
         {
             if (MpeCore.MpeInstaller.InstalledExtensions.Get(item) == null)
             {
                 collection.Items.Add(item);
             }
         }
         foreach (PackageClass packageClass in collection.Items)
         {
             try
             {
                 if (Directory.Exists(packageClass.LocationFolder))
                 {
                     Directory.Delete(packageClass.LocationFolder, true);
                 }
                 MpeCore.MpeInstaller.KnownExtensions.Remove(packageClass);
             }
             catch (Exception ex)
             {
                 MessageBox.Show("Error : " + ex.Message);
             }
         }
         MpeCore.MpeInstaller.Save();
         FilterList();
         RefreshLists();
     }
 }
Esempio n. 7
0
        private void PopulateInstallBtn()
        {
            ExtensionCollection collection = MpeCore.MpeInstaller.KnownExtensions.GetList(Package.GeneralInfo.Id);

            collection.Add(Package);
            foreach (PackageClass item in collection.GetList(Package.GeneralInfo.Id).Items)
            {
                ToolStripMenuItem testToolStripMenuItem = new ToolStripMenuItem();
                testToolStripMenuItem.Text = string.Format("Version - {0} [{1}]", item.GeneralInfo.Version,
                                                           item.GeneralInfo.DevelopmentStatus);
                PackageClass pak = MpeCore.MpeInstaller.InstalledExtensions.Get(Package.GeneralInfo.Id);
                if (pak != null && item.GeneralInfo.Version.CompareTo(pak.GeneralInfo.Version) == 0)
                {
                    testToolStripMenuItem.Font = new Font("Microsoft Sans Serif", 8.25F, FontStyle.Bold,
                                                          GraphicsUnit.Point, ((byte)(0)));
                }
                if (!item.CheckDependency(true))
                {
                    testToolStripMenuItem.ForeColor = Color.Red;
                }
                if (item.GeneralInfo.VersionDescription != null)
                {
                    testToolStripMenuItem.ToolTipText = item.GeneralInfo.VersionDescription.Length > 1024
                                                ? item.GeneralInfo.VersionDescription.Substring(0, 1024) + "..."
                                                : item.GeneralInfo.VersionDescription;
                }
                testToolStripMenuItem.Tag    = item;
                testToolStripMenuItem.Click += testToolStripMenuItem_Click;
                btn_install.DropDownItems.Add(testToolStripMenuItem);
            }
        }
Esempio n. 8
0
 /// <summary>
 /// default constructor for sc:group with attributes
 /// </summary>
 /// <param name="customAttributes">The list of attributes for the group.</param>
 public CustomGroup(ExtensionCollection <CustomAttribute> customAttributes)
     : base(ContentForShoppingNameTable.Group,
            ContentForShoppingNameTable.scDataPrefix,
            ContentForShoppingNameTable.BaseNamespace)
 {
     this.customAttributes = customAttributes;
 }
Esempio n. 9
0
        public static async Task <int> Main(string[] args)
        {
            Console.InputEncoding  = Encoding.UTF8;
            Console.OutputEncoding = Encoding.UTF8;

            ILogger             logger     = new Logger();
            ExtensionCollection extensions = new ExtensionCollection();
            {
                extensions.Load(new ExtensionLoader(typeof(Extensions.Builtin.Console.ConsoleExtension).Assembly));
                extensions.Load(new ExtensionLoader(typeof(Extensions.Builtin.Workspace.WorkspaceExtension).Assembly));
            }

            PipelineBuilder <string[], Wrapper <int> > builder = new PipelineBuilder <string[], Wrapper <int> >();

            _ = builder.ConfigureLogger(logger)
                .ConfigureExtensions(extensions)
                .ConfigureHost(new ExtensionHost())
                .ConfigureCliCommand();

            if (Environment == EnvironmentType.Test)
            {
                if (TestView.Input == null)
                {
                    throw new NullReferenceException(nameof(TestView.Input));
                }

                _ = builder.ConfigureConsole(new TestTerminal(), TestView.Input);
            }
            else
            {
                _ = builder.ConfigureConsole(new SystemConsole(), Console.In);
            }

            _ = builder.UseCommandsService().UseReplCommandService();

            _ = builder.UseCliCommand();

            if (Environment == EnvironmentType.Test)
            {
                _ = builder.UseTestView();
            }

            _ = builder.UseReplCommand();

            Pipeline <string[], Wrapper <int> > pipeline = await builder.Build(args, logger);

            PipelineResult <Wrapper <int> > result = await pipeline.Consume();

            if (result.IsOk)
            {
                return(result.Result !);
            }
            else
            {
                Console.Error.WriteLine(result.Exception !.ToString());
                return(-1);
            }
        }
 static public string GetBestUrl(ExtensionCollection <MediaThumbnail> th)
 {
     if (th.Count > 0)
     {
         return(th[th.Count - 1].Url);
     }
     else
     {
         return(string.Empty);
     }
 }
Esempio n. 11
0
        /// <summary>
        /// Merges the specified phone numbers.
        /// </summary>
        /// <param name="phoneNumbers">The phone numbers.</param>
        /// <param name="phone">The phone.</param>
        /// <returns>True if Changed.</returns>
        public static bool Merge(this ExtensionCollection <PhoneNumber> phoneNumbers, PhoneNumber phone)
        {
            if (!string.IsNullOrWhiteSpace(phone.Value) && !phoneNumbers.Any(e => e.Value.FormatPhoneClean() == phone.Value.FormatPhoneClean()))
            {
                phoneNumbers.Add(phone);

                return(true);
            }

            return(false);
        }
Esempio n. 12
0
        /// <summary>
        /// Merges the specified locations.
        /// </summary>
        /// <param name="locations">The locations.</param>
        /// <param name="location">The location.</param>
        /// <returns>True if Changed.</returns>
        public static bool Merge(this ExtensionCollection <Where> locations, string location)
        {
            if (!string.IsNullOrWhiteSpace(location) && !locations.Any(e => e.ValueString == location))
            {
                locations.Add(new Where {
                    ValueString = location, Rel = Where.RelType.EVENT
                });
                return(true);
            }

            return(false);
        }
Esempio n. 13
0
        /// <summary>
        /// Merges the specified addresses.
        /// </summary>
        /// <param name="addresses">The addresses.</param>
        /// <param name="address">The address.</param>
        /// <returns>True if Changed.</returns>
        public static bool Merge(this ExtensionCollection <StructuredPostalAddress> addresses, StructuredPostalAddress address)
        {
            if (!string.IsNullOrWhiteSpace(address.Street) && !string.IsNullOrWhiteSpace(address.City) && !string.IsNullOrWhiteSpace(address.Postcode) && !string.IsNullOrWhiteSpace(address.Country) &&
                !addresses.Any(e => (address.Street != null && address.Street.StartsWith(e.Street)) && e.City == address.City && e.Postcode == address.Postcode && e.Country == address.Country))
            {
                addresses.Add(address);

                return(true);
            }

            return(false);
        }
        public InputViewModel(IExtensions extensions)
        {
            if (extensions == null)
            {
                throw new ArgumentNullException(nameof(extensions));
            }

            _extensions = extensions;

            Extensions        = new ExtensionCollection(_extensions.DisplayInputFileExtensions);
            SelectedExtension = Extensions.FirstOrDefault();
        }
Esempio n. 15
0
        protected override Task <int> Handle(CArgument argument, IConsole console, InvocationContext context, PipelineContext pipeline, CancellationToken cancellationToken)
        {
            ITerminal           terminal = console.GetTerminal();
            ExtensionCollection manager  = pipeline.Services.GetExtensions();

            terminal.OutputTable(manager,
                                 new OutputTableColumnStringView <ExtensionLoader>(x => x.Extension.Name, nameof(IExtension.Name)),
                                 new OutputTableColumnStringView <ExtensionLoader>(x => x.Extension.Description ?? "N/A", nameof(IExtension.Description)),
                                 new OutputTableColumnStringView <ExtensionLoader>(x => x.Extension.Publisher ?? "N/A", nameof(IExtension.Publisher)),
                                 new OutputTableColumnStringView <ExtensionLoader>(x => x.Extension.Version.ToString() ?? "N/A", nameof(IExtension.Version))
                                 );
            return(Task.FromResult(0));
        }
        public static void Init()
        {
            InstallerTypeProviders = new Dictionary <string, IInstallerTypeProvider>();
            PathProviders          = new Dictionary <string, IPathProvider>();
            SectionPanels          = new SectionProviderHelper();
            ActionProviders        = new Dictionary <string, IActionType>();
            VersionProviders       = new Dictionary <string, IVersionProvider>();
            ZipProvider            = new ZipProviderClass();


            AddInstallType(new CopyFile());
            AddInstallType(new CopyFont());
            AddInstallType(new GenericSkinFile());

            PathProviders.Add("MediaPortalPaths", new MediaPortalPaths());
            PathProviders.Add("TvServerPaths", new TvServerPaths());
            PathProviders.Add("WindowsPaths", new WindowsPaths());

            AddSection(new Welcome());
            AddSection(new LicenseAgreement());
            AddSection(new ReadmeInformation());
            AddSection(new ImageRadioSelector());
            AddSection(new TreeViewSelector());
            AddSection(new InstallSection());
            AddSection(new Finish());
            AddSection(new GroupCheck());
            AddSection(new GroupCheckScript());

            AddActionProvider(new InstallFiles());
            AddActionProvider(new ShowMessageBox());
            AddActionProvider(new ClearSkinCache());
            AddActionProvider(new RunApplication());
            AddActionProvider(new KillTask());
            AddActionProvider(new CreateShortCut());
            AddActionProvider(new CreateFolder());
            AddActionProvider(new ExtensionInstaller());
            AddActionProvider(new ConfigurePlugin());
            AddActionProvider(new Script());

            AddVersion(new MediaPortalVersion());
            AddVersion(new SkinVersion());
            AddVersion(new TvServerVersion());
            AddVersion(new ExtensionVersion());
            AddVersion(new InstallerVersion());

            InstalledExtensions =
                ExtensionCollection.Load(string.Format("{0}\\InstalledExtensions.xml", BaseFolder));
            KnownExtensions =
                ExtensionCollection.Load(string.Format("{0}\\KnownExtensions.xml", BaseFolder));
        }
        private string findLargestThumbnail(ExtensionCollection <MediaThumbnail> collection)
        {
            MediaThumbnail largest = null;
            int            width   = 0;

            foreach (MediaThumbnail thumb in collection)
            {
                int iWidth = int.Parse(thumb.Attributes["width"] as string);
                if (iWidth > width)
                {
                    largest = thumb;
                }
            }
            return(largest.Attributes["url"] as string);
        }
        public void Setup()
        {
            _mockCalls          = new Mock <IMockCalls>();
            LuaTestExtension    = new LuaTestExtension(_mockCalls.Object);
            ExtensionCollection = new ExtensionCollection();
            ExtensionCollection.AddLuaExtension(LuaTestExtension);
            Pipeline = new Pipeline(ExtensionCollection);

            _statusUpdates = new List <PipelineUpdate>();

            _mockCalls.Setup(m => m.Call(It.IsAny <PipelineUpdate>()))
            .Callback <PipelineUpdate>(update => { _statusUpdates.Add(update); });

            Pipeline.Update += status => { _mockCalls.Object.Call(status); };
        }
Esempio n. 19
0
        /// <summary>
        /// Get the first reminder from a group which matches a specified type, or null if not found.
        /// </summary>
        /// <param name="reminders"></param>
        /// <param name="type"></param>
        /// <returns></returns>
        private static Reminder GetReminder(ExtensionCollection <Reminder> reminders, Reminder.ReminderMethod[] type)
        {
            foreach (Reminder.ReminderMethod method in type)
            {
                foreach (Reminder each in reminders)
                {
                    if (each.Method == method)
                    {
                        return(each);
                    }
                }
            }

            return(null);
        }
Esempio n. 20
0
        private static void UpdateReminderList(ExtensionCollection <Reminder> reminders, Reminder newReminder)
        {
            int length = reminders.Count;

            for (int i = 0; i < length; i++)
            {
                if (reminders[i].Method == newReminder.Method)
                {
                    reminders[i] = newReminder;
                    return;
                }
            }

            reminders.Add(newReminder);
        }
Esempio n. 21
0
        /// <summary>
        /// Merges the specified emails.
        /// </summary>
        /// <param name="emails">The emails.</param>
        /// <param name="mail">The mail.</param>
        /// <returns>True if Changed.</returns>
        public static bool Merge(this ExtensionCollection <EMail> emails, EMail mail)
        {
            if (!string.IsNullOrWhiteSpace(mail.Address) && !emails.Any(e => e.Address == mail.Address))
            {
                emails.Add(mail);

                if (emails.Any() && !emails.Any(e => e.Primary))
                {
                    emails.First().Primary = true;
                }

                return(true);
            }

            return(false);
        }
Esempio n. 22
0
        /// <summary>
        /// Merges the specified ims.
        /// </summary>
        /// <param name="ims">The ims.</param>
        /// <param name="im">The im.</param>
        /// <returns>True if Changed.</returns>
        public static bool Merge(this ExtensionCollection <IMAddress> ims, IMAddress im)
        {
            if (!string.IsNullOrWhiteSpace(im.Address) && !ims.Any(e => e.Address == im.Address))
            {
                ims.Add(im);

                if (ims.Any() && !ims.Any(e => e.Primary))
                {
                    ims.First().Primary = true;
                }

                return(true);
            }

            return(false);
        }
Esempio n. 23
0
        /// <summary>
        /// Merges the specified websites.
        /// </summary>
        /// <param name="websites">The websites.</param>
        /// <param name="website">The website.</param>
        /// <returns>True if Changed.</returns>
        public static bool Merge(this ExtensionCollection <Website> websites, Website website)
        {
            if (!string.IsNullOrWhiteSpace(website.Href) && !websites.Any(e => e.Href == website.Href))
            {
                websites.Add(website);

                if (websites.Any() && !websites.Any(e => e.Primary))
                {
                    websites.First().Primary = true;
                }

                return(true);
            }

            return(false);
        }
    public static void ExtensionCollectionPublicMembersTest()
    {
        ExtensionCollection <IMyExtensibleObject> collection = new ExtensionCollection <IMyExtensibleObject>(new MyExtensibleObject(), "syncRoot");

        collection.Add(new MyExtension1());
        collection.Add(new MyExtension2());

        Assert.True(collection.Count == 2, $"Expected the collection to contain 2 items, instead it contained '{collection.Count}' items.");

        IMyExtension result = collection.Find <IMyExtension>();

        Assert.NotNull(result);

        Collection <IMyExtension> myCollection = collection.FindAll <IMyExtension>();

        Assert.True(myCollection.Count == 2, $"Expected the collection to contain 2 items of type 'IMyExtension', instead it contained: '{myCollection.Count}' items.");
    }
        private void add_list_Click(object sender, EventArgs e)
        {
            string xmlFile            = txt_list1.Text;
            ExtensionCollection list  = new ExtensionCollection();
            ExtensionCollection list2 = new ExtensionCollection();

            if (File.Exists(xmlFile))
            {
                list = ExtensionCollection.Load(xmlFile);
            }
            if (File.Exists(txt_list2.Text))
            {
                list2 = ExtensionCollection.Load(txt_list2.Text);
            }
            list.Add(list2);
            list.Save(xmlFile);
        }
Esempio n. 26
0
        /// <summary>
        /// Merges the specified participants.
        /// </summary>
        /// <param name="participants">The participants.</param>
        /// <param name="outlookCalendarItem">The outlook calendar item.</param>
        /// <returns>True if Changed.</returns>
        public static bool Merge(this ExtensionCollection <Who> participants, AppointmentItem outlookCalendarItem)
        {
            var result = false;

            foreach (Recipient recipient in outlookCalendarItem.Recipients.Cast <Recipient>().Where(recipient => !participants.Any(e => e.Email == (recipient.Address ?? recipient.Name))))
            {
                participants.Add(new Who
                {
                    Attendee_Type = ((OlMeetingRecipientType)Enum.Parse(typeof(OlMeetingRecipientType), recipient.Type.ToString())).GetRecipientType(),
                    Email         = recipient.Address ?? recipient.Name,
                    Rel           = Who.RelType.EVENT_ATTENDEE
                });
                result |= true;
            }

            return(result);
        }
Esempio n. 27
0
        /// <summary>
        /// Merges the specified google groups.
        /// </summary>
        /// <param name="groups">The groups.</param>
        /// <param name="outlookGroup">The outlook group.</param>
        /// <param name="googleGroups">All google groups.</param>
        /// <returns>
        /// True if Changed.
        /// </returns>
        public static bool Merge(this ExtensionCollection <GroupMembership> groups, string outlookGroup, IEnumerable <Group> googleGroups)
        {
            if (!string.IsNullOrWhiteSpace(outlookGroup))
            {
                var outlookGroupAsGoogleGroup = googleGroups.FirstOrInstance(g => (string.IsNullOrEmpty(g.SystemGroup) ? g.Title : g.SystemGroup) == outlookGroup);
                if (!string.IsNullOrWhiteSpace(outlookGroupAsGoogleGroup.Id))
                {
                    groups.Add(new GroupMembership {
                        HRef = outlookGroupAsGoogleGroup.Id
                    });

                    return(true);
                }
            }

            return(false);
        }
Esempio n. 28
0
 public static Task LoadFromManager(this ExtensionCollection extensions, Manager manager, LoggerScope logger)
 {
     if (manager.HasInitialized)
     {
         foreach (ExtensionMetadata v in manager.GetExtensions())
         {
             try
             {
                 ExtensionLoader loader = new ExtensionLoader(v.RootPath, v.Name);
                 extensions.Load(loader);
             }
             catch
             {
                 logger.Warning($"Load extension at {v.RootPath} failed.");
             }
         }
     }
     return(Task.CompletedTask);
 }
Esempio n. 29
0
        public static Builder UseExtensionsService(this Builder builder) => builder.Use(nameof(UseExtensionsService),
                                                                                        async context =>
        {
            ExtensionCollection res = new ExtensionCollection();
            Manager manager         = context.Services.GetManager();

            res.Load(new ExtensionLoader(typeof(Extensions.Builtin.Console.ConsoleExtension).Assembly));
            res.Load(new ExtensionLoader(typeof(Extensions.Builtin.Workspace.WorkspaceExtension).Assembly));

            foreach (System.Reflection.Assembly v in ExtensionDI.ExtensionAssemblies)
            {
                res.Load(new ExtensionLoader(v));
            }

            await res.LoadFromManager(manager, context.Logs);

            context.Services.Add <ExtensionCollection>(res);
            return(context.IgnoreResult());
        });
        public void Set(ExtensionCollection collection, bool isListOfInstalledExtensions)
        {
            var oldCursor = ParentForm.Cursor;

            try
            {
                ParentForm.Cursor = Cursors.WaitCursor;
                flowLayoutPanel1.SuspendLayout();
                collection.Sort(false);
                comboBox1.Items.Clear();
                comboBox1.Items.Add("All");
                TagList.Clear();
                toolTip1.RemoveAll(); // removes all created user-objects for the tooltip - reuse this tooltip instance, otherwise memory leak!
                foreach (Control c in flowLayoutPanel1.Controls)
                {
                    c.Dispose();
                }
                flowLayoutPanel1.Controls.Clear();
                foreach (PackageClass item in collection.Items)
                {
                    var extHostCtrl = new ExtensionControlHost();
                    flowLayoutPanel1.Controls.Add(extHostCtrl);
                    extHostCtrl.Initialize(item, isListOfInstalledExtensions);
                    AddTags(item.GeneralInfo.TagList);
                }
                comboBox1.Text = "All";
                textBox1.Text  = string.Empty;
                foreach (KeyValuePair <string, int> tagList in TagList)
                {
                    if (tagList.Value > 1)
                    {
                        comboBox1.Items.Add(tagList.Key);
                    }
                }
                flowLayoutPanel1.ResumeLayout();
                flowLayoutPanel1_SizeChanged(this, EventArgs.Empty);
            }
            finally
            {
                ParentForm.Cursor = oldCursor;
            }
        }
 public PeerNeighbor(PeerNodeConfig config,
                     IPeerNodeMessageHandling messageHandler)
 {
     this.closeReason = PeerCloseReason.None;
     this.closeInitiator = PeerCloseInitiator.LocalNode;
     this.config = config;
     this.state = PeerNeighborState.Created;
     this.extensions = new ExtensionCollection<IPeerNeighbor>(this, thisLock);
     this.messageHandler = messageHandler;
 }
        /// <summary>
        /// Creates a <see cref="Sandbox"/> object, compiled expressions and configures extensions inside the sandbox application domain.
        /// </summary>
        /// <param name="appDomain">The sandbox application domain.</param>
        /// <param name="assemblyPath">The compiled expressions assembly path.</param>
        /// <param name="extensions">The extensions to initialize the compiled expression object with.</param>
        /// <returns>A remote <see cref="Sandbox"/> object.</returns>
        private static Sandbox CreateSandbox(AppDomain appDomain, string assemblyPath, ExtensionCollection extensions)
        {
            var sandboxType = typeof(Sandbox);
            var sandboxAssemblyPath = sandboxType.Assembly.ManifestModule.FullyQualifiedName;
            var typeName = sandboxType.FullName;

            Debug.Assert(typeName != null, "typeName != null");
            var sandbox = (Sandbox)Activator.CreateInstanceFrom(appDomain, sandboxAssemblyPath, typeName).Unwrap();

            var assemblyMap = new Dictionary<string, string>();
            foreach (var type in extensions.Select(e => e.GetExtensionType()))
                assemblyMap[type.Assembly.FullName] = type.Assembly.ManifestModule.FullyQualifiedName;

            sandbox.InstallAssemblyResolver(assemblyMap);
            sandbox.CreateCompiledExpressions(assemblyPath);

            // Extensions
            foreach (var extension in extensions)
                sandbox.SetValue(extension.Name, extension.Instance);

            return sandbox;
        }
Esempio n. 33
0
 internal ReportEngine()
 {
     _extensions = new ExtensionCollection(this);
 }
        public void BeforeSendRequestTest()
        {
            // Arrange.
            const string HeaderName1 = "Header1";
            const string HeaderName2 = "Header2";
            const string HeaderNamespace = "TestNamespace";
            const string Actor = "TestActor";

            var oldHeader1 = MessageHeader.CreateHeader(HeaderName1, HeaderNamespace, "Test Value 1");
            var oldHeader2 = MessageHeader.CreateHeader(HeaderName2, HeaderNamespace, "Test Value 2");

            var operationContext = Mock.Create<OperationContext>();
            Mock.Arrange(() => OperationContext.Current).Returns(operationContext);

            var headerAttributes = new SoapHeaderAttributes
                                       {
                                           HeaderName = HeaderName2,
                                           HeaderNamespace = HeaderNamespace,
                                           MustUnderstand = true,
                                           Actor = Actor,
                                           Relay = true
                                       };

            var integrationExtension = new IntegrationServiceOperationContextExtension();
            integrationExtension.HeaderAttributes.Add(headerAttributes);

            var extensions = new ExtensionCollection<OperationContext>(operationContext) { integrationExtension };
            Mock.Arrange(() => operationContext.Extensions).Returns(extensions);

            var message = Mock.Create<Message>();
            var messageHeaders = new MessageHeaders(MessageVersion.Soap11) { oldHeader1, oldHeader2 };
            Mock.Arrange(() => message.Headers).Returns(messageHeaders);

            var inspector = new IntegrationServiceMessageInspector();
            
            // Act.
            var newMessage = message;
            inspector.BeforeSendRequest(ref newMessage, Mock.Create<IClientChannel>());

            // Assert.
            Assert.AreSame(message, newMessage);

            Assert.AreEqual(2, messageHeaders.Count);
            Assert.IsTrue(messageHeaders.Contains(oldHeader1));
            Assert.IsFalse(messageHeaders.Contains(oldHeader2));

            var index = messageHeaders.FindHeader(HeaderName2, HeaderNamespace, Actor);
            var newHeader2 = (XmlElementMessageHeader)messageHeaders[index];

            Assert.IsTrue(newHeader2.MustUnderstand);
            Assert.AreEqual(Actor, newHeader2.Actor);
            Assert.IsTrue(newHeader2.Relay);

            // Exceptions.
            Message nullMessage = null;

            TestsHelper.VerifyThrow<ArgumentNullException>(() => inspector.BeforeSendRequest(ref nullMessage, Mock.Create<IClientChannel>()));

            var message2 = Mock.Create<Message>();
            TestsHelper.VerifyThrow<ArgumentNullException>(() => inspector.BeforeSendRequest(ref message2, null));
        }