Esempio n. 1
0
 /// <summary>
 /// Loads an assembly into the framework and discovers its control
 /// implementations.
 /// </summary>
 /// <param name="asm">The assembly to load.</param>
 void LoadAssembly(Assembly asm)
 {
     foreach (Type asmType in asm.GetExportedTypes())
     {
         TypeInfo type = asmType.GetTypeInfo();
         foreach (CustomAttributeData data in type.CustomAttributes)
         {
             if (data.AttributeType.FullName == typeof(ControlAttribute).FullName)
             {
                 ControlAttribute      attr = new ControlAttribute((int)data.ConstructorArguments[0].Value);
                 ControlImplementation impl = new ControlImplementation(asmType, type, attr);
                 foreach (Type iface in type.ImplementedInterfaces)
                 {
                     ControlManager manager;
                     if (Controls.ContainsKey(iface))
                     {
                         manager = Controls[iface];
                     }
                     else
                     {
                         manager = Controls[iface] = ControlManager.Create(this, iface);
                     }
                     manager.Add(impl);
                 }
             }
         }
     }
     LoadedAssemblies.Add(asm);
 }
Esempio n. 2
0
        /// <summary>
        /// Adds an implementation to the list of known implementations, then
        /// weighs each of the implementations to determine the best to use.
        /// </summary>
        /// <param name="impl">The new implementation to add.</param>
        internal virtual void Add(ControlImplementation impl)
        {
            Implementations.Add(impl);
            int weight = int.MinValue;
            ControlImplementation heaviest = null;

            foreach (ControlImplementation control in Implementations)
            {
                int w = control.Weight;
                if (w >= weight)
                {
                    weight   = w;
                    heaviest = control;
                }
            }
            if (heaviest != CurrentImpl)
            {
                CurrentImpl = heaviest;
                ImplementationChanged?.Invoke();
            }
        }
 /// <summary>
 /// Adds an implementation to the list of known implementations, then
 /// weighs each of the implementations to determine the best to use.
 /// </summary>
 /// <param name="impl">The new implementation to add.</param>
 internal override void Add(ControlImplementation impl)
 {
 }