コード例 #1
0
        internal static int GetEvaluationId(BuildEventContext buildEventContext)
        {
            if (buildEventContext == null)
            {
                return -1;
            }

            if (buildEventContext is BuildEventContextWithEvaluationId withEvaluationId)
            {
                return withEvaluationId.EvaluationId;
            }

            if (EvaluationIdGetter == null)
            {
                var type = buildEventContext.GetType();
                var field = type.GetField("_evaluationId", BindingFlags.Instance | BindingFlags.NonPublic);
                if (field != null)
                {
                    EvaluationIdGetter = b => (int)field.GetValue(b);
                }
                else
                {
                    EvaluationIdGetter = b => b.ProjectContextId <= 0 ? -b.ProjectContextId : -1;
                }
            }

            return EvaluationIdGetter(buildEventContext);
        }
コード例 #2
0
        internal static int GetEvaluationId(BuildEventContext buildEventContext)
        {
            if (EvaluationIdGetter == null)
            {
                var type  = buildEventContext.GetType();
                var field = type.GetField("_evaluationId", BindingFlags.Instance | BindingFlags.NonPublic);
                if (field != null)
                {
                    EvaluationIdGetter = b => (int)field.GetValue(b);
                }
                else
                {
                    EvaluationIdGetter = b => buildEventContext.ProjectContextId < 0 ? buildEventContext.ProjectContextId : int.MinValue;
                }
            }

            return(EvaluationIdGetter(buildEventContext));
        }
コード例 #3
0
        internal static int GetEvaluationId(BuildEventContext buildEventContext)
        {
            if (buildEventContext == null)
            {
                return(-1);
            }

            if (evaluationIdGetter == null)
            {
                Type      type  = buildEventContext.GetType();
                FieldInfo field = type.GetField("_evaluationId" /*, BindingFlags.Instance | BindingFlags.NonPublic*/);
                if (field != null)
                {
                    evaluationIdGetter = b => (int)field.GetValue(b);
                }
                else
                {
                    evaluationIdGetter = b => b.ProjectContextId <= 0 ? -b.ProjectContextId : -1;
                }
            }

            return(evaluationIdGetter(buildEventContext));
        }