• 设为首页
  • 点击收藏
  • 手机版
    手机扫一扫访问
    迪恩网络手机版
  • 关注官方公众号
    微信扫一扫关注
    公众号

C# IEventSource类代码示例

原作者: [db:作者] 来自: [db:来源] 收藏 邀请

本文整理汇总了C#中IEventSource的典型用法代码示例。如果您正苦于以下问题:C# IEventSource类的具体用法?C# IEventSource怎么用?C# IEventSource使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。



IEventSource类属于命名空间,在下文中一共展示了IEventSource类的20个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于我们的系统推荐出更棒的C#代码示例。

示例1: Initialize

			public void Initialize(IEventSource eventSource)
			{
				this.eventSource = eventSource;
				engineWorker.OutputText("${res:ICSharpCode.CodeAnalysis.RunningFxCopOn} " + Path.GetFileNameWithoutExtension(engineWorker.CurrentProjectFile));
				eventSource.ErrorRaised += OnError;
				eventSource.WarningRaised += OnWarning;
			}
开发者ID:kingjiang,项目名称:SharpDevelopLite,代码行数:7,代码来源:FxCopLogger.cs


示例2: Initialize

		/// <summary>
		/// Initializes the logger by attaching events and parsing command line.
		/// </summary>
		/// <param name="eventSource">The event source.</param>
		public override void Initialize(IEventSource eventSource)
		{
            outputPath = this.Parameters;

			InitializeLogFile();

            // attach only to events required in current log verbosity
            eventSource.ErrorRaised += new BuildErrorEventHandler(eventSource_ErrorRaised);
            eventSource.WarningRaised += new BuildWarningEventHandler(eventSource_WarningRaised);

            eventSource.BuildStarted += new BuildStartedEventHandler(eventSource_BuildStartedHandler);
            eventSource.BuildFinished += new BuildFinishedEventHandler(eventSource_BuildFinishedHandler);

            if (Verbosity != LoggerVerbosity.Quiet) // minimal and above
			{
                eventSource.MessageRaised += new BuildMessageEventHandler(eventSource_MessageHandler);
                eventSource.CustomEventRaised += new CustomBuildEventHandler(eventSource_CustomBuildEventHandler);

                eventSource.ProjectStarted += new ProjectStartedEventHandler(eventSource_ProjectStartedHandler);
                eventSource.ProjectFinished += new ProjectFinishedEventHandler(eventSource_ProjectFinishedHandler);

                if (Verbosity != LoggerVerbosity.Minimal) // normal and above
				{
                    eventSource.TargetStarted += new TargetStartedEventHandler(eventSource_TargetStartedHandler);
                    eventSource.TargetFinished += new TargetFinishedEventHandler(eventSource_TargetFinishedHandler);

                    if (Verbosity != LoggerVerbosity.Normal) // only detailed and diagnostic
					{
                        eventSource.TaskStarted += new TaskStartedEventHandler(eventSource_TaskStartedHandler);
                        eventSource.TaskFinished += new TaskFinishedEventHandler(eventSource_TaskFinishedHandler);
					}
				}
			}
		}
开发者ID:jlewin,项目名称:Kobush.Build,代码行数:38,代码来源:XmlLogger.cs


示例3: Validate

		protected virtual void Validate(object entity, IEntityPersister persister, IEventSource source)
		{
			if (persister.ImplementsValidatable(source.EntityMode))
			{
				((IValidatable)entity).Validate();
			}
		}
开发者ID:marchlud,项目名称:nhibernate-core,代码行数:7,代码来源:AbstractSaveEventListener.cs


示例4: Initialize

		public override void Initialize (IEventSource eventSource)
		{
			eventSource.TargetStarted += new TargetStartedEventHandler(TargetStarted);
			eventSource.TargetFinished += new TargetFinishedEventHandler(TargetFinished);
			eventSource.MessageRaised += new BuildMessageEventHandler(Message);
			eventSource.WarningRaised += new BuildWarningEventHandler(Warning);
		}
开发者ID:salloo,项目名称:mono,代码行数:7,代码来源:ProjectTest.cs


示例5: Initialize

        public override void Initialize(IEventSource eventSource)
        {
            if (null == Parameters)
            {
                throw new LoggerException("Log file was not set.");
            }
            string[] parameters = Parameters.Split(';');

            string logFile = parameters[0];
            if (String.IsNullOrEmpty(logFile))
            {
                throw new LoggerException("Log file was not set.");
            }

            if (parameters.Length > 1)
            {
                throw new LoggerException("Too many parameters passed.");
            }

            // Open the file
            _streamWriter = new StreamWriter(logFile);

            //eventSource.BuildStarted += new BuildStartedEventHandler(BuildStarted);
            eventSource.BuildFinished += new BuildFinishedEventHandler(BuildFinished);
            eventSource.ErrorRaised += new BuildErrorEventHandler(ErrorRaised);
            //eventSource.MessageRaised += new BuildMessageEventHandler(MessageRaised);
            eventSource.ProjectFinished += new ProjectFinishedEventHandler(ProjectFinished);
            //eventSource.ProjectStarted += new ProjectStartedEventHandler(ProjectStarted);
            //eventSource.StatusEventRaised += new BuildStatusEventHandler(StatusEventRaised);
            //eventSource.TargetFinished += new TargetFinishedEventHandler(TargetFinished);
            //eventSource.TargetStarted += new TargetStartedEventHandler(TargetStarted);
            //eventSource.TaskFinished += new TaskFinishedEventHandler(TaskFinished);
            //eventSource.TaskStarted += new TaskStartedEventHandler(TaskStarted);
            eventSource.WarningRaised += new BuildWarningEventHandler(WarningRaised);
        }
开发者ID:JSchofield,项目名称:BuildTool,代码行数:35,代码来源:MSBuildLogger.cs


示例6: GetEventHandlersFromAggregateRoot

        /// <summary>
        /// Gets the event handlers from aggregate root based on the given mapping.
        /// </summary>
        /// <param name="eventSource">The aggregate root.</param>
        /// <see cref="ExpressionBasedSourcedEventHandlerMappingStrategy"/>
        /// <returns>All the <see cref="ISourcedEventHandler"/>'s created based on the given mapping.</returns>
        public IEnumerable<ISourcedEventHandler> GetEventHandlersFromAggregateRoot(IEventSource eventSource)
        {
            Contract.Requires<ArgumentNullException>(eventSource != null, "The eventSource cannot be null.");

            if(!(eventSource is AggregateRootMappedWithExpressions))
            {
                throw new ArgumentException("aggregateRoot need to be of type AggregateRootMappedWithExpressions to be used in a ExpressionBasedSourcedEventHandlerMappingStrategy.");
            }

            var handlers = new List<ISourcedEventHandler>();

            foreach (ExpressionHandler mappinghandler in ((AggregateRootMappedWithExpressions)eventSource).MappingHandlers)
            {
                if (mappinghandler.ActionMethodInfo.IsStatic)
                {
                    var message = String.Format("The method {0}.{1} could not be mapped as an event handler, since it is static.", mappinghandler.ActionMethodInfo.DeclaringType.Name, mappinghandler.ActionMethodInfo.Name);
                    throw new InvalidEventHandlerMappingException(message);
                }

                var handler = CreateHandlerForMethod(eventSource, mappinghandler.ActionMethodInfo, mappinghandler.Exact);
                handlers.Add(handler);
            }

            return handlers;
        }
开发者ID:SzymonPobiega,项目名称:ncqrs,代码行数:31,代码来源:ExpressionBasedSourcedEventHandlerMappingStrategy.cs


示例7: Initialize

        /// <summary>
        /// Initialize is guaranteed to be called by MSBuild at the start of the build
        /// before any events are raised.
        /// </summary>
        public override void Initialize(IEventSource eventSource)
        {
            // The name of the log file should be passed as the first item in the
            // "parameters" specification in the /logger switch.  It is required
            // to pass a log file to this logger. Other loggers may have zero or more than
            // one parameters.
            if (null == Parameters)
            {
                throw new LoggerException("Log file was not set.");
            }
            string[] parameters = Parameters.Split(';');

            string logFile = parameters[0];
            if (String.IsNullOrEmpty(logFile))
            {
                throw new LoggerException("Log file was not set.");
            }

            if (parameters.Length > 1)
            {
                throw new LoggerException("Too many parameters passed.");
            }

            try
            {
                // Open the file
                this.streamWriter = new StreamWriter(logFile);
            }
            catch (Exception ex)
            {
                if
                (
                    ex is UnauthorizedAccessException
                    || ex is ArgumentNullException
                    || ex is PathTooLongException
                    || ex is DirectoryNotFoundException
                    || ex is NotSupportedException
                    || ex is ArgumentException
                    || ex is SecurityException
                    || ex is IOException
                )
                {
                    throw new LoggerException("Failed to create log file: " + ex.Message);
                }
                else
                {
                    // Unexpected failure
                    throw;
                }
            }

            // For brevity, we'll only register for certain event types. Loggers can also
            // register to handle TargetStarted/Finished and other events.
            eventSource.ProjectStarted += new ProjectStartedEventHandler(eventSource_ProjectStarted);
            eventSource.TaskStarted += new TaskStartedEventHandler(eventSource_TaskStarted);
            eventSource.MessageRaised += new BuildMessageEventHandler(eventSource_MessageRaised);
            eventSource.WarningRaised += new BuildWarningEventHandler(eventSource_WarningRaised);
            eventSource.ErrorRaised += new BuildErrorEventHandler(eventSource_ErrorRaised);
            eventSource.ProjectFinished += new ProjectFinishedEventHandler(eventSource_ProjectFinished);
        }
开发者ID:RKishore222,项目名称:TestProject,代码行数:64,代码来源:Logger.cs


示例8: Initialize

        /// <summary>
        /// Initializes the logger and subscribes to the relevant events.
        /// </summary>
        /// <param name="eventSource">The available events that processEvent logger can subscribe to.</param>
        public override void Initialize(IEventSource eventSource)
        {
            ProcessParameters();
            
            eventSource.BuildStarted    += (s, args) => _build = new Build(args);
            eventSource.BuildFinished   += (o, args) => _build.CompleteBuild(args, _logFile, _errors, _warings);

            eventSource.ProjectStarted  += (o, args) => TryProcessEvent(() => _build.AddProject(args));
            eventSource.ProjectFinished += (o, args) => TryProcessEvent(() => _build.CompleteProject(args));
            eventSource.TargetStarted   += (o, args) => TryProcessEvent(() => _build.AddTarget(args));
            eventSource.TargetFinished  += (o, args) => TryProcessEvent(() => _build.CompleteTarget(args));
            eventSource.TaskStarted     += (o, args) => TryProcessEvent(() => _build.AddTask(args));
            eventSource.TaskFinished    += (o, args) => TryProcessEvent(() => _build.CompleteTask(args));

            eventSource.TaskFinished += (o, args) => TryProcessEvent(() => _build.CompleteTask(args));

            eventSource.MessageRaised += HandleMessageRaised;

            eventSource.ErrorRaised += (o, args) =>
            {
                _errors++;
                _build.AddMessage(args, string.Format("Error {0}: {1}", args.Code, args.Message));
            };
            eventSource.WarningRaised += (o, args) =>
            {

                _warings++;
                _build.AddMessage(args, string.Format("Warning {0}: {1}", args.Code, args.Message));
            };
        }
开发者ID:cameron314,项目名称:msbuild,代码行数:34,代码来源:XmlFileLogger.cs


示例9: Initialize

        /// <summary>
        /// When overridden in a derived class, subscribes the logger to specific events.
        /// </summary>
        /// <param name="eventSource">The available events that a logger can subscribe to.</param>
        /// <exception cref="Microsoft.Build.Framework.LoggerException">
        /// Log file was not set.
        /// or
        /// Log file was not set.
        /// or
        /// Failed to create log file:  + ex.Message
        /// </exception>
        public override void Initialize(IEventSource eventSource)
        {
            // The name of the log file should be passed as the first item in the
            // "parameters" specification in the /logger switch.  It is required
            // to pass a log file to this logger. Other loggers may have zero or more than
            // one parameters.
            if (Parameters == null)
                throw new LoggerException("Log file was not set.");

            var logFilename = Parameters.Split(';').FirstOrDefault();
            if (string.IsNullOrEmpty(logFilename))
                throw new LoggerException("Log file was not set.");

            try
            {
                _streamWriter = new StreamWriter(logFilename, false, System.Text.Encoding.UTF8);
            }
            catch (Exception ex)
            {
                throw new LoggerException("Failed to create log file: " + ex.Message);
            }

            eventSource.WarningRaised += WarningRaisedEventHandler;
            eventSource.BuildFinished += BuildFinishedEventHandler;
        }
开发者ID:codehulknet,项目名称:MSBuild-Loggers,代码行数:36,代码来源:CSVWarningsLogger.cs


示例10: Initialize

        public override void Initialize(IEventSource eventSource)
        {
            //parse the values passed in as parameters
            InitializeParameters();

            if (string.IsNullOrEmpty(LogFile))
            {
                //apply default log name here
                LogFile = "hello2.log";
            }

            //always writes to a log with this name
            if (File.Exists(LogFile))
            { File.Delete(LogFile); }

            //initialize the writer
            writer = new StreamWriter(LogFile);

            //register to the events you are interested in here
            eventSource.BuildStarted += BuildStarted;
            eventSource.BuildFinished += BuildFinished;
            eventSource.CustomEventRaised += CustomEvent;
            eventSource.ErrorRaised += ErrorRaised;
            eventSource.MessageRaised += MessageRaised;
            eventSource.ProjectStarted += ProjectStarted;
            eventSource.ProjectStarted += ProjectFinished;
            eventSource.TargetStarted += TargetStarted;
            eventSource.TargetFinished += TargetFinished;
            eventSource.TaskStarted += TaskStarted;
            eventSource.TaskFinished += TaskFinished;
            eventSource.WarningRaised += WarningRaised;
        }
开发者ID:JustJenFelice,项目名称:sayed-samples,代码行数:32,代码来源:HelloLogger2.cs


示例11: DeleteEntity

        protected override void DeleteEntity(IEventSource session, object entity,

            EntityEntry entityEntry, bool isCascadeDeleteEnabled,

            IEntityPersister persister, ISet transientEntities)
        {
            if (entity is IPermanent)
            {

                var e = (IPermanent)entity;

                e.IsDeleted = true;

                CascadeBeforeDelete(session, persister, entity, entityEntry, transientEntities);

                CascadeAfterDelete(session, persister, entity, transientEntities);

            }

            else
            {

                base.DeleteEntity(session, entity, entityEntry, isCascadeDeleteEnabled,

                                  persister, transientEntities);

            }
        }
开发者ID:akhuang,项目名称:NHibernateTest,代码行数:28,代码来源:MyDeleteEventListener.cs


示例12: AttachToRequiredEvents

        private void AttachToRequiredEvents(IEventSource eventSource)
        {
            eventSource.ErrorRaised += eventSource_ErrorRaised;
            eventSource.WarningRaised += eventSource_WarningRaised;

            eventSource.BuildStarted += eventSource_BuildStartedHandler;
            eventSource.BuildFinished += eventSource_BuildFinishedHandler;

            if (Verbosity == LoggerVerbosity.Quiet) return;

            eventSource.MessageRaised += eventSource_MessageHandler;
            eventSource.CustomEventRaised += eventSource_CustomBuildEventHandler;

            eventSource.ProjectStarted += eventSource_ProjectStartedHandler;
            eventSource.ProjectFinished += eventSource_ProjectFinishedHandler;

            if (Verbosity == LoggerVerbosity.Minimal) return;

            eventSource.TargetStarted += eventSource_TargetStartedHandler;
            eventSource.TargetFinished += eventSource_TargetFinishedHandler;

            if (Verbosity == LoggerVerbosity.Normal) return;

            eventSource.TaskStarted += eventSource_TaskStartedHandler;
            eventSource.TaskFinished += eventSource_TaskFinishedHandler;
        }
开发者ID:rjasica,项目名称:Kobush.Build,代码行数:26,代码来源:XmlLogger.cs


示例13: Initialize

	public void Initialize(IEventSource eventSource)
	{
		eventSource.MessageRaised += (sender, e) =>
		{
			var shouldLog = e.Importance == MessageImportance.High &&
				Verbosity >= LoggerVerbosity.Minimal;
			shouldLog |= e.Importance == MessageImportance.Normal &&
				Verbosity >= LoggerVerbosity.Normal;
			shouldLog |= e.Importance == MessageImportance.Low &&
				Verbosity >= LoggerVerbosity.Detailed;

			if (shouldLog)
			{
				output.WriteLine(e.Message);
				Messages.Add(e);
			}
		};

		if (Verbosity >= LoggerVerbosity.Detailed)
			eventSource.AnyEventRaised += (sender, e) => output.WriteLine(e.Message);

		eventSource.ErrorRaised += (sender, e) =>
		{
			output.WriteLine(e.Message);
			Errors.Add(e);
		};

		eventSource.WarningRaised += (sender, e) =>
		{
			output.WriteLine(e.Message);
			Warnings.Add(e);
		};
	}
开发者ID:moq,项目名称:moq.proxy,代码行数:33,代码来源:TestOutputLogger.cs


示例14: Initialize

        public override void Initialize(IEventSource eventSource)
        {
            errorList = new List<string>();
            warningList = new List<string>();

            buildElements = new Stack<XmlElement>();
            projectElements = new Stack<XmlElement>();
            targetElements = new Stack<XmlElement>();
            taskElements = new Stack<XmlElement>();
            buildTypeList = new Stack<BuildType>();

            //apply default values
            if (string.IsNullOrEmpty(LogFile)) {
                LogFile = @"build.log.xml";
            }
            Append = false;
            ShowSummary = false;
            comparer = new MSBuildComparer();
            //have base init the parameters
            base.Initialize(eventSource);

            this.InitializeEvents(eventSource);

            this.InitializeXmlDoc();
        }
开发者ID:sayedihashimi,项目名称:msbuild-analyzer,代码行数:25,代码来源:DiagnosticXmlLogger.cs


示例15: AbstractPreDatabaseOperationEvent

		/// <summary> Constructs an event containing the pertinent information. </summary>
		/// <param name="source">The session from which the event originated. </param>
		/// <param name="entity">The entity to be invloved in the database operation. </param>
		/// <param name="id">The entity id to be invloved in the database operation. </param>
		/// <param name="persister">The entity's persister. </param>
		protected AbstractPreDatabaseOperationEvent(IEventSource source, object entity, object id, IEntityPersister persister)
			: base(source)
		{
			Entity = entity;
			Id = id;
			Persister = persister;
		}
开发者ID:Ruhollah,项目名称:nhibernate-core,代码行数:12,代码来源:AbstractPreDatabaseOperationEvent.cs


示例16: Initialize

        public override void Initialize(IEventSource eventSource)
        {
            this.handler = this.OnMessage;
            eventSource.BuildFinished += this.BuildFinished;
            eventSource.BuildStarted += this.BuildStarted;
            eventSource.ErrorRaised += this.ErrorRaised;
            eventSource.WarningRaised += this.WarningRaised;

            if (this.Verbosity != LoggerVerbosity.Quiet)
            {
                eventSource.MessageRaised += this.MessageRaised;
                eventSource.ProjectStarted += this.ProjectStarted;
                eventSource.ProjectFinished += this.ProjectFinished;
            }

            if (this.IsVerbosityAtLeast(LoggerVerbosity.Normal))
            {
                eventSource.TargetStarted += this.TargetStarted;
                eventSource.TargetFinished += this.TargetFinished;
            }

            if (this.IsVerbosityAtLeast(LoggerVerbosity.Detailed))
            {
                eventSource.TaskStarted += this.TaskStarted;
                eventSource.TaskFinished += this.TaskFinished;
            }
        }
开发者ID:nagyist,项目名称:MSBuildExplorer,代码行数:27,代码来源:MSBuildExplorerLogger.cs


示例17: NetworkEvent

 private NetworkEvent(INetwork network, IEventType type, IEventSource source)
 {
     Network = network;
     Type = type;
     TimeStamp = DateTime.UtcNow;
     Source = source;
 }
开发者ID:Mavtak,项目名称:roomie,代码行数:7,代码来源:NetworkEvent.cs


示例18: Initialize

 public void Initialize(IEventSource p0)
 {
     if (p0 != null)
     {
         p0.ErrorRaised += new BuildErrorEventHandler(this.m00024c);
     }
 }
开发者ID:bing2008,项目名称:CastNetGame,代码行数:7,代码来源:c000167.cs


示例19: CreateHandlerForMethod

        /// <summary>
        /// Converts the given method into an <see cref="ISourcedEventHandler"/> object.
        /// </summary>
        /// <param name="aggregateRoot">The event source from which we want to invoke the method.</param>
        /// <param name="method">The method to invoke</param>
        /// <param name="exact"><b>True</b> if we need to have an exact match, otherwise <b>False</b>.</param>
        /// <returns>An <see cref="ISourcedEventHandler"/> that handles the execution of the given method.</returns>
        private static ISourcedEventHandler CreateHandlerForMethod(IEventSource eventSource, MethodInfo method, bool exact)
        {
            Type firstParameterType = method.GetParameters().First().ParameterType;

            Action<IEvent> handler = e => method.Invoke(eventSource, new object[] { e });
            return new TypeThresholdedActionBasedDomainEventHandler(handler, firstParameterType, exact);
        }
开发者ID:SzymonPobiega,项目名称:ncqrs,代码行数:14,代码来源:ExpressionBasedSourcedEventHandlerMappingStrategy.cs


示例20: PerformSave

            protected override object PerformSave(object entity, object id, IEntityPersister persister, bool useIdentityColumn, object anything,
           IEventSource source, bool requiresImmediateIdAccess)
            {
                var entityValue = entity as EntityBase;
                if (entityValue != null)
                {
                    if (entityValue.CreatedBy == null || entityValue.CreatedBy.Equals(string.Empty))
                    {
                        entityValue.CreatedBy = EntityConstant.CreatedBy;
                        entityValue.CreatedOn = DateTime.Now;
                    }
                    else
                    {
                        entityValue.UpdatedBy = EntityConstant.UpdatedBy;
                        entityValue.UpdatedOn = DateTime.Now;
                    }
                }

                foreach (var property in entity.GetType().GetProperties())
                {
                    var propertyValue = property.GetValue(entity, null);
                    if (propertyValue == null)
                    {
                        continue;
                    }
                    if (propertyValue.GetType().IsSubclassOf(typeof(EntityBase)))
                    {
                        var value = propertyValue as EntityBase;
                        value.CreatedBy = EntityConstant.CreatedBy;
                        value.CreatedOn = DateTime.Now;
                    }
                }

                return base.PerformSave(entityValue, id, persister, useIdentityColumn, anything, source, requiresImmediateIdAccess);
            }
开发者ID:CuongDuongDuy,项目名称:MyUniversity,代码行数:35,代码来源:NHibernateEventListener.cs



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


鲜花

握手

雷人

路过

鸡蛋
该文章已有0人参与评论

请发表评论

全部评论

专题导读
上一篇:
C# IEventStore类代码示例发布时间:2022-05-24
下一篇:
C# IEventService类代码示例发布时间:2022-05-24
热门推荐
阅读排行榜

扫描微信二维码

查看手机版网站

随时了解更新最新资讯

139-2527-9053

在线客服(服务时间 9:00~18:00)

在线QQ客服
地址:深圳市南山区西丽大学城创智工业园
电邮:jeky_zhao#qq.com
移动电话:139-2527-9053

Powered by 互联科技 X3.4© 2001-2213 极客世界.|Sitemap