string.Format(System.IFormatProvider, string, object)

Here are the examples of the csharp api string.Format(System.IFormatProvider, string, object) taken from open source projects. By voting up you can indicate which examples are most useful and appropriate.

1561 Examples 7

19 View Source File : StringInjectExtension.cs
License : MIT License
Project Creator : 0x0ade

public static string InjectSingleValue(this string formatString, string key, object replacementValue) {
            string result = formatString;
            //regex replacement of key with value, where the generic key format is:
            //Regex foo = new("{(foo)(?:}|(?::(.[^}]*)}))");
            Regex attributeRegex = new("{(" + key + ")(?:}|(?::(.[^}]*)}))");  //for key = foo, matches {foo} and {foo:SomeFormat}

            //loop through matches, since each key may be used more than once (and with a different format string)
            foreach (Match? m in attributeRegex.Matches(formatString)) {
                if (m == null)
                    continue;

                string replacement = m.ToString();
                if (m.Groups[2].Length > 0) {
                    //matched {foo:SomeFormat}
                    //do a double string.Format - first to build the proper format string, and then to format the replacement value
                    string attributeFormatString = string.Format(CultureInfo.InvariantCulture, "{{0:{0}}}", m.Groups[2]);
                    replacement = string.Format(CultureInfo.CurrentCulture, attributeFormatString, replacementValue);
                } else {
                    //matched {foo}
                    replacement = replacementValue.ToString() ?? string.Empty;
                }
                //perform replacements, one match at a time
                result = result.Replace(m.ToString(), replacement);  //attributeRegex.Replace(result, replacement, 1);
            }
            return result;

        }

19 View Source File : InternalExtensions.cs
License : MIT License
Project Creator : 2881099

internal static string ToInvariantCultureToString(this object obj) => obj is string objstr ? objstr : string.Format(CultureInfo.InvariantCulture, @"{0}", obj);

19 View Source File : TfsVisualHistoryVSPackage.cs
License : MIT License
Project Creator : aabiryukov

protected override void Initialize()
        {
            Debug.WriteLine(string.Format(CultureInfo.CurrentCulture, "Entering Initialize() of: {0}", this.ToString()));
            ViewSourceControlHistoryCommand.Initialize(this);

            base.Initialize();
        }

19 View Source File : BTCChinaAPI.cs
License : MIT License
Project Creator : aabiryukov

public static List<TradeHistory> GetTradeHistory(int limit)
		{
			var queryStr = string.Format(CultureInfo.InvariantCulture, "https://" + apiHost + "/data/historydata?limit={0}", limit);
			var json = WebApi.Query(queryStr);
			var list = JsonConvert.DeserializeObject<List<TradeHistory>>(json);
			return list;
		}

19 View Source File : BTCChinaAPI.cs
License : MIT License
Project Creator : aabiryukov

public static OrderBook GetOrderBook(int limit)
		{
			var queryStr = string.Format(CultureInfo.InvariantCulture, "https://" + apiHost + "/data/orderbook?limit={0}", limit);
			var json = WebApi.Query(queryStr);
			var book = JsonConvert.DeserializeObject<OrderBook>(json);
			return book;
		}

19 View Source File : HuobiAPI.cs
License : MIT License
Project Creator : aabiryukov

public static OrderBook GetOrderBook(int limit)
		{
			var queryStr = string.Format(CultureInfo.InvariantCulture, "staticmarket/depth_btc_{0}.js", limit);
			var json = WebApi.Query(queryStr);
			var book = JsonConvert.DeserializeObject<OrderBook>(json);
			return book;
		}

19 View Source File : HistoryViewer.cs
License : MIT License
Project Creator : aabiryukov

[System.Diagnostics.Codereplacedysis.SuppressMessage("Microsoft.Maintainability", "CA1502:AvoidExcessiveComplexity")]
		private void ExecViewHistory(Uri tfsCollectionUri, string sourceControlFolder)
        {
            // gource start arguments
            string arguments;
            string replacedle;
			string avatarsDirectory = null;

            if (m_settigs.PlayMode == VisualizationSettings.PlayModeOption.History)
            {
                replacedle = "History of " + sourceControlFolder;
				var logFile = Path.Combine(FileUtils.GetTempPath(), "TfsHistoryLog.tmp.txt");
	            
	            if (m_settigs.ViewAvatars)
	            {
		            avatarsDirectory = Path.Combine(FileUtils.GetTempPath(), "TfsHistoryLog.tmp.Avatars");
					if (!Directory.Exists(avatarsDirectory))
		            {
			            Directory.CreateDirectory(avatarsDirectory);
		            }
	            }

				bool historyFound;
				bool hasLines;

                using (var waitMessage = new WaitMessage("Connecting to Team Foundation Server...", OnCancelByUser))
                {
                    var progress = waitMessage.CreateProgress("Loading history ({0}% done) ...");

                    hasLines =
                        TfsLogWriter.CreateGourceLogFile(
                            logFile,
							avatarsDirectory,
                            tfsCollectionUri,
                            sourceControlFolder,
                            m_settigs,
                            ref m_canceled,
                            progress.SetValue
                            );

	                historyFound = progress.LastValue > 0;
                    progress.Done();
                }

                if (m_canceled)
					return;

                if (!hasLines)
                {
	                MessageBox.Show(
		                historyFound
			                ? "No items found.\nCheck your filters: 'User name' and 'File type'."
							: "No items found.\nTry to change period of the history (From/To dates).",
		                "TFS History Visualization");
	                return;
                }

	            arguments = string.Format(CultureInfo.InvariantCulture, " \"{0}\" ", logFile);

                // Setting other history settings

                arguments += " --seconds-per-day " + m_settigs.SecondsPerDay.ToString(CultureInfo.InvariantCulture);

                if (m_settigs.TimeScale != VisualizationSettings.TimeScaleOption.None)
                {
                    var optionValue = ConvertToString(m_settigs.TimeScale);
                    if (optionValue != null)
                        arguments += " --time-scale " + optionValue;
                }

                if (m_settigs.LoopPlayback)
                {
                    arguments += " --loop";
                }

				arguments += " --file-idle-time 60"; // 60 is default in gource 0.40 and older. Since 0.41 default 0.
            }
            else
            {
                // PlayMode: Live
                replacedle = "Live changes of " + sourceControlFolder;

                arguments = " --realtime --log-format custom -";
                arguments += " --file-idle-time 28800"; // 8 hours (work day)
            }

            var baseDirectory = Path.GetDirectoryName(System.Reflection.replacedembly.GetExecutingreplacedembly().Location) ??
                                "unknown";


            if (baseDirectory.Contains("Test"))
            {
                baseDirectory += @"\..\..\..\VSExtension";
            }

#if DEBUG
			// baseDirectory = @"C:\Temp\aaaa\уи³пс\";
#endif
            var gourcePath = Path.Combine(baseDirectory, @"Gource\Gource.exe");
            var dataPath = Path.Combine(baseDirectory, @"Data");

            // ******************************************************
            // Configuring Gource command line
            // ******************************************************

            arguments +=
                string.Format(CultureInfo.InvariantCulture, " --highlight-users --replacedle \"{0}\"", replacedle);

			if (m_settigs.ViewLogo != CheckState.Unchecked)
			{
				var logoFile = m_settigs.ViewLogo == CheckState.Indeterminate
					? Path.Combine(dataPath, "Logo.png")
					: m_settigs.LogoFileName;

				// fix gource unicode path problems
				logoFile = FileUtils.GetShortPath(logoFile);

				arguments += string.Format(CultureInfo.InvariantCulture, " --logo \"{0}\"", logoFile);
			}

            if (m_settigs.FullScreen)
            {
                arguments += " --fullscreen";

				// By default gource not using full area of screen width ( It's a bug. Must be fixed in gource 0.41).
				// Fixing fullscreen resolution to real full screen.
				if (!m_settigs.SetResolution)
				{
					var screenBounds = Screen.PrimaryScreen.Bounds;
					arguments += string.Format(CultureInfo.InvariantCulture, " --viewport {0}x{1}", screenBounds.Width,
											   screenBounds.Height);
				}
			}

            if (m_settigs.SetResolution)
            {
                arguments += string.Format(CultureInfo.InvariantCulture, " --viewport {0}x{1}",
                                           m_settigs.ResolutionWidth, m_settigs.ResolutionHeight);
            }

            if (m_settigs.ViewFilesExtentionMap)
            {
                arguments += " --key";
            }

			if (!string.IsNullOrEmpty(avatarsDirectory))
			{
				arguments += string.Format(CultureInfo.InvariantCulture, " --user-image-dir \"{0}\"", avatarsDirectory);
			}

            // Process "--hide" option
            {
                var hideItems = string.Empty;
                if (!m_settigs.ViewDirNames)
                {
                    hideItems = "dirnames";
                }
                if (!m_settigs.ViewFileNames)
                {
                    if (hideItems.Length > 0) hideItems += ",";
                    hideItems += "filenames";
                }
                if (!m_settigs.ViewUserNames)
                {
                    if (hideItems.Length > 0) hideItems += ",";
                    hideItems += "usernames";
                }

                if (hideItems.Length > 0)
                    arguments += " --hide " + hideItems;
            }

            arguments += " --max-files " + m_settigs.MaxFiles.ToString(CultureInfo.InvariantCulture);

			if (SystemInformation.TerminalServerSession)
			{
				arguments += " --disable-bloom";
			}

			if (m_settigs.PlayMode == VisualizationSettings.PlayModeOption.History)
            {
                var si = new ProcessStartInfo(gourcePath, arguments)
                    {
                        WindowStyle = ProcessWindowStyle.Maximized,
 //                       UseShellExecute = true
					};

                Process.Start(si);
            }
            else
            {
                var logReader = new VersionControlLogReader(tfsCollectionUri, sourceControlFolder, m_settigs.UsersFilter,
                                                     m_settigs.FilesFilter);
                using (new WaitMessage("Connecting to Team Foundation Server..."))
                {
                    logReader.Connect();
                }

                System.Threading.Tasks.Task.Factory.StartNew(() => RunLiveChangesMonitor(logReader, gourcePath, arguments));
            }
        }

19 View Source File : WaitMessageProgress.cs
License : MIT License
Project Creator : aabiryukov

public void SetValue(int value)
        {
			if (LastValue == value)
				return;

	        LastValue = value;
            if (m_waitMessage != null)
                m_waitMessage.Text = string.Format(CultureInfo.CurrentCulture, m_formatString, value);
        }

19 View Source File : BTCChinaWebSocketApi.cs
License : MIT License
Project Creator : aabiryukov

public void Start()
		{
			if(m_webSocket != null)
				return;

			const string httpScheme = "https://";
			const string wsScheme = "wss://";
			const string webSocketUrl = "websocket.btcc.com/socket.io/";

			#region handshake

			string polling;
			using (var wc = new HttpClient())
			{
				polling = wc.GetStringAsync(httpScheme + webSocketUrl + "?transport=polling").Result;
				if (string.IsNullOrEmpty(polling))
				{
					throw new BTCChinaException("BtcChinaWebSocketApi.Start", "", "failed to download config");
				}
			}

			var config = polling.Substring(polling.IndexOf('{'), polling.IndexOf('}') - polling.IndexOf('{') + 1);
			var wsc = JsonConvert.DeserializeObject<WsConfigHelper>(config);

			#endregion handshake

			//set timers
			m_pingTimeoutTimer = new Timer(_ =>
			{
				if (m_pong)
				{
					m_pong = false; //waiting for another ping
				}
				else
				{
					Log.Error("[BtcChina] Ping Timeout!");
					if (TimeoutReceived != null)
					{
						TimeoutReceived(this, new EventArgs());
					}
				}
			}, null, Timeout.Infinite, Timeout.Infinite);

			m_pingIntervalTimer = new Timer(_ =>
			{
				m_webSocket.Send(string.Format(CultureInfo.InvariantCulture, "{0}", (int)EngineioMessageType.PING));
				m_pingTimeoutTimer.Change(wsc.PingTimeout, Timeout.Infinite);
				m_pong = false;
			}, null, wsc.PingInterval, wsc.PingInterval);

			//setup websocket connections and events
			m_webSocket = new WebSocket(wsScheme + webSocketUrl + "?transport=websocket&sid=" + wsc.Sid);
			m_webSocket.Opened += btc_Opened;
			m_webSocket.Error += btc_Error;
			m_webSocket.MessageReceived += btc_MessageReceived;
			m_webSocket.DataReceived += btc_DataReceived;
			m_webSocket.Closed += btc_Closed;

			Log.Info("[BtcChina] Opening websockets...");
			m_webSocket.Open();
		}

19 View Source File : OKCoinAPI.cs
License : MIT License
Project Creator : aabiryukov

public static OrderBook GetOrderBook(int limit)
		{
			var queryStr = string.Format(CultureInfo.InvariantCulture, "depth.do?symbol=btc_usd&size={0}", limit);
			var json = WebApi.Query(queryStr);
			var book = JsonConvert.DeserializeObject<OrderBook>(json);
			return book;
		}

19 View Source File : FileUtils.cs
License : MIT License
Project Creator : aabiryukov

public static string GetShortPath(string path)
		{
			var shortPath = new StringBuilder(MAX_PATH);
			if (GetShortPathName(path, shortPath, MAX_PATH) == 0)
			{
				throw new InvalidDataException(string.Format(CultureInfo.InvariantCulture, "GetShortPathName failed for path '{0}'", path));
			}
			return shortPath.ToString();
		}

19 View Source File : HatchCanvas.cs
License : GNU Lesser General Public License v3.0
Project Creator : acnicholas

private DrawingVisual CreateDrawingVisualHatch(Hatch hatch)
        {
            DrawingVisual drawingVisual = new DrawingVisual();
            if (hatch == null) {
                return drawingVisual;
            }

            DrawingContext drawingContext = drawingVisual.RenderOpen();

            double dx = 0;
            double dy = 0;

            var scale = hatch.IsDrafting ? 10 : 1;

            drawingContext.PushClip(new RectangleGeometry(new Rect(0, 0, width, height)));
            drawingContext.DrawRectangle(Brushes.White, null, new Rect(0, 0, width, height));
            drawingContext.PushTransform(new TranslateTransform(width / 2, height / 2));
            drawingContext.DrawEllipse(null, new Pen(Brushes.LightBlue, 1), new Point(0, 0), 10, 10);
            drawingContext.DrawLine(new Pen(Brushes.LightBlue, 1), new Point(-20, 0), new Point(20, 0));
            drawingContext.DrawLine(new Pen(Brushes.LightBlue, 1), new Point(0, -20), new Point(0, 20));
            drawingContext.PushTransform(new ScaleTransform(canvreplacedcale, canvreplacedcale));

            double maxLength = width > height ? width / canvreplacedcale * 2 : height / canvreplacedcale * 2;

            foreach (var fillGrid in hatch.HatchPattern.GetFillGrids()) {
                double scaledSequenceLength = GetDashedLineLength(fillGrid, 1, scale);
                double initialShiftOffset = scaledSequenceLength > 0 ? (int)Math.Floor(maxLength / scaledSequenceLength) * scaledSequenceLength : maxLength;
                if (scaledSequenceLength > maxLength / 4) {
                    initialShiftOffset = scaledSequenceLength * 16;
                }

                var segsInMM = new List<double>();
                foreach (var s in fillGrid.GetSegments()) {
                    segsInMM.Add(s.ToMM(scale));
                }

                if (Math.Abs(fillGrid.Offset) < 0.001) {
                    continue;
                }

                int b = 0;

                var pen = new Pen(Brushes.Black, 1);
                pen.DashStyle = new DashStyle(segsInMM, initialShiftOffset);

                double a = fillGrid.Angle.ToDeg();
                drawingContext.PushTransform(new RotateTransform(-a, fillGrid.Origin.U.ToMM(scale), -fillGrid.Origin.V.ToMM(scale)));

                double replacedulativeShift = 0;

                while (Math.Abs(dy) < maxLength * 2) {
                    b++;
                    if (b > 100) {
                        break;
                    }
                    double x = fillGrid.Origin.U.ToMM(scale) - initialShiftOffset;
                    double y = -fillGrid.Origin.V.ToMM(scale);
                    drawingContext.PushTransform(new TranslateTransform(x + dx, y - dy));
                    drawingContext.DrawLine(pen, new Point(0, 0), new Point(initialShiftOffset * 2, 0));
                    drawingContext.Pop();
                    drawingContext.PushTransform(new TranslateTransform(x - dx, y + dy));
                    drawingContext.DrawLine(pen, new Point(0, 0), new Point(initialShiftOffset * 2, 0));
                    drawingContext.Pop();
                    dx += fillGrid.Shift.ToMM(scale);
                    replacedulativeShift += fillGrid.Shift.ToMM(scale);
                    if (Math.Abs(replacedulativeShift) > scaledSequenceLength) {
                        dx -= scaledSequenceLength;
                        replacedulativeShift = 0;
                    }
                    dy += fillGrid.Offset.ToMM(scale);
                }
                drawingContext.Pop();
                dx = 0;
                dy = 0;
            }
            drawingContext.Pop();
            drawingContext.Pop();
            drawingContext.Pop();

            drawingContext.DrawText(
                new FormattedText(
                    string.Format(System.Globalization.CultureInfo.InvariantCulture, "Scale: {0}", scale * canvreplacedcale),
                    System.Globalization.CultureInfo.InvariantCulture,
                    FlowDirection.LeftToRight,
                    new Typeface("arial"),
                    10,
                    Brushes.LightBlue,
                    1),
                new Point(10, 10));

            drawingContext.Close();
            return drawingVisual;
        }

19 View Source File : HostContext.cs
License : MIT License
Project Creator : actions

public T CreateService<T>() where T : clreplaced, IRunnerService
        {
            Type target;
            if (!_serviceTypes.TryGetValue(typeof(T), out target))
            {
                // Infer the concrete type from the ServiceLocatorAttribute.
                CustomAttributeData attribute = typeof(T)
                    .GetTypeInfo()
                    .CustomAttributes
                    .FirstOrDefault(x => x.AttributeType == typeof(ServiceLocatorAttribute));
                if (attribute != null)
                {
                    foreach (CustomAttributeNamedArgument arg in attribute.NamedArguments)
                    {
                        if (string.Equals(arg.MemberName, ServiceLocatorAttribute.DefaultPropertyName, StringComparison.Ordinal))
                        {
                            target = arg.TypedValue.Value as Type;
                        }
                    }
                }

                if (target == null)
                {
                    throw new KeyNotFoundException(string.Format(CultureInfo.InvariantCulture, "Service mapping not found for key '{0}'.", typeof(T).FullName));
                }

                _serviceTypes.TryAdd(typeof(T), target);
                target = _serviceTypes[typeof(T)];
            }

            // Create a new instance.
            T svc = Activator.CreateInstance(target) as T;
            svc.Initialize(this);
            return svc;
        }

19 View Source File : SecretUtility.cs
License : MIT License
Project Creator : actions

private static string ScrubSecret(string message, string token, string mask, bool replacedertOnDetection, bool maskToken=false)
        {
            int startIndex = -1;

            do
            {
                startIndex = message.IndexOf(token, (startIndex < 0) ? 0 : startIndex, StringComparison.OrdinalIgnoreCase);
                if (startIndex < 0)
                {
                    // Common case, there is not a preplacedword.
                    break;
                }

                //Explicitly check for original preplacedword mask so code that uses the orignal doesn't replacedert
                if (!maskToken && (
                    message.IndexOf(token + mask, StringComparison.OrdinalIgnoreCase) == startIndex
                    || (message.IndexOf(token + PreplacedwordMask, StringComparison.OrdinalIgnoreCase) == startIndex)))
                {
                    // The preplacedword is already masked, move past this string.
                    startIndex += token.Length + mask.Length;
                    continue;
                }

                // At this point we detected a preplacedword that is not masked, remove it!
                try
                {
                    if (!maskToken)
                    {
                        startIndex += token.Length;
                    }
                    // Find the end of the preplacedword.
                    int endIndex = message.Length - 1;

                    if (message[startIndex] == '"' || message[startIndex] == '\'')
                    {
                        // The preplacedword is wrapped in quotes.  The end of the string will be the next unpaired quote. 
                        // Unless the message itself wrapped the connection string in quotes, in which case we may mask out the rest of the message.  Better to be safe than leak the connection string.
                        // Intentionally going to "i < message.Length - 1".  If the quote isn't the second to last character, it is the last character, and we delete to the end of the string anyway.
                        for (int i = startIndex + 1; i < message.Length - 1; i++)
                        {
                            if (message[startIndex] == message[i])
                            {
                                if (message[startIndex] == message[i + 1])
                                {
                                    // we found a pair of quotes. Skip over the pair and continue.
                                    i++;
                                    continue;
                                }
                                else
                                {
                                    // this is a single quote, and the end of the preplacedword.
                                    endIndex = i;
                                    break;
                                }
                            }
                        }
                    }
                    else
                    {
                        // The preplacedword is not wrapped in quotes.
                        // The end is any whitespace, semi-colon, single, or double quote character.
                        for (int i = startIndex + 1; i < message.Length; i++)
                        {
                            if (Char.IsWhiteSpace(message[i]) || ((IList<Char>)s_validPreplacedwordEnding).Contains(message[i]))
                            {
                                endIndex = i - 1;
                                break;
                            }
                        }
                    }

                    message = message.Substring(0, startIndex) + mask + message.Substring(endIndex + 1);

                    // Bug 94478: We need to scrub the message before replacedert, otherwise we will fall into
                    // a recursive replacedert where the TeamFoundationServerException contains same message
                    if (replacedertOnDetection)
                    {
                        Debug.replacedert(false, String.Format(CultureInfo.InvariantCulture, "Message contains an unmasked secret. Message: {0}", message));
                    }

                    // Trace raw that we have scrubbed a message.
                    //FUTURE: We need a work item to add Tracing to the VSS Client replacedembly.
                    //TraceLevel traceLevel = replacedertOnDetection ? TraceLevel.Error : TraceLevel.Info;
                    //TeamFoundationTracingService.TraceRaw(99230, traceLevel, s_area, s_layer, "An unmasked preplacedword was detected in a message. MESSAGE: {0}. STACK TRACE: {1}", message, Environment.StackTrace);
                }
                catch (Exception /*exception*/)
                {
                    // With an exception here the message may still contain an unmasked preplacedword.
                    // We also do not want to interupt the current thread with this exception, because it may be constucting a message 
                    // for a different exception. Trace this exception and continue on using a generic exception message.
                    //TeamFoundationTracingService.TraceExceptionRaw(99231, s_area, s_layer, exception);
                }
                finally
                {
                    // Iterate to the next preplacedword (if it exists)
                    startIndex += mask.Length;
                }
            } while (startIndex < message.Length);

            return message;
        }

19 View Source File : And.cs
License : MIT License
Project Creator : actions

internal sealed override String ConvertToExpression()
        {
            return String.Format(
                CultureInfo.InvariantCulture,
                "({0})",
                String.Join(" && ", Parameters.Select(x => x.ConvertToExpression())));
        }

19 View Source File : ExpressionUtility.cs
License : MIT License
Project Creator : actions

internal static Object ConvertToCanonicalValue(
            Object val,
            out ValueKind kind,
            out Object raw)
        {
            raw = null;

            if (Object.ReferenceEquals(val, null))
            {
                kind = ValueKind.Null;
                return null;
            }
            else if (val is Boolean)
            {
                kind = ValueKind.Boolean;
                return val;
            }
            else if (val is Double)
            {
                kind = ValueKind.Number;
                return val;
            }
            else if (val is String)
            {
                kind = ValueKind.String;
                return val;
            }
            else if (val is INull n)
            {
                kind = ValueKind.Null;
                raw = val;
                return null;
            }
            else if (val is IBoolean boolean)
            {
                kind = ValueKind.Boolean;
                raw = val;
                return boolean.GetBoolean();
            }
            else if (val is INumber number)
            {
                kind = ValueKind.Number;
                raw = val;
                return number.GetNumber();
            }
            else if (val is IString str)
            {
                kind = ValueKind.String;
                raw = val;
                return str.GetString();
            }
            else if (val is IReadOnlyObject)
            {
                kind = ValueKind.Object;
                return val;
            }
            else if (val is IReadOnlyArray)
            {
                kind = ValueKind.Array;
                return val;
            }
            else if (!val.GetType().GetTypeInfo().IsClreplaced)
            {
                if (val is Decimal || val is Byte || val is SByte || val is Int16 || val is UInt16 || val is Int32 || val is UInt32 || val is Int64 || val is UInt64 || val is Single)
                {
                    kind = ValueKind.Number;
                    return Convert.ToDouble(val);
                }
                else if (val is Enum)
                {
                    var strVal = String.Format(CultureInfo.InvariantCulture, "{0:G}", val);
                    if (Double.TryParse(strVal, NumberStyles.AllowLeadingSign, CultureInfo.InvariantCulture, out Double doubleValue))
                    {
                        kind = ValueKind.Number;
                        return doubleValue;
                    }

                    kind = ValueKind.String;
                    return strVal;
                }
            }

            kind = ValueKind.Object;
            return val;
        }

19 View Source File : VssHttpEventSource.cs
License : MIT License
Project Creator : actions

[NonEvent]
        public void HttpRequestFailed(
            VssTraceActivity activity,
            HttpRequestMessage request,
            HttpStatusCode statusCode,
            string afdRefInfo)
        {
            if (IsEnabled())
            {
                SetActivityId(activity);
                CultureInfo cultureInfo = CultureInfo.InstalledUICulture;
                String message = String.Format(cultureInfo, "HTTP Status: {0}", statusCode);

                if (!string.IsNullOrEmpty(afdRefInfo))
                {
                    message += $", AFD Ref: {afdRefInfo}";
                }

                WriteMessageEvent(request.GetHttpMethod(), request.RequestUri.AbsoluteUri, message, this.HttpRequestFailed);
            }
        }

19 View Source File : Or.cs
License : MIT License
Project Creator : actions

internal sealed override String ConvertToExpression()
        {
            return String.Format(
                CultureInfo.InvariantCulture,
                "({0})",
                String.Join(" || ", Parameters.Select(x => x.ConvertToExpression())));
        }

19 View Source File : Or.cs
License : MIT License
Project Creator : actions

internal sealed override String ConvertToRealizedExpression(EvaluationContext context)
        {
            // Check if the result was stored
            if (context.TryGetTraceResult(this, out String result))
            {
                return result;
            }

            return String.Format(
                CultureInfo.InvariantCulture,
                "({0})",
                String.Join(" || ", Parameters.Select(x => x.ConvertToRealizedExpression(context))));
        }

19 View Source File : ReferenceNameBuilder.cs
License : MIT License
Project Creator : actions

internal String Build()
        {
            var original = m_name.Length > 0 ? m_name.ToString() : "job";

            var attempt = 1;
            var suffix = default(String);
            while (true)
            {
                if (attempt == 1)
                {
                    suffix = String.Empty;
                }
                else if (attempt < 1000)
                {
                    suffix = String.Format(CultureInfo.InvariantCulture, "_{0}", attempt);
                }
                else
                {
                    throw new InvalidOperationException("Unable to create a unique name");
                }

                var candidate = original.Substring(0, Math.Min(original.Length, PipelineConstants.MaxNodeNameLength - suffix.Length)) + suffix;

                if (m_distinctNames.Add(candidate))
                {
                    m_name.Clear();
                    return candidate;
                }

                attempt++;
            }
        }

19 View Source File : CommonResources.g.cs
License : MIT License
Project Creator : actions

public static string AbsoluteVirtualPathNotAllowed(object arg0)
        {
            const string Format = @"An absolute virtual path is not allowed. Remove the leading slash: {0}";
            return string.Format(CultureInfo.CurrentCulture, Format, arg0);
        }

19 View Source File : FileContainerResources.g.cs
License : MIT License
Project Creator : actions

public static string ContainerNotFoundException(object arg0)
        {
            const string Format = @"The container {0} could not be found.";
            return string.Format(CultureInfo.CurrentCulture, Format, arg0);
        }

19 View Source File : PipelinesWebApiResources.g.cs
License : MIT License
Project Creator : actions

public static string NonEmptyEnumElementsRequired(object arg0)
        {
            const string Format = @"Each comma separated enum value must be non-empty: {0}";
            return string.Format(CultureInfo.CurrentCulture, Format, arg0);
        }

19 View Source File : TemplateStrings.g.cs
License : MIT License
Project Creator : actions

public static string TemplateNotValidWithErrors(object arg0)
        {
            const string Format = @"The template is not valid. {0}";
            return string.Format(CultureInfo.CurrentCulture, Format, arg0);
        }

19 View Source File : TemplateStrings.g.cs
License : MIT License
Project Creator : actions

public static string UnexpectedValue(object arg0)
        {
            const string Format = @"Unexpected value '{0}'";
            return string.Format(CultureInfo.CurrentCulture, Format, arg0);
        }

19 View Source File : TemplateStrings.g.cs
License : MIT License
Project Creator : actions

public static string ValueAlreadyDefined(object arg0)
        {
            const string Format = @"'{0}' is already defined";
            return string.Format(CultureInfo.CurrentCulture, Format, arg0);
        }

19 View Source File : WebApiResources.g.cs
License : MIT License
Project Creator : actions

public static string ResourceNotRegisteredMessage(object arg0)
        {
            const string Format = @"API resource location {0} is not registered on this server.";
            return string.Format(CultureInfo.CurrentCulture, Format, arg0);
        }

19 View Source File : WebApiResources.g.cs
License : MIT License
Project Creator : actions

public static string ServiceDefinitionWithNoLocations(object arg0)
        {
            const string Format = @"The service with the following type does not have a location mapping: {0}. You must provide at least one location in order to configure locations for an external service.";
            return string.Format(CultureInfo.CurrentCulture, Format, arg0);
        }

19 View Source File : WebApiResources.g.cs
License : MIT License
Project Creator : actions

public static string InvalidApiVersionStringMessage(object arg0)
        {
            const string Format = @"Invalid api version string: ""{0}"". Api version string must be in the format: {{Major}}.{{Minor}}[-preview[.{{ResourceVersion}}]].";
            return string.Format(CultureInfo.CurrentCulture, Format, arg0);
        }

19 View Source File : WebApiResources.g.cs
License : MIT License
Project Creator : actions

public static string ExtensibleServiceTypeNotRegistered(object arg0)
        {
            const string Format = @"The service type '{0}' does not have a registered implementation or default implementation attribute.";
            return string.Format(CultureInfo.CurrentCulture, Format, arg0);
        }

19 View Source File : WebApiResources.g.cs
License : MIT License
Project Creator : actions

public static string CannotGetUnattributedClient(object arg0)
        {
            const string Format = @"The current VssConnection does not support calling GetClient for this client type: '{0}'. Instead, use the GetClient overload which accepts a serviceIdentifier parameter to specify the intended target service for the given client.";
            return string.Format(CultureInfo.CurrentCulture, Format, arg0);
        }

19 View Source File : VssHttpEventSource.cs
License : MIT License
Project Creator : actions

[NonEvent]
        public void HttpRequestRetrying(
            VssTraceActivity activity,
            HttpRequestMessage request,
            Int32 attempt,
            TimeSpan backoffDuration,
            HttpStatusCode? httpStatusCode,
            WebExceptionStatus? webExceptionStatus,
            SocketError? socketErrorCode,
            WinHttpErrorCode? winHttpErrorCode,
            CurlErrorCode? curlErrorCode,
            string afdRefInfo)
        {
            if (IsEnabled())
            {
                String reason = "<unknown>";
                if (httpStatusCode != null)
                {
                    reason = String.Format(CultureInfo.InvariantCulture, "HTTP Status: {0}", httpStatusCode.Value);
                }
                else if (webExceptionStatus != null)
                {
                    reason = String.Format(CultureInfo.InvariantCulture, "Web Exception Status: {0}", webExceptionStatus.Value);
                }
                else if (socketErrorCode != null)
                {
                    reason = String.Format(CultureInfo.InvariantCulture, "Socket Error: {0}", socketErrorCode.Value);
                }
                else if (winHttpErrorCode != null)
                {
                    reason = String.Format(CultureInfo.InvariantCulture, "WinHttp Error: {0}", winHttpErrorCode);
                }
                else if (curlErrorCode != null)
                {
                    reason = String.Format(CultureInfo.InvariantCulture, "Curl Error: {0}", curlErrorCode);
                }

                if (!string.IsNullOrEmpty(afdRefInfo))
                {
                    reason += $", AFD Ref: {afdRefInfo}";
                }

                SetActivityId(activity);
                HttpRequestRetrying(request.GetHttpMethod(), request.RequestUri.AbsoluteUri, attempt, reason, backoffDuration.TotalSeconds);
            }
        }

19 View Source File : VssHttpEventSource.cs
License : MIT License
Project Creator : actions

[NonEvent]
        public void HttpRequestFailedMaxAttempts(
            VssTraceActivity activity,
            HttpRequestMessage request,
            Int32 attempt,
            HttpStatusCode? httpStatusCode,
            WebExceptionStatus? webExceptionStatus,
            SocketError? socketErrorCode,
            WinHttpErrorCode? winHttpErrorCode,
            CurlErrorCode? curlErrorCode,
            string afdRefInfo)
        {
            if (IsEnabled())
            {
                String reason = "<unknown>";
                if (httpStatusCode != null)
                {
                    reason = String.Format(CultureInfo.InvariantCulture, "HTTP Status: {0}", httpStatusCode.Value);
                }
                else if (webExceptionStatus != null)
                {
                    reason = String.Format(CultureInfo.InvariantCulture, "Web Exception Status: {0}", webExceptionStatus.Value);
                }
                else if (socketErrorCode != null)
                {
                    reason = String.Format(CultureInfo.InvariantCulture, "Socket Error: {0}", socketErrorCode.Value);
                }
                else if (winHttpErrorCode != null)
                {
                    reason = String.Format(CultureInfo.InvariantCulture, "WinHttp Error: {0}", winHttpErrorCode);
                }
                else if (curlErrorCode != null)
                {
                    reason = String.Format(CultureInfo.InvariantCulture, "Curl Error: {0}", curlErrorCode);
                }

                if (!string.IsNullOrEmpty(afdRefInfo))
                {
                    reason += $", AFD Ref: {afdRefInfo}";
                }

                SetActivityId(activity);
                HttpRequestFailedMaxAttempts(request.GetHttpMethod(), request.RequestUri.AbsoluteUri, attempt, reason);
            }
        }

19 View Source File : And.cs
License : MIT License
Project Creator : actions

internal sealed override String ConvertToRealizedExpression(EvaluationContext context)
        {
            // Check if the result was stored
            if (context.TryGetTraceResult(this, out String result))
            {
                return result;
            }

            return String.Format(
                CultureInfo.InvariantCulture,
                "({0})",
                String.Join(" && ", Parameters.Select(x => x.ConvertToRealizedExpression(context))));
        }

19 View Source File : CommonResources.g.cs
License : MIT License
Project Creator : actions

public static string EmptyGuidNotAllowed(object arg0)
        {
            const string Format = @"The guid specified for parameter {0} must not be Guid.Empty.";
            return string.Format(CultureInfo.CurrentCulture, Format, arg0);
        }

19 View Source File : CommonResources.g.cs
License : MIT License
Project Creator : actions

public static string VssInvalidUnicodeCharacter(object arg0)
        {
            const string Format = @"The string argument contains a character that is not valid:'u{0:X4}'. Correct the argument, and then try the operation again.";
            return string.Format(CultureInfo.CurrentCulture, Format, arg0);
        }

19 View Source File : CommonResources.g.cs
License : MIT License
Project Creator : actions

public static string StringContainsInvalidCharacters(object arg0)
        {
            const string Format = @"The string argument contains a character that is not valid:'{0}'. Correct the argument, and then try the operation again.";
            return string.Format(CultureInfo.CurrentCulture, Format, arg0);
        }

19 View Source File : CommonResources.g.cs
License : MIT License
Project Creator : actions

public static string HttpRequestTimeout(object arg0)
        {
            const string Format = @"The HTTP request timed out after {0}.";
            return string.Format(CultureInfo.CurrentCulture, Format, arg0);
        }

19 View Source File : CommonResources.g.cs
License : MIT License
Project Creator : actions

public static string VssUnauthorized(object arg0)
        {
            const string Format = @"You are not authorized to access {0}.";
            return string.Format(CultureInfo.CurrentCulture, Format, arg0);
        }

19 View Source File : CommonResources.g.cs
License : MIT License
Project Creator : actions

public static string OutOfRange(object arg0)
        {
            const string Format = @"The value {0} is outside of the allowed range.";
            return string.Format(CultureInfo.CurrentCulture, Format, arg0);
        }

19 View Source File : CommonResources.g.cs
License : MIT License
Project Creator : actions

public static string NullValueNecessary(object arg0)
        {
            const string Format = @"The value specified for the following variable must be null: {0}.";
            return string.Format(CultureInfo.CurrentCulture, Format, arg0);
        }

19 View Source File : CommonResources.g.cs
License : MIT License
Project Creator : actions

public static string LowercaseStringRequired(object arg0)
        {
            const string Format = @"The string argument '{0}' must only consist of lowercase characters.";
            return string.Format(CultureInfo.CurrentCulture, Format, arg0);
        }

19 View Source File : CommonResources.g.cs
License : MIT License
Project Creator : actions

public static string UppercaseStringRequired(object arg0)
        {
            const string Format = @"The string argument '{0}' must only consist of uppercase characters.";
            return string.Format(CultureInfo.CurrentCulture, Format, arg0);
        }

19 View Source File : CommonResources.g.cs
License : MIT License
Project Creator : actions

public static string StringLengthNotMatch(object arg0)
        {
            const string Format = @"Length of the string does not match with '{0}'";
            return string.Format(CultureInfo.CurrentCulture, Format, arg0);
        }

19 View Source File : CommonResources.g.cs
License : MIT License
Project Creator : actions

public static string UriUtility_AbsoluteUriRequired(object arg0)
        {
            const string Format = @"The following URL is not valid: {0}. You must specify an absolute path.";
            return string.Format(CultureInfo.CurrentCulture, Format, arg0);
        }

19 View Source File : CommonResources.g.cs
License : MIT License
Project Creator : actions

public static string UriUtility_RelativePathInvalid(object arg0)
        {
            const string Format = @"The following relative path is not valid: {0}. It must be both well formed and relative. It might be an absolute path.";
            return string.Format(CultureInfo.CurrentCulture, Format, arg0);
        }

19 View Source File : FileContainerResources.g.cs
License : MIT License
Project Creator : actions

public static string ContainerItemCopySourcePendingUpload(object arg0)
        {
            const string Format = @"The source item {0} is in the pending upload state.";
            return string.Format(CultureInfo.CurrentCulture, Format, arg0);
        }

19 View Source File : FileContainerResources.g.cs
License : MIT License
Project Creator : actions

public static string ContainerItemCopyDuplicateTargets(object arg0)
        {
            const string Format = @"The target location {0} is specified for two or more sources.";
            return string.Format(CultureInfo.CurrentCulture, Format, arg0);
        }

19 View Source File : FileContainerResources.g.cs
License : MIT License
Project Creator : actions

public static string ContainerAlreadyExists(object arg0)
        {
            const string Format = @"Container with artifact {0} already exists.";
            return string.Format(CultureInfo.CurrentCulture, Format, arg0);
        }

19 View Source File : FileContainerResources.g.cs
License : MIT License
Project Creator : actions

public static string ChunksizeWrongWithContentId(object arg0)
        {
            const string Format = @"The chunk size must be a multiple of {0} bytes when specifying a contentId.";
            return string.Format(CultureInfo.CurrentCulture, Format, arg0);
        }

See More Examples