Exemplo n.º 1
0
        internal override void TestObjectValue(UniqueProblemCollection problems, SourceContext?sourceContext, string baseNamespace, object value, string messageFormat)
        {
            if (sourceContext.HasValue && !sourceContext.Value.IsValid)
            {
                return;
            }

            //Determine the type of value
            TestObjectNamespaces(value, (instructionTypeName) =>
            {
                string instructionBaseNamespace = GetNamespaceFromTypeName(instructionTypeName, ParentNamespaceMoniker);

                if (instructionBaseNamespace != null)
                {
                    Resolution res = new Resolution("Using invalid namespace", messageFormat, baseNamespace, instructionBaseNamespace);

                    if (sourceContext.HasValue)
                    {
                        problems.Add(new Problem(res, sourceContext.Value));
                    }
                    else
                    {
                        problems.Add(new Problem(res));
                    }
                }
            });
        }
        private void CallTestObjectValue(UniqueProblemCollection problems, SourceContext?sourceContext, string baseNamespace, object type, string messageFormat)
        {
            try
            {
                TestObjectValue(problems, sourceContext, baseNamespace, type, messageFormat);
            }
            catch (Exception ex)
            {
                Resolution res = new Resolution("Exception checking code {0}\n{1}", ex.Message, ex.StackTrace);

                if (sourceContext.HasValue)
                {
                    problems.Add(new Problem(res, sourceContext.Value));
                }
                else
                {
                    problems.Add(new Problem(res));
                }
            }
        }