コード例 #1
0
ファイル: BindingItem.cs プロジェクト: mosamy/vulcan
        private IFrameworkItem ScopedSearch(string xmlValue, SymbolTable symbolTable)
        {
            Type t = BoundProperty.PropertyType;

            if (CommonUtility.IsContainerOf(typeof(ICollection <object>), t))
            {
                t = t.GetGenericArguments()[0];
            }

            var  attributes            = CustomAttributeProvider.Global.GetAttribute <AstLocalOnlyScopeBindingAttribute>(BoundProperty, false);
            bool localOnlyScopeBinding = attributes.Count > 0;

            IReferenceableItem           boundItem;
            IEnumerable <IScopeBoundary> bindingScopeBoundaries = ParentItem.BindingScopeBoundaries();

            foreach (var scopeBoundary in bindingScopeBoundaries)
            {
                IScopeBoundary currentScope = scopeBoundary;
                while (currentScope != null)
                {
                    boundItem    = FindReferenceableItem(symbolTable, currentScope, t, xmlValue);
                    currentScope = currentScope.ScopeBoundary;
                    if (CheckBoundItem(boundItem, localOnlyScopeBinding, bindingScopeBoundaries))
                    {
                        return(boundItem);
                    }
                }
            }

            // Attempt scopeless binding
            boundItem = FindReferenceableItem(symbolTable, null, t, xmlValue);
            if (CheckBoundItem(boundItem, localOnlyScopeBinding, bindingScopeBoundaries))
            {
                return(boundItem);
            }

            return(null);
        }