Exemplo n.º 1
0
 public static ISchemaType CreateInstanceByString(string newvalue)
 {
     // is it a boolean?
     if (newvalue.ToLower().CompareTo("false") == 0)
     {
         return(new SchemaBoolean(false));
     }
     if (newvalue.ToLower().CompareTo("true") == 0)
     {
         return(new SchemaBoolean(true));
     }
     // is it a kind of dateTime value?
     try
     {
         SchemaDateTime result = new SchemaDateTime(newvalue);
         return(result);
     }
     catch (StringParseException) {}
     try
     {
         SchemaDuration result = new SchemaDuration(newvalue);
         return(result);
     }
     catch (StringParseException) {}
     try
     {
         SchemaDate result = new SchemaDate(newvalue);
         return(result);
     }
     catch (StringParseException) {}
     try
     {
         SchemaTime result = new SchemaTime(newvalue);
         return(result);
     }
     catch (StringParseException) {}
     // is it a numeric value
     try
     {
         decimal tmp = Convert.ToDecimal(newvalue, CultureInfo.InvariantCulture);
         if (newvalue.IndexOf(".") < 0)
         {
             if (tmp <= Int32.MaxValue && tmp >= Int32.MinValue)
             {
                 return(new SchemaInt((int)tmp));
             }
             return(new SchemaLong((long)tmp));
         }
         else
         {
             return(new SchemaDecimal(tmp));
         }
     }
     catch (FormatException)
     {
         // non of all - use string
         return(new SchemaString(newvalue));
     }
 }
Exemplo n.º 2
0
		public static ISchemaType CreateInstanceByString(string newvalue) 
		{
			// is it a boolean?
			if( newvalue.ToLower().CompareTo("false")==0 )
				return new SchemaBoolean( false );
			if( newvalue.ToLower().CompareTo("true")==0 )
				return new SchemaBoolean( true );
			// is it a kind of dateTime value?
			try 
			{
				SchemaDateTime result = new SchemaDateTime( newvalue );
				return result;
			}
			catch( StringParseException ) {}
			try 
			{
				SchemaDuration result = new SchemaDuration( newvalue );
				return result;
			}
			catch( StringParseException ) {}
			try 
			{
				SchemaDate result = new SchemaDate( newvalue );
				return result;
			}
			catch( StringParseException ) {}
			try 
			{
				SchemaTime result = new SchemaTime( newvalue );
				return result;
			}
			catch( StringParseException ) {}
			// is it a numeric value
			try 
			{
				decimal tmp = Convert.ToDecimal(newvalue, CultureInfo.InvariantCulture);
				if( newvalue.IndexOf(".") < 0 ) 
				{
					if( tmp <= Int32.MaxValue && tmp >= Int32.MinValue )
						return new SchemaInt( (int)tmp );
					return new SchemaLong( (long)tmp );
				} 
				else 
				{
					return new SchemaDecimal( tmp );
				}
			}
			catch (FormatException ) 
			{
				// non of all - use string
				return new SchemaString( newvalue );
			}
		}
Exemplo n.º 3
0
 public SchemaDateTime(SchemaDateTime obj)
 {
     Value = obj.Value;
 }
Exemplo n.º 4
0
 public SchemaDateTime(SchemaDateTime obj)
     : base((SchemaCalendarBase)obj)
 {
 }
Exemplo n.º 5
0
 public override SchemaDateTime DateTimeValue()
 {
     if ( isNull )
     {
         SchemaDateTime	result = new SchemaDateTime();
         result.SetNull( true );
         return result;
     }
     else if ( isEmpty )
         return new SchemaDateTime();
     else
         return new SchemaDateTime( myValue.Year, myValue.Month, myValue.Day);
 }
Exemplo n.º 6
0
		public SchemaDateTime(SchemaDateTime obj)
		{
			Value = obj.Value;
		}