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


C# BuildEventArgs.GetType方法代码示例

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


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

示例1: IsEquivalent

        /// <summary>
        /// Extension method to help our tests without adding shipping code.
        /// Compare this build event context with another object to determine 
        /// equality. This means the values inside the object are identical.
        /// </summary>
        /// <param name="args">The 'this' object</param>
        /// <param name="other">Object to compare to this object</param>
        /// <returns>True if the object values are identical, false if they are not identical</returns>
        public static bool IsEquivalent(this BuildEventArgs args, BuildEventArgs other)
        {
            if (Object.ReferenceEquals(args, other))
            {
                return true;
            }

            if (Object.ReferenceEquals(other, null) || Object.ReferenceEquals(args, null))
            {
                return false;
            }

            if (args.GetType() != other.GetType())
            {
                return false;
            }

            if (args.Timestamp.Ticks != other.Timestamp.Ticks)
            {
                return false;
            }

            if (args.BuildEventContext != other.BuildEventContext)
            {
                return false;
            }

            if (!String.Equals(args.HelpKeyword, other.HelpKeyword, StringComparison.OrdinalIgnoreCase))
            {
                return false;
            }

            // Just in case we're matching chk against ret or vice versa, make sure the message still registers as the same
            string fixedArgsMessage = args.Message.Replace("\r\nThis is an unhandled exception from a task -- PLEASE OPEN A BUG AGAINST THE TASK OWNER.", String.Empty);
            string fixedOtherMessage = other.Message.Replace("\r\nThis is an unhandled exception from a task -- PLEASE OPEN A BUG AGAINST THE TASK OWNER.", String.Empty);

            if (!String.Equals(fixedArgsMessage, fixedOtherMessage, StringComparison.OrdinalIgnoreCase))
            {
                return false;
            }

            if (!String.Equals(args.SenderName, other.SenderName, StringComparison.OrdinalIgnoreCase))
            {
                return false;
            }

            if (args.ThreadId != other.ThreadId)
            {
                return false;
            }

            return true;
        }
开发者ID:JamesLinus,项目名称:msbuild,代码行数:61,代码来源:BuildEventArgsExtension.cs

示例2: SendBuildEvent

        /// <summary>
        /// Sends the requested packet across to the main node. 
        /// </summary>
        private void SendBuildEvent(BuildEventArgs e)
        {
            if (_nodeEndpoint != null && _nodeEndpoint.LinkStatus == LinkStatus.Active)
            {
                if (!e.GetType().IsSerializable)
                {
                    // log a warning and bail.  This will end up re-calling SendBuildEvent, but we know for a fact
                    // that the warning that we constructed is serializable, so everything should be good.  
                    LogWarningFromResource("ExpectedEventToBeSerializable", e.GetType().Name);
                    return;
                }

                _nodeEndpoint.SendData(new LogMessagePacket(new KeyValuePair<int, BuildEventArgs>(_currentConfiguration.NodeId, e)));
            }
        }
开发者ID:JamesLinus,项目名称:msbuild,代码行数:18,代码来源:OutOfProcTaskHostNode.cs

示例3: VerifyRegisteredHandlers

        /// <summary>
        /// Verify when an is raised the handlers which are  registered to handle the event should handle them
        /// </summary>
        /// <param name="buildEventToRaise">A buildEventArgs to raise on the event source</param>
        /// <param name="eventHelper">Helper class which events are raised on</param>
        /// <param name="testHandlers">Class which contains a set of event handlers registered on the event source</param>
        private static void VerifyRegisteredHandlers(BuildEventArgs buildEventToRaise, RaiseEventHelper eventHelper, EventHandlerHelper testHandlers)
        {
            try
            {
                eventHelper.RaiseBuildEvent(buildEventToRaise);
                if (buildEventToRaise.GetType() != typeof(GenericBuildStatusEventArgs))
                {
                    Assert.IsTrue(testHandlers.RaisedEvent == buildEventToRaise, "Expected buildevent in handler to match buildevent raised on event source");
                    Assert.IsTrue(testHandlers.RaisedEvent == testHandlers.RaisedAnyEvent, "Expected RaisedEvent and RaisedAnyEvent to match");
                    Assert.IsTrue(testHandlers.EnteredEventHandler, "Expected to enter into event handler");
                }

                Assert.IsTrue(testHandlers.RaisedAnyEvent == buildEventToRaise, "Expected buildEvent in any event handler to match buildevent raised on event source");
                Assert.IsTrue(testHandlers.EnteredAnyEventHandler, "Expected  to enter into AnyEvent handler");

                if (buildEventToRaise is BuildStatusEventArgs)
                {
                    Assert.IsTrue(testHandlers.RaisedStatusEvent == buildEventToRaise, "Expected buildevent in handler to match buildevent raised on event source");
                    Assert.IsTrue(testHandlers.EnteredStatusEventHandler, "Expected to enter into Status event handler");
                }
                else
                {
                    Assert.IsNull(testHandlers.RaisedStatusEvent);
                    Assert.IsFalse(testHandlers.EnteredStatusEventHandler);
                }
            }
            finally
            {
                testHandlers.ResetRaisedEvent();
            }
        }
开发者ID:ChronosWS,项目名称:msbuild,代码行数:37,代码来源:EventSourceSink_Tests.cs

示例4: IsEventSerializable

        /// <summary>
        /// Determine if the event is serializable. If we are running with multiple nodes we need to make sure the logging events are serializable. If not
        /// we need to log a warning.
        /// </summary>
        internal bool IsEventSerializable(BuildEventArgs e)
        {
            if (!e.GetType().IsSerializable)
            {
                _loggingContext.LogWarning(new BuildEventFileInfo(string.Empty), null, "ExpectedEventToBeSerializable", e.GetType().Name);
                return false;
            }

            return true;
        }
开发者ID:cameron314,项目名称:msbuild,代码行数:14,代码来源:TaskFactoryLoggingHost.cs

示例5: GetLoggingEventId

 /// <summary>
 /// Based on the type of the BuildEventArg to be wrapped
 /// generate an Id which identifies which concrete type the
 /// BuildEventArg is.
 /// </summary>
 /// <param name="eventArg">Argument to get the type Id for</param>
 /// <returns>An enumeration entry which represents the type</returns>
 private LoggingEventType GetLoggingEventId(BuildEventArgs eventArg)
 {
     Type eventType = eventArg.GetType();
     if (eventType == typeof(BuildMessageEventArgs))
     {
         return LoggingEventType.BuildMessageEvent;
     }
     else if (eventType == typeof(TaskCommandLineEventArgs))
     {
         return LoggingEventType.TaskCommandLineEvent;
     }
     else if (eventType == typeof(ProjectFinishedEventArgs))
     {
         return LoggingEventType.ProjectFinishedEvent;
     }
     else if (eventType == typeof(ProjectStartedEventArgs))
     {
         return LoggingEventType.ProjectStartedEvent;
     }
     else if (eventType == typeof(TargetStartedEventArgs))
     {
         return LoggingEventType.TargetStartedEvent;
     }
     else if (eventType == typeof(TargetFinishedEventArgs))
     {
         return LoggingEventType.TargetFinishedEvent;
     }
     else if (eventType == typeof(TaskStartedEventArgs))
     {
         return LoggingEventType.TaskStartedEvent;
     }
     else if (eventType == typeof(TaskFinishedEventArgs))
     {
         return LoggingEventType.TaskFinishedEvent;
     }
     else if (eventType == typeof(BuildFinishedEventArgs))
     {
         return LoggingEventType.BuildFinishedEvent;
     }
     else if (eventType == typeof(BuildStartedEventArgs))
     {
         return LoggingEventType.BuildStartedEvent;
     }
     else if (eventType == typeof(BuildWarningEventArgs))
     {
         return LoggingEventType.BuildWarningEvent;
     }
     else if (eventType == typeof(BuildErrorEventArgs))
     {
         return LoggingEventType.BuildErrorEvent;
     }
     else
     {
         return LoggingEventType.CustomEvent;
     }
 }
开发者ID:cameron314,项目名称:msbuild,代码行数:63,代码来源:LogMessagePacketBase.cs

示例6: ReadFromStream

        /// <summary>
        /// Reads the logging packet from the translator.
        /// </summary>
        internal void ReadFromStream(INodePacketTranslator translator)
        {
            if (LoggingEventType.CustomEvent != _eventType)
            {
                _buildEvent = GetBuildEventArgFromId();

                // The other side is telling us whether the event knows how to log itself, or whether we're going to have 
                // to do it manually 
                int packetVersion = s_defaultPacketVersion;
                translator.Translate(ref packetVersion);

                bool eventCanSerializeItself = true;
                translator.Translate(ref eventCanSerializeItself);

                if (eventCanSerializeItself)
                {
                    MethodInfo methodInfo = null;
                    lock (s_readMethodCache)
                    {
                        if (!s_readMethodCache.TryGetValue(_eventType, out methodInfo))
                        {
                            Type eventDerivedType = _buildEvent.GetType();
                            methodInfo = eventDerivedType.GetMethod("CreateFromStream", BindingFlags.NonPublic | BindingFlags.Instance | BindingFlags.InvokeMethod);
                            s_readMethodCache.Add(_eventType, methodInfo);
                        }
                    }

                    ArgsReaderDelegate readerMethod = (ArgsReaderDelegate)CreateDelegateRobust(typeof(ArgsReaderDelegate), _buildEvent, methodInfo);

                    readerMethod(translator.Reader, packetVersion);
                    if (_eventType == LoggingEventType.TargetFinishedEvent && _targetFinishedTranslator != null)
                    {
                        _targetFinishedTranslator(translator, (TargetFinishedEventArgs)_buildEvent);
                    }
                }
                else
                {
                    _buildEvent = ReadEventFromStream(_eventType, translator);
                }
            }
            else
            {
                string fileLocation = null;
                translator.Translate(ref fileLocation);

                bool resolveAssembly = false;
                lock (s_lockObject)
                {
                    if (!s_customEventsLoaded.Contains(fileLocation))
                    {
                        resolveAssembly = true;
                    }

                    // If we are to resolve the assembly add it to the list of assemblies resolved
                    if (resolveAssembly)
                    {
                        s_customEventsLoaded.Add(fileLocation);
                    }
                }

                if (resolveAssembly)
                {
                    s_resolver = new TaskEngineAssemblyResolver();
                    s_resolver.InstallHandler();
                    s_resolver.Initialize(fileLocation);
                }

                try
                {
                    translator.TranslateDotNet(ref _buildEvent);
                }
                finally
                {
                    if (resolveAssembly)
                    {
                        s_resolver.RemoveHandler();
                        s_resolver = null;
                    }
                }
            }

            _eventType = GetLoggingEventId(_buildEvent);
        }
开发者ID:cameron314,项目名称:msbuild,代码行数:86,代码来源:LogMessagePacketBase.cs


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