コード例 #1
0
        public NodePickerConfigAttribute(int minimumItems = -1, 
										 int maximumItems = -1, 
										 Type[] allowedDescendants = null, 
										 string startNode = null, 
										 StartNodeSpecifier startNodeSpecifier = StartNodeSpecifier.Path, 
										 bool showOpenButton = false, 
										 bool showEditButton = false, 
										 bool showPathsWhenHovering = false)
        {
            _minimumItems = minimumItems;
            _maximumItems = maximumItems;
            _startNodeMode = startNodeSpecifier;
            _startNodeInput = startNode;
            _allowedDescendants = allowedDescendants;
            _showOpenButton = showOpenButton;
            _showEditButton = showEditButton;
            _showPathsWhenHovering = showPathsWhenHovering;
        }
コード例 #2
0
 public NodePickerConfigAttribute(int minimumItems                      = -1,
                                  int maximumItems                      = -1,
                                  Type[] allowedDescendants             = null,
                                  string startNode                      = null,
                                  StartNodeSpecifier startNodeSpecifier = StartNodeSpecifier.Path,
                                  bool showOpenButton                   = false,
                                  bool showEditButton                   = false,
                                  bool showPathsWhenHovering            = false)
 {
     _minimumItems          = minimumItems;
     _maximumItems          = maximumItems;
     _startNodeMode         = startNodeSpecifier;
     _startNodeInput        = startNode;
     _allowedDescendants    = allowedDescendants;
     _showOpenButton        = showOpenButton;
     _showEditButton        = showEditButton;
     _showPathsWhenHovering = showPathsWhenHovering;
 }
コード例 #3
0
        private void Init(string memberName)
        {
            if (_allowedDescendants == null)
            {
                _allowedDescendants = new Type[] { };
            }

            if (_basis != null)
            {
                _allowedDescendants = _allowedDescendants.Union(_basis.AllowedDescendants).ToArray();
                if (_minimumItems == -1)
                {
                    _minimumItems = _basis._maximumItems;
                }
                if (_maximumItems == -1)
                {
                    _maximumItems = _basis._maximumItems;
                }
                if (_startNodeInput == null)
                {
                    _startNodeInput = _basis._startNodeInput;
                    _startNodeMode = _basis._startNodeMode;
                }
            }

            foreach (var desc in _allowedDescendants)
            {
                if (!desc.Inherits(_targetType))
                {
                    throw new CodeFirstException("Specified allowed descendant " + desc.Name + " does not inherit target type " + _targetType.Name + ". Affected node picker: " + memberName);
                }
                else if (desc.GetCodeFirstAttribute<ContentTypeAttribute>() == null)
                {
                    throw new CodeFirstException("Specified allowed descendant " + desc.Name + " does not have a [ContentType] attribute (e.g. [DocumentType], [MediaType]). Affected node picker: " + memberName);
                }
            }

            switch (_startNodeMode)
            {
                case StartNodeSpecifier.Path:
                    try
                    {
                        _startNodeId = GetNodeIdFromPath(_startNodeInput);
                    }
                    catch (Exception ex)
                    {
                        throw new CodeFirstException("Unexpected error when initialising [NodePickerConfigAttribute] with StartNodeSpecifier.Path and input string " + (string.IsNullOrWhiteSpace(_startNodeInput) ? "[null or empty]" : _startNodeInput) + ". Affected node picker: " + memberName, ex);
                    }
                    break;
                case StartNodeSpecifier.Id:
                    try
                    {
                        _startNodeId = int.Parse(_startNodeInput);
                    }
                    catch (Exception ex)
                    {
                        throw new CodeFirstException("startNode must be a string representation of a valid integer if StartNodeSpecifier.Id is specified. Affected member: " + memberName, ex);
                    }
                    break;
                default:
                    throw new CodeFirstException("StartNodeSpecifier type " + _startNodeMode.ToString() + " is not supported. Affected member: " + memberName);
            }
            _initialised = true;
        }
コード例 #4
0
        private void Init(string memberName)
        {
            if (_allowedDescendants == null)
            {
                _allowedDescendants = new Type[] { };
            }

            if (_basis != null)
            {
                _allowedDescendants = _allowedDescendants.Union(_basis.AllowedDescendants).ToArray();
                if (_minimumItems == -1)
                {
                    _minimumItems = _basis._maximumItems;
                }
                if (_maximumItems == -1)
                {
                    _maximumItems = _basis._maximumItems;
                }
                if (_startNodeInput == null)
                {
                    _startNodeInput = _basis._startNodeInput;
                    _startNodeMode  = _basis._startNodeMode;
                }
            }

            foreach (var desc in _allowedDescendants)
            {
                if (!desc.Inherits(_targetType))
                {
                    throw new CodeFirstException("Specified allowed descendant " + desc.Name + " does not inherit target type " + _targetType.Name + ". Affected node picker: " + memberName);
                }
                else if (desc.GetCodeFirstAttribute <ContentTypeAttribute>() == null)
                {
                    throw new CodeFirstException("Specified allowed descendant " + desc.Name + " does not have a [ContentType] attribute (e.g. [DocumentType], [MediaType]). Affected node picker: " + memberName);
                }
            }

            switch (_startNodeMode)
            {
            case StartNodeSpecifier.Path:
                try
                {
                    _startNodeId = GetNodeIdFromPath(_startNodeInput);
                }
                catch (Exception ex)
                {
                    throw new CodeFirstException("Unexpected error when initialising [NodePickerConfigAttribute] with StartNodeSpecifier.Path and input string " + (string.IsNullOrWhiteSpace(_startNodeInput) ? "[null or empty]" : _startNodeInput) + ". Affected node picker: " + memberName, ex);
                }
                break;

            case StartNodeSpecifier.Id:
                try
                {
                    _startNodeId = int.Parse(_startNodeInput);
                }
                catch (Exception ex)
                {
                    throw new CodeFirstException("startNode must be a string representation of a valid integer if StartNodeSpecifier.Id is specified. Affected member: " + memberName, ex);
                }
                break;

            default:
                throw new CodeFirstException("StartNodeSpecifier type " + _startNodeMode.ToString() + " is not supported. Affected member: " + memberName);
            }
            _initialised = true;
        }