예제 #1
0
 public FluentWidgets Add(PropertyA pa, PropertyB pb)
 {
     return(Add(Do <Widget>(w => {
         w.PropertyA = pa;
         w.PropertyB = pb;
     })));
 }
예제 #2
0
        /// <summary>
        /// Parse option having crude option, string or HtmlMode. Is a variable-argument method.
        /// </summary>
        public OptionParseResult Parse(string str, HtmlNode node)
        {
            bool strFormalMode  = str != null;
            bool nodeFormalMode = node != null;

            if (strFormalMode == nodeFormalMode)
            {
                throw new InvalidOperationException("This is a two-mode method, please provide only single desired parameter.");
            }

            if (PriceAmount == null)
            {
                throw new NullReferenceException($"Price extraction is not defined.");
            }

            #region Option Info Parsing

            var newOptionParse = new OptionParseResult();

            // Details
            try
            {
                if (Code != null)
                {
                    newOptionParse.Code = Code.ExtractSingle(str, node);
                }
            }
            catch (NullReferenceException nrex) { Logger.Log(nrex.Message + " @ Option Code Parsing"); }

            try
            {
                if (PropertyA != null)
                {
                    newOptionParse.PropertyA = PropertyA.ExtractSingle(str, node);
                }
            }
            catch (NullReferenceException nrex) { Logger.Log(nrex.Message + " @ Option PropertyA Parsing"); }

            try
            {
                if (PropertyB != null)
                {
                    newOptionParse.PropertyB = PropertyB.ExtractSingle(str, node);
                }
            }
            catch (NullReferenceException nrex) { Logger.Log(nrex.Message + " @ Option PropertyB Parsing"); }

            try
            {
                if (PropertyC != null)
                {
                    newOptionParse.PropertyC = PropertyC.ExtractSingle(str, node);
                }
            }
            catch (NullReferenceException nrex) { Logger.Log(nrex.Message + " @ Option PropertyC Parsing"); }

            #endregion Option Info Parsing

            #region Snapshot Info Parsing
            var snapshot = new Snapshot(newOptionParse)
            {
                Timestamp = DateTime.Now
            };

            try
            {
                if (Stock != null)
                {
                    newOptionParse.StockStatus = Stock.ExtractSingle(str, node);
                }
            }
            catch (NullReferenceException nrex) { Logger.Log(nrex.Message + " @ Option Snapshot Stock Parsing"); }

            //Price
            try
            {
                var extracted = PriceAmount.ExtractSingle(str, node);
                decimal.TryParse(extracted, NumberStyles.Any, CultureInfo.InvariantCulture, out decimal parsedDouble);

                newOptionParse.Price = new Money(parsedDouble, PriceCurrency);
            }
            catch (NullReferenceException nrex) { Logger.Log(nrex.Message + " @ Option Snapshot Price Parsing"); }
            #endregion Snapshot Info Parsing

            return(newOptionParse);
        }
예제 #3
0
 public static FluentWidgets Add(PropertyB pb)
 {
     return(new FluentWidgets().Add(pb));
 }
예제 #4
0
 public FluentWidgets Add(PropertyB pb)
 {
     return(Add(Do <Widget>(w => w.PropertyB = pb)));
 }