Exemplo n.º 1
0
        public static void InsertMinMax(EmberContainer container, BerTag tag, GlowMinMax value)
        {
            switch (value.Type)
            {
            case GlowParameterType.Integer:
                container.Insert(new LongEmberLeaf(tag, value.Integer));
                break;

            case GlowParameterType.Real:
                container.Insert(new RealEmberLeaf(tag, value.Real));
                break;

            default:
                throw new ArgumentException("Type not supported");
            }
        }
Exemplo n.º 2
0
        /// <summary>
        /// Tries to parse a GlowMinMax value of the specified type from a string.
        /// </summary>
        /// <param name="str">The string to parse.</param>
        /// <param name="type">The expected parameter type of the value. Must be either
        /// GlowParameterType.Integer or GlowParameterType.Real.</param>
        /// <param name="provider">The string format to use.</param>
        /// <param name="value">If successful, receives the parse GlowMinMax value.</param>
        /// <returns>True if the passed string could be parsed, otherwise false.</returns>
        public static bool TryParse(string str, int type, IFormatProvider provider, out GlowMinMax value)
        {
            switch (type)
            {
            case GlowParameterType.Integer:
            {
                long integer;

                if (Int64.TryParse(str, NumberStyles.Any, provider, out integer))
                {
                    value = new GlowMinMax(integer);
                    return(true);
                }

                break;
            }

            case GlowParameterType.Real:
            {
                double real;

                if (Double.TryParse(str, NumberStyles.Any, provider, out real))
                {
                    value = new GlowMinMax(real);
                    return(true);
                }

                break;
            }

            case GlowParameterType.None:
            {
                value = new GlowMinMax(type);
                return(true);
            }

            default:
                throw new ArgumentException("Unsupported type");
            }

            value = null;
            return(false);
        }
Exemplo n.º 3
0
        public static GlowMinMax GetMinMax(EmberContainer container, BerTag tag)
        {
            var node  = container[tag];
            var value = null as GlowMinMax;

            if (node != null)
            {
                switch (node.BerTypeNumber)
                {
                case BerType.Integer:
                    value = new GlowMinMax(GetIntegerNodeValue(node));
                    break;

                case BerType.Real:
                    value = new GlowMinMax(((RealEmberLeaf)node).Value);
                    break;
                }
            }

            return(value);
        }
Exemplo n.º 4
0
 void InsertMinMax(BerTag tag, GlowMinMax value)
 {
     InternalTools.InsertMinMax(EnsureContentsAndRemove(tag), tag, value);
 }
Exemplo n.º 5
0
        /// <summary>
        /// Tries to parse a GlowMinMax value of the specified type from a string.
        /// </summary>
        /// <param name="str">The string to parse.</param>
        /// <param name="type">The expected parameter type of the value. Must be either
        /// GlowParameterType.Integer or GlowParameterType.Real.</param>
        /// <param name="provider">The string format to use.</param>
        /// <param name="value">If successful, receives the parse GlowMinMax value.</param>
        /// <returns>True if the passed string could be parsed, otherwise false.</returns>
        public static bool TryParse(string str, int type, IFormatProvider provider, out GlowMinMax value)
        {
            switch(type)
             {
            case GlowParameterType.Integer:
            {
               long integer;

               if(Int64.TryParse(str, NumberStyles.Any, provider, out integer))
               {
                  value = new GlowMinMax(integer);
                  return true;
               }

               break;
            }

            case GlowParameterType.Real:
            {
               double real;

               if(Double.TryParse(str, NumberStyles.Any, provider, out real))
               {
                  value = new GlowMinMax(real);
                  return true;
               }

               break;
            }

            default:
               throw new ArgumentException("Unsupported type");
             }

             value = null;
             return false;
        }
Exemplo n.º 6
0
 void InsertMinMax(BerTag tag, GlowMinMax value)
 {
     InternalTools.InsertMinMax(EnsureContentsAndRemove(tag), tag, value);
 }