当前位置: 首页>>代码示例>>C#>>正文


C# IGrainState.GetType方法代码示例

本文整理汇总了C#中IGrainState.GetType方法的典型用法代码示例。如果您正苦于以下问题:C# IGrainState.GetType方法的具体用法?C# IGrainState.GetType怎么用?C# IGrainState.GetType使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在IGrainState的用法示例。


在下文中一共展示了IGrainState.GetType方法的11个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。

示例1: ReadStateAsync

        public async Task ReadStateAsync(string grainType, GrainReference grainReference, IGrainState grainState)
        {
            if (!(grainState is IAggregateState))
                throw new NotAggregateStateException(grainState.GetType());

            var stream = this.GetStreamName(grainType, grainReference);

            var sliceStart = 0;
            StreamEventsSlice currentSlice;

            do
            {
                var sliceCount = sliceStart + ReadPageSize;

                currentSlice = await this.Connection.ReadStreamEventsForwardAsync(stream, sliceStart, sliceCount, true);

                if (currentSlice.Status == SliceReadStatus.StreamNotFound)
                    return;

                if (currentSlice.Status == SliceReadStatus.StreamDeleted)
                    throw new StreamDeletedException();

                sliceStart = currentSlice.NextEventNumber;

                foreach (var @event in currentSlice.Events)
                {
                    dynamic deserialisedEvent = DeserializeEvent(@event.Event);
                    StateTransformer.ApplyEvent(deserialisedEvent, grainState as IAggregateState);
                }

            } while (!currentSlice.IsEndOfStream);
        }
开发者ID:timfun,项目名称:orleans.eventsourcing,代码行数:32,代码来源:EventStoreProvider.cs

示例2: ReadStateAsync

        public async Task ReadStateAsync(string grainType, GrainReference grainId, IGrainState grainState)
        {
            try
            {
                var blobName = BlobStorageProvider.GetBlobName(grainType, grainId);
                var blob = container.GetBlockBlobReference(blobName);
                var text = await blob.DownloadTextAsync();
                if (string.IsNullOrWhiteSpace(text))
                {
                    return;
                }

                var data = JsonConvert.DeserializeObject(text, grainState.GetType());
                var dict = ((IGrainState)data).AsDictionary();
                grainState.SetAll(dict);
            }
            catch (StorageException ex)
            {
                ;
            }
            catch (Exception ex)
            {
                Log.Error(0, ex.ToString());
            }
        }
开发者ID:justinliew,项目名称:OrleansBlobStorageProvider,代码行数:25,代码来源:BlobStorageProvider.cs

示例3: ReadStateAsync

 /// <summary>
 /// Reads persisted state from the backing store and deserializes it into the the target
 /// grain state object.
 /// </summary>
 /// <param name="grainType">A string holding the name of the grain class.</param>
 /// <param name="grainReference">Represents the long-lived identity of the grain.</param>
 /// <param name="grainState">A reference to an object to hold the persisted state of the grain.</param>
 /// <returns>Completion promise for this operation.</returns>
 public async Task ReadStateAsync(string grainType, GrainReference grainReference, IGrainState grainState)
 {
     if (DataManager == null) throw new ArgumentException("DataManager property not initialized");
     var entityData = await DataManager.Read(grainState.GetType().Name, grainReference.ToKeyString());
     if (entityData != null)
     {
         ConvertFromStorageFormat(grainState, entityData);
     }
 }
开发者ID:Joshua-Ferguson,项目名称:orleans,代码行数:17,代码来源:BaseJSONStorageProvider.cs

示例4: ClearStateAsync

        public Task ClearStateAsync(string grainType, GrainReference grainReference, IGrainState grainState)
        {
            if (!(grainState is IAggregateState))
                throw new NotAggregateStateException(grainState.GetType());

            var state = grainState as IAggregateState;
            var stream = this.GetStreamName(grainType, grainReference);

            return this.Connection.DeleteStreamAsync(stream, state.Version);
        }
开发者ID:timfun,项目名称:orleans.eventsourcing,代码行数:10,代码来源:EventStoreProvider.cs

示例5: ReadStateAsync

        public async Task ReadStateAsync(string grainType, GrainReference grainReference, IGrainState grainState)
        {
            var stateName = grainState.GetType().Name;
            var key = grainReference.ToKeyString();
            var id = string.Format(CultureInfo.InvariantCulture, "{0}/{1}", stateName, key);

            using (IAsyncDocumentSession session = this.documentStore.OpenAsyncSession())
            {
                var state = await session.LoadAsync<RavenJObject>(id);
                if (state != null)
                {
                    grainState.SetAll(state.ToDictionary(x => x.Key, x => x.Value.Value<object>()));
                }
            }
        }
开发者ID:ReubenBond,项目名称:orleans.storageprovider.ravendb,代码行数:15,代码来源:RavenDBStorageProvider.cs

示例6: WriteStateAsync

 /// <summary>
 /// Writes the persisted state from a grain state object into its backing store.
 /// </summary>
 /// <param name="grainType">A string holding the name of the grain class.</param>
 /// <param name="grainReference">Represents the long-lived identity of the grain.</param>
 /// <param name="grainState">A reference to an object holding the persisted state of the grain.</param>
 /// <returns>Completion promise for this operation.</returns>
 public Task WriteStateAsync(string grainType, GrainReference grainReference, IGrainState grainState)
 {
     if (DataManager == null) throw new ArgumentException("DataManager property not initialized");
     var entityData = ConvertToStorageFormat(grainState);
     return DataManager.Write(grainState.GetType().Name, grainReference.ToKeyString(), entityData);
 }
开发者ID:Joshua-Ferguson,项目名称:orleans,代码行数:13,代码来源:BaseJSONStorageProvider.cs

示例7: ClearStateAsync

 /// <summary>
 /// Removes grain state from its backing store, if found.
 /// </summary>
 /// <param name="grainType">A string holding the name of the grain class.</param>
 /// <param name="grainReference">Represents the long-lived identity of the grain.</param>
 /// <param name="grainState">An object holding the persisted state of the grain.</param>
 /// <returns></returns>
 public Task ClearStateAsync(string grainType, GrainReference grainReference, IGrainState grainState)
 {
     if (DataManager == null) throw new ArgumentException("DataManager property not initialized");
     DataManager.Delete(grainState.GetType().Name, grainReference.ToKeyString());
     return TaskDone.Done;
 }
开发者ID:Joshua-Ferguson,项目名称:orleans,代码行数:13,代码来源:BaseJSONStorageProvider.cs

示例8: ConvertFromStorageFormat

 /// <summary>
 /// Constructs a grain state instance by deserializing a JSON document.
 /// </summary>
 /// <param name="grainState">Grain state to be populated for storage.</param>
 /// <param name="entityData">JSON storage format representaiton of the grain state.</param>
 protected static void ConvertFromStorageFormat(IGrainState grainState, string entityData)
 {
     object data = JsonConvert.DeserializeObject(entityData, grainState.GetType(), GrainStateMongoDataManager.JsonSetting);
     var dict = ((IGrainState)data).AsDictionary();
     grainState.SetAll(dict);
 }
开发者ID:sharpe5,项目名称:Orleans.Storage.MongoDB,代码行数:11,代码来源:MongoDBStorage.cs

示例9: ConvertFromStorageFormat

 /// <summary>
 /// Constructs a grain state instance by deserializing a JSON document.
 /// </summary>
 /// <param name="grainState">Grain state to be populated for storage.</param>
 /// <param name="entityData">JSON storage format representaiton of the grain state.</param>
 protected static void ConvertFromStorageFormat(IGrainState grainState, string entityData)
 {
     var setting = new JsonSerializerSettings();
     object data = JsonConvert.DeserializeObject(entityData, grainState.GetType());
     var dict = ((IGrainState)data).AsDictionary();
     grainState.SetAll(dict);
 }
开发者ID:SmartFire,项目名称:Orleans.Storage.Couchbase,代码行数:12,代码来源:CouchbaseStorage.cs

示例10: WriteStateAsync

        public async Task WriteStateAsync(string grainType, GrainReference grainReference, IGrainState grainState)
        {
            var stateName = grainState.GetType().Name;
            var key = grainReference.ToKeyString();
            var id = string.Format(CultureInfo.InvariantCulture, "{0}/{1}", stateName, key);

            using (IAsyncDocumentSession session = this.documentStore.OpenAsyncSession())
            {
                await session.StoreAsync(grainState, id);
                await session.SaveChangesAsync();
            }
        }
开发者ID:ReubenBond,项目名称:orleans.storageprovider.ravendb,代码行数:12,代码来源:RavenDBStorageProvider.cs

示例11: ConvertFromStorageFormat

 /// <summary>
 /// Constructs a grain state instance by deserializing a JSON document.
 /// </summary>
 /// <param name="grainState">Grain state to be populated for storage.</param>
 /// <param name="entityData">JSON storage format representaiton of the grain state.</param>
 protected static void ConvertFromStorageFormat(IGrainState grainState, string entityData)
 {
     JavaScriptSerializer deserializer = new JavaScriptSerializer();
     object data = deserializer.Deserialize(entityData, grainState.GetType());
     var dict = ((IGrainState)data).AsDictionary();
     grainState.SetAll(dict);
 }
开发者ID:stanroze,项目名称:orleans,代码行数:12,代码来源:BaseJSONStorageProvider.cs


注:本文中的IGrainState.GetType方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。