/// <summary> /// 获取指定类型的实体元数据。 /// </summary> /// <param name="entityType">实体类型。</param> /// <returns></returns> public static EntityMetadata GetEntityMetadata(Type entityType) { Guard.ArgumentNull(entityType, nameof(entityType)); entityType = entityType.GetDefinitionEntityType(); return(cache.GetOrAdd(entityType, () => { var metadata = new EntityMetadata(entityType); //由于此代码段是缓存项创建工厂函数,此时的 metadata 并未添加到缓存中,接下来 PropertyUnity //会再一次获取 EntityMetadata,因此需要在此线程中共享出 EntityMetadata using (var scope = new MetadataScope { Metadata = metadata }) { if (typeof(ICompilableEntity).IsAssignableFrom(entityType)) { PropertyUnity.Initialize(entityType); } else { //需要找出其中的一个字段,然后以引发 RegisterProperty 调用 var field = entityType.GetFields(BindingFlags.Static | BindingFlags.NonPublic | BindingFlags.Public).FirstOrDefault(); if (field != null) { field.GetValue(null); } } } return metadata; })); }
public MetadataEventArgs(MetadataCommand command, MetadataCategory category, MetadataScope scope, bool finished, string reason, int successCount, int totalCount, bool canceled) { Command = command; Category = category; Scope = scope; Finished = finished; Reason = reason; SuccessCount = successCount; TotalCount = totalCount; Canceled = canceled; }
public async Task <TM> GetMetadataAync <TM>(MetadataScope scope, int id, CancellationToken cancellationToken, int?parentId = null) { var request = _client.NewRequest("contacts/{id}/metadata/{scope}"); request.AddUrlSegment("id", id.ToString()); request.AddUrlSegment("scope", scope.ToString()); var result = await _client.ExecuteAsync <TM>(request, cancellationToken); return(result.Data); }
public async Task <TM> PutMetadataAsync <TM>(MetadataScope scope, int entityId, TM data, CancellationToken cancellationToken, int?parentId = null) { var request = _client.NewRequest("contacts/{id}/metadata/{scope}", Method.PUT); request.AddUrlSegment("id", entityId.ToString()); request.AddUrlSegment("scope", scope.ToString()); request.AddBody(data); var result = await _client.ExecuteAsync <TM>(request, cancellationToken); return(result.Data); }
/// <summary> /// Get the Course Metadata in XML Format /// </summary> /// <param name="courseId">Unique Identifier for the course</param> /// <param name="versionId">Version of the specified course</param> /// <param name="scope">Defines the scope of the data to return: Course or Activity level</param> /// <param name="format">Defines the amount of data to return: Summary or Detailed</param> /// <returns>XML string representing the Metadata</returns> public string GetMetadata(string courseId, int versionId, MetadataScope scope, MetadataFormat format) { ServiceRequest request = new ServiceRequest(configuration); request.Parameters.Add("courseid", courseId); if (versionId != Int32.MinValue) { request.Parameters.Add("versionid", versionId); } request.Parameters.Add("scope", Enum.GetName(scope.GetType(), scope).ToLower()); request.Parameters.Add("format", Enum.GetName(format.GetType(), format).ToLower()); XmlDocument response = request.CallService("rustici.course.getMetadata"); // Return the subset of the xml starting with the top <object> return(response.ChildNodes[1].InnerXml); }
/// <summary> /// 获取指定类型的实体元数据。 /// </summary> /// <param name="entityType">实体类型。</param> /// <returns></returns> public static EntityMetadata GetEntityMetadata(Type entityType) { Guard.ArgumentNull(entityType, nameof(entityType)); var mapType = entityType.GetMapEntityType(); var result = _cache.GetOrAdd(mapType, key => { var metadata = new EntityMetadata(key); //由于此代码段是缓存项创建工厂函数,此时的 metadata 并未添加到缓存中,接下来 PropertyUnity //会再一次获取 EntityMetadata,因此需要在此线程中共享出 EntityMetadata using (var scope = new MetadataScope { Metadata = metadata }) { metadata.Attach(key); } return(metadata); }); return(result.Attach(mapType)); }
/// <summary> /// Get the Course Metadata in XML Format. /// </summary> /// <param name="courseId">Unique Identifier for the course</param> /// <param name="scope">Defines the scope of the data to return: Course or Activity level</param> /// <param name="format">Defines the amount of data to return: Summary or Detailed</param> /// <returns>XML string representing the Metadata</returns> public string GetMetadata(string courseId, MetadataScope scope, MetadataFormat format) { return GetMetadata(courseId, Int32.MinValue, scope, format); }
/// <summary> /// Get the Course Metadata in XML Format /// </summary> /// <param name="courseId">Unique Identifier for the course</param> /// <param name="versionId">Version of the specified course</param> /// <param name="scope">Defines the scope of the data to return: Course or Activity level</param> /// <param name="format">Defines the amount of data to return: Summary or Detailed</param> /// <returns>XML string representing the Metadata</returns> public string GetMetadata(string courseId, int versionId, MetadataScope scope, MetadataFormat format) { ServiceRequest request = new ServiceRequest(configuration); request.Parameters.Add("courseid", courseId); if (versionId != Int32.MinValue) { request.Parameters.Add("versionid", versionId); } request.Parameters.Add("scope", Enum.GetName(scope.GetType(), scope).ToLower()); request.Parameters.Add("format", Enum.GetName(format.GetType(), format).ToLower()); XmlDocument response = request.CallService("rustici.course.getMetadata"); // Return the subset of the xml starting with the top <object> return response.ChildNodes[1].InnerXml; }
/// <summary> /// Get the Course Metadata in XML Format. /// </summary> /// <param name="courseId">Unique Identifier for the course</param> /// <param name="scope">Defines the scope of the data to return: Course or Activity level</param> /// <param name="format">Defines the amount of data to return: Summary or Detailed</param> /// <returns>XML string representing the Metadata</returns> public string GetMetadata(string courseId, MetadataScope scope, MetadataFormat format) { return(GetMetadata(courseId, Int32.MinValue, scope, format)); }
public Task <TM> PutMetadataAsync <TM>(MetadataScope scope, int entityId, TM data, CancellationToken cancellationToken, int?parentId = null) { return(Task.FromResult(default(TM))); }