// Module defining this command // Optional custom code for this activity /// <summary> /// Returns a configured instance of System.Management.Automation.PowerShell, pre-populated with the command to run. /// </summary> /// <param name="context">The NativeActivityContext for the currently running activity.</param> /// <returns>A populated instance of Sytem.Management.Automation.PowerShell</returns> /// <remarks>The infrastructure takes responsibility for closing and disposing the PowerShell instance returned.</remarks> protected override ActivityImplementationContext GetPowerShell(NativeActivityContext context) { System.Management.Automation.PowerShell invoker = global::System.Management.Automation.PowerShell.Create(); System.Management.Automation.PowerShell targetCommand = invoker.AddCommand(PSCommandName); // Initialize the arguments if (Name.Expression != null) { targetCommand.AddParameter("Name", Name.Get(context)); } if (DependentServices.Expression != null) { targetCommand.AddParameter("DependentServices", DependentServices.Get(context)); } if (RequiredServices.Expression != null) { targetCommand.AddParameter("RequiredServices", RequiredServices.Get(context)); } if (ServiceDisplayName.Expression != null) { targetCommand.AddParameter("DisplayName", ServiceDisplayName.Get(context)); } if (Include.Expression != null) { targetCommand.AddParameter("Include", Include.Get(context)); } if (Exclude.Expression != null) { targetCommand.AddParameter("Exclude", Exclude.Get(context)); } if (InputObject.Expression != null) { targetCommand.AddParameter("InputObject", InputObject.Get(context)); } if (GetIsComputerNameSpecified(context) && (PSRemotingBehavior.Get(context) == RemotingBehavior.Custom)) { targetCommand.AddParameter("ComputerName", PSComputerName.Get(context)); } return(new ActivityImplementationContext() { PowerShellInstance = invoker }); }
public static IServices Init(RequiredServices services) { AddDecoders(); var config = services.NdmConfig; var providerAddress = string.IsNullOrWhiteSpace(config.ProviderAddress) ? Address.Zero : new Address(config.ProviderAddress); var consumerAddress = string.IsNullOrWhiteSpace(config.ConsumerAddress) ? Address.Zero : new Address(config.ConsumerAddress); UnlockHardcodedAccounts(providerAddress, consumerAddress, services.Wallet); var readOnlyDbProvider = new ReadOnlyDbProvider(services.RocksProvider, false); var filterStore = new FilterStore(); var filterManager = new FilterManager(filterStore, services.BlockProcessor, services.TransactionPool, services.LogManager); var state = new RpcState(services.BlockTree, services.SpecProvider, readOnlyDbProvider, services.LogManager); var blockchainBridge = new BlockchainBridge( state.StateReader, state.StateProvider, state.StorageProvider, state.BlockTree, services.TransactionPool, services.TransactionPoolInfoProvider, services.ReceiptStorage, filterStore, filterManager, services.Wallet, state.TransactionProcessor, services.Ecdsa); var dataHeaderRlpDecoder = new DataHeaderDecoder(); var encoder = new AbiEncoder(); var depositService = new DepositService(blockchainBridge, encoder, services.Wallet, config, LimboLogs.Instance); var ndmConsumerChannelManager = services.NdmConsumerChannelManager; var ndmDataPublisher = services.NdmDataPublisher; var jsonRpcNdmConsumerChannel = new JsonRpcNdmConsumerChannel(); // ndmConsumerChannelManager.Add(jsonRpcNdmConsumerChannel); return(new Services(services, new CreatedServices(consumerAddress, encoder, dataHeaderRlpDecoder, depositService, ndmDataPublisher, jsonRpcNdmConsumerChannel, ndmConsumerChannelManager, blockchainBridge))); }
// See https://webbluetoothcg.github.io/web-bluetooth/#matches-a-filter public bool Matches(BluetoothLEAdvertisement advertisement) { if (!string.IsNullOrWhiteSpace(Name) && (advertisement.LocalName != Name)) { return(false); } if (!string.IsNullOrWhiteSpace(NamePrefix) && (!advertisement.LocalName.StartsWith(NamePrefix))) { return(false); } if (RequiredServices != null) { if (!RequiredServices.All(service => advertisement.ServiceUuids.Contains(service))) { return(false); } } if (ManufacturerData != null) { foreach (var manufacturerDataFilter in ManufacturerData) { var advertisedData = advertisement.ManufacturerData .FirstOrDefault(d => d.CompanyId == manufacturerDataFilter.Key); if (advertisedData == null) { // the peripheral doesn't advertise any data under that manufacturer ID return(false); } if (!manufacturerDataFilter.Value.Matches(advertisedData.Data)) { // the advertised data doesn't match the filter return(false); } } } return(true); }
public Services(RequiredServices requiredServices, CreatedServices createdServices) { RequiredServices = requiredServices; CreatedServices = createdServices; }