/// <summary>
        /// Adds a new settings entry in the list, or update an existing one.
        /// </summary>
        /// <param name="_TargetType">The target type of the custom editor.</param>
        /// <param name="_CreateEditorMethod">The method to use to create an instance of the custom editor extension.</param>
        /// <param name="_DefaultOptions">The default options to use for the custom editor extension.</param>
        /// <returns>Returns the created settings.</returns>
        private CustomEditorExtensionSettings AddOrUpdateCustomEditorSettings(CreateEditorDelegate _CreateEditorMethod, Type _TargetType, CustomEditorExtensionOptions _DefaultOptions)
        {
            Type customEditorType = _CreateEditorMethod.Invoke().GetType();

            // Gets the existing settings for the custom inspector.
            CustomEditorExtensionSettings settings = m_CustomEditorSettings.Find(currentSettings => { return(currentSettings.CustomEditorType == customEditorType); });

            // Update the existing settings if it exists
            if (settings != null)
            {
                settings.Update(_TargetType, _CreateEditorMethod, _DefaultOptions);
            }
            // If no matching settings has been found, create a new one using the given params, and add it to the list
            else
            {
                settings = new CustomEditorExtensionSettings(_TargetType, customEditorType, _CreateEditorMethod, _DefaultOptions);
                m_CustomEditorSettings.Add(settings);
            }

            m_CustomEditorSettings.Sort();
            return(settings);
        }
 /// <summary>
 /// Registers a CustomEditorExtension that customizes the inspector of the given target type.
 /// </summary>
 /// <typeparam name="TTarget">The type of the decorated Object.</typeparam>
 /// <param name="_CustomEditorCreator">The method to use to instantiate a CustomObectEditor.</param>
 /// <param name="_Options">The options and default values to use for the CustomEditorExtension.</param>
 /// <returns>Returns true if the CustomEditorExtension has successfully been registered, otherwise false.</returns>
 public static bool RegisterCustomEditor <TTarget>(CreateEditorDelegate _CustomEditorCreator, CustomEditorExtensionOptions _Options)
     where TTarget : Object
 {
     Instance.AddOrUpdateCustomEditorSettings <TTarget>(_CustomEditorCreator, _Options);
     return(true);
 }
 /// <summary>
 /// Registers a CustomEditorExtension that customizes the inspector of the given target type.
 /// </summary>
 /// <typeparam name="TTarget">The type of the decorated Object.</typeparam>
 /// <param name="_CustomEditorCreator">The method to use to instantiate a CustomObectEditor.</param>
 /// <returns>Returns true if the CustomEditorExtension has successfully been registered, otherwise false.</returns>
 public static bool RegisterCustomEditor <TTarget>(CreateEditorDelegate _CustomEditorCreator)
     where TTarget : Object
 {
     return(RegisterCustomEditor <TTarget>(_CustomEditorCreator, CustomEditorExtensionOptions.Default));
 }
 /// <summary>
 /// Adds a new settings entry in the list, or update an existing one.
 /// </summary>
 /// <typeparam name="TTarget">The target type of the custom editor.</typeparam>
 /// <param name="_CreateEditorMethod">The method to use to create an instance of the custom editor extension.</param>
 /// <param name="_DefaultOptions">The default options to use for the custom editor extension.</param>
 /// <returns>Returns the created settings.</returns>
 private CustomEditorExtensionSettings AddOrUpdateCustomEditorSettings <TTarget>(CreateEditorDelegate _CreateEditorMethod, CustomEditorExtensionOptions _DefaultOptions)
     where TTarget : Object
 {
     return(AddOrUpdateCustomEditorSettings(_CreateEditorMethod, typeof(TTarget), _DefaultOptions));
 }
Exemple #5
0
 protected Descriptor(
     DescriptorType descriptorType,
     Type type,
     string header,
     GetGolumnsDelegate getColumns,
     CreateEditorDelegate createEditor,
     DocumentTypeEnum? documentType = null,
     RefBookTypeEnum? refBookType = null,
     ReportTypeEnum? reportType = null)
 {
     this.descriptorType = descriptorType;
     this.type = type;
     this.header = header;
     this.getColumns = getColumns;
     this.createEditor = createEditor;
     if (documentType.HasValue)
     {
         this.documentType = documentType.Value;
     }
     if (refBookType.HasValue)
     {
         this.refBookType = refBookType.Value;
     }
     if (reportType.HasValue)
     {
         this.reportType = reportType.Value;
     }
 }