Ejemplo n.º 1
0
        /// <summary>
        /// Decides whether given part satisfies a filter.
        /// </summary>
        /// <param name="part"><see cref="ComposablePartDefinition"/> being filtered.</param>
        /// <returns>True if a given <see cref="ComposablePartDefinition"/> satisfies the filter.
        /// False otherwise.</returns>
        public bool Filter(ComposablePartDefinition part)
        {
            // Fetch all metadata
            Dictionary <string, object> metadata = new Dictionary <string, object>(StringComparer.InvariantCultureIgnoreCase);

            foreach (var md in part.Metadata)
            {
                metadata.Add(md.Key, md.Value);
            }
            var additionalMetadata = from ed in part.ExportDefinitions
                                     from md in ed.Metadata
                                     select md;

            foreach (var md in additionalMetadata)
            {
                if (!metadata.ContainsKey(md.Key))
                {
                    metadata.Add(md.Key, md.Value);
                }
            }

            // Fetch "Scope"
            var key = "Scope";

            if (metadata.ContainsKey(key))
            {
                PartCreationScope scope = PartCreationScope.Default;
                Enum.TryParse(metadata[key].ToString(), out scope);

                return(scope == _partCreationScope);
            }
            else if (_partCreationScope == PartCreationScope.Default)
            {
                return(true);
            }
            return(false);
        }
Ejemplo n.º 2
0
 /// <summary>
 /// Initializes a new instance of the <see cref="PartCreationScopeAttribute"/> class.
 /// </summary>
 /// <param name="scope">The part's scope.</param>
 public PartCreationScopeAttribute(PartCreationScope scope)
 {
     Scope = scope;
 }
Ejemplo n.º 3
0
 /// <summary>
 /// Initializes a new instance of the <see cref="HasPartCreationScope"/> class.
 /// </summary>
 /// <param name="_partCreationScope">The part creation scope.</param>
 public HasPartCreationScope(PartCreationScope _partCreationScope)
 {
     this._partCreationScope = _partCreationScope;
 }
 /// <summary>
 /// Initializes a new instance of the <see cref="PartCreationScopeAttribute"/> class.
 /// </summary>
 /// <param name="scope">The part's scope.</param>
 public PartCreationScopeAttribute(PartCreationScope scope)
 {
     Scope = scope;
 }
Ejemplo n.º 5
0
 /// <summary>
 /// Initializes a new instance of the <see cref="HasPartCreationScope"/> class.
 /// </summary>
 /// <param name="partCreationScope">The part creation scope.</param>
 public HasPartCreationScope(PartCreationScope partCreationScope)
 {
     this.partCreationScope = partCreationScope;
 }
Ejemplo n.º 6
0
 /// <summary>
 /// Initializes a new instance of the <see cref="HasPartCreationScope"/> class.
 /// </summary>
 /// <param name="partCreationScope">The part creation scope.</param>
 public WebFiltering(PartCreationScope partCreationScope)
 {
     _partCreationScope = partCreationScope;
 }
Ejemplo n.º 7
0
 /// <summary>
 /// Initializes a new instance of the <see cref="HasPartCreationScope"/> class.
 /// </summary>
 /// <param name="_partCreationScope">The part creation scope.</param>
 public HasPartCreationScope(PartCreationScope _partCreationScope)
 {
     this._partCreationScope = _partCreationScope;
 }