Ejemplo n.º 1
0
        private void AddObject(Asn1Object current)
        {
            if (_filterStack == null)
            {
                _filterStack = new Stack <Asn1Object>();
            }

            if (ChoiceValue == null)
            {
                // ChoiceValue is the root Asn1 node
                ChoiceValue = current;
            }
            else
            {
                var topOfStack = (Asn1Tagged)_filterStack.Peek();
                var value      = topOfStack.TaggedValue;

                switch (value)
                {
                case null:
                    topOfStack.TaggedValue = current;
                    _filterStack.Push(current);
                    break;

                case Asn1SetOf _:
                    ((Asn1SetOf)value).Add(current);
                    break;

                case Asn1Set _:
                    ((Asn1Set)value).Add(current);
                    break;

                default:
                    if (value.GetIdentifier().Tag == (int)FilterOp.Not)
                    {
                        throw new LdapException("Attemp to create more than one 'not' sub-filter",
                                                LdapStatusCode.FilterError);
                    }

                    break;
                }
            }

            var type = (FilterOp)current.GetIdentifier().Tag;

            if (type == FilterOp.And || type == FilterOp.Or || type == FilterOp.Not)
            {
                _filterStack.Push(current);
            }
        }