string.ToString()

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

2893 Examples 7

19 Source : WmiProvider.cs
with MIT License
from AlexGyver

private void RevokeInstance(string identifier) {
      int instanceIndex = activeInstances.FindIndex(
        item => item.Identifier == identifier.ToString()
      );

      if (instanceIndex == -1)
        return;

      try {
        Instrumentation.Revoke(activeInstances[instanceIndex]);
      } catch (Exception) { }

      activeInstances.RemoveAt(instanceIndex);
    }

19 Source : AdditionalSurfaceOptionsHelper.cs
with MIT License
from alexismorin

public void WriteToString( ref string nodeInfo )
		{
			int optionsCount = m_availableOptions.Count;
			IOUtils.AddFieldValueToString( ref nodeInfo, optionsCount );
			for( int i = 0; i < optionsCount; i++ )
			{
				IOUtils.AddFieldValueToString( ref nodeInfo, m_availableOptions[ i ].ToString() );
			}
		}

19 Source : GlobalArrayNode.cs
with GNU General Public License v3.0
from alexismorin

public override string GenerateShaderForOutput( int outputId, ref MasterNodeDataCollector dataCollector, bool ignoreLocalvar )
		{
			if( m_outputPorts[ 0 ].IsLocalValue( dataCollector.PortCategory ) )
				return m_outputPorts[ 0 ].LocalValue( dataCollector.PortCategory );

			string arrayIndex = m_inputPorts[ 0 ].IsConnected ? m_inputPorts[ 0 ].GeneratePortInstructions( ref dataCollector ) : m_index.ToString();
			string arrayLength = m_inputPorts[ 1 ].IsConnected ? m_inputPorts[ 1 ].GeneratePortInstructions( ref dataCollector ) : m_arrayLength.ToString();

			string dataType = UIUtils.FinalPrecisionWirePortToCgType( m_currentPrecisionType, AvailableTypesValues[ m_type ] );
			dataCollector.AddToUniforms( UniqueId, dataType, string.Format( ArrayFormatStr, m_name, arrayLength ) );

			string index = m_autoRangeCheck ? string.Format( "clamp({0},0,({1} - 1))", arrayIndex, arrayLength ) : arrayIndex.ToString();
			m_outputPorts[ 0 ].SetLocalValue( string.Format( ArrayFormatStr, m_name, index ), dataCollector.PortCategory );

			return m_outputPorts[ 0 ].LocalValue( dataCollector.PortCategory );
		}

19 Source : BitMaxProClient.cs
with Apache License 2.0
from AlexWan

private string GetData(string apiPath, bool auth = false, string accGroup = null, string jsonContent = null,
            string orderId = null, string time = null, Method method = Method.GET, bool need = false)
        {
            lock (_queryLocker)
            {
                try
                {
                    Uri uri;

                    HttpWebRequest httpWebRequest;

                    if (!auth)
                    {
                        uri = new Uri(_baseUrl + "api/pro/v1/" + apiPath);

                        httpWebRequest = (HttpWebRequest)WebRequest.Create(uri);
                    }
                    else
                    {
                        if (accGroup == null)
                        {
                            uri = new Uri(_baseUrl + "api/pro/v1/" + apiPath);
                        }
                        else
                        {
                            var str = _baseUrl + accGroup + "/" + "api/pro/v1/" + apiPath;

                            if (need)
                            {
                                str += "?n=10&executedOnly=True";
                            }

                            uri = new Uri(str);
                        }

                        string timestamp;

                        if (time == null)
                        {
                            timestamp = TimeManager.GetUnixTimeStampMilliseconds().ToString();
                        }
                        else
                        {
                            timestamp = time;
                        }

                        string signatureMsg;

                        if (orderId == null)
                        {
                            signatureMsg = timestamp + "+" + apiPath;
                        }
                        else
                        {
                            //signatureMsg = timestamp + "+" + apiPath + "+" + orderId;
                            signatureMsg = timestamp + "+" + "order";
                        }

                        if (signatureMsg.EndsWith("cash/balance"))
                        {
                            signatureMsg = signatureMsg.Replace("cash/", "");
                            //signatureMsg = signatureMsg.Remove(signatureMsg.Length - 11, 4);
                        }

                        if (signatureMsg.EndsWith("margin/balance"))
                        {
                            signatureMsg = signatureMsg.Replace("margin/", "");
                            //signatureMsg = signatureMsg.Remove(signatureMsg.Length - 13, 6);
                        }


                        var codedSignature = CreateSignature(signatureMsg);

                        httpWebRequest = (HttpWebRequest)WebRequest.Create(uri);

                        httpWebRequest.Headers.Add("x-auth-key", _apiKey);
                        httpWebRequest.Headers.Add("x-auth-signature", codedSignature);
                        httpWebRequest.Headers.Add("x-auth-timestamp", timestamp.ToString());

                        if (orderId != null)
                        {
                            httpWebRequest.Headers.Add("x-auth-coid", orderId);
                        }
                    }

                    httpWebRequest.Method = method.ToString();

                    if (jsonContent != null)
                    {
                        var data = Encoding.UTF8.GetBytes(jsonContent);

                        httpWebRequest.ContentType = "application/json";

                        httpWebRequest.ContentLength = data.Length;

                        using (Stream requestStream = httpWebRequest.GetRequestStream())
                        {
                            requestStream.Write(data, 0, data.Length);
                        }
                    }

                    HttpWebResponse httpWebResponse = (HttpWebResponse)httpWebRequest.GetResponse();

                    string responseMsg;

                    using (var stream = httpWebResponse.GetResponseStream())
                    {
                        using (StreamReader reader = new StreamReader(stream ?? throw new InvalidOperationException()))
                        {
                            responseMsg = reader.ReadToEnd();
                        }
                    }

                    httpWebResponse.Close();

                    return responseMsg;
                }
                catch (InvalidOperationException invalidOperationException)
                {
                    SendLogMessage("Failed to get stream to read response from server..   " + invalidOperationException.Message, LogMessageType.Error);
                    return null;
                }
                catch (Exception exception)
                {
                    SendLogMessage(exception.Message, LogMessageType.Error);
                    return null;
                }
            }
        }

19 Source : ExmoClient.cs
with Apache License 2.0
from AlexWan

private List<string> GetCurrencies()
        {
            List<string> currencies = new List<string>();


            var jsonCurrency = ApiQuery("currency", new Dictionary<string, string>());

            var parserStrings = jsonCurrency.ToString()
                .Replace("[", "")
                .Replace("]", "")
                .Replace("\"", "")
                .Split(new char[] { ',' }, StringSplitOptions.RemoveEmptyEntries);
            currencies = parserStrings.Cast<string>().ToList();


            return currencies;
        }

19 Source : OandaServer.cs
with Apache License 2.0
from AlexWan

private void CandleGeterThread()
        {
            while (true)
            {
                Thread.Sleep(1000);

                if (_depthsDontGo == false)
                {
                    return;
                }

                try
                {
                    for (int i = 0; i < _namesSecuritiesToGetTicks.Count; i++)
                    {
                        short count = 1;
                        string price = "MBA";
                        string instrument = _namesSecuritiesToGetTicks[i].Name;
                        string granularity = GetTimeFrameInOandaFormat(TimeFrame.Min1).ToString();

                        var parameters = new Dictionary<string, string>();
                        parameters.Add("price", price);
                        parameters.Add("granularity", granularity);
                        parameters.Add("count", count.ToString());

                        Task<List<CandlestickPlus>> result = Rest20.GetCandlesAsync(instrument, parameters);

                        while (!result.IsCanceled &&
                               !result.IsCompleted &&
                               !result.IsFaulted)
                        {
                            Thread.Sleep(10);
                        }

                        List<CandlestickPlus> candleOanda = result.Result;

                        Trade newCandle = new Trade();

                        newCandle.Price = Convert.ToDecimal(candleOanda[0].bid.c);
                        newCandle.Time = DateTime.Parse(candleOanda[0].time);
                        newCandle.SecurityNameCode = _namesSecuritiesToGetTicks[i].Name;
                        newCandle.Volume = candleOanda[0].volume;
                        newCandle.Side = Side.Buy;

                        if (NewTradesEvent != null)
                        {
                            NewTradesEvent(newCandle);
                        }

                        MarketDepth depth = new MarketDepth();
                        depth.SecurityNameCode = newCandle.SecurityNameCode;
                        depth.Time = newCandle.Time;

                        depth.Asks = new List<MarketDepthLevel>()
                        {
                            new MarketDepthLevel()
                            {
                                Ask = 1,Price = newCandle.Price + _namesSecuritiesToGetTicks[i].PriceStep
                            }
                        };

                        depth.Bids = new List<MarketDepthLevel>()
                        {
                            new MarketDepthLevel()
                            {
                                Bid= 1,Price = newCandle.Price - _namesSecuritiesToGetTicks[i].PriceStep
                            }
                        };

                        if (MarketDepthEvent != null)
                        {
                            MarketDepthEvent(depth);
                        }
                    }
                }
                catch (Exception error)
                {
                    SendLogMessage(error.ToString(), LogMessageType.Error);
                    Thread.Sleep(1000);
                }


            }
        }

19 Source : Wizard.cs
with Apache License 2.0
from Algoryx

public void Update()
    {
      if ( CurrentWindow >= GetNumWindows() )
        return;

      MethodInfo windowMethod = m_windowCallbacks[ CurrentWindow ];
      if ( windowMethod != null ) {
        GUILayout.Window( m_windowId,
                          m_windowRect,
                          id =>
                          {
                            EventType windowEventType = Event.current.GetTypeForControl( id );
                            windowMethod.Invoke( this, new object[] { windowEventType } );
                          },
                          Enum.GetName( m_enumType, CurrentWindow ).ToString().SplitCamelCase(),
                          GUI.Skin.window,
                          new GUILayoutOption[] { GUILayout.Width( WindowSize.x ) } );
      }
      else
        NextWindow();

      HandleUtility.Repaint();
    }

19 Source : SimUtil.cs
with Apache License 2.0
from allenai

public static bool FindItemFromReceptacleByID(string itemID, Receptacle r, out SimObj item) {
        item = null;
        // make sure we're not doing something insane
        if (r == null) {
            Debug.LogError("Receptacle was null, not searching for item");
            return false;
        }

        if (!IsObjectIDValid(itemID)) {
            Debug.LogError("itemID " + itemID.ToString() + " is NOT valid, not searching for item");
            return false;
        }
        SimObj checkItem = null;
        for (int i = 0; i < r.Pivots.Length; i++) {
            if (r.Pivots[i].childCount > 0) {
                checkItem = r.Pivots[i].GetChild(0).GetComponent<SimObj>();
                if (checkItem != null && checkItem.ObjectID == itemID) {
                    // if the item under the pivot is a SimObj with the right id
                    // we've found what we're after
                    item = checkItem;
                    return true;
                }
            }
        }
        // couldn't find it!
        return false;
    }

19 Source : MemoryEditor.cs
with MIT License
from allenwp

private static bool TryHexParse(byte[] bytes, out int result)
        {
            string input = System.Text.Encoding.UTF8.GetString(bytes).ToString();
            return int.TryParse(input, NumberStyles.AllowHexSpecifier, CultureInfo.CurrentCulture, out result);
        }

19 Source : StringSetAttributeValue.cs
with MIT License
from AllocZero

public override string ToString() => $"[{string.Join(", ", _items.Select(x => x.ToString()))}]";

19 Source : FileLogger.cs
with GNU General Public License v3.0
from Alois-xx

private void ReopenFileAndWriteHeader()
        {
            string logFile = Path.Combine(myLoggingDirectory, myFileBaseName);
            myFile = null;
            for (int i = 0; i < 2; i++)
            {
                try
                {
                    myFile = new FileStream(logFile, FileMode.Append, FileAccess.Write, FileShare.Read);
                    break;
                }
                catch (Exception)
                {
                    logFile = Path.Combine(Path.GetDirectoryName(logFile), $"{myFileBaseName}_{DateTime.Now.ToString("hh_MM_ss.fff").ToString()}.csv");
                }
            }

            myLog = new StreamWriter(myFile);

            // only write header when new file was created
            if (myFile.Position == 0)
            {
                WriteHeader();
            }
        }

19 Source : SYS_MASTER.cs
with GNU General Public License v3.0
from Alpaca-Studio

public static void SaveLog(){
			//logData.Clear();
			string path = Application.persistentDataPath + "/" + Application.productName + "/Logs/SysLog.txt";
				foreach(string message in logData){
					File.AppendAllText(path, string.Format("{0}{1}", message.ToString(), System.Environment.NewLine));
				}
					lastPath = path;
				Debug.Log("SysLog.txt saved to default location: " + (Application.persistentDataPath + "/" + Application.productName + "/Logs/SysLog.txt"));
		}

19 Source : SYS_MASTER.cs
with GNU General Public License v3.0
from Alpaca-Studio

public static void SaveLog(string path){
			//logData.Clear();
				foreach(string message in logData){
					File.AppendAllText(path, string.Format("{0}{1}", message.ToString(), System.Environment.NewLine));
				}
					lastPath = path;
				Debug.Log("SysLog.txt saved to location: " + path);
		}

19 Source : SYS_MASTER.cs
with GNU General Public License v3.0
from Alpaca-Studio

public static void SaveLog(string path, bool openDir){
			//logData.Clear();
				foreach(string message in logData){
					File.AppendAllText(path, string.Format("{0}{1}", message.ToString(), System.Environment.NewLine));
				}
					if(openDir){System.Diagnostics.Process.Start(path);}
						lastPath = path;
				Debug.Log("SysLog.txt saved to location: " + path);
				Debug.Log("Opening Directory: " + path);
		}

19 Source : SYS_MASTER.cs
with GNU General Public License v3.0
from Alpaca-Studio

public static void SaveDataToFile(string path, string[] data){
			if(!File.Exists(path)){
				File.Create(path).Dispose();
				foreach(string d in data){
					File.AppendAllText(path, string.Format("{0}{1}", d.ToString(), System.Environment.NewLine));
				}
			} else {
				File.Create(path).Dispose();
				foreach(string d in data){
					File.AppendAllText(path, string.Format("{0}{1}", d.ToString(), System.Environment.NewLine));
				}
			}
			
		}

19 Source : SYS_MASTER.cs
with GNU General Public License v3.0
from Alpaca-Studio

public static void SaveDataToFile(string path, string[] data, bool clearOldFiles){
			if(!File.Exists(path)){
				File.Create(path).Dispose();
				foreach(string d in data){
					File.AppendAllText(path, string.Format("{0}{1}", d.ToString(), System.Environment.NewLine));
				}
			} else {
				if(clearOldFiles){
					File.Create(path).Dispose();
					foreach(string d in data){
						File.AppendAllText(path, string.Format("{0}{1}", d.ToString(), System.Environment.NewLine));
					}
				} else {
					foreach(string d in data){
						File.AppendAllText(path, string.Format("{0}{1}", d.ToString(), System.Environment.NewLine));
					}
				}
			}
			
		}

19 Source : SYS_MASTER.cs
with GNU General Public License v3.0
from Alpaca-Studio

public static void SaveFile(string path, string[] data, bool clearOldFiles){
			if(!File.Exists(path)){
				File.Create(path).Dispose();
				foreach(string d in data){
					File.AppendAllText(path, string.Format("{0}{1}", d.ToString(), System.Environment.NewLine));
				}
			} else {
				if(clearOldFiles){
					File.Create(path).Dispose();
					foreach(string d in data){
						File.AppendAllText(path, string.Format("{0}{1}", d.ToString(), System.Environment.NewLine));
					}
				} else {
					foreach(string d in data){
						File.AppendAllText(path, string.Format("{0}{1}", d.ToString(), System.Environment.NewLine));
					}
				}
			}
			
		}

19 Source : SYS_MASTER.cs
with GNU General Public License v3.0
from Alpaca-Studio

public static void SaveFile(string path, string[] data){
			if(!File.Exists(path)){
				File.Create(path).Dispose();
				foreach(string d in data){
					File.AppendAllText(path, string.Format("{0}{1}", d.ToString(), System.Environment.NewLine));
				}
			} else {
				File.Create(path).Dispose();
				foreach(string d in data){
					File.AppendAllText(path, string.Format("{0}{1}", d.ToString(), System.Environment.NewLine));
				}
			}
			
		}

19 Source : AbstracCacheProvider.cs
with MIT License
from AlphaYu

public bool Exists(string cacheKey)
        {
            var operationId = s_diagnosticListener.WriteExistsCacheBefore(new BeforeExistsRequestEventData(CachingProviderType.ToString(), Name, nameof(Exists), cacheKey));
            Exception e = null;
            try
            {
                return BaseExists(cacheKey);
            }
            catch (Exception ex)
            {
                e = ex;
                throw;
            }
            finally
            {
                if (e != null)
                {
                    s_diagnosticListener.WriteExistsCacheError(operationId, e);
                }
                else
                {
                    s_diagnosticListener.WriteExistsCacheAfter(operationId);
                }
            }
        }

19 Source : AbstracCacheProvider.cs
with MIT License
from AlphaYu

public async Task<bool> ExistsAsync(string cacheKey)
        {
            var operationId = s_diagnosticListener.WriteExistsCacheBefore(new BeforeExistsRequestEventData(CachingProviderType.ToString(), Name, nameof(ExistsAsync), cacheKey));
            Exception e = null;
            try
            {
                var flag = await BaseExistsAsync(cacheKey);
                return flag;
            }
            catch (Exception ex)
            {
                e = ex;
                throw;
            }
            finally
            {
                if (e != null)
                {
                    s_diagnosticListener.WriteExistsCacheError(operationId, e);
                }
                else
                {
                    s_diagnosticListener.WriteExistsCacheAfter(operationId);
                }
            }
        }

19 Source : AbstracCacheProvider.cs
with MIT License
from AlphaYu

public void Flush()
        {
            var operationId = s_diagnosticListener.WriteFlushCacheBefore(new EventData(CachingProviderType.ToString(), Name, nameof(Flush)));
            Exception e = null;
            try
            {
                BaseFlush();
            }
            catch (Exception ex)
            {
                e = ex;
                throw;
            }
            finally
            {
                if (e != null)
                {
                    s_diagnosticListener.WriteFlushCacheError(operationId, e);
                }
                else
                {
                    s_diagnosticListener.WriteFlushCacheAfter(operationId);
                }
            }
        }

19 Source : AbstracCacheProvider.cs
with MIT License
from AlphaYu

public async Task FlushAsync()
        {
            var operationId = s_diagnosticListener.WriteFlushCacheBefore(new EventData(CachingProviderType.ToString(), Name, nameof(FlushAsync)));
            Exception e = null;
            try
            {
                await BaseFlushAsync();
            }
            catch (Exception ex)
            {
                e = ex;
                throw;
            }
            finally
            {
                if (e != null)
                {
                    s_diagnosticListener.WriteFlushCacheError(operationId, e);
                }
                else
                {
                    s_diagnosticListener.WriteFlushCacheAfter(operationId);
                }
            }
        }

19 Source : AbstracCacheProvider.cs
with MIT License
from AlphaYu

public CacheValue<T> Get<T>(string cacheKey, Func<T> dataRetriever, TimeSpan expiration)
        {
            var operationId = s_diagnosticListener.WriteGetCacheBefore(new BeforeGetRequestEventData(CachingProviderType.ToString(), Name, nameof(Get), new[] { cacheKey }, expiration));
            Exception e = null;
            try
            {
                return BaseGet(cacheKey, dataRetriever, expiration);
            }
            catch (Exception ex)
            {
                e = ex;
                throw;
            }
            finally
            {
                if (e != null)
                {
                    s_diagnosticListener.WriteGetCacheError(operationId, e);
                }
                else
                {
                    s_diagnosticListener.WriteGetCacheAfter(operationId);
                }
            }
        }

19 Source : AbstracCacheProvider.cs
with MIT License
from AlphaYu

public CacheValue<T> Get<T>(string cacheKey)
        {
            var operationId = s_diagnosticListener.WriteGetCacheBefore(new BeforeGetRequestEventData(CachingProviderType.ToString(), Name, nameof(Get), new[] { cacheKey }));
            Exception e = null;
            try
            {
                return BaseGet<T>(cacheKey);
            }
            catch (Exception ex)
            {
                e = ex;
                throw;
            }
            finally
            {
                if (e != null)
                {
                    s_diagnosticListener.WriteGetCacheError(operationId, e);
                }
                else
                {
                    s_diagnosticListener.WriteGetCacheAfter(operationId);
                }
            }
        }

19 Source : AbstracCacheProvider.cs
with MIT License
from AlphaYu

public IDictionary<string, CacheValue<T>> GetAll<T>(IEnumerable<string> cacheKeys)
        {
            var operationId = s_diagnosticListener.WriteGetCacheBefore(new BeforeGetRequestEventData(CachingProviderType.ToString(), Name, nameof(GetAll), cacheKeys.ToArray()));
            Exception e = null;
            try
            {
                return BaseGetAll<T>(cacheKeys);
            }
            catch (Exception ex)
            {
                e = ex;
                throw;
            }
            finally
            {
                if (e != null)
                {
                    s_diagnosticListener.WriteGetCacheError(operationId, e);
                }
                else
                {
                    s_diagnosticListener.WriteGetCacheAfter(operationId);
                }
            }
        }

19 Source : AbstracCacheProvider.cs
with MIT License
from AlphaYu

public async Task<IDictionary<string, CacheValue<T>>> GetAllAsync<T>(IEnumerable<string> cacheKeys)
        {
            var operationId = s_diagnosticListener.WriteGetCacheBefore(new BeforeGetRequestEventData(CachingProviderType.ToString(), Name, nameof(GetAllAsync), cacheKeys.ToArray()));
            Exception e = null;
            try
            {
                return await BaseGetAllAsync<T>(cacheKeys);
            }
            catch (Exception ex)
            {
                e = ex;
                throw;
            }
            finally
            {
                if (e != null)
                {
                    s_diagnosticListener.WriteGetCacheError(operationId, e);
                }
                else
                {
                    s_diagnosticListener.WriteGetCacheAfter(operationId);
                }
            }
        }

19 Source : AbstracCacheProvider.cs
with MIT License
from AlphaYu

public async Task<CacheValue<T>> GetAsync<T>(string cacheKey, Func<Task<T>> dataRetriever, TimeSpan expiration)
        {
            var operationId = s_diagnosticListener.WriteGetCacheBefore(new BeforeGetRequestEventData(CachingProviderType.ToString(), Name, nameof(GetAsync), new[] { cacheKey }, expiration));
            Exception e = null;
            try
            {
                return await BaseGetAsync<T>(cacheKey, dataRetriever, expiration);
            }
            catch (Exception ex)
            {
                e = ex;
                throw;
            }
            finally
            {
                if (e != null)
                {
                    s_diagnosticListener.WriteGetCacheError(operationId, e);
                }
                else
                {
                    s_diagnosticListener.WriteGetCacheAfter(operationId);
                }
            }
        }

19 Source : AbstracCacheProvider.cs
with MIT License
from AlphaYu

public async Task<object> GetAsync(string cacheKey, Type type)
        {
            var operationId = s_diagnosticListener.WriteGetCacheBefore(new BeforeGetRequestEventData(CachingProviderType.ToString(), Name, "GetAsync_Type", new[] { cacheKey }));
            Exception e = null;
            try
            {
                return await BaseGetAsync(cacheKey, type);
            }
            catch (Exception ex)
            {
                e = ex;
                throw;
            }
            finally
            {
                if (e != null)
                {
                    s_diagnosticListener.WriteGetCacheError(operationId, e);
                }
                else
                {
                    s_diagnosticListener.WriteGetCacheAfter(operationId);
                }
            }
        }

19 Source : AbstracCacheProvider.cs
with MIT License
from AlphaYu

public async Task<CacheValue<T>> GetAsync<T>(string cacheKey)
        {
            var operationId = s_diagnosticListener.WriteGetCacheBefore(new BeforeGetRequestEventData(CachingProviderType.ToString(), Name, nameof(GetAsync), new[] { cacheKey }));
            Exception e = null;
            try
            {
                return await BaseGetAsync<T>(cacheKey);
            }
            catch (Exception ex)
            {
                e = ex;
                throw;
            }
            finally
            {
                if (e != null)
                {
                    s_diagnosticListener.WriteGetCacheError(operationId, e);
                }
                else
                {
                    s_diagnosticListener.WriteGetCacheAfter(operationId);
                }
            }
        }

19 Source : AbstracCacheProvider.cs
with MIT License
from AlphaYu

public IDictionary<string, CacheValue<T>> GetByPrefix<T>(string prefix)
        {
            var operationId = s_diagnosticListener.WriteGetCacheBefore(new BeforeGetRequestEventData(CachingProviderType.ToString(), Name, nameof(GetByPrefix), new[] { prefix }));
            Exception e = null;
            try
            {
                return BaseGetByPrefix<T>(prefix);
            }
            catch (Exception ex)
            {
                e = ex;
                throw;
            }
            finally
            {
                if (e != null)
                {
                    s_diagnosticListener.WriteGetCacheError(operationId, e);
                }
                else
                {
                    s_diagnosticListener.WriteGetCacheAfter(operationId);
                }
            }
        }

19 Source : AbstracCacheProvider.cs
with MIT License
from AlphaYu

public async Task<IDictionary<string, CacheValue<T>>> GetByPrefixAsync<T>(string prefix)
        {
            var operationId = s_diagnosticListener.WriteGetCacheBefore(new BeforeGetRequestEventData(CachingProviderType.ToString(), Name, nameof(GetByPrefixAsync), new[] { prefix }));
            Exception e = null;
            try
            {
                return await BaseGetByPrefixAsync<T>(prefix);
            }
            catch (Exception ex)
            {
                e = ex;
                throw;
            }
            finally
            {
                if (e != null)
                {
                    s_diagnosticListener.WriteGetCacheError(operationId, e);
                }
                else
                {
                    s_diagnosticListener.WriteGetCacheAfter(operationId);
                }
            }
        }

19 Source : AbstracCacheProvider.cs
with MIT License
from AlphaYu

public void Remove(string cacheKey)
        {
            var operationId = s_diagnosticListener.WriteRemoveCacheBefore(new BeforeRemoveRequestEventData(CachingProviderType.ToString(), Name, nameof(Remove), new[] { cacheKey }));
            Exception e = null;
            try
            {
                BaseRemove(cacheKey);
            }
            catch (Exception ex)
            {
                e = ex;
                throw;
            }
            finally
            {
                if (e != null)
                {
                    s_diagnosticListener.WriteRemoveCacheError(operationId, e);
                }
                else
                {
                    s_diagnosticListener.WriteRemoveCacheAfter(operationId);
                }
            }
        }

19 Source : AbstracCacheProvider.cs
with MIT License
from AlphaYu

public void RemoveAll(IEnumerable<string> cacheKeys)
        {
            var operationId = s_diagnosticListener.WriteRemoveCacheBefore(new BeforeRemoveRequestEventData(CachingProviderType.ToString(), Name, nameof(RemoveAll), cacheKeys.ToArray()));
            Exception e = null;
            try
            {
                BaseRemoveAll(cacheKeys);
            }
            catch (Exception ex)
            {
                e = ex;
                throw;
            }
            finally
            {
                if (e != null)
                {
                    s_diagnosticListener.WriteRemoveCacheError(operationId, e);
                }
                else
                {
                    s_diagnosticListener.WriteRemoveCacheAfter(operationId);
                }
            }
        }

19 Source : AbstracCacheProvider.cs
with MIT License
from AlphaYu

public async Task RemoveAllAsync(IEnumerable<string> cacheKeys)
        {
            var operationId = s_diagnosticListener.WriteRemoveCacheBefore(new BeforeRemoveRequestEventData(CachingProviderType.ToString(), Name, nameof(RemoveAllAsync), cacheKeys.ToArray()));
            Exception e = null;
            try
            {
                await BaseRemoveAllAsync(cacheKeys);
            }
            catch (Exception ex)
            {
                e = ex;
                throw;
            }
            finally
            {
                if (e != null)
                {
                    s_diagnosticListener.WriteRemoveCacheError(operationId, e);
                }
                else
                {
                    s_diagnosticListener.WriteRemoveCacheAfter(operationId);
                }
            }
        }

19 Source : AbstracCacheProvider.cs
with MIT License
from AlphaYu

public async Task RemoveAsync(string cacheKey)
        {
            var operationId = s_diagnosticListener.WriteRemoveCacheBefore(new BeforeRemoveRequestEventData(CachingProviderType.ToString(), Name, nameof(RemoveAsync), new[] { cacheKey }));
            Exception e = null;
            try
            {
                await BaseRemoveAsync(cacheKey);
            }
            catch (Exception ex)
            {
                e = ex;
                throw;
            }
            finally
            {
                if (e != null)
                {
                    s_diagnosticListener.WriteRemoveCacheError(operationId, e);
                }
                else
                {
                    s_diagnosticListener.WriteRemoveCacheAfter(operationId);
                }
            }
        }

19 Source : AbstracCacheProvider.cs
with MIT License
from AlphaYu

public void RemoveByPrefix(string prefix)
        {
            var operationId = s_diagnosticListener.WriteRemoveCacheBefore(new BeforeRemoveRequestEventData(CachingProviderType.ToString(), Name, nameof(RemoveByPrefix), new[] { prefix }));
            Exception e = null;
            try
            {
                BaseRemoveByPrefix(prefix);
            }
            catch (Exception ex)
            {
                e = ex;
                throw;
            }
            finally
            {
                if (e != null)
                {
                    s_diagnosticListener.WriteRemoveCacheError(operationId, e);
                }
                else
                {
                    s_diagnosticListener.WriteRemoveCacheAfter(operationId);
                }
            }
        }

19 Source : AbstracCacheProvider.cs
with MIT License
from AlphaYu

public async Task RemoveByPrefixAsync(string prefix)
        {
            var operationId = s_diagnosticListener.WriteRemoveCacheBefore(new BeforeRemoveRequestEventData(CachingProviderType.ToString(), Name, nameof(RemoveByPrefixAsync), new[] { prefix }));
            Exception e = null;
            try
            {
                await BaseRemoveByPrefixAsync(prefix);
            }
            catch (Exception ex)
            {
                e = ex;
                throw;
            }
            finally
            {
                if (e != null)
                {
                    s_diagnosticListener.WriteRemoveCacheError(operationId, e);
                }
                else
                {
                    s_diagnosticListener.WriteRemoveCacheAfter(operationId);
                }
            }
        }

19 Source : AbstracCacheProvider.cs
with MIT License
from AlphaYu

public void Set<T>(string cacheKey, T cacheValue, TimeSpan expiration)
        {
            var operationId = s_diagnosticListener.WriteSetCacheBefore(new BeforeSetRequestEventData(CachingProviderType.ToString(), Name, nameof(Set), new Dictionary<string, object> { { cacheKey, cacheValue } }, expiration));
            Exception e = null;
            try
            {
                BaseSet(cacheKey, cacheValue, expiration);
            }
            catch (Exception ex)
            {
                e = ex;
                throw;
            }
            finally
            {
                if (e != null)
                {
                    s_diagnosticListener.WriteSetCacheError(operationId, e);
                }
                else
                {
                    s_diagnosticListener.WriteSetCacheAfter(operationId);
                }
            }
        }

19 Source : AbstracCacheProvider.cs
with MIT License
from AlphaYu

public void SetAll<T>(IDictionary<string, T> value, TimeSpan expiration)
        {
            var operationId = s_diagnosticListener.WriteSetCacheBefore(new BeforeSetRequestEventData(CachingProviderType.ToString(), Name, nameof(SetAll), value.ToDictionary(k => k.Key, v => (object)v.Value), expiration));
            Exception e = null;
            try
            {
                BaseSetAll(value, expiration);
            }
            catch (Exception ex)
            {
                e = ex;
                throw;
            }
            finally
            {
                if (e != null)
                {
                    s_diagnosticListener.WriteSetCacheError(operationId, e);
                }
                else
                {
                    s_diagnosticListener.WriteSetCacheAfter(operationId);
                }
            }
        }

19 Source : AbstracCacheProvider.cs
with MIT License
from AlphaYu

public async Task SetAllAsync<T>(IDictionary<string, T> value, TimeSpan expiration)
        {
            var operationId = s_diagnosticListener.WriteSetCacheBefore(new BeforeSetRequestEventData(CachingProviderType.ToString(), Name, nameof(SetAllAsync), value.ToDictionary(k => k.Key, v => (object)v.Value), expiration));
            Exception e = null;
            try
            {
                await BaseSetAllAsync(value, expiration);
            }
            catch (Exception ex)
            {
                e = ex;
                throw;
            }
            finally
            {
                if (e != null)
                {
                    s_diagnosticListener.WriteSetCacheError(operationId, e);
                }
                else
                {
                    s_diagnosticListener.WriteSetCacheAfter(operationId);
                }
            }
        }

19 Source : AbstracCacheProvider.cs
with MIT License
from AlphaYu

public async Task SetAsync<T>(string cacheKey, T cacheValue, TimeSpan expiration)
        {
            var operationId = s_diagnosticListener.WriteSetCacheBefore(new BeforeSetRequestEventData(CachingProviderType.ToString(), Name, nameof(SetAsync), new Dictionary<string, object> { { cacheKey, cacheValue } }, expiration));
            Exception e = null;
            try
            {
                await BaseSetAsync(cacheKey, cacheValue, expiration);
            }
            catch (Exception ex)
            {
                e = ex;
                throw;
            }
            finally
            {
                if (e != null)
                {
                    s_diagnosticListener.WriteSetCacheError(operationId, e);
                }
                else
                {
                    s_diagnosticListener.WriteSetCacheAfter(operationId);
                }
            }
        }

19 Source : AbstracCacheProvider.cs
with MIT License
from AlphaYu

public bool TrySet<T>(string cacheKey, T cacheValue, TimeSpan expiration)
        {
            var operationId = s_diagnosticListener.WriteSetCacheBefore(new BeforeSetRequestEventData(CachingProviderType.ToString(), Name, nameof(TrySet), new Dictionary<string, object> { { cacheKey, cacheValue } }, expiration));
            Exception e = null;
            try
            {
                return BaseTrySet(cacheKey, cacheValue, expiration);
            }
            catch (Exception ex)
            {
                e = ex;
                throw;
            }
            finally
            {
                if (e != null)
                {
                    s_diagnosticListener.WriteSetCacheError(operationId, e);
                }
                else
                {
                    s_diagnosticListener.WriteSetCacheAfter(operationId);
                }
            }
        }

19 Source : AbstracCacheProvider.cs
with MIT License
from AlphaYu

public async Task<bool> TrySetAsync<T>(string cacheKey, T cacheValue, TimeSpan expiration)
        {
            var operationId = s_diagnosticListener.WriteSetCacheBefore(new BeforeSetRequestEventData(CachingProviderType.ToString(), Name, nameof(TrySetAsync), new Dictionary<string, object> { { cacheKey, cacheValue } }, expiration));
            Exception e = null;
            try
            {
                return await BaseTrySetAsync(cacheKey, cacheValue, expiration);
            }
            catch (Exception ex)
            {
                e = ex;
                throw;
            }
            finally
            {
                if (e != null)
                {
                    s_diagnosticListener.WriteSetCacheError(operationId, e);
                }
                else
                {
                    s_diagnosticListener.WriteSetCacheAfter(operationId);
                }
            }
        }

19 Source : AbstracCacheProvider.cs
with MIT License
from AlphaYu

public async Task KeyExpireAsync(IEnumerable<string> cacheKeys, int seconds)
        {
            var operationId = s_diagnosticListener.WriteSetCacheBefore(new BeforeSetRequestEventData(CachingProviderType.ToString(), Name, nameof(TrySetAsync), new Dictionary<string, object> { { "cacheKeys", cacheKeys } }, TimeSpan.FromSeconds(seconds)));
            Exception e = null;
            try
            {
                await BaseKeyExpireAsync(cacheKeys, seconds);
            }
            catch (Exception ex)
            {
                e = ex;
                throw;
            }
            finally
            {
                if (e != null)
                {
                    s_diagnosticListener.WriteSetCacheError(operationId, e);
                }
                else
                {
                    s_diagnosticListener.WriteSetCacheAfter(operationId);
                }
            }
        }

19 Source : DataMockSI.cs
with BSD 3-Clause "New" or "Revised" License
from Altinn

public async Task<DataElement> InsertBinaryData(string org, string app, int instanceOwnerId, Guid instanceGuid, string dataType, HttpRequest request)
        {
            Guid dataGuid = Guid.NewGuid();
            string dataPath = GetDataPath(org, app, instanceOwnerId, instanceGuid);
            Instance instance = GetTestInstance(app, org, instanceOwnerId, instanceGuid);
            DataElement dataElement = new DataElement() { Id = dataGuid.ToString(), DataType = dataType, ContentType = request.ContentType };

            if (!Directory.Exists(Path.GetDirectoryName(dataPath)))
            {
                Directory.CreateDirectory(Path.GetDirectoryName(dataPath));
            }

            Directory.CreateDirectory(dataPath + @"blob");

            long filesize;

            using (Stream streamToWriteTo = File.Open(dataPath + @"blob\" + dataGuid.ToString(), FileMode.OpenOrCreate, FileAccess.ReadWrite, FileShare.ReadWrite))
            {
                await request.Body.CopyToAsync(streamToWriteTo);
                streamToWriteTo.Flush();
                filesize = streamToWriteTo.Length;
                streamToWriteTo.Close();
            }

            dataElement.Size = filesize;
            string jsonData = JsonConvert.SerializeObject(dataElement);
            using StreamWriter sw = new StreamWriter(dataPath + dataGuid.ToString() + @".json");

            sw.Write(jsonData.ToString());
            sw.Close();

            return dataElement;
        }

19 Source : DataMockSI.cs
with BSD 3-Clause "New" or "Revised" License
from Altinn

public Task<DataElement> InsertFormData<T>(T dataToSerialize, Guid instanceGuid, Type type, string org, string app, int instanceOwnerId, string dataType)
        {
            Guid dataGuid = Guid.NewGuid();
            string dataPath = GetDataPath(org, app, instanceOwnerId, instanceGuid);

            Instance instance = GetTestInstance(app, org, instanceOwnerId, instanceGuid);

            DataElement dataElement = new DataElement() { Id = dataGuid.ToString(), DataType = dataType, ContentType = "application/xml", };

            try
            {
                Directory.CreateDirectory(dataPath + @"blob");

                using (Stream stream = File.Open(dataPath + @"blob\" + dataGuid.ToString(), FileMode.Create, FileAccess.ReadWrite))
                {
                    XmlSerializer serializer = new XmlSerializer(type);
                    serializer.Serialize(stream, dataToSerialize);
                }

                string jsonData = JsonConvert.SerializeObject(dataElement);
                using StreamWriter sw = new StreamWriter(dataPath + dataGuid.ToString() + @".json");

                sw.Write(jsonData.ToString());
                sw.Close();
            }
            catch
            {
            }

            instance.Data = GetDataElements(org, app, instanceOwnerId, instanceGuid);

            return Task.FromResult(dataElement);
        }

19 Source : DataMockSI.cs
with BSD 3-Clause "New" or "Revised" License
from Altinn

public Task<DataElement> Update(Instance instance, DataElement dataElement)
        {
            string org = instance.Org;
            string app = instance.AppId.Split("/")[1];
            int instanceOwnerId = int.Parse(instance.InstanceOwner.PartyId);
            Guid instanceGuid = Guid.Parse(instance.Id.Split("/")[1]);

            string path = GetDataPath(org, app, instanceOwnerId, instanceGuid);

            string jsonData = JsonConvert.SerializeObject(dataElement);
            using StreamWriter sw = new StreamWriter(path + dataElement.Id + @".json");

            sw.Write(jsonData.ToString());
            sw.Close();

            return Task.FromResult(dataElement);
        }

19 Source : EnterpriseUserAuthenticationService.cs
with BSD 3-Clause "New" or "Revised" License
from Altinn

public async Task<HttpResponseMessage> AuthenticateEnterpriseUser(EnterpriseUserCredentials credentials)
        {
            string credentialsJson = JsonSerializer.Serialize(credentials);
            var request = new HttpRequestMessage
            {
                Method = HttpMethod.Post,
                RequestUri = new Uri(_settings.BridgeAuthnApiEndpoint + "enterpriseuser"),
                Content = new StringContent(credentialsJson.ToString(), Encoding.UTF8, "application/json")
            };

            return await _client.SendAsync(request).ConfigureAwait(false);
        }

19 Source : DataMockSI.cs
with BSD 3-Clause "New" or "Revised" License
from Altinn

public Task<DataElement> UpdateData<T>(T dataToSerialize, Guid instanceGuid, Type type, string org, string app, int instanceOwnerId, Guid dataId)
        {
            string dataPath = GetDataPath(org, app, instanceOwnerId, instanceGuid);

            Instance instance = GetTestInstance(app, org, instanceOwnerId, instanceGuid);

            DataElement dataElement = instance.Data.FirstOrDefault(r => r.Id.Equals(dataId.ToString()));

            Directory.CreateDirectory(dataPath + @"blob");

            using (Stream stream = File.Open(dataPath + @"blob\" + dataId.ToString(), FileMode.Create, FileAccess.ReadWrite))
            {
                XmlSerializer serializer = new XmlSerializer(type);
                serializer.Serialize(stream, dataToSerialize);
            }

            dataElement.LastChanged = DateTime.Now;
            string jsonData = JsonConvert.SerializeObject(dataElement);
            using StreamWriter sw = new StreamWriter(dataPath + dataId.ToString() + @".json");

            sw.Write(jsonData.ToString());
            sw.Close();

            return Task.FromResult(dataElement);
        }

19 Source : DataMockSI.cs
with BSD 3-Clause "New" or "Revised" License
from Altinn

public async Task<DataElement> InsertBinaryData(string instanceId, string dataType, string contentType, string filename, Stream stream)
        {
            Application app = _applicationService.GetApplication();

            Guid dataGuid = Guid.NewGuid();
            string dataPath = GetDataPath(app.Org, app.Id.Split("/")[1], Convert.ToInt32(instanceId.Split("/")[0]), new Guid(instanceId.Split("/")[1]));

            DataElement dataElement = new DataElement() { Id = dataGuid.ToString(), DataType = dataType, ContentType = contentType, };

            if (!Directory.Exists(Path.GetDirectoryName(dataPath)))
            {
                Directory.CreateDirectory(Path.GetDirectoryName(dataPath));
            }

            Directory.CreateDirectory(dataPath + @"blob");

            long filesize;

            using (Stream streamToWriteTo = File.Open(dataPath + @"blob\" + dataGuid.ToString(), FileMode.OpenOrCreate, FileAccess.ReadWrite, FileShare.ReadWrite))
            {
                await stream.CopyToAsync(streamToWriteTo);
                streamToWriteTo.Flush();
                filesize = streamToWriteTo.Length;
            }

            dataElement.Size = filesize;
            string jsonData = JsonConvert.SerializeObject(dataElement);
            using StreamWriter sw = new StreamWriter(dataPath + dataGuid.ToString() + @".json");

            sw.Write(jsonData.ToString());
            sw.Close();

            return dataElement;
        }

See More Examples