Exemple #1
0
 public ExtensionEntry(Type extensionType, ExtensionServer server, Type overriddenExtensionType, int order)
 {
     this.ExtensionType = extensionType;
     this.Server        = server;
     this.OverriddenExtensionTypes.Add(overriddenExtensionType);
     this.Order = order;
 }
Exemple #2
0
 public ExtensionEntry(Type extensionType, ExtensionServer server, List <Type> overriddenExtensionTypes,
                       int order)
 {
     this.ExtensionType            = extensionType;
     this.Server                   = server;
     this.OverriddenExtensionTypes = overriddenExtensionTypes;
     this.Order = order;
 }
Exemple #3
0
 /// <summary>
 /// Re-applies extensions from the ExtensionServer to the specified design items.
 /// </summary>
 void ReapplyExtensions(IEnumerable <DesignItem> items, ExtensionServer server)
 {
     foreach (DesignItem item in items)
     {
         if (item != null)
         {
             item.ReapplyExtensionServer(this, server);
         }
     }
 }
Exemple #4
0
        internal IEnumerable <Extension> CreateExtensions(ExtensionServer server, DesignItem item)
        {
            Debug.Assert(server != null);
            Debug.Assert(item != null);

            foreach (ExtensionEntry entry in GetExtensionEntries(item))
            {
                if (entry.Server == server)
                {
                    var disabledExtensions = Extension.GetDisabledExtensions(item.View);
                    if (string.IsNullOrEmpty(disabledExtensions) ||
                        !disabledExtensions.Split(';').Contains(entry.ExtensionType.Name))
                    {
                        yield return(server.CreateExtension(entry.ExtensionType, item));
                    }
                }
            }
        }
Exemple #5
0
        /// <summary>
        /// Registers extensions from the specified assembly.
        /// </summary>
        public void RegisterAssembly(Assembly assembly)
        {
            if (assembly == null)
            {
                throw new ArgumentNullException("assembly");
            }

//			object[] assemblyAttributes = assembly.GetCustomAttributes(typeof(IsWpfDesignerAssemblyAttribute), false);
//			if (assemblyAttributes.Length == 0)
//				return;

            if (!_registeredAssemblies.Add(assembly))
            {
                // the assembly already is registered, don't try to register it again.
                return;
            }

//			IsWpfDesignerAssemblyAttribute isWpfDesignerAssembly = (IsWpfDesignerAssemblyAttribute)assemblyAttributes[0];
//			foreach (Type type in isWpfDesignerAssembly.UsePrivateReflection ? assembly.GetTypes() : assembly.GetExportedTypes()) {
            foreach (Type type in assembly.GetTypes())
            {
                object[] extensionForAttributes = type.GetCustomAttributes(typeof(ExtensionForAttribute), false);
                if (extensionForAttributes.Length == 0)
                {
                    continue;
                }

                foreach (ExtensionForAttribute designerFor in extensionForAttributes)
                {
                    ExtensionServer    server             = GetServerForExtension(type);
                    ExtensionAttribute extensionAttribute =
                        type.GetCustomAttributes(typeof(ExtensionAttribute), false)
                        .FirstOrDefault() as ExtensionAttribute;
                    AddExtensionEntry(designerFor.DesignedItemType,
                                      new ExtensionEntry(type, server, designerFor.OverrideExtensions.ToList(),
                                                         extensionAttribute != null ? extensionAttribute.Order : 0));
                }
            }
        }