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


C# EventSource.GetType方法代码示例

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


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

示例1: GetForEventSource

#pragma warning disable 1591 // Xml Comments
        public CommittedEventStream GetForEventSource(EventSource eventSource, Guid eventSourceId)
        {
            var eventPath = GetPathFor(eventSource.GetType().Name, eventSourceId);
            var files = Directory.GetFiles(eventPath).OrderBy(f => f);

            var stream = new CommittedEventStream(eventSourceId);

            var target = new EventHolder
            {
                Type = typeof(string),
                Version = EventSourceVersion.Zero,
                Event = string.Empty
            };

            foreach (var file in files)
            {
                var json = File.ReadAllText(file);
                _serializer.FromJson(target, json);

                var @event = _serializer.FromJson(target.Type, json) as IEvent;
                stream.Append(new[] { @event });
            }
            return stream;
        }
开发者ID:LenFon,项目名称:Bifrost,代码行数:25,代码来源:EventStore.cs

示例2: GetSchema

        /// <summary>
        /// Gets the schema for the specified event source.
        /// </summary>
        /// <param name="eventSource">The event source.</param>
        /// <returns>The event schema.</returns>
        public IDictionary<int, EventSchema> GetSchema(EventSource eventSource)
        {
            Guard.ArgumentNotNull(eventSource, "eventSource");

            return this.GetSchema(EventSource.GenerateManifest(eventSource.GetType(), null));
        }
开发者ID:EdHastings,项目名称:semantic-logging,代码行数:11,代码来源:EventSourceSchemaReader.cs

示例3: GetMethodFromSchema

 private MethodInfo GetMethodFromSchema(EventSource source, EventSchema schema)
 {
     return source.GetType().GetMethods(Bindings).SingleOrDefault(m => this.IsEvent(m, schema.Id)) ??
            source.GetType().GetMethod(schema.TaskName, Bindings);
 }
开发者ID:jakub-sturc,项目名称:semantic-logging,代码行数:5,代码来源:EventSourceAnalyzer.cs

示例4: GetEventSchemas

 private ICollection<EventSchema> GetEventSchemas(EventSource eventSource)
 {
     try
     {
         string manifest = EventSource.GenerateManifest(eventSource.GetType(), null);
         this.CheckForBadFormedManifest(manifest);
         return new EventSourceSchemaReader().GetSchema(manifest).Values;
     }
     catch (EventSourceAnalyzerException)
     {
         throw;
     }
     catch (Exception e)
     {
         throw new EventSourceAnalyzerException(string.Format(CultureInfo.CurrentCulture, Properties.Resources.EventSourceAnalyzerManifestGenerationError, e.Message, EventSource.GenerateManifest(eventSource.GetType(), null)));
     }
 }
开发者ID:jakub-sturc,项目名称:semantic-logging,代码行数:17,代码来源:EventSourceAnalyzer.cs

示例5: GetLastCommittedVersion

        public EventSourceVersion GetLastCommittedVersion(EventSource eventSource, Guid eventSourceId)
        {
            var eventPath = GetPathFor(eventSource.GetType().Name, eventSourceId);
            var first = Directory.GetFiles(eventPath).OrderByDescending(f => f).FirstOrDefault();
            if (first == null) return EventSourceVersion.Zero;

            var json = File.ReadAllText(first);
            var target = new EventHolder
            {
                Type = typeof(string),
                Version = EventSourceVersion.Zero,
                Event = string.Empty
            };

            _serializer.FromJson(target, json);

            return target.Version;
        }
开发者ID:LenFon,项目名称:Bifrost,代码行数:18,代码来源:EventStore.cs

示例6: GetEventSchemas

        private ICollection<EventSchema> GetEventSchemas(EventSource eventSource)
        {
            if(eventSource == null)
                throw  new ArgumentNullException("eventSource");

            try
            {
                var manifest = EventSource.GenerateManifest(
                    eventSource.GetType(),
                    Assembly.GetAssembly(eventSource.GetType()).Location
                    );
                this.CheckForBadFormedManifest(manifest);
                return new EventSourceSchemaReader().GetSchema(manifest).Values;
            }
            catch (EventSourceAnalyzerException)
            {
                throw;
            }
            catch (Exception e)
            {
                if (eventSource.ConstructionException != null)
                {
                    throw new EventSourceAnalyzerException(
                        e.Message,
                        eventSource.ConstructionException
                        );
                }

                throw new EventSourceAnalyzerException(
                    string.Format(
                        CultureInfo.CurrentCulture,
                        Resources.EventSourceAnalyzerManifestGenerationError,
                        e.Message,
                        EventSource.GenerateManifest(
                            eventSource.GetType(),
                            null
                            )));
            }
        }
开发者ID:EdHastings,项目名称:semantic-logging,代码行数:39,代码来源:EventSourceAnalyzer.cs


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