Exemple #1
0
        /// <summary>
        /// Obtains the <see cref="SampleStore"/> corresponding to a given resource store.
        /// Returns the global <see cref="SampleStore"/> if no resource store is passed.
        /// </summary>
        /// <param name="store">The <see cref="IResourceStore{T}"/> of which to retrieve the <see cref="SampleStore"/>.</param>
        public ISampleStore GetSampleStore(IResourceStore <byte[]> store = null)
        {
            if (store == null)
            {
                return(globalSampleStore.Value);
            }

            SampleStore sm = new SampleStore(store);

            globalSampleStore.Value.AddItem(sm);
            return(sm);
        }
Exemple #2
0
        public async Task <ActionResult> PostAsync()
        {
            if (!ModelState.IsValid)
            {
                return(BadRequest(ModelState));
            }

            SampleStore store  = new SampleStore();
            var         result = await store.Publish("value");

            return(Created($"OrderID: {"value"}", $"Order Status: {result}"));
        }
        /// <summary>
        /// Obtains the <see cref="SampleStore"/> corresponding to a given resource store.
        /// Returns the global <see cref="SampleStore"/> if no resource store is passed.
        /// </summary>
        /// <param name="store">The <see cref="IResourceStore{T}"/> of which to retrieve the <see cref="SampleStore"/>.</param>
        /// <param name="mixer">The <see cref="AudioMixer"/> to use for samples created by this store. Defaults to the global <see cref="SampleMixer"/>.</param>
        public ISampleStore GetSampleStore(IResourceStore <byte[]> store = null, AudioMixer mixer = null)
        {
            if (store == null)
            {
                return(globalSampleStore.Value);
            }

            SampleStore sm = new SampleStore(store, mixer ?? SampleMixer);

            globalSampleStore.Value.AddItem(sm);
            return(sm);
        }
        protected void Dispose(bool disposing)
        {
            if (isDisposed)
            {
                return;
            }

            isDisposed = true;

            SampleStore?.Dispose();
            RulesetConfigManager = null;
        }
Exemple #5
0
        public void Setup()
        {
            if (File.Exists(sampleStoreFile))
            {
                // For testing start fresh
                File.Delete(sampleStoreFile);
            }

            sampleStore = new SampleStore(sampleStoreFile);

            // SampleUser can be any implementation that implements org.hyperledger.fabric.sdk.User Interface
            admin = sampleStore.GetMember(TEST_ADMIN_NAME, TEST_ADMIN_ORG);
        }
        /// <summary>
        /// Constructs an AudioStore given a track resource store, and a sample resource store.
        /// </summary>
        /// <param name="audioThread">The host's audio thread.</param>
        /// <param name="trackStore">The resource store containing all audio tracks to be used in the future.</param>
        /// <param name="sampleStore">The sample store containing all audio samples to be used in the future.</param>
        public AudioManager(AudioThread audioThread, ResourceStore <byte[]> trackStore, ResourceStore <byte[]> sampleStore)
        {
            thread = audioThread;

            thread.RegisterManager(this);

            AudioDevice.ValueChanged += onDeviceChanged;

            globalTrackStore = new Lazy <TrackStore>(() =>
            {
                var store = new TrackStore(trackStore, TrackMixer);
                AddItem(store);
                store.AddAdjustment(AdjustableProperty.Volume, VolumeTrack);
                return(store);
            });

            globalSampleStore = new Lazy <SampleStore>(() =>
            {
                var store = new SampleStore(sampleStore, SampleMixer);
                AddItem(store);
                store.AddAdjustment(AdjustableProperty.Volume, VolumeSample);
                return(store);
            });

            AddItem(TrackMixer  = createAudioMixer(null, nameof(TrackMixer)));
            AddItem(SampleMixer = createAudioMixer(null, nameof(SampleMixer)));

            CancellationToken token = cancelSource.Token;

            scheduler.Add(() =>
            {
                // sync audioDevices every 1000ms
                new Thread(() =>
                {
                    while (!token.IsCancellationRequested)
                    {
                        try
                        {
                            syncAudioDevices();
                            Thread.Sleep(1000);
                        }
                        catch
                        {
                        }
                    }
                })
                {
                    IsBackground = true
                }.Start();
            });
        }
        /// <summary>
        /// Constructs an AudioStore given a track resource store, and a sample resource store.
        /// </summary>
        /// <param name="audioThread">The host's audio thread.</param>
        /// <param name="trackStore">The resource store containing all audio tracks to be used in the future.</param>
        /// <param name="sampleStore">The sample store containing all audio samples to be used in the future.</param>
        public AudioManager(AudioThread audioThread, ResourceStore <byte[]> trackStore, ResourceStore <byte[]> sampleStore)
        {
            Thread = audioThread;

            Thread.RegisterManager(this);

            AudioDevice.ValueChanged += onDeviceChanged;

            globalTrackStore = new Lazy <TrackStore>(() =>
            {
                var store = new TrackStore(trackStore);
                AddItem(store);
                store.AddAdjustment(AdjustableProperty.Volume, VolumeTrack);
                return(store);
            });

            globalSampleStore = new Lazy <SampleStore>(() =>
            {
                var store = new SampleStore(sampleStore);
                AddItem(store);
                store.AddAdjustment(AdjustableProperty.Volume, VolumeSample);
                return(store);
            });

            // check for device validity every 100ms
            scheduler.AddDelayed(() =>
            {
                try
                {
                    if (!IsCurrentDeviceValid())
                    {
                        setAudioDevice();
                    }
                }
                catch
                {
                }
            }, 100, true);

            // enumerate new list of devices every second
            scheduler.AddDelayed(() =>
            {
                try
                {
                    setAudioDevice(AudioDevice.Value);
                }
                catch
                {
                }
            }, 1000, true);
        }
        /// <summary>
        /// Obtains the <see cref="SampleStore"/> corresponding to a given resource store.
        /// Returns the global <see cref="SampleStore"/> if no resource store is passed.
        /// </summary>
        /// <param name="store">The <see cref="IResourceStore{T}"/> of which to retrieve the <see cref="SampleStore"/>.</param>
        public IAdjustableResourceStore <SampleChannel> GetSampleStore(IResourceStore <byte[]> store = null)
        {
            if (store == null)
            {
                return(globalSampleManager.Value);
            }

            SampleStore sm = new SampleStore(store);

            AddItem(sm);
            sm.AddAdjustment(AdjustableProperty.Volume, VolumeSample);

            return(sm);
        }
        public BassTestComponents(bool init = true)
        {
            if (init)
            {
                Init();
            }

            Mixer = CreateMixer();

            Resources   = new DllResourceStore(typeof(TrackBassTest).Assembly);
            TrackStore  = new TrackStore(Resources, Mixer);
            SampleStore = new SampleStore(Resources, Mixer);

            Add(TrackStore, SampleStore);
        }
Exemple #10
0
        public void Setup()
        {
            string sampleStoreFile = Path.Combine(Path.GetTempPath(), "HFCSampletest.properties");

            if (File.Exists(sampleStoreFile))
            {
                // For testing start fresh
                File.Delete(sampleStoreFile);
            }

            sampleStore = new SampleStore(sampleStoreFile);

            // SampleUser can be any implementation that implements org.hyperledger.fabric.sdk.User Interface
            admin = sampleStore.GetMember(TEST_ADMIN_NAME, TEST_ADMIN_ORG);
        }
Exemple #11
0
        /// <summary>
        /// Constructs an AudioStore given a track resource store, and a sample resource store.
        /// </summary>
        /// <param name="audioThread">The host's audio thread.</param>
        /// <param name="trackStore">The resource store containing all audio tracks to be used in the future.</param>
        /// <param name="sampleStore">The sample store containing all audio samples to be used in the future.</param>
        public AudioManager(AudioThread audioThread, ResourceStore <byte[]> trackStore, ResourceStore <byte[]> sampleStore)
        {
            Thread = audioThread;

            Thread.RegisterManager(this);

            AudioDevice.ValueChanged += onDeviceChanged;

            trackStore.AddExtension(@"mp3");

            sampleStore.AddExtension(@"wav");
            sampleStore.AddExtension(@"mp3");

            globalTrackStore = new Lazy <TrackStore>(() =>
            {
                var store = new TrackStore(trackStore);
                AddItem(store);
                store.AddAdjustment(AdjustableProperty.Volume, VolumeTrack);
                return(store);
            });

            globalSampleStore = new Lazy <SampleStore>(() =>
            {
                var store = new SampleStore(sampleStore);
                AddItem(store);
                store.AddAdjustment(AdjustableProperty.Volume, VolumeSample);
                return(store);
            });

            scheduler.Add(() =>
            {
                try
                {
                    setAudioDevice();
                }
                catch
                {
                }
            });

            scheduler.AddDelayed(delegate
            {
                updateAvailableAudioDevices();
                checkAudioDeviceChanged();
            }, 1000, true);
        }
Exemple #12
0
        /// <summary>
        /// Constructs an AudioStore given a track resource store, and a sample resource store.
        /// </summary>
        /// <param name="audioThread">The host's audio thread.</param>
        /// <param name="trackStore">The resource store containing all audio tracks to be used in the future.</param>
        /// <param name="sampleStore">The sample store containing all audio samples to be used in the future.</param>
        public AudioManager(AudioThread audioThread, ResourceStore <byte[]> trackStore, ResourceStore <byte[]> sampleStore)
        {
            Thread = audioThread;

            Thread.RegisterManager(this);

            AudioDevice.ValueChanged += onDeviceChanged;

            globalTrackStore = new Lazy <TrackStore>(() =>
            {
                var store = new TrackStore(trackStore);
                AddItem(store);
                store.AddAdjustment(AdjustableProperty.Volume, VolumeTrack);
                return(store);
            });

            globalSampleStore = new Lazy <SampleStore>(() =>
            {
                var store = new SampleStore(sampleStore);
                AddItem(store);
                store.AddAdjustment(AdjustableProperty.Volume, VolumeSample);
                return(store);
            });

            // sync audioDevices every 200ms
            CancellationToken token = cancellationTokenSource.Token;

            Task.Factory.StartNew(() =>
            {
                while (!token.IsCancellationRequested)
                {
                    try
                    {
                        var task = Task.Delay(200, token);
                        syncAudioDevices();
                        task.Wait(token);
                    }
                    catch
                    {
                    }
                }
            }, token, TaskCreationOptions.None, TaskScheduler.Default);
        }
        public static void SetupClient(HFClient hfclient)
        {
            ICryptoSuite cryptoSuite = Factory.GetCryptoSuite();

            string props = Path.Combine(GetHomePath(), "test.properties");

            if (File.Exists(props))
            {
                File.Delete(props);
            }
            SampleStore sampleStore = new SampleStore(props);

            //src/test/fixture/sdkintegration/e2e-2Orgs/channel/crypto-config/peerOrganizations/org1.example.com/users/[email protected]/msp/keystore/

            //SampleUser someTestUSER = sampleStore.getMember("someTestUSER", "someTestORG");
            SampleUser someTestUSER = sampleStore.GetMember("someTestUSER", "someTestORG", "mspid", FindFileSk("fixture/sdkintegration/e2e-2Orgs/" + TestConfig.Instance.FAB_CONFIG_GEN_VERS + "/crypto-config/peerOrganizations/org1.example.com/users/[email protected]/msp/keystore"), ("fixture/sdkintegration/e2e-2Orgs/" + TestConfig.Instance.FAB_CONFIG_GEN_VERS + "/crypto-config/peerOrganizations/org1.example.com/users/[email protected]/msp/signcerts/[email protected]").Locate());

            someTestUSER.MspId = "testMSPID?";

            hfclient.CryptoSuite = Factory.Instance.GetCryptoSuite();
            hfclient.UserContext = someTestUSER;
        }