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


C# IEventSource类代码示例

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


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


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