/// <summary> /// Unregisters a content handler /// </summary> /// <param name="handler">The handler to remove</param> /// <returns></returns> public bool Unregister(IContentHandler handler) { NewContentAttribute[] handlerAttributes = (NewContentAttribute[])(handler.GetType()).GetCustomAttributes(typeof(NewContentAttribute), true); _availableNewContent.RemoveAll(handlerAttributes.Contains); foreach (NewContentAttribute newContentAttribute in handlerAttributes) { _dictionary.Remove(newContentAttribute); } _availableNewContent.Sort((attribute, contentAttribute) => attribute.Priority - contentAttribute.Priority); return(ContentHandlers.Remove(handler)); }
/// <summary> /// Register a content handler with the registry /// </summary> /// <param name="handler">The content handler</param> /// <returns>true, if successful - false, otherwise</returns> public bool Register(IContentHandler handler) { ContentHandlers.Add(handler); NewContentAttribute[] handlerAttributes = (NewContentAttribute[])(handler.GetType()).GetCustomAttributes(typeof(NewContentAttribute), true); _availableNewContent.AddRange(handlerAttributes); foreach (NewContentAttribute newContentAttribute in handlerAttributes) { _dictionary.Add(newContentAttribute, handler); } _availableNewContent.Sort((attribute, contentAttribute) => attribute.Priority - contentAttribute.Priority); return(true); }
/// <summary> /// Unregisters a content handler /// </summary> /// <param name="handler">The handler to remove</param> /// <returns></returns> public bool Unregister(IContentHandler handler) { NewContentAttribute[] handlerAttributes = (NewContentAttribute[])(handler.GetType()).GetCustomAttributes(typeof(NewContentAttribute), true); _availableNewContent.RemoveAll(handlerAttributes.Contains); foreach (NewContentAttribute newContentAttribute in handlerAttributes) { _dictionary.Remove(newContentAttribute); } _availableNewContent.Sort((attribute, contentAttribute) => attribute.Priority - contentAttribute.Priority); return ContentHandlers.Remove(handler); }
/// <summary> /// Register a content handler with the registry /// </summary> /// <param name="handler">The content handler</param> /// <returns>true, if successful - false, otherwise</returns> public bool Register(IContentHandler handler) { ContentHandlers.Add(handler); NewContentAttribute[] handlerAttributes = (NewContentAttribute[])(handler.GetType()).GetCustomAttributes(typeof(NewContentAttribute), true); _availableNewContent.AddRange(handlerAttributes); foreach (NewContentAttribute newContentAttribute in handlerAttributes) { _dictionary.Add(newContentAttribute, handler); } _availableNewContent.Sort((attribute, contentAttribute) => attribute.Priority - contentAttribute.Priority); return true; }