Example #1
0
 internal object Decode(Variable v)
 {
     if (_syntax is IntegerType)
     {
         Integer32 i = v.Data as Integer32;
         if (i == null || (_syntax as IntegerType).IsEnumeration)
         {
             return(null);
         }
         else if (_displayHint != null)
         {
             return(_displayHint.Decode(i.ToInt32()));
         }
         else
         {
             return(i.ToInt32());
         }
     }
     else if (_syntax is UnsignedType)
     {
         Integer32 i = v.Data as Integer32;
         if (i == null)
         {
             return(null);
         }
         else if (_displayHint != null)
         {
             return(_displayHint.Decode(i.ToInt32()));
         }
         else
         {
             return(i.ToInt32());
         }
     }
     else if (_syntax is OctetStringType)
     {
         OctetString o = v.Data as OctetString;
         if (o == null)
         {
             return(null);
         }
         else
         {
             // TODO: Follow the format specifier for octet strings.
             return(null);
         }
     }
     else
     {
         return(null);
     }
 }
        internal object Decode(Variable v)
        {
            if (_syntax is IntegerType)
            {
                var i = v.Data as Integer32;
                if (i == null || (_syntax as IntegerType).IsEnumeration)
                {
                    return null;
                }

                return _displayHint != null ? _displayHint.Decode(i.ToInt32()) : i.ToInt32();
            }

            if (_syntax is UnsignedType)
            {
                var i = v.Data as Integer32;
                if (i == null)
                {
                    return null;
                }

                return _displayHint != null ? _displayHint.Decode(i.ToInt32()) : i.ToInt32();
            }

            if (_syntax is OctetStringType)
            {
                var o = v.Data as OctetString;
                if (o == null)
                {
                    return null;
                }

                // TODO: Follow the format specifier for octet strings.
                return null;
            }

            return null;
        }