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


C# GrainReference.ToKeyString方法代码示例

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


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

示例1: ReadStateAsync

		public async Task ReadStateAsync(string grainType, GrainReference grainReference, IGrainState grainState)
		{
			var tableResult = await _table.ExecuteAsync(TableOperation.Retrieve<DynamicTableEntity>(grainReference.ToKeyString(), grainType));
			if (tableResult.Result == null)
			{
				return;
			}
			var entity = tableResult.Result as DynamicTableEntity;

			var serializer = new JsonSerializer();
			using (var memoryStream = new MemoryStream())
			{
				foreach (var propertyName in entity.Properties.Keys.Where(p => p.StartsWith("d")).OrderBy(p => p))
				{
					var dataPart = entity.Properties[propertyName];
					await memoryStream.WriteAsync(dataPart.BinaryValue, 0, dataPart.BinaryValue.Length);
				}

				memoryStream.Position = 0;
				using (var bsonReader = new BsonReader(memoryStream))
				{
					var data = serializer.Deserialize<Dictionary<string, object>>(bsonReader);
					grainState.SetAll(data);
				}
			}
		}
开发者ID:justinliew,项目名称:Orleans.StorageEx,代码行数:26,代码来源:AzureTableStorageEx.cs

示例2: ToElasticValue

 public string ToElasticValue(GrainReference gref)
 {
     ///"GrainReference=00000000000000000000000000000000060000006aa96326+abc"
     /// to
     /// "GrainReference^00000000000000000000000000000000060000006aa96326_abc"
     return gref.ToKeyString().Replace("=", "__").Replace("_", "+");
 }
开发者ID:kowalot,项目名称:Pk.OrleansUtils,代码行数:7,代码来源:ElasticReminderEntry.cs

示例3: WriteStateAsync

        public async Task WriteStateAsync(string grainType, GrainReference grainReference, IGrainState grainState)
        {
            try
            {
                var collection = await this.EnsureCollection(grainType);
                var documents = await this.Client.ReadDocumentFeedAsync(collection.DocumentsLink);
                var documentId = grainReference.ToKeyString();

                var document = documents.Where(d => d.Id == documentId).FirstOrDefault();

                if(document != null)
                {
                    document.State = grainState.AsDictionary();
                    await this.Client.ReplaceDocumentAsync(document);
                }
                else
                {
                    await this.Client.CreateDocumentAsync(collection.DocumentsLink,
                        new GrainStateDocument { Id = documentId, State = grainState.AsDictionary() });
                }
            }
            catch (Exception ex)
            {
                Log.Error(0, "Error in WriteStateAsync", ex);
            }
        }
开发者ID:SmartFire,项目名称:orleans.storageprovider.documentdb,代码行数:26,代码来源:DocumentDBStorageProvider.cs

示例4: CreateIdFrom

 public static string CreateIdFrom(GrainReference grainRef,string reminderName)
 {
     if (String.IsNullOrEmpty(reminderName))
         throw new ArgumentNullException("reminderName");
     if (grainRef==null)
         throw new ArgumentNullException("grainRef");
     return grainRef.ToKeyString() + "," + reminderName;
 }
开发者ID:kowalot,项目名称:Pk.OrleansUtils,代码行数:8,代码来源:ElasticReminderEntry.cs

示例5: 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

示例6: FromGrainReference

        /// <summary>
        /// Createa a GrainIdentity from a grain reference and type name
        /// </summary>
        /// <param name="grainType"></param>
        /// <param name="grainReference"></param>
        /// <returns></returns>
        public static GrainIdentity FromGrainReference(string grainType, GrainReference grainReference)
        {
            Guard.NotNullOrEmpty(grainType, "grainType");
            Guard.NotNull(grainReference, "grainReference");

            return new GrainIdentity()
            {
                GrainType = grainType,
                ShardKey = (int)grainReference.GetUniformHashCode(),
                GrainKey = grainReference.ToKeyString()
            };
        }
开发者ID:sbambach,项目名称:orleans,代码行数:18,代码来源:GrainIdentity.cs

示例7: WriteStateAsync

        public async Task WriteStateAsync(string grainType, GrainReference grainReference, GrainState 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:nahugrau,项目名称:OrleansTest,代码行数:12,代码来源:RavenDBStorageProvider.cs

示例8: ReadRows

        public async Task<ReminderTableData> ReadRows(GrainReference grainRef)
        {
            using (var conn = new SqlConnection(connectionString))
            {
                conn.Open();

                var command = new SqlCommand(READ_GRAIN_ROWS);
                command.Parameters.Add(new SqlParameter { ParameterName = "@id", DbType = DbType.String, Value = serviceId });
                command.Parameters.Add(new SqlParameter { ParameterName = "@grainid", DbType = DbType.String, Value = grainRef.ToKeyString() });
                command.Connection = conn;

                return await ProcessResults(command);
            }
        }
开发者ID:stanroze,项目名称:orleans,代码行数:14,代码来源:SqlReminderTable.cs

示例9: 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

示例10: ClearStateAsync

        public async Task ClearStateAsync(string grainType, GrainReference grainReference, GrainState 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())
            {
                session.Advanced.Defer(new DeleteCommandData
                {
                    Key = id
                });
                await session.SaveChangesAsync();
            }
        }
开发者ID:nahugrau,项目名称:OrleansTest,代码行数:15,代码来源:RavenDBStorageProvider.cs

示例11: ReadStateAsync

        public async Task ReadStateAsync(string grainType, GrainReference grainReference, IGrainState grainState)
        {
            try
            {
                var collection = await this.EnsureCollection(grainType);
                var documents = await this.Client.ReadDocumentFeedAsync(collection.DocumentsLink);
                var documentId = grainReference.ToKeyString();
                GrainStateDocument document = documents.Where(d => d.Id == documentId).FirstOrDefault();

                if(document != null)
                    grainState.SetAll(document.State);
            }
            catch (Exception ex)
            {
                Log.Error(0, "Error in ReadStateAsync", ex);
            }            
        }
开发者ID:SmartFire,项目名称:orleans.storageprovider.documentdb,代码行数:17,代码来源:DocumentDBStorageProvider.cs

示例12: WriteStateAsync

		public Task WriteStateAsync(string grainType, GrainReference grainReference, IGrainState grainState)
		{
			var entity = new DynamicTableEntity(grainReference.ToKeyString(), grainType) { ETag = "*" };

			var serializer = new JsonSerializer();
			using (var memoryStream = new MemoryStream())
			{
				using (var bsonWriter = new BsonWriter(memoryStream))
				{
					serializer.Serialize(bsonWriter, grainState.AsDictionary());

					SplitBinaryData(entity, memoryStream.ToArray());
				}
			}

			return _table.ExecuteAsync(TableOperation.InsertOrReplace(entity));
		}
开发者ID:justinliew,项目名称:Orleans.StorageEx,代码行数:17,代码来源:AzureTableStorageEx.cs

示例13: ReadReminderRowAsync

        /// <summary>
        /// Reads one row of reminder data.
        /// </summary>
        /// <param name="serviceId">Service ID.</param>
        /// <param name="grainRef">The grain reference (ID).</param>
        /// <param name="reminderName">The reminder name to retrieve.</param>
        /// <returns>A remainder entry.</returns>
        internal async Task<ReminderEntry> ReadReminderRowAsync( string serviceId, GrainReference grainRef, string reminderName)
        {
            var ret = await storage.ReadAsync(orleansQueries.ReadReminderRowKey, command =>
            {
                var serviceIdParameter = CreateServiceIdParameter(command, serviceId);
                command.Parameters.Add(serviceIdParameter);

                var grainIdParameter = CreateGrainIdParameter(command, grainRef.ToKeyString());
                command.Parameters.Add(grainIdParameter);

                var reminderNameParameter = CreateReminderName(command, reminderName);
                command.Parameters.Add(reminderNameParameter);
            }, (selector, _) =>
            {
                return CreateReminderEntry(selector);
            }).ConfigureAwait(continueOnCapturedContext: false);

            return ret != null ? ret.FirstOrDefault() : null;
        }
开发者ID:sbambach,项目名称:orleans,代码行数:26,代码来源:RelationalOrleansQueries.cs

示例14: ReadReminderRowsAsync

        /// <summary>
        /// Reads Orleans reminder data from the tables.
        /// </summary>
        /// <param name="serviceId">The service ID.</param>
        /// <param name="grainRef">The grain reference (ID).</param>
        /// <returns>Reminder table data.</returns>
        internal async Task<ReminderTableData> ReadReminderRowsAsync(string serviceId, GrainReference grainRef)
        {
            var ret = await storage.ReadAsync(orleansQueries.ReadReminderRowsKey, command =>
            {
                var serviceIdParameter = CreateServiceIdParameter(command, serviceId);
                command.Parameters.Add(serviceIdParameter);

                var grainIdParameter = CreateGrainIdParameter(command, grainRef.ToKeyString());
                command.Parameters.Add(grainIdParameter);
            }, (selector, _) =>
            {
                return CreateReminderEntry(selector);
            }).ConfigureAwait(continueOnCapturedContext: false);

            return new ReminderTableData(ret.Where(i => i != null).ToList());
        }
开发者ID:sbambach,项目名称:orleans,代码行数:22,代码来源:RelationalOrleansQueries.cs

示例15: UpsertReminderRowAsync

        /// <summary>
        /// Either inserts or updates a reminder row.
        /// </summary>
        /// <param name="serviceId">The service ID.</param>
        /// <param name="grainRef">The grain reference (ID).</param>
        /// <param name="reminderName">The reminder name to retrieve.</param>
        /// <param name="startTime">Start time of the reminder.</param>
        /// <param name="period">Period of the reminder.</param>
        /// <returns>The new etag of the either or updated or inserted reminder row.</returns>
        internal async Task<string> UpsertReminderRowAsync(string serviceId, GrainReference grainRef, string reminderName, DateTime startTime, TimeSpan period)
        {
            var ret = await storage.ReadAsync(orleansQueries.UpsertReminderRowKey, command =>
            {
                var serviceIdParameter = CreateServiceIdParameter(command, serviceId);
                command.Parameters.Add(serviceIdParameter);

                var grainIdParameter = CreateGrainIdParameter(command, grainRef.ToKeyString());
                command.Parameters.Add(grainIdParameter);

                var reminderNameParameter = CreateReminderName(command, reminderName);
                command.Parameters.Add(reminderNameParameter);

                var startTimeParameter = CreateStartTimeParameter(command, startTime);
                command.Parameters.Add(startTimeParameter);

                var periodParameter = CreatePeriodParameter(command, period);
                command.Parameters.Add(periodParameter);

                var grainIdConsistentHashParameter = CreateGrainIdConsistentHashParameter(command, grainRef.GetUniformHashCode());
                command.Parameters.Add(grainIdConsistentHashParameter);
            }, (selector, resultSetCount, cancellationToken) =>
            {
                return Task.FromResult(Convert.ToBase64String(selector.GetValue<byte[]>("ETag")));
            }).ConfigureAwait(continueOnCapturedContext: false);

            return ret != null ? ret.FirstOrDefault() : null;
        }
开发者ID:ca-ta,项目名称:orleans,代码行数:37,代码来源:RelationalOrleansQueries.cs


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