Exemple #1
0
        protected static Binding <T> CreateBindingInstance <T>(
            EFArtifactSet artifactSet, Symbol normalizedName, ItemBinding parentItemBinding) where T : EFNormalizableItem
        {
            var status = BindingStatus.None;
            T   target = null;

            var items = artifactSet.GetSymbolList(normalizedName);

            if (items.Count == 0)
            {
                // TODO: Enable this assert once we can suppress it during our InvalidDocumentTests. This will help in providing guidance for BindingStatus.Unknown issues.
                //Debug.Fail("Attempted to CreateBindingInstance for '" + parentItemBinding.ToPrettyString() + "' given the symbol: '" +
                //    normalizedName.ToDebugString() + "' but this symbol was not found in the ArtifactSet. This can happen if the given symbol " +
                //    " is composed of a name that is not constructed correctly. Check the custom NameNormalizer code for this ItemBinding.");
                status = BindingStatus.Unknown;
            }
            else
            {
                // Loop through items collection to find an element with the same type
                foreach (var element in items)
                {
                    target = element as T;
                    if (null != target)
                    {
                        break;
                    }
                }

                // Ideal case: where there is only 1 instance with the same name
                if (null != target &&
                    items.Count == 1)
                {
                    status = BindingStatus.Known;
                }
                else if (null != target &&
                         items.Count > 1)
                {
                    status = BindingStatus.Duplicate;
                }
                else // target is null
                {
                    // TODO: Enable this assert once we can suppress it during our InvalidDocumentTests. This will help in providing guidance for BindingStatus.Unknown issues.
                    //Debug.Fail("Attempted to CreateBindingInstance for '" + parentItemBinding.ToPrettyString() + "' given the symbol: '" +
                    //    normalizedName.ToDebugString() + "' but none of the symbols found in the ArtifactSet match the type " + typeof(T).ToString());
                    status = BindingStatus.Unknown;
                }
            }
            return(new Binding <T>(parentItemBinding, status, target));
        }
Exemple #2
0
        internal Binding(ItemBinding parent, BindingStatus status, T target)
        {
            _parent = parent;
            _status = status;
            _target = target;

            if (_parent != null)
            {
                var artifactSet = _parent.Artifact.ArtifactSet;
                if (_target != null)
                {
                    artifactSet.AddDependency(_parent, _target);
                }
            }
        }
Exemple #3
0
 /// <summary>
 ///     This the text that should be written out to the XML that can refer back to this
 ///     item.  Most items can use the NormalizedNameExternal so that is what we
 ///     will use by default.
 /// </summary>
 /// <param name="binding"></param>
 /// <returns></returns>
 internal virtual string GetRefNameForBinding(ItemBinding binding)
 {
     return(NormalizedNameExternal);
 }