本文整理汇总了C#中IDataStore类的典型用法代码示例。如果您正苦于以下问题:C# IDataStore类的具体用法?C# IDataStore怎么用?C# IDataStore使用的例子?那么, 这里精选的类代码示例或许可以为您提供帮助。
IDataStore类属于命名空间,在下文中一共展示了IDataStore类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。
示例1: QueueProcessor
public QueueProcessor(Logger log, IDataStore dataStore, IHubContext<IMatchmakingClient> hub, ITracker tracker, IMatchEvaluator matchBuilder, CircularBuffer<TimeSpan> timeToMatch)
{
_log = log;
_dataStore = dataStore;
_hub = hub;
_tracker = tracker;
_matchBuilder = matchBuilder;
_timeToMatch = timeToMatch;
_queueSleepMin = Int32.Parse( CloudConfigurationManager.GetSetting("QueueSleepMin") );
_queueSleepMax = Int32.Parse( CloudConfigurationManager.GetSetting("QueueSleepMax") );
_queueSleepLength = Int32.Parse( CloudConfigurationManager.GetSetting("QueueSleepLength") );
Task.Run( async () =>
{
_log.Info("Running QueueProcessor...");
while( true )
{
var sleepTime = _queueSleepMax;
try
{
await processQueue();
sleepTime = _queueSleepMax - (_dataStore.DocumentDbPopulation * (_queueSleepMax/_queueSleepLength));
}
catch(Exception ex)
{
_log.Error(ex);
}
Thread.Sleep(sleepTime < _queueSleepMin ? _queueSleepMin : sleepTime);
}
});
}
示例2: init
public void init()
{
_request = new HttpRequestMessage()
{
Properties = { { HttpPropertyKeys.HttpConfigurationKey, new HttpConfiguration() } }
};
_controller = new RecordsController
{
Request = _request
};
MockRepository repo = new MockRepository();
_mockDataStore = repo.Stub<IDataStore>();
SetupResult.For(_mockDataStore.GetRecords()).Return(
new List<RecordDetail>{
new RecordDetail
{
DateOfBirth = new DateTime(2000, 1, 1),
FavColor = "Black",
Gender = "Male",
FirstName = "test",
LastName = "testL"
},new RecordDetail
{
DateOfBirth = new DateTime(2001, 1, 1),
FavColor = "Blue",
Gender = "Female",
FirstName = "test",
LastName = "lasttest"
}
}
);
}
示例3: AuthenticateOauth
/// <summary>
/// Authenticate to Google Using Oauth2
/// Documentation https://developers.google.com/accounts/docs/OAuth2
/// </summary>
/// <param name="clientId">From Google Developer console https://console.developers.google.com</param>
/// <param name="clientSecret">From Google Developer console https://console.developers.google.com</param>
/// <param name="userName">A string used to identify a user.</param>
/// <param name="datastore">datastore to use </param>
/// <returns></returns>
public static PlusService AuthenticateOauth(string clientId, string clientSecret, string userName, IDataStore datastore)
{
string[] scopes = new string[] { PlusService.Scope.PlusLogin, // know your basic profile info and your circles
PlusService.Scope.PlusMe, // Know who you are on google
PlusService.Scope.UserinfoEmail, // view your email address
PlusService.Scope.UserinfoProfile}; // view your basic profile info.
try
{
// here is where we Request the user to give us access, or use the Refresh Token that was previously stored in %AppData%
UserCredential credential = GoogleWebAuthorizationBroker.AuthorizeAsync(new ClientSecrets { ClientId = clientId, ClientSecret = clientSecret }
, scopes
, userName
, CancellationToken.None
, datastore).Result;
PlusService service = new PlusService(new BaseClientService.Initializer()
{
HttpClientInitializer = credential,
ApplicationName = "Authentication Sample",
});
return service;
}
catch (Exception ex)
{
Console.WriteLine(ex.InnerException);
return null;
}
}
示例4: HomeModule
public HomeModule(IDataStore dataStore) {
Get["/"] = _ => {
var model = this.GetDefaultModel<StartContent>();
model.Page.Title = "Start";
using (var session = dataStore.DocumentStore.OpenSession()) {
session.Store(new Member() { Id = Guid.NewGuid(), Firstname = "Test", Lastname = "Last", Email = "[email protected]" });
session.SaveChanges();
}
using (var session = dataStore.DocumentStore.OpenSession()) {
var content = new StartContent();
content.Members = session.Query<Member>().ToList();
model.Content = content;
}
return View["start.cshtml", model];
};
Get["/cleanup"] = _ => {
var model = this.GetDefaultModel<StartContent>();
model.Page.Title = "Cleanup";
using (var session = dataStore.DocumentStore.OpenSession()) {
//dataStore.DocumentStore.DatabaseCommands.DeleteByIndex
//session.SaveChanges();
}
return View["start.cshtml", model];
};
Get["/error"] = _ => { throw new NotImplementedException(); };
}
示例5: AzureProfile
public AzureProfile(IDataStore store, string profilePath)
{
this.store = store;
this.profilePath = profilePath;
Load();
}
示例6: BTCMarketsExchange
public BTCMarketsExchange(IDataStore _dataStore, ICurrencyPairRepository _currencyPairRepository)
{
wallets = new List<CurrencyWallet>();
pairsToUpdate = new List<BTCMarketsCurrencyWalletPair>();
syntheticPairsToUpdate = new List<BTCMarketsSyntheticCurrencyWalletPair>();
dataStore = _dataStore;
var btcWallet = new FixedFeeCurrencyWallet(0.001M,0.001M, CurrencyType.Bitcoin , this);
var ltcWallet = new FixedFeeCurrencyWallet(0.01M, 0.01M, CurrencyType.Litecoin, this);
var audWallet = new PercentageFeeCurrencyWallet(0.01M, 0.015M, CurrencyType.AUD, this);
wallets.Add(btcWallet);
wallets.Add(ltcWallet);
wallets.Add(audWallet);
var btcusd = new BTCMarketsCurrencyWalletPair(btcWallet, audWallet, _dataStore, "https://api.btcmarkets.net/market/BTC/AUD/tick");
var ltcusd = new BTCMarketsCurrencyWalletPair(ltcWallet, audWallet, _dataStore, "https://api.btcmarkets.net/market/LTC/AUD/tick");
var btcltc = new BTCMarketsSyntheticCurrencyWalletPair(btcWallet, ltcWallet, _dataStore, "https://api.btcmarkets.net/market/BTC/AUD/tick", "https://api.btcmarkets.net/market/LTC/AUD/tick");
pairsToUpdate.Add(btcusd);
pairsToUpdate.Add(ltcusd);
syntheticPairsToUpdate.Add(btcltc);
_currencyPairRepository.Store(btcusd);
_currencyPairRepository.Store(ltcusd);
_currencyPairRepository.Store(btcltc);
}
示例7: ExceptionStateMachine
public ExceptionStateMachine(IWorkItemRepository repository, IDataStore dataStore,
IWorkflowPathNavigator navigator)
{
_repository = repository;
_dataStore = dataStore;
_navigator = navigator;
}
示例8: CrossCopy
///<summary>
/// Copy from one module to another. Can copy from s3 to disk and vice versa
///</summary>
///<param name="srcStore"></param>
///<param name="srcDomain"></param>
///<param name="srcFilename"></param>
///<param name="dstStore"></param>
///<param name="dstDomain"></param>
///<param name="dstFilename"></param>
///<returns></returns>
///<exception cref="ArgumentNullException"></exception>
public static Uri CrossCopy(IDataStore srcStore, string srcDomain, string srcFilename, IDataStore dstStore,
string dstDomain, string dstFilename)
{
if (srcStore == null) throw new ArgumentNullException("srcStore");
if (srcDomain == null) throw new ArgumentNullException("srcDomain");
if (srcFilename == null) throw new ArgumentNullException("srcFilename");
if (dstStore == null) throw new ArgumentNullException("dstStore");
if (dstDomain == null) throw new ArgumentNullException("dstDomain");
if (dstFilename == null) throw new ArgumentNullException("dstFilename");
//Read contents
using (Stream srcStream = srcStore.GetReadStream(srcDomain, srcFilename))
{
using (var memoryStream = TempStream.Create())
{
//Copy
var buffer = new byte[4096];
int readed;
while ((readed = srcStream.Read(buffer, 0, 4096)) != 0)
{
memoryStream.Write(buffer, 0, readed);
}
memoryStream.Position = 0;
return dstStore.Save(dstDomain, dstFilename, memoryStream);
}
}
}
示例9: InvokeDatabaseExported
public static void InvokeDatabaseExported(IDataStore db)
{
if (OnDatabaseExported != null)
{
OnDatabaseExported.Invoke(new DatabaseExportedEventArgs(db));
}
}
示例10: FeedbackListViewModel
public FeedbackListViewModel (Page page) : base(page)
{
Title = "Feedback";
dataStore = DependencyService.Get<IDataStore> ();
Feedbacks = new ObservableCollection<Feedback> ();
FeedbacksGrouped = new ObservableCollection<Grouping<string, Feedback>> ();
}
示例11: Start
public void Start(IScene scene)
{
m_scene = scene;
m_dataStore = m_scene.Simian.GetAppModule<IDataStore>();
if (m_dataStore == null)
{
m_log.Error("LLPrimitiveLoader requires an IDataStore");
return;
}
m_primMesher = m_scene.GetSceneModule<IPrimMesher>();
if (m_primMesher == null)
{
m_log.Error("LLPrimitiveLoader requires an IPrimMesher");
return;
}
m_writeQueue = new ThrottledQueue<UUID, PrimSerialization>(5, 1000 * 30, true, SerializationHandler);
m_writeQueue.Start();
m_scene.OnEntityAddOrUpdate += EntityAddOrUpdateHandler;
m_scene.OnEntityRemove += EntityRemoveHandler;
Deserialize();
}
示例12: ObjectStore
public ObjectStore(IDataStore dataStore, ISerializer serializer)
{
DataStore = dataStore;
Serializer = serializer;
CacheObjects = true;
RemoveBadData = true;
}
示例13: LoadDataStoreItemData
public static byte[] LoadDataStoreItemData(string domain, string fileLink, IDataStore storage)
{
using (var stream = storage.GetReadStream(domain, fileLink))
{
return stream.GetCorrectBuffer();
}
}
示例14: Handle
/// <summary>
/// Handles the provided data store as part of the batch.
/// </summary>
/// <param name="store">The data store being handled as part of the batch.</param>
public static void Handle(IDataStore store)
{
using (LogGroup logGroup = LogGroup.Start("Adding a data store to the batch.", LogLevel.Debug))
{
LogWriter.Debug("Batch stack: " + BatchState.Batches.Count.ToString());
if (BatchState.IsRunning)
{
Stack<Batch> batches = BatchState.Batches;
// Get the position of the outermost batch
// The stack is reversed so the last position is the outermost batch
int outerPosition = batches.Count-1;
// Get the outermost batch and add the data store to it
Batch batch = batches.ToArray()[outerPosition];
if (!batch.DataStores.Contains(store))
{
LogWriter.Debug("Data store added.");
batch.DataStores.Add(store);
// Commit the batch stack to state
Batches = batches;
}
else
{
LogWriter.Debug("Data store already found. Not added.");
}
}
else
throw new InvalidOperationException("No batch running. Use Batch.IsRunning to check before calling this method.");
}
}
示例15: StoresViewModel
public StoresViewModel(Page page) : base(page)
{
Title = "Locations";
dataStore = DependencyService.Get<IDataStore>();
Stores = new ObservableRangeCollection<Store>();
StoresGrouped = new ObservableRangeCollection<Grouping<string, Store>>();
}