Beispiel #1
0
        public GoodsFiller(int link_id, IDataBase cdb, IXMLReader xreader, decimal userSale)
        {
            this.XGoods = new dev_xml_goods();

            this.cdb = cdb;
            this.cdb.SetStoredProcedure("WebSite.GetGoodsXML");
            this.cdb.AddParameter(new SqlParameter("@Link_id", link_id));
            this.cdb.AddParameter(new SqlParameter("@UserSale", userSale));

            this.xreader = xreader;
            this.xreader.LoadXML(this.cdb.GetScalarValue());

            XGoods.Brand_id = this.xreader.GetAttribute<int>("brand_id", 0);
            XGoods.Link_id = this.xreader.GetAttribute<int>("link_id", 0);
            XGoods.Group_id = this.xreader.GetAttribute<int>("group_id", 0);
            XGoods.Root = this.xreader.GetAttribute<int>("root", 0);
            XGoods.Sound = this.xreader.GetAttribute<int>("sound", 0);
            XGoods.Info = this.xreader.GetAttribute<int>("info", 0);
            XGoods.Consists_id = this.xreader.GetAttribute<int>("consists_id", 0);
            XGoods.Country_id = this.xreader.GetAttribute<int>("country_id", 0);
            XGoods.Gtype_id = this.xreader.GetAttribute<int>("gtype_id", 0);
            XGoods.Seria_id = this.xreader.GetAttribute<int>("seria_id", 0);
            XGoods.Weight = this.xreader.GetAttribute<decimal>("weight", 0);
            XGoods.Sale = this.xreader.GetAttribute<byte>("sale", 0);
            XGoods.Seria_name = this.xreader.GetAttribute<string>("seria_name", "");
            XGoods.Consists_name = this.xreader.GetAttribute<string>("consists_name", "");
            XGoods.Gtype_name = this.xreader.GetAttribute<string>("gtype_name", "");
            XGoods.Country_name = this.xreader.GetAttribute<string>("country_name", "");
            XGoods.UT_video = this.xreader.GetAttribute<string>("ut_video", "");
            XGoods.Name = this.xreader.GetAttribute<string>("name", "");
            XGoods.Brand_name = this.xreader.GetAttribute<string>("brand_name", "");
            XGoods.HasImg = this.xreader.GetAttribute<string>("has_img", "0").Equals("1") ? true : false;
            XGoods.Descr = this.xreader.GetValue<string>("//link/descr", "").Replace(@"\n", "<br/>");
            XGoods.Descr_Seo = this.xreader.GetValue<string>("//link/descr_seo", "");

            //filling goods properies
            XmlNodeList goodsList = this.xreader.GetXmlNodes("//link//goods//good");
            foreach (XmlNode child in goodsList)
            {
                SGoodsFiller sgFiller = new SGoodsFiller(child, this.xreader);
                XGoods.Items.Add(sgFiller.XSGoods);
            }

            //filling goods mechs
            XmlNodeList mechList = this.xreader.GetXmlNodes("//link//mechs//mech");
            foreach (XmlNode child in mechList)
            {
                GoodsMechsFiller smFiller = new GoodsMechsFiller(child, this.xreader);
                XGoods.Mechs.Add(smFiller.Mech);
            }

            //filling goods sames
            XmlNodeList sameList = this.xreader.GetXmlNodes("//link//sames//same");
            foreach (XmlNode child in sameList)
            {
                GoodsSamesFiller gsameFiller = new GoodsSamesFiller(child, this.xreader);
                XGoods.Sames.Add(gsameFiller.Same);
            }
        }
Beispiel #2
0
        public void HandleTag(bool opening, string tag, IEditable output, IXMLReader xmlReader)
        {
            if (tag.Equals("ul"))
            {
                parent = "ul";
            }
            else if (tag.Equals("ol"))
            {
                parent = "ol";
            }

            if (tag.Equals("li"))
            {
                char lastChar = '0';
                if (output.Length() > 0)
                {
                    lastChar = output.CharAt(output.Length() - 1);
                }
                if (parent.Equals("ul"))
                {
                    if (first)
                    {
                        if (lastChar == '\n')
                        {
                            output.Append("\t•  ");
                        }
                        else
                        {
                            output.Append("\n\t•  ");
                        }
                        first = false;
                    }
                    else
                    {
                        first = true;
                    }
                }
                else
                {
                    if (first)
                    {
                        if (lastChar == '\n')
                        {
                            output.Append("\t" + index + ". ");
                        }
                        else
                        {
                            output.Append("\n\t" + index + ". ");
                        }
                        first = false;
                        index++;
                    }
                    else
                    {
                        first = true;
                    }
                }
            }
        }
Beispiel #3
0
        public void HandleTag(bool opening, string tag, IEditable output, IXMLReader xmlReader)
        {
            if (tag.Equals("ulc"))
            {
                _parent = "ulc";
                _index  = 1;
            }
            else if (tag.Equals("olc"))
            {
                _parent = "olc";
                _index  = 1;
            }

            if (!tag.Equals("lic"))
            {
                return;
            }

            var lastChar = (char)0;

            if (output.Length() > 0)
            {
                lastChar = output.CharAt(output.Length() - 1);
            }

            if (_parent.Equals("ulc"))
            {
                if (_first)
                {
                    output.Append(lastChar == '\n' ? "\t•  " : "\n\t•  ");
                    _first = false;
                }
                else
                {
                    _first = true;
                }
            }
            else
            {
                if (_first)
                {
                    if (lastChar == '\n')
                    {
                        output.Append("\t" + _index + ". ");
                    }
                    else
                    {
                        output.Append("\n\t" + _index + ". ");
                    }
                    _first = false;
                    _index++;
                }
                else
                {
                    _first = true;
                }
            }
        }
Beispiel #4
0
        /// <summary>
        /// Initializes a new instance of the <see cref="T:TextStyles.Android.CustomHtmlParser"/> class.
        /// </summary>
        /// <param name="source">Source.</param>
        /// <param name="textStyles">Text styles.</param>
        /// <param name="defaultStyleID">Default style identifier.</param>
        public CustomHtmlParser(string source, Dictionary <string, TextStyleParameters> textStyles, string defaultStyleID = null)
        {
            _htmlSource   = source;
            _styles       = textStyles;
            _defaultStyle = String.IsNullOrEmpty(defaultStyleID) ? null : _styles [defaultStyleID];

            _spannableStringBuilder = new SpannableStringBuilder();
            _reader      = XMLReaderFactory.CreateXMLReader("org.ccil.cowan.tagsoup.Parser");
            _imageGetter = null;
            _tagHandler  = new CustomTagHandler(textStyles);
        }
Beispiel #5
0
 public void HandleTag(bool opening, string tag, IEditable output, IXMLReader xmlReader)
 {
     tag = tag.ToLowerInvariant();
     if (tag == "hr" && opening)
     {
         output.Append("---------------------------------------------\r\n");
     }
     else if (TAGS_WITH_IGNORED_CONTENT.Contains(tag))
     {
         HandleIgnoredTag(opening, output);
     }
 }
 public void HandleTag(bool opening, string tag, IEditable output, IXMLReader xmlReader)
 {
     Console.WriteLine("Tag:" + tag);
     if (tag.Equals("ulc") && !opening)
     {
         output.Append("\n");
     }
     else if (tag.Equals("lic") && opening)
     {
         output.Append("\n\t•\t");
     }
 }
Beispiel #7
0
        /// <summary>
        /// Initializes a new instance of the <see cref="T:TextStyles.Android.CustomHtmlParser"/> class.
        /// </summary>
        /// <param name="source">Source.</param>
        /// <param name="textStyles">Text styles.</param>
        /// <param name="defaultStyleID">Default style identifier.</param>
        public CustomHtmlParser(TextStyle instance, string source, Dictionary <string, TextStyleParameters> textStyles, string defaultStyleID = null)
        {
            _instance   = instance;
            _htmlSource = source;
            _styles     = textStyles;

            if (!String.IsNullOrEmpty(defaultStyleID) && _styles.ContainsKey(defaultStyleID))
            {
                _defaultStyle = _styles [defaultStyleID];
            }

            _spannableStringBuilder = new SpannableStringBuilder();
            _reader      = XMLReaderFactory.CreateXMLReader("org.ccil.cowan.tagsoup.Parser");
            _imageGetter = null;
            _tagHandler  = new CustomTagHandler(_instance, _styles);
        }
        public void HandleTag(bool opening, string tag, IEditable output, IXMLReader xmlReader)
        {
            switch (tag)
            {
            case UL_Tag:
                if (opening)
                {
                    _lists.Push(new UlTag(LeadingMargin));
                }
                else
                {
                    _lists.Pop();
                }
                break;

            case OL_Tag:
                if (opening)
                {
                    _lists.Push(new OlTag(LeadingMargin));
                }
                else
                {
                    _lists.Pop();
                }
                break;

            case LI_Tag:
                if (opening)
                {
                    _lists.Peek().OpenItem(output);
                }
                else
                {
                    _lists.Peek().CloseItem(output);
                }
                break;

            default:
                Debug.WriteLine($"Unknow HTML tag: {tag}");
                break;
            }
        }
 public void HandleTag(bool opening, string tag, IEditable output, IXMLReader xmlReader)
 {
     tag = tag.ToUpperInvariant();
     if (tag.Equals("LIC", StringComparison.Ordinal))
     {
         _listBuilder.Li(opening, output);
         return;
     }
     if (tag.Equals("OLC", StringComparison.Ordinal) || tag.Equals("ULC", StringComparison.Ordinal))
     {
         if (opening)
         {
             _listBuilder = _listBuilder.StartList(tag[0] == 'o', output);
         }
         else
         {
             _listBuilder = _listBuilder.CloseList(output);
         }
         return;
     }
 }
 protected override IDanmakus Parse()
 {
     try
     {
         if (MDataSource != null)
         {
             AndroidFileSource source         = (AndroidFileSource)MDataSource;
             IXMLReader        xmlReader      = XMLReaderFactory.CreateXMLReader();
             XmlContentHandler contentHandler = new XmlContentHandler(this);
             xmlReader.ContentHandler = contentHandler;
             var inputSource = new InputSource(source.DataStream);
             xmlReader.Parse(inputSource);
             return(contentHandler.Result);
         }
     }
     catch (Exception ex)
     {
         Debug.WriteLine(ex.Message);
     }
     return(new Danmakus());
 }
Beispiel #11
0
        public void HandleTag(bool isOpening, string tag, IEditable output, IXMLReader xmlReader)
        {
            tag = tag.ToUpperInvariant();
            var isItem = tag == TagLi;

            // Is list item
            if (isItem)
            {
                _listBuilder.AddListItem(isOpening, output);
            }
            // Is list
            else
            {
                if (isOpening)
                {
                    var isOrdered = tag == TagOl;
                    _listBuilder = _listBuilder.StartList(isOrdered, output);
                }
                else
                {
                    _listBuilder = _listBuilder.CloseList(output);
                }
            }
        }
Beispiel #12
0
 /// <summary>
 /// Construct an XML filter with the specified parent.
 /// </summary>
 /// <param name="parent">The parent</param>
 /// <seealso cref="Parent" />
 public XMLFilter(IXMLReader parent)
 {
     this.parent = parent;
 }
Beispiel #13
0
 public BookRepository()
 {
     xmlReader = DataAccess._dependecyContainer.GetInstance <IXMLReader>();
 }
Beispiel #14
0
 public UserRepository(IXMLReader xMLReader)
 {
     _xMLReader = xMLReader;
     ReadAll();
 }
Beispiel #15
0
        public void HandleTag(bool opening, string tag, Android.Text.IEditable output, IXMLReader xmlReader)
        {
            if (opening)
            {
                // opening tag
                //          if (HtmlTextView.DEBUG) {
                //              Log.d(HtmlTextView.TAG, "opening, output: " + output.ToString());
                //          }

                if (tag.ToLower() == "ul")
                {
                    lists.Push(tag);
                }
                else if (tag.EqualsIgnoreCase("ol"))
                {
                    lists.Push(tag);
                    olNextIndex.Push(1);
                }
                else if (tag.EqualsIgnoreCase("li"))
                {
                    if (output.Length() > 0 && output.CharAt(output.Length() - 1) != '\n')
                    {
                        output.Append("\n");
                    }
                    var parentList = lists.Peek();
                    if (parentList.EqualsIgnoreCase("ol"))
                    {
                        Start(output, new Ol());
                        output.Append(olNextIndex.Peek().ToString()).Append('.').Append(' ');
                        olNextIndex.Push(olNextIndex.Pop() + 1);
                    }
                    else if (parentList.EqualsIgnoreCase("ul"))
                    {
                        Start(output, new Ul());
                    }
                }
                else if (tag.EqualsIgnoreCase("code"))
                {
                    Start(output, new Code());
                }
                else if (tag.EqualsIgnoreCase("center"))
                {
                    Start(output, new Center());
                }
                else if (tag.EqualsIgnoreCase("s") || tag.EqualsIgnoreCase("strike"))
                {
                    Start(output, new Strike());
                }
            }
            else
            {
                // closing tag
                //          if (HtmlTextView.DEBUG) {
                //              Log.d(HtmlTextView.TAG, "closing, output: " + output.ToString());
                //          }

                if (tag.EqualsIgnoreCase("ul"))
                {
                    lists.Pop();
                }
                else if (tag.EqualsIgnoreCase("ol"))
                {
                    lists.Pop();
                    olNextIndex.Pop();
                }
                else if (tag.EqualsIgnoreCase("li"))
                {
                    if (lists.Peek().EqualsIgnoreCase("ul"))
                    {
                        if (output.Length() > 0 && output.CharAt(output.Length() - 1) != '\n')
                        {
                            output.Append("\n");
                        }

                        // Nested BulletSpans increases distance between bullet and Text, so we must prevent it.
                        int bulletMargin = indent;
                        if (lists.Count > 1)
                        {
                            bulletMargin = indent - bullet.GetLeadingMargin(true);
                            if (lists.Count > 2)
                            {
                                // This get's more complicated when we add a LeadingMarginSpan into the same line:
                                // we have also counter it's effect to BulletSpan
                                bulletMargin -= (lists.Count - 2) * listItemIndent;
                            }
                        }
                        BulletSpan newBullet = new BulletSpan(bulletMargin);
                        End(
                            output,
                            typeof(Ul),
                            false,
                            new LeadingMarginSpanStandard(listItemIndent * (lists.Count - 1)),
                            newBullet);
                    }
                    else if (lists.Peek().EqualsIgnoreCase("ol"))
                    {
                        if (output.Length() > 0 && output.CharAt(output.Length() - 1) != '\n')
                        {
                            output.Append("\n");
                        }
                        int numberMargin = listItemIndent * (lists.Count - 1);
                        if (lists.Count > 2)
                        {
                            // Same as in ordered lists: counter the effect of nested Spans
                            numberMargin -= (lists.Count - 2) * listItemIndent;
                        }
                        End(output, typeof(Ol), false, new LeadingMarginSpanStandard(numberMargin));
                    }
                }
                else if (tag.EqualsIgnoreCase("code"))
                {
                    End(output, typeof(Code), false, new TypefaceSpan("monospace"));
                }
                else if (tag.EqualsIgnoreCase("center"))
                {
                    End(output, typeof(Center), true, new AlignmentSpanStandard(Layout.Alignment.AlignCenter));
                }
                else if (tag.EqualsIgnoreCase("s") || tag.EqualsIgnoreCase("strike"))
                {
                    End(output, typeof(Strike), false, new StrikethroughSpan());
                }
            }
        }
Beispiel #16
0
 public PerformLookup(IXMLParser xmlParser, IXMLReader xmlReader)
 {
     this.xmlParser = xmlParser;
     this.xmlReader = xmlReader;
 }
Beispiel #17
0
 public SGoodsFiller(XmlNode node, IXMLReader xreader)
 {
     this.xreader = xreader;
     XSGoods = new dev_xml_subgoods();
     FillSGoods(node);
 }
Beispiel #18
0
 public SGoodsSizeFiller(XmlNode node, IXMLReader xreader)
 {
     this.xreader = xreader;
     XSize = new dev_xml_size();
     FillSGoodsSizes(node);
 }
Beispiel #19
0
 public MoviesData(IXMLReader xmlReader)
 {
     this.xmlReader = xmlReader;
 }
Beispiel #20
0
 public void HandleTag( Boolean opening, String tag, Android.Text.IEditable output,  IXMLReader xmlReader)
 {
     if (opening) {
         // opening tag
         //          if (HtmlTextView.DEBUG) {
         //              Log.d(HtmlTextView.TAG, "opening, output: " + output.ToString());
         //          }
         //
         if (tag.ToLower() == "ul") {
             lists.Push(tag);
         } else if (tag.Equals("ol")) {
             lists.Push(tag);
             olNextIndex.Push(1);
         } else if (tag.Equals("li")) {
             if (output.Length() > 0 && output.CharAt(output.Length() - 1) != '\n') {
                 output.Append("\n");
             }
             String parentList = lists.Peek();
             if (parentList.Equals("ol")) {
                 start(output, new Ol());
                 output.Append(olNextIndex.Peek().ToString()).Append('.').Append(' ');
                 olNextIndex.Push(olNextIndex.Pop() + 1);
             } else if (parentList.Equals("ul")) {
                 start(output, new Ul());
             }
         } else if (tag.Equals("code")) {
             start(output, new Code());
         } else if (tag.Equals("center")) {
             start(output, new Center());
         } else if (tag.Equals("s") || tag.Equals("strike")) {
             start(output, new Strike());
         }
     } else {
         // closing tag
         //          if (HtmlTextView.DEBUG) {
         //              Log.d(HtmlTextView.TAG, "closing, output: " + output.ToString());
         //          }
         //
         if (tag.Equals("ul")) {
             lists.Pop();
         } else if (tag.Equals("ol")) {
             lists.Pop();
             olNextIndex.Pop();
         } else if (tag.Equals("li")) {
             if (lists.Peek().Equals("ul")) {
                 if (output.Length() > 0 && output.CharAt(output.Length() - 1) != '\n') {
                     output.Append("\n");
                 }
                 // Nested BulletSpans increases distance between bullet and Text, so we must prevent it.
                 int bulletMargin = indent;
                 if (lists.Count > 1) {
                     bulletMargin = indent - bullet.GetLeadingMargin(true);
                     if (lists.Count > 2) {
                         // This get's more complicated when we add a LeadingMarginSpan into the same line:
                         // we have also counter it's effect to BulletSpan
                         bulletMargin -= (lists.Count - 2) * listItemIndent;
                     }
                 }
                 BulletSpan newBullet = new BulletSpan(bulletMargin);
                 end(output, typeof(Ul), false,
                     new LeadingMarginSpanStandard(listItemIndent * (lists.Count - 1)),
                     newBullet);
             } else if (lists.Peek().Equals("ol")) {
                 if (output.Length() > 0 && output.CharAt(output.Length() - 1) != '\n') {
                     output.Append("\n");
                 }
                 int numberMargin = listItemIndent * (lists.Count - 1);
                 if (lists.Count > 2) {
                     // Same as in ordered lists: counter the effect of nested Spans
                     numberMargin -= (lists.Count - 2) * listItemIndent;
                 }
                 end(output, typeof(Ol), false, new LeadingMarginSpanStandard(numberMargin));
             }
         } else if (tag.Equals("code")) {
             end(output, typeof(Code), false, new TypefaceSpan("monospace"));
         } else if (tag.Equals("center")) {
             end(output, typeof(Center), true, new AlignmentSpanStandard(Layout.Alignment.AlignCenter));
         } else if (tag.Equals("s") || tag.Equals("strike")) {
             end(output, typeof(Strike), false, new StrikethroughSpan());
         }
     }
 }
Beispiel #21
0
 public CartRepository(IXMLReader xMLReader, IXMLWriter xMLWriter)
 {
     _xMLReader = xMLReader;
     _xMLWriter = xMLWriter;
 }
Beispiel #22
0
 public GoodsSamesFiller(XmlNode node, IXMLReader xreader)
 {
     this.xreader = xreader;
     Same = new dev_xml_sames();
     FillGoodsSames(node);
 }
Beispiel #23
0
 public ArticleModel(IXMLReader _reader, IRepository repository = null)
 {
     this.reader = _reader;
 }
Beispiel #24
0
 public GoodsMechsFiller(XmlNode node, IXMLReader xreader)
 {
     this.xreader = xreader;
     Mech = new dev_xml_mechs();
     FillGoodsMechs(node);
 }
Beispiel #25
0
 public XmlTrainRepository(IXMLReader reader)
 {
     _reader = reader;
 }
 public ProductRepository(IXMLReader xMLReader)
 {
     _xMLReader = xMLReader;
     ReadAll();
 }