Пример #1
0
		/////////////////////////////////////////////////////////////////////////////

		private void HandleMessages( NmpResult nmpResult )
		{
			// ******
			//
			// clear the error list
			//
			TaskProvider.TaskCollection tc = errListProvider.Tasks;
			tc.Clear();

			// ******
			foreach( var msg in nmpResult.Messages ) {
				WriteOutput( msg.FullMessage );

				if( TraceMessage != msg.MessageType ) {
					//GeneratorErrorCallback( HostMessageType.Warning == msg.MessageType, msg.DistressLevel, msg.Message, msg.Line, msg.Column );
					//
					// this allows us to add messages as well
					//
					ErrList( errListProvider, msg.MessageType, nmpResult.FileName, msg.Message, msg.Line - 1, msg.Column - 1 );
				}
			}

			// ******
			errListProvider.Refresh();
		}
Пример #2
0
		/////////////////////////////////////////////////////////////////////////////

		public NmpResult Evaluate( IDictionary vsBuildPaths, IDictionary projProperties, string text, string inputFileName )
		{
			// ******
			string inputFullPath = Path.GetFullPath( inputFileName ).ToLower();

			// ******
			NmpResult evalResult = new NmpResult();

			evalResult.InputText = text;
			evalResult.FileName = inputFullPath;

			// ******
			var host = new CustomToolHost( evalResult.Messages );

			using( var nmp = new NmpEvaluator(host) ) {
				if( ! string.IsNullOrEmpty(inputFullPath) ) {
					nmp.ChangeRootDirectory( inputFileName );
				}

				// ******
				if( null != vsBuildPaths ) {
					AddObjectMacro( VSBUILD_PATHS_MACRO_NAME, new NmpArray(vsBuildPaths) );
				}

				if( null != projProperties ) {
					AddObjectMacro( VSPROJECT_PROPERTIES, new NmpArray(projProperties) );
			
					AddMacros( nmp, vsBuildPaths );
				}

				// ******
				var evx = nmp.GetStringContext( text );
				evx.SetFileInfo( inputFullPath );

				// ******
				bool errors = false;
				string result = string.Empty;
				try {
					evalResult.MacroResult = nmp.Evaluate( evx, true );
					evalResult.FileExt = nmp.FileExt;
				}
				catch ( CustomToolEvaluatorDieException ) {
					//
					// this is an exception we've created for as a generic terminal error
					// which simply causes us to return
					//
					errors = true;
				}
		
		//
		// catch error and report here
		//
	#if EXREPORTING
				// ref dll
	#endif
				//catch ( Exception ex ) {
				//	throw;
				//}

				// ******
				evalResult.Errors = errors;
				return evalResult;

			}
		}