Beispiel #1
0
		/////////////////////////////////////////////////////////////////////////////

		protected void WalkList( NmpObjectList list )
		{
			// ******
			++indent;
			output.Append( '[' );
			
			// ******
			for( int index = 0; index < list.Count; index++ ) {
				if( index > 0 ) {
					output.Append( ',' );
				}
				Value( list[index] );
			}
			
			// ******
			output.Append( "]" );
			--indent;
		}
Beispiel #2
0
		/////////////////////////////////////////////////////////////////////////////

		public static string VisualizeList( NmpObjectList list, JSONDateFormat dateFormat = JSONDateFormat.ISODate )
		{
			var x = new JSONVisualizer( dateFormat );
			return x.List( list );
		}
Beispiel #3
0
		/////////////////////////////////////////////////////////////////////////////

		protected string List( NmpObjectList list )
		{
			// ******
			indent = 0;
			output = new StringBuilder();
			WalkList( list );
			return output.ToString();
		}
Beispiel #4
0
		///////////////////////////////////////////////////////////////////////////

		public void EnterArray( JSONParser jp )
		{
			// ******
			//Trace.Write( "Enter array\n" );

			// ******
			var list = new NmpObjectList();
			if( string.IsNullOrEmpty(lastIdentifier) ) {
				CurrentList.Add( list );
			}
			else {
				CurrentArray.Add( lastIdentifier, list );
				lastIdentifier = null;
			}

			// ******
			listStack.Push( list );
		}
Beispiel #5
0
		/////////////////////////////////////////////////////////////////////////////

		public static object [] Create( NmpStringList argList )
		{
			// ******
			if( 0 == argList.Count ) {
				return new object [0];
			}

			// ******
			var args = new NmpObjectList();
			
			foreach( string arg in argList ) {
				string s = arg.Trim();
				
				// ******
				if( string.IsNullOrEmpty(s) ) {
					args.Add( string.Empty );
				}
				else if( 1 == s.Length ) {
					args.Add( s );
				}
				else if( '(' == s [ 0 ] && '(' != s [ 1 ] ) {
					args.Add( CastArg( s ) );
				}
				else if( '[' == s [ 0 ] && '[' != s [ 1 ] ) {
					args.Add( CollectionArg(s) );
				}
				else { 
					//
					// as a string
					//
					args.Add( s );
				}
			}

			// ******
			return args.ToArray();
		}
Beispiel #6
0
		public object Else( params object [] argsIn )
		{
			// ******
			var args = new NmpObjectList( argsIn );

			// ******
			if( args.Count < 3 ) {
				ThreadContext.MacroError( "#if.Else requires at least three arguments: #if.Else(lhsValue, rhsValue, trueResult [, falseResult ...])" );
			}

			// ******			
			while( true ) {
				int numstrs = args.Count;
				if( numstrs < 3 ) {
					ThreadContext.MacroError( "in the current iteration of the #if.Else() there are fewer than 3 arguments, at least 3 are required:\n lhsValue, rhsValue, a result when comparison is true" );
				}

				// ******
				bool match = args [ 0 ].Equals( args [ 1 ] );
				if( match ) {
					return args [ 2 ];
				}
				else {
					if( numstrs >= 6 ) {
						args.RemoveRange( 0, 3 );
					}
					else {
						return numstrs >= 4 ? args [ 3 ] : string.Empty;
					}
				}
			}
		}