internal void ValidateGuidanceReference(ValidationContext context, IProductElement element)
        {
            try
            {
                if (this.GuidanceManager == null)
                {
                    return;
                }

                var reference = element.TryGetReference(ReferenceKindConstants.GuidanceTopic);
                if (!string.IsNullOrEmpty(reference))
                {
                    var uri = GuidanceReference.GetResolvedReferences(element, this.GuidanceManager).FirstOrDefault();
                    if (uri == null)
                    {
                        context.LogError(
                            string.Format(CultureInfo.InvariantCulture,
                                          Properties.Resources.Validate_GuidanceReferenceNotFound,
                                          element.InstanceName, reference, ReflectionExtensions.DisplayName(typeof(GuidanceReference))),
                            Properties.Resources.Validate_GuidanceReferenceNotFoundCode,
                            element as ModelElement);
                    }
                }
            }
            catch (Exception ex)
            {
                tracer.Error(
                    ex,
                    Properties.Resources.ValidationMethodFailed_Error,
                    Reflector <GuidanceReferenceValidation> .GetMethod(n => n.ValidateGuidanceReference(context, element)).Name);

                throw;
            }
        }
        internal void ValidateGuidanceReference(ValidationContext context, IProductElement element)
        {
            try
            {
                if (this.GuidanceManager == null)
                {
                    return;
                }

                var reference = element.TryGetReference(ReferenceKindConstants.GuidanceTopic);
                if (!string.IsNullOrEmpty(reference))
                {
                    var uri = GuidanceReference.GetResolvedReferences(element, this.GuidanceManager).FirstOrDefault();
                    if (uri == null)
                    {
                        context.LogError(
                            string.Format(CultureInfo.InvariantCulture,
                                Properties.Resources.Validate_GuidanceReferenceNotFound,
                                element.InstanceName, reference, ReflectionExtensions.DisplayName(typeof(GuidanceReference))),
                            Properties.Resources.Validate_GuidanceReferenceNotFoundCode,
                            element as ModelElement);
                    }
                }
            }
            catch (Exception ex)
            {
                tracer.Error(
                    ex,
                    Properties.Resources.ValidationMethodFailed_Error,
                    Reflector<GuidanceReferenceValidation>.GetMethod(n => n.ValidateGuidanceReference(context, element)).Name);

                throw;
            }
        }
Exemplo n.º 3
0
        private static void ThrowIfNoLinkOnElement(IProductElement context, string path)
        {
            if (string.IsNullOrEmpty(context.TryGetReference(ReferenceKindConstants.SolutionItem)))
            {
                tracer.Verbose(
                    Resources.PathResolver_TraceInvalidParentArtifactLink);

                throw new InvalidOperationException(string.Format(
                                                        CultureInfo.CurrentCulture,
                                                        Resources.PathResolver_ErrorNoArtifactLinkOnParent,
                                                        path,
                                                        context.GetSafeInstanceName()));
            }
        }
Exemplo n.º 4
0
        private static void ThrowIfInvalidArtifactLink(IProductElement elementWithArtifactLink, IItemContainer targetItem)
        {
            if (targetItem == null)
            {
                tracer.Verbose(
                    Resources.PathResolver_TraceInvalidArtifactLink, elementWithArtifactLink.GetSafeInstanceName());

                throw new InvalidOperationException(string.Format(
                                                        CultureInfo.CurrentCulture,
                                                        Resources.PathResolver_ErrorInvalidArtifactLink,
                                                        elementWithArtifactLink.TryGetReference(ReferenceKindConstants.SolutionItem),
                                                        elementWithArtifactLink.GetSafeInstanceName()));
            }
        }