Ejemplo n.º 1
0
        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);
        }
Ejemplo n.º 2
0
        private static IReferenceableItem FindReferenceableItem(SymbolTable symbolTable, IScopeBoundary scopeBoundary, Type itemType, string symbolName)
        {
            string fullName = symbolName;

            if (scopeBoundary != null)
            {
                fullName = String.Format(CultureInfo.InvariantCulture, "{0}.{1}", scopeBoundary.ScopedName, symbolName);
            }

            return(symbolTable[itemType, fullName]);
        }
Ejemplo n.º 3
0
        private static IReferenceableItem FindReferenceableItem(SymbolTable symbolTable, IScopeBoundary scopeBoundary, Type itemType, string symbolName)
        {
            string fullName = symbolName;
            if (scopeBoundary != null)
            {
                fullName = String.Format(CultureInfo.InvariantCulture, "{0}.{1}", scopeBoundary.ScopedName, symbolName);
            }

            return symbolTable[itemType, fullName];
        }