Beispiel #1
0
        /// <summary>
        /// Process inner node
        /// </summary>
        /// <param name="context">XML context</param>
        /// <param name="reader">Reader</param>
        protected override void ProcessInnerNode(IXsContext context, XmlReader reader)
        {
            PropertyInfo collProperty = null;

            switch (reader.NodeType)
            {
                case XmlNodeType.Comment:
                    collProperty = FindCollectionForNode(reader);
                    if (collProperty != null)
                        SetChildObject(reader, new Rem(reader.Value), null, collProperty);
                    reader.Read();
                    break;
                case XmlNodeType.ProcessingInstruction:
                    IScriptAction a = null;

                    if (string.Compare(reader.LocalName, "_", StringComparison.OrdinalIgnoreCase) == 0 ||
                        string.Compare(reader.LocalName, "code", StringComparison.OrdinalIgnoreCase) == 0)
                        a = new Code(reader.Value);
                    else if (string.Compare(reader.LocalName, "_d", StringComparison.OrdinalIgnoreCase) == 0 ||
                        string.Compare(reader.LocalName, "codeD", StringComparison.OrdinalIgnoreCase) == 0 ||
                        string.Compare(reader.LocalName, "codeDynamic", StringComparison.OrdinalIgnoreCase) == 0)
                        a = new Code(reader.Value) {Dynamic = true};
                    else if (string.Compare(reader.LocalName, "header", StringComparison.OrdinalIgnoreCase) == 0 ||
                             string.Compare(reader.LocalName, "h", StringComparison.OrdinalIgnoreCase) == 0)
                        a = new Header(reader.Value);
                    else if (string.Compare(reader.LocalName, "headerWithTypes", StringComparison.OrdinalIgnoreCase) == 0 ||
                             string.Compare(reader.LocalName, "ht", StringComparison.OrdinalIgnoreCase) == 0)
                    {
                        var h = new Header(reader.Value) {WithTypes = true};
                        h.RunWithTypes(context);
                        a = h;
                    }
                    else if (string.Compare(reader.LocalName, "rem", StringComparison.OrdinalIgnoreCase) == 0)
                        a = new Rem { Text = reader.Value };
                    else if (string.Compare(reader.LocalName, "xsharper-args", StringComparison.OrdinalIgnoreCase) == 0)
                    {
                        reader.Read();
                        break;
                    }

                    if (a == null)
                        throw new XsException(reader, string.Format("Unexpected processing instruction {0}", reader.Name));

                    if (this is Code)
                    {
                        if (a is Code)
                            ProcessAttribute(context, string.Empty, reader.Value, null);
                        else
                            ((Code) this).Add(a);
                    }
                    else
                    {
                        collProperty = FindCollectionForNode(reader);
                        try
                        {
                            SetChildObject(reader, a, null, collProperty);
                        }
                        catch (XsException)
                        {
                            if (!(a is Rem))
                                throw;

                        }
                    }
                    //    coll.Add(a);

                    reader.Read();
                    break;
                default:
                    base.ProcessInnerNode(context, reader);
                    break;
            }
        }
Beispiel #2
0
        /// <summary>
        /// Process inner node
        /// </summary>
        /// <param name="context">XML context</param>
        /// <param name="reader">Reader</param>
        protected override void ProcessInnerNode(IXsContext context, XmlReader reader)
        {
            PropertyInfo collProperty = null;

            switch (reader.NodeType)
            {
            case XmlNodeType.Comment:
                collProperty = FindCollectionForNode(reader);
                if (collProperty != null)
                {
                    SetChildObject(reader, new Rem(reader.Value), null, collProperty);
                }
                reader.Read();
                break;

            case XmlNodeType.ProcessingInstruction:
                IScriptAction a = null;

                if (string.Compare(reader.LocalName, "_", StringComparison.OrdinalIgnoreCase) == 0 ||
                    string.Compare(reader.LocalName, "code", StringComparison.OrdinalIgnoreCase) == 0)
                {
                    a = new Code(reader.Value);
                }
                else if (string.Compare(reader.LocalName, "_d", StringComparison.OrdinalIgnoreCase) == 0 ||
                         string.Compare(reader.LocalName, "codeD", StringComparison.OrdinalIgnoreCase) == 0 ||
                         string.Compare(reader.LocalName, "codeDynamic", StringComparison.OrdinalIgnoreCase) == 0)
                {
                    a = new Code(reader.Value)
                    {
                        Dynamic = true
                    }
                }
                ;
                else if (string.Compare(reader.LocalName, "header", StringComparison.OrdinalIgnoreCase) == 0 ||
                         string.Compare(reader.LocalName, "h", StringComparison.OrdinalIgnoreCase) == 0)
                {
                    a = new Header(reader.Value);
                }
                else if (string.Compare(reader.LocalName, "headerWithTypes", StringComparison.OrdinalIgnoreCase) == 0 ||
                         string.Compare(reader.LocalName, "ht", StringComparison.OrdinalIgnoreCase) == 0)
                {
                    var h = new Header(reader.Value)
                    {
                        WithTypes = true
                    };
                    h.RunWithTypes(context);
                    a = h;
                }
                else if (string.Compare(reader.LocalName, "rem", StringComparison.OrdinalIgnoreCase) == 0)
                {
                    a = new Rem {
                        Text = reader.Value
                    }
                }
                ;
                else if (string.Compare(reader.LocalName, "xsharper-args", StringComparison.OrdinalIgnoreCase) == 0)
                {
                    reader.Read();
                    break;
                }


                if (a == null)
                {
                    throw new XsException(reader, string.Format("Unexpected processing instruction {0}", reader.Name));
                }


                if (this is Code)
                {
                    if (a is Code)
                    {
                        ProcessAttribute(context, string.Empty, reader.Value, null);
                    }
                    else
                    {
                        ((Code)this).Add(a);
                    }
                }
                else
                {
                    collProperty = FindCollectionForNode(reader);
                    try
                    {
                        SetChildObject(reader, a, null, collProperty);
                    }
                    catch (XsException)
                    {
                        if (!(a is Rem))
                        {
                            throw;
                        }
                    }
                }
                //    coll.Add(a);

                reader.Read();
                break;

            default:
                base.ProcessInnerNode(context, reader);
                break;
            }
        }