Example #1
0
        public void TestParse(ComponentOptions expectedOptions, string toString)
        {
            var options = ComponentOptions.Parse(toString);

            Assert.Equal(expectedOptions.ComponentName, options.ComponentName);
            Assert.Equal(expectedOptions.Options, options.Options);
        }
 public override Task <TextFieldComponent> ResolveAsync(ComponentOptions type)
 {
     Component.Name       = type.Name;
     Component.Title      = type.PropertyInfo.GetDisplayName();
     Component.Validators = type.Validators;
     return(Task.FromResult(Component));
 }
 public override Task <NumberFieldComponent> ResolveAsync(ComponentOptions options)
 {
     Component.Name       = options.Name;
     Component.Title      = options.PropertyInfo.GetDisplayName();
     Component.Validators = options.Validators;
     return(Task.FromResult(Component));
 }
Example #4
0
 public override Task <DropDownComponent> ResolveAsync(ComponentOptions options)
 {
     Component.Title = options.PropertyInfo.GetDisplayName();
     Component.Items = GetItems(options.PropertyInfo.PropertyType);
     Component.Name  = options.Name;
     return(Task.FromResult(Component));
 }
Example #5
0
 public override bool IsOwner(ComponentOptions options)
 {
     return(options.Type == typeof(DateTimeOffset) ||
            options.Type == typeof(DateTimeOffset?) ||
            options.Type == typeof(DateTime) ||
            options.Type == typeof(DateTime?));
 }
Example #6
0
 public static ComponentOptions AddMethodProfiler(this ComponentOptions apmComponent, params AspectPredicate[] predicates)
 {
     if (apmComponent == null)
     {
         throw new ArgumentNullException(nameof(apmComponent));
     }
     return(AddMethodProfiler(apmComponent, null, predicates));
 }
Example #7
0
 public static dynamic GetTSObject(ComponentOptions dynObject)
 {
     if (dynObject is null)
     {
         return(null);
     }
     return(dynObject.teklaObject);
 }
Example #8
0
 public static ComponentOptions AddHttpProfiler(this ComponentOptions apmComponent)
 {
     if (apmComponent == null)
     {
         throw new ArgumentNullException(nameof(apmComponent));
     }
     apmComponent.Services.AddType <IProfiler <HttpProfilingContext>, HttpProfiler>(Lifetime.Singleton);
     return(apmComponent);
 }
Example #9
0
        public static Task <RemoteDesktopChannel> CreateScreenChannel(ComponentOptions captureOptions, ComponentOptions encoderOptions,
                                                                      ITargetedRestClient restClient)
        {
            var requestBuilder = CreateRequest(HttpVerb.Get, "screen");

            requestBuilder.Message.Headers.Add("capture", captureOptions.ToString());
            requestBuilder.Message.Headers.AcceptEncoding.Add(new StringWithQualityHeaderValue(encoderOptions.ToString(), 1));

            return(requestBuilder.CreateChannel <RemoteDesktopChannel>(restClient, CancellationToken.None));
        }
Example #10
0
        public void Initialize(ScreenInfo screenInfo, IFrameTransmitter transmitter, ComponentOptions componentOptions)
        {
            if (_x264Net != null)
            {
                throw new InvalidOperationException("Already initialized.");
            }

            _x264Net     = new X264Net(screenInfo.Width, screenInfo.Height);
            _transmitter = transmitter;
        }
Example #11
0
    public override async Task <LinearLayoutComponent> ResolveAsync(ComponentOptions options)
    {
        Component.Children = new List <IComponent>();

        foreach (var property in options.Type.GetProperties())
        {
            Component.Children.Add(await FormBuilder.FromProperty(property));
        }

        return(Component);
    }
Example #12
0
    public override Task <SelectComponent> ResolveAsync(ComponentOptions options)
    {
        var attribute = options.PropertyInfo.GetCustomAttribute <SelectAttribute>() ?? throw new Exception("`SelectAttribute` is not set");

        Component.FetchUrl  = attribute.FetchUrl;
        Component.QueryName = attribute.QueryName;

        Component.Title = options.PropertyInfo.GetDisplayName();
        Component.Name  = options.Name;

        return(Task.FromResult(Component));
    }
Example #13
0
        public static ComponentOptions AddMethodProfiler(this ComponentOptions apmComponent, Action <MethodProfilingOptions> configure, params AspectPredicate[] predicates)
        {
            if (apmComponent == null)
            {
                throw new ArgumentNullException(nameof(apmComponent));
            }
            var options = new MethodProfilingOptions();

            configure?.Invoke(options);
            apmComponent.Services.AddInstance <IOptionAccessor <MethodProfilingOptions> >(options);
            apmComponent.Services.AddType <IProfiler <MethodProfilingContext>, MethodProfiler>(Lifetime.Singleton);
            apmComponent.Services.Configuration.Interceptors.AddTyped <MethodProfilingInterceptor>(predicates);
            return(apmComponent);
        }
Example #14
0
        private static T ResolveService <T>(ComponentOptions options, IEnumerable <T> services) where T : IScreenComponent
        {
            var service = services.FirstOrDefault(x => x.Id == options.ComponentName);

            if (service?.IsPlatformSupported != true)
            {
                service = services.FirstOrDefault(x => x.IsPlatformSupported);
                if (service == null)
                {
                    throw new InvalidOperationException($"No available service found for {typeof(T).Name}");
                }
            }

            return(service);
        }
Example #15
0
        public static ComponentOptions AddApplicationProfiler(this ComponentOptions apmComponent, Action <ApplicationProfilingOptions> configure)
        {
            if (apmComponent == null)
            {
                throw new ArgumentNullException(nameof(apmComponent));
            }
            var options = new ApplicationProfilingOptions();

            configure?.Invoke(options);
            apmComponent.Services.AddType <IOptionAccessor <ApplicationProfilingOptions>, ApplicationProfilingOptions>(Lifetime.Singleton);
            apmComponent.Services.AddType <IProfilerSetup, ApplicationProfilerSetup>(Lifetime.Singleton);
            apmComponent.Services.AddType <IProfiler <ApplicationGCProfilingContext>, ApplicationGCProfiler>(Lifetime.Singleton);
            apmComponent.Services.AddType <IProfiler <ApplicationThreadingProfilingContext>, ApplicationThreadingProfiler>(Lifetime.Singleton);
            return(apmComponent);
        }
Example #16
0
 public JobManipulationUseCase(
     IRegistrationService registrationService,
     IMessageBrokerConsumer interactiveConsumer,
     IOptions <TwitterCredentialsOptions> twitterCredentialsOptionsAccessor,
     JobConfigurationUpdateListenerHostedService jobConfigurationUpdateListenerHostedService,
     IOptions <ComponentOptions> componentOptionsAccessor,
     ILogger <JobManipulationUseCase> logger)
 {
     _twitterCredentials  = twitterCredentialsOptionsAccessor.Value;
     _registrationService = registrationService;
     _jobConfigurationUpdateListenerHostedService = jobConfigurationUpdateListenerHostedService;
     _interactiveConsumer = interactiveConsumer as InteractiveConsumer;
     _logger           = logger;
     _componentOptions = componentOptionsAccessor.Value;
 }
Example #17
0
        private void Intent()
        {
            ComponentOptions componentOptions = new ComponentOptions();

            componentOptions.Package = "com.twitter.android";
            componentOptions.Name    = "com.twitter.android.StartActivity";

            Chameleon.ComponentExists(componentOptions);

            IntentOptions intentOptions = new IntentOptions();

            intentOptions.Component = componentOptions;
            intentOptions.Action    = "android.intent.action.MAIN";
            Chameleon.Intent(intentOptions);
        }
        public static T To <T>(this ComponentOptions options) where T : ComponentOptions, new()
        {
            var result = new T();

            if (result.ComponentName != options.ComponentName)
            {
                throw new ArgumentException($"Cannot convert options of {options.ComponentName} to options of {result.ComponentName}.");
            }

            foreach (var val in options.Options)
            {
                result.Options.Add(val.Key, val.Value);
            }

            return(result);
        }
Example #19
0
        public override void Initialize()
        {
            base.Initialize();
            var captureCommandLine = MazeContext.Request.Headers["capture"];
            var encoderCommandLine = MazeContext.Request.Headers[HeaderNames.AcceptEncoding];

            var captureOptions = ComponentOptions.Parse(captureCommandLine);
            var encoderOptions = ComponentOptions.Parse(encoderCommandLine);

            _captureService = ResolveService(captureOptions, _captureServices);
            _streamEncoder  = ResolveService(encoderOptions, _streamEncoders);

            var screenInfo = _captureService.Initialize(captureOptions);

            _streamEncoder.Initialize(screenInfo, this, encoderOptions);
        }
Example #20
0
        } = true;                                        //GDI is supported everywhere

        public ScreenInfo Initialize(ComponentOptions componentOptions)
        {
            var options = componentOptions.To <GdiOptions>();
            var screen  = Screen.AllScreens[options.Monitor.Value];

            _screenBounds = screen.Bounds;

            _currentImage        = new Bitmap(screen.Bounds.Width, screen.Bounds.Height, PixelFormat.Format24bppRgb);
            _screenDeviceContext = NativeMethods.CreateDC("DISPLAY", null, null, IntPtr.Zero);

            if (_screenDeviceContext == IntPtr.Zero)
            {
                throw new InvalidOperationException("Creating device context for display failed.");
            }

            return(new ScreenInfo(screen.Bounds.Width, screen.Bounds.Height));
        }
Example #21
0
        public static IServiceCollection AddAspectCoreAPM(this IServiceCollection services, Action <ComponentOptions> componentOptions, Action <ApplicationOptions> applicationOptions = null)
        {
            if (services == null)
            {
                throw new ArgumentNullException(nameof(services));
            }
            if (componentOptions == null)
            {
                throw new ArgumentNullException(nameof(componentOptions));
            }

            var apmComponent = new ComponentOptions();

            apmComponent.AddAPMCore(applicationOptions);
            componentOptions(apmComponent);

            foreach (var service in apmComponent.Services)
            {
                var descriptor = GetServiceDescriptor(service);
                if (descriptor != null)
                {
                    services.Add(descriptor);
                }
            }

            services.AddDynamicProxy(config =>
            {
                foreach (var interceptor in apmComponent.Services.Configuration.Interceptors)
                {
                    config.Interceptors.Add(interceptor);
                }
                foreach (var nonAspectPredicate in apmComponent.Services.Configuration.NonAspectPredicates)
                {
                    config.NonAspectPredicates.Add(nonAspectPredicate);
                }
                foreach (var validationHandler in apmComponent.Services.Configuration.ValidationHandlers)
                {
                    config.ValidationHandlers.Add(validationHandler);
                }
            });

            services.AddTransient <IInternalLogger, InternalLogger>();
            services.AddTransient <IHostedService, ComponentHostedService>();

            return(services);
        }
        public static ComponentOptions AddLineProtocolCollector(this ComponentOptions apmComponent, Action <LineProtocolClientOptions> configure)
        {
            if (apmComponent == null)
            {
                throw new ArgumentNullException(nameof(apmComponent));
            }
            if (configure == null)
            {
                throw new ArgumentNullException(nameof(configure));
            }
            apmComponent.Services.AddType <IPayloadClientProvider, LineProtocolPayloadClientProvider>(Lifetime.Singleton);
            var lineProtocolClientOptions = new LineProtocolClientOptions();

            configure(lineProtocolClientOptions);
            apmComponent.Services.AddInstance <IOptionAccessor <LineProtocolClientOptions> >(lineProtocolClientOptions);
            return(apmComponent);
        }
Example #23
0
 public static ComponentOptions AddRedisProfiler(this ComponentOptions apmComponent, Action<RedisProfilingOptions> configure)
 {
     if (apmComponent == null)
     {
         throw new ArgumentNullException(nameof(apmComponent));
     }
     if (configure == null)
     {
         throw new ArgumentNullException(nameof(configure));
     }
     var redisConfigurationOptions = new RedisProfilingOptions();
     configure(redisConfigurationOptions);
     apmComponent.Services.AddInstance<IOptionAccessor<RedisProfilingOptions>>(redisConfigurationOptions);
     apmComponent.Services.AddType<IConnectionMultiplexerProvider, ConnectionMultiplexerProvider>(Lifetime.Singleton);
     apmComponent.Services.AddDelegate<IConnectionMultiplexer>(r => r.ResolveRequired<IConnectionMultiplexerProvider>().ConnectionMultiplexer, Lifetime.Singleton);
     apmComponent.Services.Configure(ConfigureRedisProfiler);
     apmComponent.Services.AddType<IProfiler<RedisProfilingContext>, RedisProfiler>(Lifetime.Singleton);
     return apmComponent;
 }
Example #24
0
        public static int ComponentMain(ComponentOptions opts)
        {
            try {
                var installer = new InstallerFrontend(opts.Offline ? InstallerFrontend.InstallerOptions.Offline : InstallerFrontend.InstallerOptions.None);

                foreach (var component_file in opts.CustomComponentFiles)
                {
                    Logger.Debug($"Adding custom component file: {component_file}");
                    installer.LoadComponentsFile(component_file);
                }

                ETGModComponent component;
                if (installer.AvailableComponents.TryGetValue(opts.Name, out component))
                {
                    Console.WriteLine($"Name: {component.Name}");
                    Console.WriteLine($"Author: {component.Author}");
                    if (component.Description.Contains("\n"))
                    {
                        Console.WriteLine($"Description:");
                        Console.WriteLine($"  {component.Description.Replace("\n", "\n  ")}");
                    }
                    else
                    {
                        Console.WriteLine($"Description: {component.Description}");
                    }
                    Console.WriteLine("Versions:");
                    foreach (var ver in component.Versions)
                    {
                        Console.WriteLine($"  {ver}");
                    }
                }
                else
                {
                    Console.WriteLine($"Component {opts.Name} doesn't exist or isn't in the official list.");
                    return(1);
                }
            } catch (Exception e) {
                _WriteError(e);
                return(1);
            }
            return(0);
        }
Example #25
0
 async Task <IComponent> IComponentResolver.ResolveAsync(ComponentOptions type) => await ResolveAsync(type);
Example #26
0
 public abstract Task <TComponent> ResolveAsync(ComponentOptions options);
Example #27
0
 public override bool IsOwner(ComponentOptions options) => options.Type.IsEnum;
Example #28
0
 public void Initialize(ScreenInfo screenInfo, IFrameTransmitter transmitter, ComponentOptions componentOptions)
 {
     throw new NotImplementedException();
 }
Example #29
0
        public ListDialog(String p_listItemType, String p_listLinkType, DataEntryController p_listController, int p_rootIDForList, DataEntryController p_callingController, int p_callingRootID)
            : base()
        {
            InitializeComponent();

            m_listLinkType = p_listLinkType;
            m_listItemType = p_listItemType;
            m_rootIDForList = p_rootIDForList;
            m_callingRootID = p_callingRootID;

            listController = p_listController;
            callingController = p_callingController;

            newNumericUpDown = new NumericUpDown();
            this.listView1.Controls.Add(newNumericUpDown);
            newNumericUpDown.Hide();

            //image list 
            Dictionary<String, Bitmap> typeImage = listController.GetIcons();
            ImageList tempList = new ImageList();
            Image image;
            foreach (String k in typeImage.Keys)
            {
                image = typeImage[k];
                tempList.Images.Add(k, image);
            }
            this.listView1.SmallImageList = tempList;

            this.listView1.ItemSelectionChanged += new ListViewItemSelectionChangedEventHandler(listView1_ItemSelectionChanged);
            this.listView1.DoubleClick += new EventHandler(ListDialog_DoubleClick);
            this.listView1.HScrollMoved += new EventHandler(listView1_ScrollMoved);
            this.listView1.VScrollMoved += new EventHandler(listView1_ScrollMoved);
            this.listView1.MouseWheelRotated += new EventHandler(listView1_MouseWheelRotated);

            this.newNumericUpDown.KeyDown += new KeyEventHandler(newNumericUpDown_KeyDown);

            ComponentOptions compOptions = new ComponentOptions();
            compOptions.LevelDown = 0;

            IXPathNavigable callingInfoIXP = callingController.GetComponentAndChildren(m_callingRootID, p_listLinkType, compOptions);
            XPathNavigator callingNavigator = callingInfoIXP.CreateNavigator();

            XPathNavigator callingRootComponent = callingNavigator.SelectSingleNode("/Components/Component");

            if (callingRootComponent != null)
            {
                String rootName = callingRootComponent.GetAttribute("Name", callingRootComponent.NamespaceURI);
                String rootType = callingRootComponent.GetAttribute("Type", callingRootComponent.NamespaceURI);
                addButtonLabel.Text = "Add selected items to " + rootType + " " + rootName + ":"; 
            }

            IXPathNavigable titleIXP = listController.GetComponentAndChildren(m_rootIDForList, p_listLinkType, compOptions);
            XPathNavigator titleNavigator = titleIXP.CreateNavigator();

            XPathNavigator titleComponent = titleNavigator.SelectSingleNode("/Components/Component");

            if (titleComponent != null)
            {
                String titleType = titleComponent.GetAttribute("Type", titleComponent.NamespaceURI);
                this.Text = "Items of type " + m_listItemType + " from the " + titleType;
            }

            addButton.AutoSize = true;
            addButton.Text = "Add";
            addButton.Click += new EventHandler(addButton_Click);

            buttonCancel.Click += new EventHandler(buttonCancel_Click);

            this.listView1.MultiSelect = true;
        }
Example #30
0
 public IComponentHandler FindHandler(ComponentOptions options) => this.First(x => x.IsOwner(options));
Example #31
0
 public override Task <DropDownComponent> ResolveAsync(ComponentOptions options)
 {
     throw new System.NotImplementedException();
 }
Example #32
0
        public void AddComponentToCache(Controller c, AME.Model.Model model, int topID, int parentID, int id, string type, string baseType, int linkID, string name, string linkType, string desc, Component.eComponentType eType, String lastValidateAddParentXPath, List<ComponentFunction> lastSchemaValuesValidateAdd)
        {
            String key = CreateCacheKey(topID, topID, linkType);
            if (!this.Contains(model, key))
            {
                ComponentOptions full = new ComponentOptions();
                full.CompParams = true;
                full.ClassInstanceInfo = true;
                full.SubclassInstanceInfo = true;
                full.LinkParams = true;
                XmlDocument doc2 = c._GetComponentsXmlDoc(topID, topID, linkType, full);
                AddCacheDocument(model, key, doc2);
                // This occurs at the -end- of a connect that would normally cause a cache add.
                // However, we haven't seen the document before, and the connect has already gone through to the DB.
                // This means the document we just retrieved above to initially populate the cache (c_.GetCompnentsXmlDoc)
                // already contains the item we're looking to add with this call.  So we should actually just return.
                // If we continue as below we will see doubles for the first items added under a linktype.
                // Because the cache is similarly populated (outside of this call) when a linktype is fetched, this side effect usually occurs with programmatic creation
                // where no data has been fetched / used yet, but links are being created and items are being added to the cache.

                // grab the element we're interested in (including children)
                XmlElement alreadyPresent = (XmlElement)doc2.SelectSingleNode(lastValidateAddParentXPath + createComponentXPath(id).Substring(1)); // remove the first slash in the //Component

                // bug fix - add to other link types as well
                addToOtherLinkTypes(key, c, model, alreadyPresent, id, linkID, linkType, lastValidateAddParentXPath);

                return;
            }
            XmlDocument doc = documentCache[model][key];
            XmlElement createForCache;
            DataTable childCheck = model.GetChildComponentLinks(id, linkType);
            if (childCheck.Rows.Count > 0)
            {
                ComponentOptions full = new ComponentOptions();
                full.CompParams = true;
                full.ClassInstanceInfo = true;
                full.SubclassInstanceInfo = true;
                full.LinkParams = true;
                XmlDocument thisCompDoc = (XmlDocument)c._GetComponentsXmlDoc(topID, id, linkType, full);
                XmlNode findChild = thisCompDoc.SelectSingleNode("/Components/Component");
                // set the link ID - the get call doesn't have enough information to do this for the top component
                int lID = c.GetLinkID(parentID, id, linkType);
                XmlAttribute attrLinkID = thisCompDoc.CreateAttribute(XmlSchemaConstants.Display.Component.LinkID);
                attrLinkID.Value = ""+lID;
                findChild.Attributes.Append(attrLinkID);

                // link parameters?
                IXPathNavigable linkParameters = c.GetParametersForLink(lID);

                if (linkParameters != null)
                {
                    XmlNode insert = ((XmlNode)linkParameters).SelectSingleNode(XmlSchemaConstants.Display.sLinkParameters);
                    insert = thisCompDoc.ImportNode(insert, true);
                    findChild.AppendChild(insert);
                }
   
                findChild = doc.ImportNode(findChild, true);
                createForCache = (XmlElement)findChild;
            }
            else
            {
                createForCache = CreateCacheElement(c, doc, id, linkID, type, baseType, name, desc, eType, lastSchemaValuesValidateAdd);
            }
 
            c.AddChildAtXPath(doc, lastValidateAddParentXPath, createForCache, false);
            
            // find other documents with the same linktype = e.g. display ID based
            addToOtherLinkTypes(key, c, model, createForCache, id, linkID, linkType, lastValidateAddParentXPath);
        }