Ejemplo n.º 1
0
        public bool Load(string id, bool append = false)
        {
            string absPath = "{0}/{1}.lbs".FormateEx(RootPath, id);

            if (!append)
            {
                Whole = "";
                Tokens.Clear();
            }
            if (append)
            {
                if (id == ID)
                {
                    throw new StackOverflowException();
                }
                Whole += _load(absPath);
            }
            Whole = _load(absPath);
            ID    = id;
            return(Whole.AvailableEx());
        }
Ejemplo n.º 2
0
        public bool Parse()
        {
            int pos = 0;

            foreach (string each in Whole.Split('\n'))
            {
                pos++;
                if (!each.AvailableEx())
                {
                    continue;
                }
                try
                {
                    if (each.StartsWith("#pragma", true, null))
                    {
                        ParsingMarco(each);
                        continue;
                    }
                    Tokens.Add(Tokenize(each));
                }
                catch (FormatException)
                {
                    ErrorOccured?.Invoke("CORE_LBS_SynatxError", each, pos);
                    return(false);
                }
                catch (StackOverflowException)
                {
                    ErrorOccured?.Invoke("CORE_LBS_InfiniteCall", each, pos);
                    return(false);
                }
                catch (KeyNotFoundException)
                {
                    ErrorOccured?.Invoke("CORE_LBS_PragmaNotFound", each, pos);
                    return(false);
                }
            }
            return(true);
        }
Ejemplo n.º 3
0
        public void ComplexMixinsCanMapToOtherComplexMixins()
        {
            var source = new Whole
            {
                Part = new Part {
                    Name = "part1"
                },
                Parts = new[] { new Part {
                                    Name = "part2"
                                }, new Part {
                                    Name = "part3"
                                } }
            };

            var destination = new VievModel();

            source.MapTo(destination, deep: true);
            Assert.AreNotSame(source.Part, destination.Part);
            Assert.AreEqual(source.Part.Name, destination.Part.Name);
            Assert.AreNotSame(source.Parts, destination.Parts);
            Assert.AreEqual(source.Parts.Count(), destination.Parts.Count());
            Assert.AreEqual(source.Parts.First().Name, destination.Parts.First().Name);
            Assert.AreEqual(source.Parts.Last().Name, destination.Parts.Last().Name);
        }
Ejemplo n.º 4
0
        public string toString()
        {
            improperToMixed(Numerator, Denominator);

            string result;

            if (Numerator == 0)
            {
                result = Whole.ToString();
            }
            else
            {
                if (Whole == 0)
                {
                    result = Numerator + "/" + Denominator;
                }
                else
                {
                    result = Whole + "_" + Numerator + "/" + Denominator;
                }
            }

            return(result);
        }
Ejemplo n.º 5
0
        /// <summary>
        /// Checks whether value is prime.
        /// </summary>
        /// <param name="value">Numbereger to test.</param>
        /// <returns>True if value is prime.</returns>
        public static bool IsPrime(this Whole value)
        {
            //
            //    Value is known prime?
            //
            if (_known.Contains(value))
            {
                return(true);
            }

            //
            //    Value below known boundary?
            //
            if (value <= _boundary)
            {
                return(false);
            }

            //
            //    Upper factor boundary.
            //
            var root  = Math.Sqrt(value);
            var upper = (Whole)root;

            //
            //    Check result.
            //
            var prime = true;

            //
            //    Iterate factors.
            //
            for (Whole factor = 2; factor <= upper; factor++)
            {
                //
                //    Factor is prime?
                //
                if (factor.IsPrime())
                {
                    var remainder = value % factor;

                    if (0 == remainder)
                    {
                        prime = false;
                        break;
                    }
                }
            }

            if (prime)
            {
                //
                //    The value is prime so accept it.
                //
                Accept(value);
            }
            else
            {
                AdvanceBoundary(value);
            }

            return(prime);
        }
Ejemplo n.º 6
0
 void Awake()
 {
     S     = this;
     rigid = GetComponent <Rigidbody2D>();
 }
Ejemplo n.º 7
0
        /// <summary>
        /// Print the faction as string
        /// </summary>
        /// <returns></returns>
        public string ToString()
        {
            ImpropertoMixed(Numerator, Denominator);
            string ret = Numerator != 0 ? (Whole != 0 ? $"{Whole}_{Numerator}/{Denominator}" : $"{Numerator}/{Denominator}") : Whole.ToString();

            // convert back to improper for calc
            MixedtoImproper(Whole, Numerator, Denominator);
            return(ret);
        }
 public notWhole()
 {
     int[] arr = new int[] { 1, 2, 3 };
     w1 = new Whole(arr);
 }