Ejemplo n.º 1
0
        private void TrimInteger()
        {
            int temp;

            if (HasDecimal)
            {
                var point = Raw.IndexOf('.');

                var integerText = Raw.Substring(0, point);
                var decimalText = Raw.Substring(point, Raw.Length - point); // 小数 + "."

                if (int.TryParse(integerText, out temp))
                {
                    Raw = temp.ToString() + decimalText;
                }
                else
                {
                    throw new InvalidOperationException();
                }
            }
            else
            {
                if (int.TryParse(Raw, out temp))
                {
                    Raw = temp.ToString();
                }
                else
                {
                    throw new InvalidOperationException();
                }
            }
        }
Ejemplo n.º 2
0
        private bool IncludeDecimal(int index)
        {
            if (!HasDecimal)
            {
                return(false);
            }

            var point = Raw.IndexOf('.');

            return(index > point);
        }
Ejemplo n.º 3
0
        private bool IncludeInteger(int index)
        {
            if (!HasDecimal)
            {
                return(true);
            }

            var point = Raw.IndexOf('.');

            return(index <= point);
        }
Ejemplo n.º 4
0
        protected override void ExtractContent()
        {
            base.ExtractContent();

            var posBegin = Raw.IndexOf("<div id=\"img-content\" class=\"rich_media_area_primary\">");
            var posEnd   = Raw.IndexOf("<div class=\"rich_media_area_primary sougou\" id=\"sg_tj\" style=\"display:none\">");

            var tmpStr = Raw.Substring(posBegin, posEnd - posBegin);

            tmpStr.Trim(new char[] { ' ' });

            Content = tmpStr;
        }
Ejemplo n.º 5
0
        public string SetDecimals(int length)
        {
            var tail = "";

            if (length == 0)
            {
                if (HasDecimal)
                {
                    Raw = Raw.Substring(0, Raw.IndexOf('.'));
                    return(Raw);
                }
            }

            if (!HasDecimal)
            {
                // 小数を持たない
                tail += ".";
                tail += string.Concat(Enumerable.Repeat("0", length));

                Raw += tail;

                return(Raw);
            }
            else
            {
                // 小数を持つ
                if (length == DecimalPartText.Length)
                {
                    return(Raw);
                }

                if (length > DecimalPartText.Length)
                {
                    tail += string.Concat(Enumerable.Repeat("0", length - DecimalPartText.Length));
                    Raw  += tail;
                }
                else if (length < DecimalPartText.Length)
                {
                    Raw = Raw.Substring(0, Raw.Length - (DecimalPartText.Length - length));
                }
            }

            return(Raw);
        }
Ejemplo n.º 6
0
        protected override void ExtractContent()
        {
            base.ExtractContent();

            var posBegin = Raw.IndexOf("var msgList =");
            var posEnd   = Raw.IndexOf("seajs.use(");

            if (posBegin == -1 || posEnd == -1)
            {
                return;
            }

            var msgListStr = Raw.Substring(posBegin, posEnd - posBegin);

            msgListStr = msgListStr.Replace("var msgList = ", "");
            msgListStr = msgListStr.TrimStart(new char[] { ' ' });
            msgListStr = msgListStr.TrimEnd(new char[] { ';', ' ', '\r', '\n' });

            Content = msgListStr;
        }
Ejemplo n.º 7
0
        public void InizializerValues()
        {
            IndexParameters = new List <int>();
            Parameters      = new Dictionary <int, string>();
            Built           = Raw;
            var fromIndex = 0;

            while (fromIndex < Raw.Length)
            {
                var index = Raw.IndexOf("?", fromIndex);
                if (index != -1)
                {
                    IndexParameters.Add(index);
                    fromIndex = index + 1;
                }
                else
                {
                    fromIndex = Raw.Length;
                }
            }
        }
Ejemplo n.º 8
0
        protected string GetRawData()
        {
            var pos = Raw.IndexOf('{');

            return(Raw.Substring(pos));
        }
Ejemplo n.º 9
0
        private void ParseRaw()
        {
            if (string.IsNullOrWhiteSpace(Raw))
            {
                return;
            }

            int    index = Raw.IndexOf(":");
            string member, value, hashCode = null;
            bool   isPrimitive;

            if (index == -1)
            {
                value = null;

                var parts = Raw.Split('.');
                if (StringUtils.IsNumber(parts.LastOrDefault()))
                {
                    // IS COMPLEX: "Prop.12345"
                    hashCode = parts.LastOrDefault();

                    // ShowType = None
                    if (parts.Length == 1)
                    {
                        member = parts[0];
                    }
                    // ShowType = [OTHERS]
                    else
                    {
                        member = parts[parts.Length - 2];
                    }

                    isPrimitive = false;
                }
                else
                {
                    // IS PRIMITIVE AND IS NULL: "Prop"
                    member      = Raw;
                    isPrimitive = true;
                }
            }
            else
            {
                // IS PRIMITIVE AND HAS VALUE: "Prop: value"
                member      = Raw.Substring(0, index);
                value       = Raw.Substring(index + 2); // consider space after colon ": "
                isPrimitive = true;
            }

            // ShowType = FullTypeName || TypeName
            var partsWithType = member.Split('.');

            if (partsWithType.Length > 0)
            {
                member = partsWithType.LastOrDefault();
            }

            this.Name            = member;
            this.ValueRaw        = value;
            this.IsPrimitive     = isPrimitive;
            this.ComplexEntityId = hashCode;
        }