Exemplo n.º 1
0
        public void Remove(IMetadatumDefinition customAttribute)
        {
            bool found = false;
            List <IMetadataDefinition> containers = new List <IMetadataDefinition>();

            foreach (var set in base.baseList)
            {
                if (set.Contains(customAttribute))
                {
                    containers.Add(set);
                    set.Remove(customAttribute);
                    found = true;
                }
            }
            foreach (var set in containers)
            {
                if (set.Count == 0)
                {
                    base.baseList.Remove(set);
                }
            }
            if (!found)
            {
                throw new ArgumentException("customAttribute provided was not found in any collection of the series.", "customAttribute");
            }
        }
Exemplo n.º 2
0
        public IMetadatumDefinition[] Flatten()
        {
            int count = 0;

            foreach (var set in this.baseList)
            {
                count += set.Count;
            }
            IMetadatumDefinition[] result = new IMetadatumDefinition[count];
            int k = 0;

            foreach (var item in this)
            {
                foreach (var decl in item)
                {
                    result[k++] = decl;
                }
            }
            return(result);
        }
Exemplo n.º 3
0
 public IMetadatumDefinition this[IType attributeType]
 {
     get {
         /* *
          * No mru series for this setup, mainly because there's no benefit
          * to caching instances that may no longer exist as elements of the
          * series.
          * *
          * I *could* setup a versioning system for the definition sets and adjust
          * the MRU as needed, but that's a bit of a pain, and not worth the effort.
          * */
         IMetadataDefinition containing = null;
         foreach (var item in this)
         {
             if (item.Contains(attributeType))
             {
                 containing = item;
                 break;
             }
         }
         IMetadatumDefinition closeMatch = null;
         if (containing == null)
         {
             return(null);
         }
         foreach (var item in containing)
         {
             if (item.Type == attributeType)
             {
                 return(item);
             }
             else if (closeMatch == null && attributeType.IsAssignableFrom(item.Type))
             {
                 closeMatch = item;
             }
         }
         return(closeMatch);
     }
 }