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


C# Cmdlet.WriteWarning方法代码示例

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


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

示例1: WriteErrorDetails

        /// <summary>
        /// Process the exception that was thrown and write the error details.
        /// </summary>
        /// <param name="cmdlet">The cmdlet for which to write the error output.</param>
        /// <param name="clientRequestId">The unique id for this request.</param>
        /// <param name="exception">The exception that was thrown.</param>
        public static void WriteErrorDetails(
            Cmdlet cmdlet,
            string clientRequestId,
            Exception exception)
        {
            string requestId;
            ErrorRecord errorRecord = RetrieveExceptionDetails(exception, out requestId);

            // Write the request Id as a warning
            if (requestId != null)
            {
                // requestId was availiable from the server response, write that as warning to the
                // console.
                cmdlet.WriteWarning(string.Format(
                    CultureInfo.InvariantCulture,
                    Resources.ExceptionRequestId,
                    requestId));
            }
            else
            {
                // requestId was not availiable from the server response, write the client Ids that
                // was sent.
                cmdlet.WriteWarning(string.Format(
                    CultureInfo.InvariantCulture,
                    Resources.ExceptionClientSessionId,
                    SqlDatabaseCmdletBase.clientSessionId));
                cmdlet.WriteWarning(string.Format(
                    CultureInfo.InvariantCulture,
                    Resources.ExceptionClientRequestId,
                    clientRequestId));
            }

            // Write the actual errorRecord containing the exception details
            cmdlet.WriteError(errorRecord);
        }
开发者ID:hovsepm,项目名称:azure-sdk-tools,代码行数:41,代码来源:SqlDatabaseExceptionHandler.cs

示例2: WriteLoadError

		private static bool WriteLoadError(Cmdlet cmdlet, ArrayList loadError, string errorId)
		{
			bool flag;
			IEnumerator enumerator = loadError.GetEnumerator();
			try
			{
				while (enumerator.MoveNext())
				{
					DataFileLoadError current = (DataFileLoadError)enumerator.Current;
					if (current.status != DataFileLoadError.ErrorStatus.Warning)
					{
						if (current.status != DataFileLoadError.ErrorStatus.Error)
						{
							continue;
						}
						cmdlet.WriteError(new ErrorRecord(current.exception, errorId, ErrorCategory.InvalidOperation, null));
						flag = false;
						return flag;
					}
					else
					{
						cmdlet.WriteWarning(string.Concat(current.message, "\n\n"));
					}
				}
				return true;
			}
			finally
			{
				IDisposable disposable = enumerator as IDisposable;
				if (disposable != null)
				{
					disposable.Dispose();
				}
			}
			return flag;
		}
开发者ID:nickchal,项目名称:pash,代码行数:36,代码来源:PswaAuthorizationRuleCommandHelper.cs

示例3: CopyDirectory


//.........这里部分代码省略.........
                    while (!task.IsCompleted && !task.IsCanceled)
                    {
                        // if we somehow made it in here prior to the cancel, I want to issue a throw
                        cmdletCancellationToken.ThrowIfCancellationRequested();

                        // only update progress if the percentage has changed.
                        if ((int) Math.Ceiling((decimal) testFileCountChanged/totalFiles*100)
                            < (int) Math.Ceiling((decimal) fileCount/totalFiles*100))
                        {
                            testFileCountChanged = fileCount;
                            var percentComplete = (int) Math.Ceiling((decimal) fileCount/totalFiles*100);
                            if (percentComplete > 100)
                            {
                                // in some cases we can get 101 percent complete using ceiling, however we want to be
                                // able to round up to full percentage values, instead of down.
                                percentComplete = 100;
                            }

                            progress.PercentComplete = percentComplete;
                            UpdateProgress(progress, cmdletRunningRequest);
                        }

                        // sleep for a half of a second.
                        TestMockSupport.Delay(500);
                    }

                    if (task.IsFaulted && !task.IsCanceled)
                    {
                        var ae = task.Exception;
                        if (ae != null)
                        {
                            if (cmdletRunningRequest != null)
                            {
                                cmdletRunningRequest.WriteWarning(
                                    "The following errors were encountered during the copy:");
                            }
                            else
                            {
                                Console.WriteLine(@"The following errors were encountered during the copy:");
                            }

                            ae.Handle(
                                ex =>
                                {
                                    if (ex is AggregateException)
                                    {
                                        var secondLevel = ex as AggregateException;
                                        secondLevel.Handle(
                                            secondEx =>
                                            {
                                                if (cmdletRunningRequest != null)
                                                {
                                                    cmdletRunningRequest.WriteWarning(secondEx.ToString());
                                                }
                                                else
                                                {
                                                    Console.WriteLine(secondEx);
                                                }

                                                return true;
                                            });
                                    }
                                    else
                                    {
                                        if (cmdletRunningRequest != null)
                                        {
开发者ID:singhkays,项目名称:azure-powershell,代码行数:67,代码来源:DataLakeStoreFileSystemClient.cs

示例4: AutoFillMetricsConfig

        private static void AutoFillMetricsConfig(JObject wadCfgObject, string resourceId, Cmdlet cmdlet)
        {
            if (string.IsNullOrEmpty(resourceId))
            {
                return;
            }

            var configObject = wadCfgObject[DiagnosticMonitorConfigurationElemStr] as JObject;
            if (configObject == null)
            {
                throw new ArgumentException(Properties.Resources.DiagnosticsExtensionDiagnosticMonitorConfigurationElementNotDefined);
            }

            var metricsObject = configObject[MetricsElemStr] as JObject;
            if (metricsObject == null)
            {
                configObject.Add(new JProperty(MetricsElemStr,
                                    new JObject(
                                        new JProperty(MetricsResourceIdAttr, resourceId))));
            }
            else
            {
                var resourceIdValue = metricsObject[MetricsResourceIdAttr] as JValue;
                if (resourceIdValue != null && !resourceIdValue.Value.Equals(resourceId))
                {
                    cmdlet.WriteWarning(Properties.Resources.DiagnosticsExtensionMetricsResourceIdNotMatch);
                }
                metricsObject[MetricsResourceIdAttr] = resourceId;
            }
        }
开发者ID:singhkays,项目名称:azure-powershell,代码行数:30,代码来源:DiagnosticsHelper.cs

示例5: WriteGenomeHostWarning

 internal static void WriteGenomeHostWarning(Cmdlet self, string message)
 {
     self.WriteWarning(message);
 }
开发者ID:AlexeyEvlampiev,项目名称:genome-ctl,代码行数:4,代码来源:CmdletHelpers.cs

示例6: AssignNewValue

        public void AssignNewValue(Cmdlet myCmdlet, attributeSchema prop, card so, object newValue)
        {
            if (newValue == null) { return; } // Hacky Workaround
            var lists = so.attributeList != null ? so.attributeList.ToList() : new List<attribute>();

            myCmdlet.WriteVerbose("Want to set " + prop.name + " to " + newValue.ToString());

            var dict = lists.ToDictionary(key => key.name, value => value);
            var as1 = new attribute{ name = prop.name};
            switch (prop.type)
            {
                case  "DATE":
                    string valtoset = newValue != null ? newValue.ToString() : null;
                    if (!string.IsNullOrEmpty(valtoset))
                    {
                        try
                        {
                            myCmdlet.WriteVerbose("DATE: Convert string to DateTimeObject");
                            DateTime xd = DateTime.Parse(valtoset.ToString(), CultureInfo.CurrentCulture);
                            as1.value = xd.ToString("yyyy-MM-ddThh:mm:ssZ");
                        }
                        catch (Exception e) { myCmdlet.WriteWarning(e.Message); }
                    }
                    break;
                case "TIMESTAMP":
                    string datetimetoset = newValue != null ? newValue.ToString() : null;
                    if (!string.IsNullOrEmpty(datetimetoset))
                    {
                        try
                        {
                            myCmdlet.WriteVerbose("TIMESTAMP: Convert string to DateTimeObject -> _" + datetimetoset.ToString() +"_");
                            DateTime xd = DateTime.Parse(datetimetoset.ToString(), CultureInfo.CurrentCulture);
                            as1.value = xd.ToString("yyyy-MM-ddThh:mm:ssZ");
                        }
                        catch (Exception e) { myCmdlet.WriteWarning(e.Message); }
                    }
                    break;
                case "REFERENCE":
                    if (prop.referencedIdClassSpecified && newValue.ToString().Length > 0)
                    {

                        int codeint = 0;
                        int.TryParse(newValue.ToString(), out codeint);
                        if (codeint == 0)
                        {
                            myCmdlet.WriteVerbose("Try it with Workaround Parent Class: " + prop.referencedClassName);
                            int tmpvalue = 0;
                            var parentclass = _clientconnection.getAttributeList(prop.referencedClassName);
                            foreach (attributeSchema attributeschema in parentclass)
                            {
                                if (attributeschema.name == as1.name)
                                {
                                    string newclassname = attributeschema.referencedClassName;
                                    myCmdlet.WriteVerbose("Try it with Fulltext search classname: " + newclassname);
                                    tmpvalue = GetCardbyCode(newclassname, newValue.ToString());
                                    if (tmpvalue == 0)
                                    {
                                        myCmdlet.WriteWarning("Reference Card not found: " + newValue.ToString());
                                        dict.Remove(as1.name);
                                    }
                                    else
                                    {
                                        myCmdlet.WriteVerbose("Card found: " + tmpvalue);
                                        newValue = tmpvalue;
                                    }

                                    break;
                                }
                            }

                            if (tmpvalue == 0)
                            {
                                myCmdlet.WriteVerbose("Fulltext search ReferenceCard: " + newValue.ToString());
                                myCmdlet.WriteVerbose("Fulltext search classname: " + prop.referencedClassName);
                                tmpvalue = GetCardbyCode(prop.referencedClassName, newValue.ToString());
                                newValue = tmpvalue;
                            }
                            else
                            {
                                myCmdlet.WriteVerbose("Card found Set to Value: " + tmpvalue);
                                newValue = tmpvalue;
                            }

                        }
                        else
                        {

                            //myCmdlet.WriteVerbose("Check if ReferenceCard exists: " + codeint);
                            //var check = _clientconnection.getCard(prop.referencedClassName, codeint, null);
                            //if (check == null)
                            //{
                            //    myCmdlet.WriteWarning("Reference Card not found: " + codeint);
                            //    dict.Remove(as1.name);
                            //}
                        }
                        as1.value = newValue.ToString();

                    }
                    break;
                default:
//.........这里部分代码省略.........
开发者ID:simonfuhrer,项目名称:CMDBLets,代码行数:101,代码来源:EntityTypes.cs

示例7: AdaptCardObject

 public PSObject AdaptCardObject(Cmdlet myCmdlet, card cardObject)
 {
     var promotedObject = new PSObject(cardObject);
     promotedObject.TypeNames.Insert(1, cardObject.GetType().FullName);
     promotedObject.TypeNames[0] = String.Format(CultureInfo.CurrentCulture, "CardObject#{0}",cardObject.className);
     // loop through the properties and promote them into the PSObject we're going to return
     foreach ( var p in cardObject.attributeList)
     {
         try
         {
             promotedObject.Members.Add(new PSNoteProperty(p.name, p.value));
         }
         catch (ExtendedTypeSystemException ets)
         {
             myCmdlet.WriteWarning(String.Format("The property '{0}' already exists, skipping.\nException: {1}", p.name, ets.Message));
         }
         catch (Exception e)
         {
             myCmdlet.WriteError(new ErrorRecord(e, "Property", ErrorCategory.NotSpecified, p.name));
         }
     }
     return promotedObject;
 }
开发者ID:simonfuhrer,项目名称:CMDBLets,代码行数:23,代码来源:EntityTypes.cs


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