예제 #1
0
 static FieldCacheImpl()
 {
     BYTE_PARSER = new AnonymousClassByteParser();
     SHORT_PARSER = new AnonymousClassShortParser();
     INT_PARSER = new AnonymousClassIntParser();
     FLOAT_PARSER = new AnonymousClassFloatParser();
 }
예제 #2
0
        public List <Stock> GetAllStocks()
        {
            var document = web.Load(sharesUrl);

            var tickers = document.DocumentNode
                          .SelectNodes(".//span[@class='portfolio_action']")
                          .Select(n => n.ParentNode.ParentNode.ChildNodes[7].InnerText)
                          .ToList();

            var prices = document.DocumentNode
                         .SelectNodes(".//span[@class='portfolio_action']")
                         .Select(n => n.ParentNode.ParentNode.ChildNodes[15].InnerText)
                         .ToList();

            var stocks = new List <Stock>();

            for (int i = 0; i < tickers.Count(); i++)
            {
                stocks.Add(new Stock()
                {
                    Ticker         = tickers[i],
                    Price          = FloatParser.SafeParse(prices[i]),
                    LastUpdateTime = DateTime.Now
                });
            }

            return(stocks);
        }
예제 #3
0
            protected internal override object CreateValue(IndexReader reader, object entryKey)
            {
                Entry entry = (Entry)entryKey;

                System.String field  = entry.field;
                FloatParser   parser = (FloatParser)entry.custom;

                float[]  retArray = new float[reader.MaxDoc()];
                TermDocs termDocs = reader.TermDocs();
                TermEnum termEnum = reader.Terms(new Term(field));

                try
                {
                    do
                    {
                        Term term = termEnum.Term();
                        if (term == null || (object)term.Field() != (object)field)
                        {
                            break;
                        }
                        float termval = parser.ParseFloat(term.Text());
                        termDocs.Seek(termEnum);
                        while (termDocs.Next())
                        {
                            retArray[termDocs.Doc()] = termval;
                        }
                    }while (termEnum.Next());
                }
                finally
                {
                    termDocs.Close();
                    termEnum.Close();
                }
                return(retArray);
            }
 public static Either <TLeft, float> ParseToFloat <TLeft>(
     this Either <TLeft, string> source,
     NumberStyles style,
     TLeft left)
 {
     return(source.FlatMap(x => FloatParser.Parse <TLeft>(x, style, left)));
 }
예제 #5
0
 static FieldCacheImpl()
 {
     BYTE_PARSER  = new AnonymousClassByteParser();
     SHORT_PARSER = new AnonymousClassShortParser();
     INT_PARSER   = new AnonymousClassIntParser();
     FLOAT_PARSER = new AnonymousClassFloatParser();
 }
예제 #6
0
        public static Value ConvertStringToNumber(Value source)
        {
            if (source.IsEmpty)
            {
                return(0);
            }

            var    sourceText = source.Text;
            Parser parser     = new FloatParser();
            var    coloring   = Parser.Coloring;

            Parser.Coloring = false;
            if (parser.Scan(sourceText, 0))
            {
                Parser.Coloring = coloring;
                return(parser.Result.Value);
            }

            parser = new IntegerParser();
            if (parser.Scan(sourceText, 0))
            {
                Parser.Coloring = coloring;
                return(parser.Result.Value);
            }

            Parser.Coloring = coloring;
            return(0);
        }
 public static Either <TLeft, float> ParseToFloat <TLeft>(
     this Either <TLeft, string> source,
     IFormatProvider provider,
     TLeft left)
 {
     return(source.FlatMap(x => FloatParser.Parse <TLeft>(x, provider, left)));
 }
예제 #8
0
            protected internal override System.Object CreateValue(IndexReader reader, Entry entryKey)
            {
                Entry entry = (Entry)entryKey;

                System.String field  = entry.field;
                FloatParser   parser = (FloatParser)entry.custom;

                if (parser == null)
                {
                    try
                    {
                        return(wrapper.GetFloats(reader, field, Lucene.Net.Search.FieldCache_Fields.DEFAULT_FLOAT_PARSER));
                    }
                    catch (System.FormatException ne)
                    {
                        return(wrapper.GetFloats(reader, field, Lucene.Net.Search.FieldCache_Fields.NUMERIC_UTILS_FLOAT_PARSER));
                    }
                }
                float[]  retArray = null;
                TermDocs termDocs = reader.TermDocs();
                TermEnum termEnum = reader.Terms(new Term(field));

                try
                {
                    do
                    {
                        Term term = termEnum.Term();
                        if (term == null || (System.Object)term.Field() != (System.Object)field)
                        {
                            break;
                        }
                        float termval = parser.ParseFloat(term.Text());
                        if (retArray == null)
                        {
                            // late init
                            retArray = new float[reader.MaxDoc()];
                        }
                        termDocs.Seek(termEnum);
                        while (termDocs.Next())
                        {
                            retArray[termDocs.Doc()] = termval;
                        }
                    }while (termEnum.Next());
                }
                catch (StopFillCacheException stop)
                {
                }
                finally
                {
                    termDocs.Close();
                    termEnum.Close();
                }
                if (retArray == null)
                {
                    // no values
                    retArray = new float[reader.MaxDoc()];
                }
                return(retArray);
            }
 public static Either <TLeft, float> ParseToFloat <TLeft>(
     this string source,
     NumberStyles style,
     IFormatProvider provider,
     TLeft left)
 {
     return(FloatParser.Parse <TLeft>(source, style, provider, left));
 }
예제 #10
0
 public void Deserialize(XElement xml)
 {
     shader  = xml.Element("shader").Attribute("value").Value;
     color.r = FloatParser.stof(xml.Element("colorR").Attribute("value").Value);
     color.g = FloatParser.stof(xml.Element("colorG").Attribute("value").Value);
     color.b = FloatParser.stof(xml.Element("colorB").Attribute("value").Value);
     color.a = 1.0f;
     texture = xml.Element("texture").Attribute("value").Value;
 }
예제 #11
0
 private XElement WriteValue(string name, float value)
 {
     return(new XElement(
                name,
                new XAttribute(
                    "value", FloatParser.ftos(value)
                    )
                ));
 }
예제 #12
0
 // inherit javadocs
 public virtual float[] GetFloats(IndexReader reader, System.String field, FloatParser parser)
 {
     field = String.Intern(field);
     System.Object ret = Lookup(reader, field, parser);
     if (ret == null)
     {
         float[] retArray = new float[reader.MaxDoc()];
         if (retArray.Length > 0)
         {
             TermDocs termDocs = reader.TermDocs();
             TermEnum termEnum = reader.Terms(new Term(field, ""));
             try
             {
                 if (termEnum.Term() == null)
                 {
                     throw new System.SystemException("no terms in field " + field);
                 }
                 do
                 {
                     Term term = termEnum.Term();
                     if (term.Field() != field)
                     {
                         break;
                     }
                     float termval;
                     try
                     {
                         termval = SupportClass.Single.Parse(term.Text());
                     }
                     catch (Exception e)
                     {
                         termval = 0;
                     }
                     termDocs.Seek(termEnum);
                     while (termDocs.Next())
                     {
                         retArray[termDocs.Doc()] = termval;
                     }
                 }while (termEnum.Next());
             }
             finally
             {
                 termDocs.Close();
                 termEnum.Close();
             }
         }
         Store(reader, field, parser, retArray);
         return(retArray);
     }
     return((float[])ret);
 }
예제 #13
0
 public void Deserialize(XElement xml)
 {
     if (points == null)
     {
         points = new Dictionary <float, float>();
     }
     points.Clear();
     foreach (XElement elem in xml.Elements())
     {
         float x = FloatParser.stof(elem.Attribute("x").Value);
         float y = FloatParser.stof(elem.Attribute("y").Value);
         points.Add(x, y);
     }
 }
예제 #14
0
 static FieldCache_Fields()
 {
     DEFAULT                     = new FieldCacheImpl();
     DEFAULT_BYTE_PARSER         = new AnonymousClassByteParser();
     DEFAULT_SHORT_PARSER        = new AnonymousClassShortParser();
     DEFAULT_INT_PARSER          = new AnonymousClassIntParser();
     DEFAULT_FLOAT_PARSER        = new AnonymousClassFloatParser();
     DEFAULT_LONG_PARSER         = new AnonymousClassLongParser();
     DEFAULT_DOUBLE_PARSER       = new AnonymousClassDoubleParser();
     NUMERIC_UTILS_INT_PARSER    = new AnonymousClassIntParser1();
     NUMERIC_UTILS_FLOAT_PARSER  = new AnonymousClassFloatParser1();
     NUMERIC_UTILS_LONG_PARSER   = new AnonymousClassLongParser1();
     NUMERIC_UTILS_DOUBLE_PARSER = new AnonymousClassDoubleParser1();
 }
예제 #15
0
 public void Deserialize(XElement xml)
 {
     for (int i = 0; i < 6; i++)
     {
         animCurves[i] = new AnimationCurve();
         animCurves[i].postWrapMode = WrapMode.Loop;
     }
     foreach (XElement x in xml.Elements("key"))
     {
         animCurves[0].AddKey(FloatParser.stof(x.Attribute("t").Value), FloatParser.stof(x.Attribute("px").Value));
         animCurves[1].AddKey(FloatParser.stof(x.Attribute("t").Value), FloatParser.stof(x.Attribute("py").Value));
         animCurves[2].AddKey(FloatParser.stof(x.Attribute("t").Value), FloatParser.stof(x.Attribute("pz").Value));
         animCurves[3].AddKey(FloatParser.stof(x.Attribute("t").Value), FloatParser.stof(x.Attribute("rx").Value));
         animCurves[4].AddKey(FloatParser.stof(x.Attribute("t").Value), FloatParser.stof(x.Attribute("ry").Value));
         animCurves[5].AddKey(FloatParser.stof(x.Attribute("t").Value), FloatParser.stof(x.Attribute("rz").Value));
     }
 }
예제 #16
0
    public AnimationCurve[] animCurves = new AnimationCurve[6]; // pos xyz, rot xyz

    public XElement Serialize()
    {
        List <XElement> keys = new List <XElement>();

        for (int i = 0; i < animCurves[0].keys.Length; i++)
        {
            keys.Add(new XElement(
                         "key",
                         new XAttribute("t", FloatParser.ftos(animCurves[0].keys[i].time)),
                         new XAttribute("px", FloatParser.ftos(animCurves[0].keys[i].value)),
                         new XAttribute("py", FloatParser.ftos(animCurves[1].keys[i].value)),
                         new XAttribute("pz", FloatParser.ftos(animCurves[2].keys[i].value)),
                         new XAttribute("rx", FloatParser.ftos(animCurves[3].keys[i].value)),
                         new XAttribute("ry", FloatParser.ftos(animCurves[4].keys[i].value)),
                         new XAttribute("rz", FloatParser.ftos(animCurves[5].keys[i].value))
                         ));
        }
        return(new XElement("anim", keys.ToArray()));
    }
예제 #17
0
    private float ReadValue(XElement xml, string name)
    {
        XElement value = xml.Element(name);

        if (value == null)
        {
            Debug.LogError("couldn't find '" + name + "' in quad config");
            return(0.0f);
        }
        else
        {
            try {
                return(FloatParser.stof(value.Attribute("value").Value));
            }
            catch (FormatException) {
                Debug.LogError("couldn't parse '" + name + "' in quad config");
                return(0.0f);
            }
        }
    }
예제 #18
0
    private Vector3 StrVec(string str)
    {
        string[] split = str.Split(',');
        if (split.Length < 2 || split.Length > 3)
        {
            Debug.LogError("LevelElement.StrVec value count: '" + str + "'");
            return(Vector3.zero);
        }
        Vector3 vec = Vector3.zero;

        for (int i = 0; i < split.Length; i++)
        {
            try {
                vec[i] = FloatParser.stof(split[i]);
            }
            catch (FormatException) {
                Debug.LogError("LevelElement.StrVec just received proper bullshit: '" + str + "'");
                return(vec);
            }
        }
        return(vec);
    }
예제 #19
0
    private Quaternion StrQuat(string str)
    {
        string[] split = str.Split(',');
        if (split.Length != 4)
        {
            Debug.LogError("LevelElement.StrQuat value count: '" + str + "'");
            return(Quaternion.identity);
        }
        Quaternion quat = Quaternion.identity;

        for (int i = 0; i < split.Length; i++)
        {
            try {
                quat[i] = FloatParser.stof(split[i]);
            }
            catch (FormatException) {
                Debug.LogError("LevelElement.StrQuat just received proper bullshit: '" + str + "'");
                return(quat);
            }
        }
        return(quat);
    }
예제 #20
0
    public XElement Serialize()
    {
        List <XElement> dataPoints = new List <XElement>();

        foreach (KeyValuePair <float, float> entry in points)
        {
            dataPoints.Add(new XElement(
                               "dataPoint",
                               new XAttribute(
                                   "x",
                                   FloatParser.ftos(entry.Key)
                                   ),
                               new XAttribute(
                                   "y",
                                   FloatParser.ftos(entry.Value)
                                   )
                               ));
        }

        return(new XElement(
                   "dataCurve",
                   dataPoints.ToArray()
                   ));
    }
 public static Either <TLeft, float> ParseToFloat <TLeft>(this string source, TLeft left)
 {
     return(FloatParser.Parse(source, left));
 }
예제 #22
0
 private string QuatStr(Quaternion quat)
 {
     return(string.Format("{0},{1},{2},{3}", FloatParser.ftos(quat.x), FloatParser.ftos(quat.y), FloatParser.ftos(quat.z), FloatParser.ftos(quat.w)));
 }
예제 #23
0
 static FieldCacheImpl()
 {
     INT_PARSER   = new AnonymousClassIntParser();
     FLOAT_PARSER = new AnonymousClassFloatParser();
 }
예제 #24
0
 // inherit javadocs
 public virtual float[] GetFloats(IndexReader reader, System.String field, FloatParser parser)
 {
     return((float[])((Cache)caches[System.Type.GetType("System.Single")]).Get(reader, new Entry(field, parser)));
 }
예제 #25
0
 internal FloatComparator(int numHits, System.String field, Lucene.Net.Search.Parser parser)
 {
     values      = new float[numHits];
     this.field  = field;
     this.parser = (FloatParser)parser;
 }
예제 #26
0
			internal FloatComparator(int numHits, System.String field, Lucene.Net.Search.Parser parser)
			{
				values = new float[numHits];
				this.field = field;
				this.parser = (FloatParser) parser;
			}
예제 #27
0
 // inherit javadocs
 public virtual float[] GetFloats(IndexReader reader, System.String field, FloatParser parser)
 {
     return (float[]) ((Cache) caches[System.Type.GetType("System.Single")]).Get(reader, new Entry(field, parser));
 }
예제 #28
0
		static FieldCache_Fields()
		{
			DEFAULT = new FieldCacheImpl();
			DEFAULT_BYTE_PARSER = new AnonymousClassByteParser();
			DEFAULT_SHORT_PARSER = new AnonymousClassShortParser();
			DEFAULT_INT_PARSER = new AnonymousClassIntParser();
			DEFAULT_FLOAT_PARSER = new AnonymousClassFloatParser();
			DEFAULT_LONG_PARSER = new AnonymousClassLongParser();
			DEFAULT_DOUBLE_PARSER = new AnonymousClassDoubleParser();
			NUMERIC_UTILS_INT_PARSER = new AnonymousClassIntParser1();
			NUMERIC_UTILS_FLOAT_PARSER = new AnonymousClassFloatParser1();
			NUMERIC_UTILS_LONG_PARSER = new AnonymousClassLongParser1();
			NUMERIC_UTILS_DOUBLE_PARSER = new AnonymousClassDoubleParser1();
		}
예제 #29
0
 private string VecStr(Vector3 vec)
 {
     return(string.Format("{0},{1},{2}", FloatParser.ftos(vec.x), FloatParser.ftos(vec.y), FloatParser.ftos(vec.z)));
 }
예제 #30
0
 // inherit javadocs
 public virtual float[] GetFloats(IndexReader reader, System.String field, FloatParser parser, IState state)
 {
     return((float[])caches[typeof(float)].Get(reader, new Entry(field, parser), state));
 }
예제 #31
0
		// inherit javadocs
		public virtual float[] GetFloats(IndexReader reader, System.String field, FloatParser parser)
		{
			field = String.Intern(field);
			System.Object ret = Lookup(reader, field, parser);
			if (ret == null)
			{
				float[] retArray = new float[reader.MaxDoc()];
				if (retArray.Length > 0)
				{
					TermDocs termDocs = reader.TermDocs();
					TermEnum termEnum = reader.Terms(new Term(field, ""));
					try
					{
						if (termEnum.Term() == null)
						{
							throw new System.SystemException("no terms in field " + field);
						}
						do 
						{
							Term term = termEnum.Term();
							if (term.Field() != field)
								break;
							float termval;
                            try
                            {
                                termval = SupportClass.Single.Parse(term.Text());
                            }
                            catch (Exception e)
                            {
                                termval = 0;
                            }
							termDocs.Seek(termEnum);
							while (termDocs.Next())
							{
								retArray[termDocs.Doc()] = termval;
							}
						}
						while (termEnum.Next());
					}
					finally
					{
						termDocs.Close();
						termEnum.Close();
					}
				}
				Store(reader, field, parser, retArray);
				return retArray;
			}
			return (float[]) ret;
		}
예제 #32
0
 // inherit javadocs
 public virtual float[] GetFloats(IndexReader reader, System.String field, FloatParser parser)
 {
     return((float[])floatsCache.Get(reader, new Entry(field, parser)));
 }
예제 #33
0
		static FieldCacheImpl()
		{
			INT_PARSER = new AnonymousClassIntParser();
			FLOAT_PARSER = new AnonymousClassFloatParser();
		}
예제 #34
0
 private float ReadValue(XElement xml, string name)
 {
     return(FloatParser.stof(xml.Element(name).Attribute("value").Value));
 }
예제 #35
0
 public void Activate(string settingsID = null, string populationID = null, string delay = null, string triggerAlarm = null)
 {
     Activate(DataBlockIDParser <SurvivalWaveSettingsDataBlock> .Parse(settingsID), DataBlockIDParser <SurvivalWaveSettingsDataBlock> .Parse(populationID), FloatParser.Parse(delay), BooleanParser.Parse(triggerAlarm));
 }
예제 #36
0
 // inherit javadocs
 public virtual float[] GetFloats(IndexReader reader, System.String field, FloatParser parser)
 {
     
     return (float[]) caches[typeof(float)].Get(reader, new Entry(field, parser));
 }
예제 #37
0
 // inherit javadocs
 public virtual float[] GetFloats(IndexReader reader, string field, FloatParser parser)
 {
     return((float[])caches[typeof(float)].Get(reader, new Entry(field, parser)));
 }