当前位置: 首页>>代码示例>>C#>>正文


C# Context.ReadConfigAsString方法代码示例

本文整理汇总了C#中Context.ReadConfigAsString方法的典型用法代码示例。如果您正苦于以下问题:C# Context.ReadConfigAsString方法的具体用法?C# Context.ReadConfigAsString怎么用?C# Context.ReadConfigAsString使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在Context的用法示例。


在下文中一共展示了Context.ReadConfigAsString方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。

示例1: Execute

		/// <summary>
		/// ITestStep.Execute() implementation
		/// </summary>
		/// <param name='testConfig'>The Xml fragment containing the configuration for this test step</param>
		/// <param name='context'>The context for the test, this holds state that is passed beteen tests</param>
		public void Execute(System.Xml.XmlNode testConfig, Context context)
		{
			// read test config...
			string path = context.ReadConfigAsString( testConfig, "Path" );
			string fileFilter = context.ReadConfigAsString( testConfig, "FileFilter" );
			int timeOut = context.ReadConfigAsInt32( testConfig, "TimeOut" );
			
			var watcher = new FileSystemWatcher
			                  {
			                      Path = path,
			                      Filter = fileFilter,
			                      NotifyFilter = NotifyFilters.LastWrite,
			                      EnableRaisingEvents = true,
			                      IncludeSubdirectories = false
			                  };
		    watcher.Changed += OnCreated;
			_mre = new ManualResetEvent(false);

			if(!_mre.WaitOne(timeOut, false))
			{
				throw new Exception(string.Format("WaitOnFileStep timed out after {0} milisecs watching path:{1}, filter{2}", timeOut, path, fileFilter));
			}

            context.LogInfo(string.Format("WaitOnFileStep found the file: {0}", _newFilePath));
            context.Add("waitedForFileName", _newFilePath);
		}
开发者ID:RobBowman,项目名称:BizUnit,代码行数:31,代码来源:WaitOnFileStep.cs

示例2: Execute

        /// <summary>
		/// ITestStep.Execute() implementation
		/// </summary>
		/// <param name='testConfig'>The Xml fragment containing the configuration for this test step</param>
		/// <param name='context'>The context for the test, this holds state that is passed beteen tests</param>
		public void Execute(XmlNode testConfig, Context context)
		{
			_directory = context.ReadConfigAsString( testConfig, "Directory" );
			_searchPattern = context.ReadConfigAsString( testConfig, "SearchPattern" );

            Execute(context);
		}
开发者ID:RobBowman,项目名称:BizUnit,代码行数:12,代码来源:FileDeleteMultipleStep.cs

示例3: Execute

        /// <summary>
        /// ITestStep.Execute() implementation
        /// </summary>
        /// <param name='testConfig'>The Xml fragment containing the configuration for this test step</param>
        /// <param name='context'>The context for the test, this holds state that is passed beteen tests</param>
        public void Execute(XmlNode testConfig, Context context)
        {
            _sourcePath = context.ReadConfigAsString(testConfig, "SourcePath");
            _creationPath = context.ReadConfigAsString(testConfig, "CreationPath");

            Execute(context);
        }
开发者ID:RobBowman,项目名称:BizUnit,代码行数:12,代码来源:FileCreateStep.cs

示例4: Execute

		/// <summary>
		/// ITestStep.Execute() implementation
		/// </summary>
		/// <param name='testConfig'>The Xml fragment containing the configuration for this test step</param>
		/// <param name='context'>The context for the test, this holds state that is passed beteen tests</param>
		public void Execute(XmlNode testConfig, Context context)
		{
			var rawListOfMachines = context.ReadConfigAsString(testConfig, "Machine", true);
            
            var listOfMachines = new List<string>();

            if (string.IsNullOrEmpty(rawListOfMachines))
            {
                listOfMachines.Add(Environment.MachineName);
            }
            else
            {
                listOfMachines.AddRange(rawListOfMachines.Split(','));
            }

            foreach (var machine in listOfMachines)
            {
                var eventLog = context.ReadConfigAsString(testConfig, "EventLog");

                using (var log = new EventLog(eventLog, machine))
                {
                    context.LogInfo("About to clear the '{0}' event log on machine '{1}'of all entries.", eventLog,
                                    machine);
                    log.Clear();
                }
            }
		}
开发者ID:RobBowman,项目名称:BizUnit,代码行数:32,代码来源:EventLogClearStep.cs

示例5: Execute

		/// <summary>
		/// ITestStep.Execute() implementation
		/// </summary>
		/// <param name='testConfig'>The Xml fragment containing the configuration for this test step</param>
		/// <param name='context'>The context for the test, this holds state that is passed beteen tests</param>
		public void Execute(XmlNode testConfig, Context context)
        {
			string sourcePath = context.ReadConfigAsString(testConfig, "SourcePath");
			string destinationPath = context.ReadConfigAsString(testConfig, "DestinationPath");

			File.Move( sourcePath, destinationPath ) ;

			context.LogInfo( "FileMoveStep has moved file: \"{0}\" to \"{1}\"", sourcePath, destinationPath ) ;
		}
开发者ID:RobBowman,项目名称:BizUnit,代码行数:14,代码来源:FileMoveStep.cs

示例6: Execute

		/// <summary>
		/// ITestStep.Execute() implementation
		/// </summary>
		/// <param name='testConfig'>The Xml fragment containing the configuration for this test step</param>
		/// <param name='context'>The context for the test, this holds state that is passed beteen tests</param>
		public void Execute(XmlNode testConfig, Context context)
		{
			string srcDirectory = context.ReadConfigAsString( testConfig, "SourceDirectory");
			string dstDirectory = context.ReadConfigAsString( testConfig, "DestinationDirectory");

			context.LogInfo("About to renme the directory \"{0}\" to \"{1}\"", srcDirectory, dstDirectory);

			var di = new DirectoryInfo(srcDirectory);
			di.MoveTo(dstDirectory);
		}
开发者ID:RobBowman,项目名称:BizUnit,代码行数:15,代码来源:RenameDirectoryStep.cs

示例7: Execute

        /// <summary>
        /// ITestStep.Execute() implementation
        /// </summary>
        /// <param name='testConfig'>The Xml fragment containing the configuration for this test step</param>
        /// <param name='context'>The context for the test, this holds state that is passed beteen tests</param>
        public void Execute(XmlNode testConfig, Context context)
        {
            var destinationPath = context.ReadConfigAsString(testConfig, "DestinationPath");
            var rawListOfServers = context.ReadConfigAsString(testConfig, "Server");
            
            var listOfServers = new List<string>();
            listOfServers.AddRange(rawListOfServers.Split(','));

            foreach (var server in listOfServers)
            {
                context.LogInfo("About to save the event on server: {0} to the following directory: {1}", server,
                                destinationPath);

                ManagementScope scope;

                if ((server.ToUpper() != Environment.MachineName.ToUpper()))
                {
                    var options = new ConnectionOptions
                                      {
                                          Impersonation = ImpersonationLevel.Impersonate,
                                          EnablePrivileges = true
                                      };
                    scope = new ManagementScope(string.Format(@"\\{0}\root\cimv2", server), options);
                }
                else
                {
                    var options = new ConnectionOptions
                                      {
                                          Impersonation = ImpersonationLevel.Impersonate,
                                          EnablePrivileges = true
                                      };
                    scope = new ManagementScope(@"root\cimv2", options);
                }

                var query = new SelectQuery("Select * from Win32_NTEventLogFile");
                var searcher = new ManagementObjectSearcher(scope, query);

                foreach (var logFileObject in searcher.Get())
                {
                    var methodArgs = new object[] { destinationPath + @"\" + server + ".evt" };

                    try
                    {
                        ((ManagementObject)logFileObject).InvokeMethod("BackupEventLog", methodArgs);
                    }
                    catch (Exception e1)
                    {
                        //access denied on method call if scope path referes to the same  
                        context.LogException(e1);

                        throw;
                    }
                }
            }
        }
开发者ID:RobBowman,项目名称:BizUnit,代码行数:60,代码来源:EventLogSaveStep.cs

示例8: Execute

		/// <summary>
		/// ITestStep.Execute() implementation
		/// </summary>
		/// <param name='testConfig'>The Xml fragment containing the configuration for this test step</param>
		/// <param name='context'>The context for the test, this holds state that is passed beteen tests</param>
		public void Execute(XmlNode testConfig, Context context)
		{
			string queueManager = context.ReadConfigAsString(testConfig, "QueueManager");
			string queue = context.ReadConfigAsString(testConfig, "Queue");
			int waitTimeout = context.ReadConfigAsInt32(testConfig, "WaitTimeout");
			XmlNode validationConfig = testConfig.SelectSingleNode("ValidationStep");

		    string message = MQSeriesHelper.ReadMessage(queueManager, queue, waitTimeout, context);

            context.LogData("MQSeries output message:", message);

            context.ExecuteValidator(StreamHelper.LoadMemoryStream(message), validationConfig);
		}
开发者ID:RobBowman,项目名称:BizUnit,代码行数:18,代码来源:MQSeriesGetStep.cs

示例9: Execute

		/// <summary>
		/// ITestStep.Execute() implementation
		/// </summary>
		/// <param name='testConfig'>The Xml fragment containing the configuration for this test step</param>
		/// <param name='context'>The context for the test, this holds state that is passed beteen tests</param>
		public void Execute(XmlNode testConfig, Context context)
        {
			string sourcePath = context.ReadConfigAsString(testConfig, "SourceDirectory");
			string pattern = context.ReadConfigAsString(testConfig, "SearchPattern");
			string destinationPath = context.ReadConfigAsString(testConfig, "DestinationDirectory");
			string [] filelist = Directory.GetFiles( sourcePath, pattern ) ;

			foreach( string file in filelist)
			{
				File.Move( file, destinationPath + @"\" + Path.GetFileName( file ) ) ;

				context.LogInfo( "FilesMoveStep has moved file: \"{0}\" to \"{1}\"", file, destinationPath ) ;
			}
		}
开发者ID:RobBowman,项目名称:BizUnit,代码行数:19,代码来源:FilesMoveStep.cs

示例10: Execute

		/// <summary>
		/// ITestStep.Execute() implementation
		/// </summary>
		/// <param name='testConfig'>The Xml fragment containing the configuration for this test step</param>
		/// <param name='context'>The context for the test, this holds state that is passed beteen tests</param>
		public void Execute(XmlNode testConfig, Context context)
        {
            string connectionString = context.ReadConfigAsString(testConfig, "ConnectionString" );
            string table = context.ReadConfigAsString(testConfig, "Table" );
            string condition = context.ReadConfigAsString(testConfig, "Condition" );

            // Build the SQL statement
            string sqlStatement = "delete from " + table + " where " + condition ;

            context.LogInfo( "DatabaseDeleteStep connecting to \"{0}\", executing statement \"{1}\"", connectionString, sqlStatement ) ;

            // Execute command against specified database
            DatabaseHelper.ExecuteNonQuery( connectionString, sqlStatement ) ;
        }
开发者ID:RobBowman,项目名称:BizUnit,代码行数:19,代码来源:DatabaseDeleteStep.cs

示例11: Execute

		/// <summary>
		/// ITestStep.Execute() implementation
		/// </summary>
		/// <param name='testConfig'>The Xml fragment containing the configuration for this test step</param>
		/// <param name='context'>The context for the test, this holds state that is passed beteen tests</param>
		public void Execute(XmlNode testConfig, Context context)
		{
			MemoryStream request = null;
			MemoryStream response = null;

			try
			{
				// read test config...
				string sourcePath = context.ReadConfigAsString( testConfig, "SourcePath" );
				string destinationUrl = context.ReadConfigAsString( testConfig, "DestinationUrl" );
				int requestTimeout = context.ReadConfigAsInt32( testConfig, "RequestTimeout" );
				XmlNode validationConfig = testConfig.SelectSingleNode("ValidationStep");

				context.LogInfo("HttpRequestResponseStep about to post data from File: {0} to the Url: {1}", sourcePath, destinationUrl );

				// Get the data to post...
				request = StreamHelper.LoadFileToStream(sourcePath);
				byte[] data = request.GetBuffer();

				// Post the data...
				response = HttpHelper.SendRequestData(destinationUrl, data, requestTimeout, context);

				// Dump the respons to the console...
				StreamHelper.WriteStreamToConsole("HttpRequestResponseStep response data", response, context);

				// Validate the response...
				try
				{
					response.Seek(0, SeekOrigin.Begin);
					context.ExecuteValidator( response, validationConfig );
				}
				catch(Exception e)
				{
					throw new ApplicationException("HttpRequestResponseStep response stream was not correct!", e);
				}
			}
			finally
			{
				if ( null != response )
				{
					response.Close();
				}

				if ( null != request )
				{
					request.Close();
				}
			}
		}
开发者ID:RobBowman,项目名称:BizUnit,代码行数:54,代码来源:HttpRequestResponseStep.cs

示例12: ExecuteValidation

        /// <summary>
		/// IValidationStep.ExecuteValidation() implementation
		/// </summary>
		/// <param name='data'>The stream cintaining the data to be validated.</param>
		/// <param name='validatorConfig'>The Xml fragment containing the configuration for the test step</param>
		/// <param name='context'>The context for the test, this holds state that is passed beteen tests</param>
		public void ExecuteValidation(Stream data, XmlNode validatorConfig, Context context)
		{
			_comparisonDataPath = context.ReadConfigAsString( validatorConfig, "ComparisonDataPath" );
			_compareAsUtf8 = context.ReadConfigAsBool( validatorConfig, "CompareAsUTF8", true);

            ExecuteValidation(data, context);
		}
开发者ID:RobBowman,项目名称:BizUnit,代码行数:13,代码来源:BinaryValidationStep.cs

示例13: Execute

		/// <summary>
		/// ITestStep.Execute() implementation
		/// </summary>
		/// <param name='testConfig'>The Xml fragment containing the configuration for this test step</param>
		/// <param name='context'>The context for the test, this holds state that is passed beteen tests</param>
		public void Execute(XmlNode testConfig, Context context)
		{
			// Rread test config...
			var typeName = context.ReadConfigAsString( testConfig, "TypeName" );
			var assemblyPath = context.ReadConfigAsString( testConfig, "AssemblyPath" );
			var methodToInvoke = context.ReadConfigAsString( testConfig, "MethodToInvoke" );
            var parameters = testConfig.SelectNodes("Parameter");
			var returnParameter = context.ReadConfigAsXml( testConfig, "ReturnParameter", true );
			
			var obj = CreateObject(typeName, assemblyPath, context);

			var mi = obj.GetType().GetMethod(methodToInvoke);
			var pi = mi.GetParameters();
			
			var parameterArray = new ArrayList();

			for( int c = 0; c < pi.Length; c++)
			{
				var t = pi[c].ParameterType;
				var xs = new XmlSerializer(t);
                parameterArray.Add(xs.Deserialize(new XmlTextReader(StreamHelper.LoadMemoryStream(context.GetInnerXml(parameters[c])))));
			}

			var paramsForCall = new object[parameterArray.Count];
			for( int c = 0; c < parameterArray.Count; c++ )
			{
				paramsForCall[c] = parameterArray[c];
			}

			context.LogInfo("About to call the method: {0}() on the type {1}", methodToInvoke, typeName );
			// Call the .Net Object...
			var returnValue = mi.Invoke(obj, paramsForCall);
			context.LogInfo("Return value: {0}", returnValue);

            if (!string.IsNullOrEmpty(returnParameter))
			{
				var xsRet = new XmlSerializer(returnValue.GetType());

				var rs = new MemoryStream();
				xsRet.Serialize( new StreamWriter(rs), returnValue );
				var es = StreamHelper.LoadMemoryStream(returnParameter);

				rs.Seek(0, SeekOrigin.Begin);
				es.Seek(0, SeekOrigin.Begin);
				StreamHelper.CompareXmlDocs(rs, es, context);
			}
		}
开发者ID:RobBowman,项目名称:BizUnit,代码行数:52,代码来源:DotNetObjectInvokerStep.cs

示例14: Execute

        /// <summary>
        /// ITestStep.Execute() implementation
        /// </summary>
        /// <param name='testConfig'>The Xml fragment containing the configuration for this test step</param>
        /// <param name='context'>The context for the test, this holds state that is passed beteen tests</param>
        public void Execute(XmlNode testConfig, Context context)
		{
			var delayBeforeCheck = context.ReadConfigAsInt32( testConfig, "DelayBeforeExecution" );			
			var connectionString = context.ReadConfigAsString( testConfig, "ConnectionString" );

			var datasetWriteXmlSchemaPath = context.ReadConfigAsString(testConfig, "DatasetWriteXmlSchemaPath");
			var datasetWriteXmlPath = context.ReadConfigAsString(testConfig, "DatasetWriteXmlPath");
			var tableNames = context.ReadConfigAsString(testConfig, "TableNames");

			// Sleep for delay seconds...
			System.Threading.Thread.Sleep(delayBeforeCheck);

			var ds = GetDataSet(connectionString, tableNames);

			ds.WriteXml(datasetWriteXmlPath);
			ds.WriteXmlSchema(datasetWriteXmlSchemaPath);
		}
开发者ID:RobBowman,项目名称:BizUnit,代码行数:22,代码来源:ExportDBDataToDataSetStep.cs

示例15: Execute

		/// <summary>
		/// ITestStep.Execute() implementation
		/// </summary>
		/// <param name='testConfig'>The Xml fragment containing the configuration for this test step</param>
		/// <param name='context'>The context for the test, this holds state that is passed beteen tests</param>
        
        public void Execute(XmlNode testConfig, Context context)
        {
            string directoryName = context.ReadConfigAsString(testConfig, "DirectoryName");

            context.LogInfo("About to create the directory: {0}", directoryName);
		    
            System.IO.Directory.CreateDirectory(directoryName);
        }
开发者ID:RobBowman,项目名称:BizUnit,代码行数:14,代码来源:CreateDirectory.cs


注:本文中的Context.ReadConfigAsString方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。