Exemplo n.º 1
0
 private void reset()
 {
     this.scheme = null;
     this.authority = null;
     this.path = null;
     this.query = null;
     this.fragment = null;
 }
Exemplo n.º 2
0
        private void read()
        {
            this.reset();

            object obj = this.rule;	// xri

            // read xri_scheme or xri_noscheme from xri

            IList<Rule> list_xri = ((Parser.Parser.xri)obj).rules;
            if (list_xri.Count < 1)
                return;
            obj = list_xri[0];	// xri_scheme or xri_noscheme

            // xri_scheme or xri_noscheme ?

            if (obj is Parser.Parser.xri_scheme)
            {

                // read "xri:" from xri_scheme

                IList<Rule> list_xri_scheme = ((Parser.Parser.xri_scheme)obj).rules;
                if (list_xri_scheme.Count < 1)
                    return;
                obj = list_xri_scheme[0];	// "xri:"
                this.scheme = ((Parser.Parser.StringValue)obj).spelling;

                // read xri_noscheme from xri_scheme

                if (list_xri_scheme.Count < 2)
                    return;
                obj = list_xri_scheme[1];	// xri_noscheme
            }
            else if (obj is Parser.Parser.xri_noscheme)
            {

            }
            else
            {
                throw new InvalidCastException(obj.GetType().Name);
            }

            // read xri_hier_part from xri_noscheme

            IList<Rule> list_xri_noscheme = ((Parser.Parser.xri_noscheme)obj).rules;
            if (list_xri_noscheme.Count < 1)
                return;
            obj = list_xri_noscheme[0];	// xri_hier_part

            // read xri_authority from xri_hier_part

            IList<Rule> list_xri_hier_part = ((Parser.Parser.xri_hier_part)obj).rules;
            if (list_xri_hier_part.Count < 1)
                return;
            obj = list_xri_hier_part[0];	// xri_authority
            this.authority = new XRI3Authority((Parser.Parser.xri_authority)obj);
            if (this.authority.getParserObject().spelling.Length < 1)
                this.authority = null;

            // read xri_path_abempty from xri_hier_part

            if (list_xri_hier_part.Count < 2)
                return;
            obj = list_xri_hier_part[1];	// xri_path_abempty
            this.path = new XRI3Path((Parser.Parser.xri_path_abempty)obj);
            if (this.path.getParserObject().spelling.Length < 1)
                this.path = null;

            // read iquery or ifragment from xri_noscheme

            if (list_xri_noscheme.Count < 3)
                return;
            obj = list_xri_noscheme[2];	// iquery or ifragment

            // iquery or ifragment ?

            if (obj is Parser.Parser.iquery)
            {
                this.query = new XRI3Query((Parser.Parser.iquery)obj);
                if (this.query.getParserObject().spelling.Length < 1)
                    this.query = null;

                // read ifragment from xri_noscheme

                if (list_xri_noscheme.Count < 5)
                    return;
                obj = list_xri_noscheme[4];	// ifragment
                this.fragment = new XRI3Fragment((Parser.Parser.ifragment)obj);
                if (this.fragment.getParserObject().spelling.Length < 1)
                    this.fragment = null;
            }
            else if (obj is Parser.Parser.ifragment)
            {
                this.fragment = new XRI3Fragment((Parser.Parser.ifragment)obj);
                if (this.fragment.getParserObject().spelling.Length < 1)
                    this.fragment = null;
            }
            else
            {
                throw new InvalidCastException(obj.GetType().Name);
            }
        }