public string ToTriStateString(TriState Value, string DefaultItem = "") { // 1406 DM switch (Value) { case TriState.True: { if (DefaultItem.Length == 0) { DefaultItem = "Ticked"; } break; } case TriState.False: { if (DefaultItem.Length == 0) { DefaultItem = "Unticked"; } break; } default: { if (DefaultItem.Length == 0) { DefaultItem = "(N/A)"; } break; } } return(DefaultItem); }
public override string SetFieldValue(object value, ISitecoreService service) { if (value is TriState) { TriState state = (TriState)value; switch (state) { case TriState.Default: return(""); case TriState.No: return("0"); case TriState.Yes: return("1"); default: return(""); } } else { throw new MapperException("Value is not of type {0}".Formatted(typeof(TriState).FullName)); } }
internal ServicePoint(Uri address, TimerThread.Queue defaultIdlingQueue, int defaultConnectionLimit, string lookupString, bool userChangedLimit, bool proxyServicePoint) { this.m_HostName = string.Empty; this.m_ProxyServicePoint = proxyServicePoint; this.m_Address = address; this.m_ConnectionName = address.Scheme; this.m_Host = address.DnsSafeHost; this.m_Port = address.Port; this.m_IdlingQueue = defaultIdlingQueue; this.m_ConnectionLimit = defaultConnectionLimit; this.m_HostLoopbackGuess = TriState.Unspecified; this.m_LookupString = lookupString; this.m_UserChangedLimit = userChangedLimit; this.m_UseNagleAlgorithm = ServicePointManager.UseNagleAlgorithm; this.m_Expect100Continue = ServicePointManager.Expect100Continue; this.m_ConnectionGroupList = new Hashtable(10); this.m_ConnectionLeaseTimeout = -1; this.m_ReceiveBufferSize = -1; this.m_UseTcpKeepAlive = ServicePointManager.s_UseTcpKeepAlive; this.m_TcpKeepAliveTime = ServicePointManager.s_TcpKeepAliveTime; this.m_TcpKeepAliveInterval = ServicePointManager.s_TcpKeepAliveInterval; this.m_Understands100Continue = true; this.m_HttpBehaviour = System.Net.HttpBehaviour.Unknown; this.m_IdleSince = DateTime.Now; this.m_ExpiringTimer = this.m_IdlingQueue.CreateTimer(ServicePointManager.IdleServicePointTimeoutDelegate, this); }
// // Private methods // private void Initialize() { _encoding = Encoding.UTF8; _omitXmlDecl = false; _newLineHandling = NewLineHandling.Replace; _newLineChars = Environment.NewLine; // "\r\n" on Windows, "\n" on Unix _indent = TriState.Unknown; _indentChars = " "; _newLineOnAttributes = false; _closeOutput = false; _namespaceHandling = NamespaceHandling.Default; _conformanceLevel = ConformanceLevel.Document; _checkCharacters = true; _writeEndDocumentOnClose = true; _outputMethod = XmlOutputMethod.Xml; _cdataSections.Clear(); _mergeCDataSections = false; _mediaType = null; _docTypeSystem = null; _docTypePublic = null; _standalone = XmlStandalone.Omit; _doNotEscapeUriAttributes = false; _useAsync = false; _isReadOnly = false; }
private void LoadSettings() { ////////////////////////////// // Toolbar Size __sUIButtonsLarge.Checked = !S.Toolbar24; ////////////////////////////// // Gimmicks __sGimmick.Checked = S.Gimmicks; ////////////////////////////// // File Associations TriState isAssoc = S.IsAssociatedWithFiles; __sAssoc.CheckState = isAssoc == TriState.True ? CheckState.Checked : isAssoc == TriState.False ? CheckState.Unchecked : CheckState.Indeterminate; __sAssoc.Enabled = Miscellaneous.IsElevatedAdministrator; ////////////////////////////// // Load Assemblies if (S.LoadAssemblies != null) { foreach (String filename in S.LoadAssemblies) { LibraryEntry ent = new LibraryEntry(filename); __sLib.Items.Add(ent); } } }
/// <summary> /// Initializes a new instance of the <see cref="WeakConcurrentDictionary<TKey, TValue>"/> class. /// </summary> /// <param name="collection">The collection to copy into the dictionary.</param> /// <param name="concurrencyLevel">The estimated number of threads that will update the lookup concurrently.</param> /// <param name="capacity">The initial number of elements that the lookup can contain.</param> /// <param name="comparer">The comparer to use when comparing keys.</param> /// <param name="allowResurrection"> /// If set to <see langword="true"/> then allow resurrections. /// If unset will allow resurrection if the type does not support dispose.</param> public WeakConcurrentDictionary( [CanBeNull] IEnumerable <KeyValuePair <TKey, TValue> > collection, int concurrencyLevel = 0, int capacity = 0, [CanBeNull] IEqualityComparer <TKey> comparer = null, TriState allowResurrection = default(TriState)) { // Create underlying dictionary. _dictionary = new ConcurrentDictionary <TKey, WeakReference <TValue> >( concurrencyLevel < 1 ? 4 * Environment.ProcessorCount : concurrencyLevel, capacity < 1 ? 32 : capacity, comparer ?? EqualityComparer <TKey> .Default); // Set allow resurrection. _allowResurrection = allowResurrection == TriState.Undefined ? !ObservableWeakReference <TValue> .Disposable : allowResurrection == TriState.Yes; // We are only observing finalization if the type supports it and we're not allowing resurrection. _observable = !_allowResurrection && ObservableWeakReference <TValue> .ObservableFinalize; if (collection == null) { return; } // ReSharper disable AssignNullToNotNullAttribute foreach (KeyValuePair <TKey, TValue> kvp in collection) { Add(kvp.Key, kvp.Value); } // ReSharper restore AssignNullToNotNullAttribute }
private void InternalSetTriState(TriState state) { ThreeStateTreeView treeView = base.TreeView as ThreeStateTreeView; if (treeView != null) { WinFormsUI.Controls.NativeMethods.TVITEM lParam = new WinFormsUI.Controls.NativeMethods.TVITEM { mask = 24, hItem = base.Handle, stateMask = 61440 }; switch (state) { case TriState.Unchecked: lParam.state |= 4096; break; case TriState.Checked: lParam.state |= 8192; break; case TriState.Indeterminate: lParam.state |= 12288; break; default: throw new ArgumentOutOfRangeException("state"); } WinFormsUI.Controls.NativeMethods.SendMessage(new HandleRef(base.TreeView, base.TreeView.Handle), 4365, 0, ref lParam); treeView.TreeViewAfterTriStateUpdate(this); } }
protected override void OnTick() { if (Trade.IsExecuting) { return; } //Local declaration TriState _Open_Sell_Position = new TriState(); TriState _Open_Buy_Position = new TriState(); //Step 1 _Open = MarketSeries.Open.Last(1); _Close = MarketSeries.Close.Last(1); _Transform = Transform(_Candle_Points, 2); //Step 2 //Step 3 //Step 4 //Step 5 if ((((_Open - (_Close)) >= _Transform) && (MarketSeries.TickVolume.LastValue == 1))) { _Open_Sell_Position = _OpenPosition(0, true, Symbol.Code, TradeType.Sell, _Lots, 10, _SL_Points, _TP_Points, ""); } if ((((_Close - (_Open)) >= _Transform) && (MarketSeries.TickVolume.LastValue == 1))) { _Open_Buy_Position = _OpenPosition(0, true, Symbol.Code, TradeType.Buy, _Lots, 10, _SL_Points, _TP_Points, ""); } }
protected override void OnTick() { if (Trade.IsExecuting) return; //Local declaration TriState _Open_Sell_Position = new TriState(); TriState _Open_Buy_Position = new TriState(); //Step 1 _Open = MarketSeries.Open.Last(1); _Close = MarketSeries.Close.Last(1); _Transform = Transform(_Candle_Points, 2); //Step 2 //Step 3 //Step 4 //Step 5 if ((((_Open - (_Close)) >= _Transform) && (MarketSeries.TickVolume.LastValue == 1))) _Open_Sell_Position = _OpenPosition(0, true, Symbol.Code, TradeType.Sell, _Lots, 10, _SL_Points, _TP_Points, ""); if ((((_Close - (_Open)) >= _Transform) && (MarketSeries.TickVolume.LastValue == 1))) _Open_Buy_Position = _OpenPosition(0, true, Symbol.Code, TradeType.Buy, _Lots, 10, _SL_Points, _TP_Points, ""); }
// // Private methods // void Initialize() { encoding = Encoding.UTF8; omitXmlDecl = false; newLineHandling = NewLineHandling.Replace; newLineChars = Environment.NewLine; // "\r\n" on Windows, "\n" on Unix indent = TriState.Unknown; indentChars = " "; newLineOnAttributes = false; closeOutput = false; namespaceHandling = NamespaceHandling.Default; conformanceLevel = ConformanceLevel.Document; checkCharacters = true; writeEndDocumentOnClose = true; #if !SILVERLIGHT outputMethod = XmlOutputMethod.Xml; cdataSections.Clear(); mergeCDataSections = false; mediaType = null; docTypeSystem = null; docTypePublic = null; standalone = XmlStandalone.Omit; doNotEscapeUriAttributes = false; #endif #if ASYNC || FEATURE_NETCORE useAsync = false; #endif isReadOnly = false; }
public PackageState(uint uid, TriState state, string info) { this.uid = uid; this.state = state; this.info = info; this.data = new uint[0]; }
protected override void OnTick() { if (Trade.IsExecuting) return; //Local declaration TriState _Close_Position = new TriState(); TriState _Close_Position_2 = new TriState(); TriState _Buy = new TriState(); TriState _Sell = new TriState(); //Step 1 _Moving_Average_200MA = i_Moving_Average_200MA.Result.Last(0); _Relative_Strength_Index = i_Relative_Strength_Index.Result.Last(0); _Moving_Average_5MA = i_Moving_Average_5MA.Result.Last(0); //Step 2 _Compare_7 = (MarketSeries.Close.Last(0) > _Moving_Average_5MA); _Compare_4 = (MarketSeries.Close.Last(0) < _Moving_Average_5MA); //Step 3 _AND_2 = ((_Relative_Strength_Index < 5) && (MarketSeries.Close.Last(0) > _Moving_Average_200MA) && (MarketSeries.Close.Last(0) < _Moving_Average_5MA) && (i_Relative_Strength_Index_2.Result.Last(1) < _Relative_Strength_Index)); if (_Compare_7) _Close_Position = _ClosePosition(1, Symbol.Code, 0); _AND = ((_Relative_Strength_Index > 95) && (MarketSeries.Close.Last(0) > _Moving_Average_5MA) && (MarketSeries.Close.Last(0) < _Moving_Average_200MA) && (_Relative_Strength_Index > i_Relative_Strength_Index_2.Result.Last(1))); if (_Compare_4) _Close_Position_2 = _ClosePosition(2, Symbol.Code, 0); //Step 4 if (_AND_2) _Buy = Buy(1, _Open_Lot, 1, _StopLoss_Pips, 1, 0, 0, _MaxOpenTrade, _MaxTradingFreqMins, ""); if (_AND) _Sell = Sell(2, _Open_Lot, 1, _StopLoss_Pips, 1, 0, 0, _MaxOpenTrade, _MaxTradingFreqMins, ""); }
private void OnTriState(TriState t) { if (TriStateProperty != null) { TriStateProperty(t); } }
protected override void OnTick() { if (Trade.IsExecuting) return; //Local declaration TriState _Close_Position = new TriState(); TriState _Close_Position_2 = new TriState(); TriState _Sell = new TriState(); TriState _Buy = new TriState(); //Step 1 _Relative_Strength_Index = i_Relative_Strength_Index.Result.Last(0); _Moving_Average_200MA = i_Moving_Average_200MA.Result.Last(0); _Moving_Average_5MA = i_Moving_Average_5MA.Result.Last(0); //Step 2 _Compare_7 = (MarketSeries.Close.Last(0) > _Moving_Average_5MA); _Compare_4 = (MarketSeries.Close.Last(0) < _Moving_Average_5MA); //Step 3 _AND_2 = ((_Relative_Strength_Index < 5) && (MarketSeries.Close.Last(0) > _Moving_Average_200MA) && (MarketSeries.Close.Last(0) < _Moving_Average_5MA)); if (_Compare_7) _Close_Position = _ClosePosition(1, Symbol.Code, 0); if (_Compare_4) _Close_Position_2 = _ClosePosition(2, Symbol.Code, 0); _AND = ((_Relative_Strength_Index > 95) && (MarketSeries.Close.Last(0) > _Moving_Average_5MA) && (MarketSeries.Close.Last(0) < _Moving_Average_200MA)); //Step 4 if (_AND) _Sell = Sell(2, 0.5, 0, 360, 0, 0, 5, 1, 0, ""); if (_AND_2) _Buy = Buy(1, 0.5, 0, 360, 0, 0, 5, 1, 0, ""); }
internal void SetAutoValues() { if (this.owner is TextBoxBase) { SetAutoValues((TextBoxBase)this.owner); } else if (this.owner is NumericUpDown) { SetAutoValues((NumericUpDown)this.owner); } else if (this.owner is CheckBox) { SetAutoValues((CheckBox)this.owner); } else if (this.owner is RadioButton) { SetAutoValues((RadioButton)this.owner); } else if (this.owner is Button) { SetAutoValues((Button)this.owner); } // DataGridViewCell ?? // TreeNode ?? _hidden = owner.Visible ? TriState.False : TriState.True; // determine label Control prevControl = this.owner.Parent?.GetNextControl(this.owner, false); if (prevControl != null && prevControl is Label) { _labeledBy = prevControl; } }
protected override void OnLoad(ConfigNode node) { base.OnLoad(node); situationTokenizedTexts = new Dictionary <ExtendedSituation, List <List <Token> > >(); isRandom = node.GetBoolean("Random", false); resetOnLaunch = node.GetBoolean("ResetOnLaunch", false); evaOnly = node.GetEnum("EvaOnly", TriState.UseDefault); foreach (ConfigNode section in node.GetNodes()) { string name = section.name; try { ExtendedSituation situation = (ExtendedSituation)(object)ConfigNode.ParseEnum(typeof(ExtendedSituation), name); if (!situationTokenizedTexts.ContainsKey(situation)) { situationTokenizedTexts.Add(situation, new List <List <Token> >()); messageIndices.Add(situation, -1); } situationTokenizedTexts[situation].AddTokenizedRange(section.GetValues("Text")); } catch { Historian.Print($"Unrecognised situation block {name} in TEXT_LIST"); } } }
/// <summary> /// Initializes a new instance of the <see cref="WeakConcurrentDictionary<TKey, TValue>"/> class. /// </summary> /// <param name="concurrencyLevel">The estimated number of threads that will update the lookup concurrently.</param> /// <param name="capacity">The initial number of elements that the lookup can contain.</param> /// <param name="comparer">The comparer to use when comparing keys.</param> /// <param name="allowResurrection"> /// If set to <see langword="true"/> then allow resurrections. /// If unset will allow resurrection if the type does not support dispose. /// </param> public WeakConcurrentDictionary( int concurrencyLevel = 0, int capacity = 0, [CanBeNull] IEqualityComparer <TKey> comparer = null, TriState allowResurrection = default(TriState)) : this(null, concurrencyLevel, capacity, comparer, allowResurrection) { }
private void SetTriState(TriState state) { this.triState = state; if (((base.TreeView != null) && base.TreeView.IsHandleCreated) && (base.Handle != IntPtr.Zero)) { this.InternalSetTriState(state); } }
/// <summary> /// Initializes a new instance of the <see cref="Miracle.FileZilla.Api.Test.RandomTriStateSequenceGenerator"/> class /// for a specific range of TriStates. /// </summary> /// <param name="minTriState">The lower bound of the TriState range.</param> /// <param name="maxTriState">The uppder bound of the TriState range.</param> /// <exception cref="ArgumentException"> /// <paramref name="minTriState"/> is greater than <paramref name="maxTriState"/>. /// </exception> public RandomTriStateSequenceGenerator(TriState minTriState, TriState maxTriState) { if (minTriState >= maxTriState) { throw new ArgumentException("The 'minTriState' argument must be less than the 'maxTriState'."); } this.randomizer = new RandomNumericSequenceGenerator((byte)minTriState, (byte)maxTriState); }
public void TriState_ToString_DefaultsToYesNoUnknownStyle() { TriState testTriState = (Random.Next() % 3 - 1); Assert.AreEqual( testTriState.ToString(TriState.Style.YesUnknownNo), testTriState.ToString(), "The string representation of a TriState should default to YesUnknownNo formatting."); }
public void TriState_IFormattableWithFormatT_GivesSameResultAsToStringTrueUndefinedFalse() { TriState testTriState = (Random.Next() % 3 - 1); Assert.AreEqual( testTriState.ToString("T", null), testTriState.ToString(TriState.Style.TrueUndefinedFalse), "The result of IFormattable.ToString with format 'T' should be the same as ToString with style TrueUndefinedFalse."); }
public void TriState_IFormattableWithFormatY_GivesSameResultAsToStringYesUnknownNo() { TriState testTriState = (Random.Next() % 3 - 1); Assert.AreEqual( testTriState.ToString("Y", null), testTriState.ToString(TriState.Style.YesUnknownNo), "The result of IFormattable.ToString with format 'Y' should be the same as ToString with style YesUnknownNo."); }
public void TriState_IFormattableWithFormatN_GivesSameResultAsToStringNegativeEqualPositive() { TriState testTriState = (Random.Next() % 3 - 1); Assert.AreEqual( testTriState.ToString("N", null), testTriState.ToString(TriState.Style.NegativeEqualPositive), "The result of IFormattable.ToString with format 'N' should be the same as ToString with style NegativeEqualPositive."); }
public Variable(Definition def, string name, DataType dataType, Value value, bool isArg, TriState isInitialized, bool isUsed) { _def = def; _name = name; _dataType = dataType; _value = value; _isArg = isArg; _isInitialized = isInitialized; _isUsed = isUsed; }
public void TriState_IFormattableWithInvalidStyle_ThrowsFormatException() { Random randSource = new Random(); TriState testTriState = (Random.Next() % 3 - 1); String testInvalidStyle = "ThisIsNotAValidStyleType"; TriState.Style testStyle; Assert.IsFalse(Enum.TryParse(testInvalidStyle, false, out testStyle)); String value = testTriState.ToString("ThisIsNotAValidStyleType", null); }
public static string FormatCurrency(object o, int NumDigitsAfterDecimal, TriState IncludeLeadingDigit, TriState UseParensForNegativeNumbers, TriState GroupDigits) { if (o == null || o is DateTime) { throw (new Exception("Invalid currency expression")); } string sValue = String.Format("{0:$#,#}", o); return(sValue); }
private void SetAppDomain(bool useSandBoxAppDomain) { if (useSandBoxAppDomain) { m_executeInSandbox = TriState.True; return; } m_executeInSandbox = TriState.False; ReleaseSandboxAppDomain(); }
protected override void OnTick() { if (Trade.IsExecuting) { return; } //Local declaration TriState _CloseShortPosition = new TriState(); TriState _CloseLongPosition = new TriState(); TriState _Buy = new TriState(); TriState _LongSimple_TrailingStop = new TriState(); TriState _ShortSimple_TrailingStop = new TriState(); TriState _Sell = new TriState(); //Step 1 _TrendMovingAverage = i_TrendMovingAverage.Result.Last(0); _Intermediate_SMA = i_Intermediate_SMA.Result.Last(0); _RSI_StopLoss = i_RSI_StopLoss.Result.Last((int)_wRSI_Shift); _TriggerMovingAverage = i_TriggerMovingAverage.Result.Last(0); _RSI = i_RSI.Result.Last((int)_cRSI_MA_Shift); //Step 2 _CompareCloseShort = (_RSI_StopLoss <= _wRSI_CloseShortLevel); _CompareCloseLong = (_RSI_StopLoss >= _wRSI_CloseLongLevel); //Step 3 _AND_2 = ((MarketSeries.Close.Last(0) > _TriggerMovingAverage) && (MarketSeries.Close.Last((int)_OHLC_Shift) < _TrendMovingAverage) && (_RSI > _cRSI_OverBoughtLevel) && (MarketData.GetSeries(TimeFrame.Daily).Close.Last((int)_OHLC_Shift) < _Intermediate_SMA)); if (_CompareCloseShort) { _CloseShortPosition = _ClosePosition((_MagicNumber + (1)), Symbol.Code, 0); } _AND = ((MarketSeries.Close.Last((int)_OHLC_Shift) > _TrendMovingAverage) && (MarketSeries.Close.Last(0) < _TriggerMovingAverage) && (_RSI < _cRSI_OverSoldLevel) && (MarketData.GetSeries(TimeFrame.Daily).Close.Last((int)_OHLC_Shift) > _Intermediate_SMA)); _AgregateArithmetic = ((i_Average_True_Range.Result.Last((int)_ATR_MA) * (_Pips_Multiplier)) * (_ATR_Risk_Multiplier)); if (_CompareCloseLong) { _CloseLongPosition = _ClosePosition(_MagicNumber, Symbol.Code, 0); } //Step 4 //Step 5 //Step 6 if (_AND) { _Buy = Buy(_MagicNumber, _LotSize, 1, ((Symbol.Ask + (_AgregateArithmetic)) / (_EquityIndexDivisor)), 0, 0, 1, _MaxOpenTrades, _MaxFreqMins, ""); } _LongSimple_TrailingStop = Simple_Trailing_Stop(_MagicNumber, 0, (Symbol.Ask + (_AgregateArithmetic)), ((Symbol.Ask + (_AgregateArithmetic)) / (_TrailingStop_Dividsor_Value))); _ShortSimple_TrailingStop = Simple_Trailing_Stop((_MagicNumber + (1)), 0, (Symbol.Ask + (_AgregateArithmetic)), ((Symbol.Ask + (_AgregateArithmetic)) / (_TrailingStop_Dividsor_Value))); if (_AND_2) { _Sell = Sell((_MagicNumber + (1)), _LotSize, 1, ((Symbol.Ask + (_AgregateArithmetic)) / (_EquityIndexDivisor)), 0, 0, 1, _MaxOpenTrades, _MaxFreqMins, ""); } }
internal unsafe HttpListenerRequest(System.Net.HttpListenerContext httpContext, RequestContextBase memoryBlob) { if (Logging.On) { Logging.PrintInfo(Logging.HttpListener, this, ".ctor", "httpContext#" + ValidationHelper.HashString(httpContext) + " memoryBlob# " + ValidationHelper.HashString((IntPtr) memoryBlob.RequestBlob)); } if (Logging.On) { Logging.Associate(Logging.HttpListener, this, httpContext); } this.m_HttpContext = httpContext; this.m_MemoryBlob = memoryBlob; this.m_BoundaryType = BoundaryType.None; this.m_RequestId = memoryBlob.RequestBlob.RequestId; this.m_ConnectionId = memoryBlob.RequestBlob.ConnectionId; this.m_SslStatus = (memoryBlob.RequestBlob.pSslInfo == null) ? SslStatus.Insecure : ((memoryBlob.RequestBlob.pSslInfo.SslClientCertNegotiated == 0) ? SslStatus.NoClientCert : SslStatus.ClientCert); if ((memoryBlob.RequestBlob.pRawUrl != null) && (memoryBlob.RequestBlob.RawUrlLength > 0)) { this.m_RawUrl = Marshal.PtrToStringAnsi((IntPtr) memoryBlob.RequestBlob.pRawUrl, memoryBlob.RequestBlob.RawUrlLength); } UnsafeNclNativeMethods.HttpApi.HTTP_COOKED_URL cookedUrl = memoryBlob.RequestBlob.CookedUrl; if ((cookedUrl.pHost != null) && (cookedUrl.HostLength > 0)) { this.m_CookedUrlHost = Marshal.PtrToStringUni((IntPtr) cookedUrl.pHost, cookedUrl.HostLength / 2); } if ((cookedUrl.pAbsPath != null) && (cookedUrl.AbsPathLength > 0)) { this.m_CookedUrlPath = Marshal.PtrToStringUni((IntPtr) cookedUrl.pAbsPath, cookedUrl.AbsPathLength / 2); } if ((cookedUrl.pQueryString != null) && (cookedUrl.QueryStringLength > 0)) { this.m_CookedUrlQuery = Marshal.PtrToStringUni((IntPtr) cookedUrl.pQueryString, cookedUrl.QueryStringLength / 2); } this.m_Version = new Version(memoryBlob.RequestBlob.Version.MajorVersion, memoryBlob.RequestBlob.Version.MinorVersion); this.m_ClientCertState = ListenerClientCertState.NotInitialized; this.m_KeepAlive = TriState.Unspecified; if (Logging.On) { Logging.PrintInfo(Logging.HttpListener, this, ".ctor", "httpContext#" + ValidationHelper.HashString(httpContext) + " RequestUri:" + ValidationHelper.ToString(this.RequestUri) + " Content-Length:" + ValidationHelper.ToString(this.ContentLength64) + " HTTP Method:" + ValidationHelper.ToString(this.HttpMethod)); } if (Logging.On) { StringBuilder builder = new StringBuilder("HttpListenerRequest Headers:\n"); for (int i = 0; i < this.Headers.Count; i++) { builder.Append("\t"); builder.Append(this.Headers.GetKey(i)); builder.Append(" : "); builder.Append(this.Headers.Get(i)); builder.Append("\n"); } Logging.PrintInfo(Logging.HttpListener, this, ".ctor", builder.ToString()); } }
protected override void OnLoad(ConfigNode node) { base.OnLoad(node); foreach (ExtendedSituation key in System.Enum.GetValues(typeof(ExtendedSituation))) { situations.Add(key, Parser.GetTokens(node.GetString(key.ToString(), ""))); } evaOnly = node.GetEnum("EvaOnly", TriState.UseDefault); }
public void SetFieldValue_StateDefault_ReturnsEmptyString() { //Assign TriState value = TriState.Default; //Act var result = _handler.SetFieldValue(value, null); //Assert Assert.AreEqual("", result); }
internal unsafe HttpListenerRequest(System.Net.HttpListenerContext httpContext, RequestContextBase memoryBlob) { if (Logging.On) { Logging.PrintInfo(Logging.HttpListener, this, ".ctor", "httpContext#" + ValidationHelper.HashString(httpContext) + " memoryBlob# " + ValidationHelper.HashString((IntPtr)memoryBlob.RequestBlob)); } if (Logging.On) { Logging.Associate(Logging.HttpListener, this, httpContext); } this.m_HttpContext = httpContext; this.m_MemoryBlob = memoryBlob; this.m_BoundaryType = BoundaryType.None; this.m_RequestId = memoryBlob.RequestBlob.RequestId; this.m_ConnectionId = memoryBlob.RequestBlob.ConnectionId; this.m_SslStatus = (memoryBlob.RequestBlob.pSslInfo == null) ? SslStatus.Insecure : ((memoryBlob.RequestBlob.pSslInfo.SslClientCertNegotiated == 0) ? SslStatus.NoClientCert : SslStatus.ClientCert); if ((memoryBlob.RequestBlob.pRawUrl != null) && (memoryBlob.RequestBlob.RawUrlLength > 0)) { this.m_RawUrl = Marshal.PtrToStringAnsi((IntPtr)memoryBlob.RequestBlob.pRawUrl, memoryBlob.RequestBlob.RawUrlLength); } UnsafeNclNativeMethods.HttpApi.HTTP_COOKED_URL cookedUrl = memoryBlob.RequestBlob.CookedUrl; if ((cookedUrl.pHost != null) && (cookedUrl.HostLength > 0)) { this.m_CookedUrlHost = Marshal.PtrToStringUni((IntPtr)cookedUrl.pHost, cookedUrl.HostLength / 2); } if ((cookedUrl.pAbsPath != null) && (cookedUrl.AbsPathLength > 0)) { this.m_CookedUrlPath = Marshal.PtrToStringUni((IntPtr)cookedUrl.pAbsPath, cookedUrl.AbsPathLength / 2); } if ((cookedUrl.pQueryString != null) && (cookedUrl.QueryStringLength > 0)) { this.m_CookedUrlQuery = Marshal.PtrToStringUni((IntPtr)cookedUrl.pQueryString, cookedUrl.QueryStringLength / 2); } this.m_Version = new Version(memoryBlob.RequestBlob.Version.MajorVersion, memoryBlob.RequestBlob.Version.MinorVersion); this.m_ClientCertState = ListenerClientCertState.NotInitialized; this.m_KeepAlive = TriState.Unspecified; if (Logging.On) { Logging.PrintInfo(Logging.HttpListener, this, ".ctor", "httpContext#" + ValidationHelper.HashString(httpContext) + " RequestUri:" + ValidationHelper.ToString(this.RequestUri) + " Content-Length:" + ValidationHelper.ToString(this.ContentLength64) + " HTTP Method:" + ValidationHelper.ToString(this.HttpMethod)); } if (Logging.On) { StringBuilder builder = new StringBuilder("HttpListenerRequest Headers:\n"); for (int i = 0; i < this.Headers.Count; i++) { builder.Append("\t"); builder.Append(this.Headers.GetKey(i)); builder.Append(" : "); builder.Append(this.Headers.Get(i)); builder.Append("\n"); } Logging.PrintInfo(Logging.HttpListener, this, ".ctor", builder.ToString()); } }
public bool IsBlockElement() { if (_isBlockElement == TriState.Undefined) { _isBlockElement = this.NodeType == XmlNodeType.Element && !InlineElements.Contains(GetNamespaceName()) ? TriState.True : TriState.False;; } return(_isBlockElement == TriState.True); }
public void SetFieldValue_StateYes_ReturnsStringOne() { //Assign TriState value = TriState.Yes; //Act var result = _handler.SetFieldValue(value, null); //Assert Assert.AreEqual("1", result); }
internal FtpDataStream(NetworkStream networkStream, FtpWebRequest request, TriState writeOnly) { GlobalLog.Print("FtpDataStream#" + ValidationHelper.HashString(this) + "::FtpDataStream"); m_Readable = true; m_Writeable = true; if (writeOnly == TriState.True) { m_Readable = false; } else if (writeOnly == TriState.False) { m_Writeable = false; } m_NetworkStream = networkStream; m_Request = request; }
internal FtpDataStream(NetworkStream networkStream, FtpWebRequest request, TriState writeOnly) { if (NetEventSource.IsEnabled) NetEventSource.Info(this); _readable = true; _writeable = true; if (writeOnly == TriState.True) { _readable = false; } else if (writeOnly == TriState.False) { _writeable = false; } _networkStream = networkStream; _request = request; }
public override bool CanResetValue(object component) { if (this.canReset == TriState.Unknown) { this.canReset = TriState.Yes; Array a = (Array) component; for (int i = 0; i < this.descriptors.Length; i++) { if (!this.descriptors[i].CanResetValue(this.GetPropertyOwnerForComponent(a, i))) { this.canReset = TriState.No; break; } } } return (this.canReset == TriState.Yes); }
internal FtpDataStream(NetworkStream networkStream, FtpWebRequest request, TriState writeOnly) { if (GlobalLog.IsEnabled) { GlobalLog.Print("FtpDataStream#" + LoggingHash.HashString(this) + "::FtpDataStream"); } _readable = true; _writeable = true; if (writeOnly == TriState.True) { _readable = false; } else if (writeOnly == TriState.False) { _writeable = false; } _networkStream = networkStream; _request = request; }
/// <summary> /// Forces the the list collection wrapper to reset it's internal trackers (i.e. resynchronize with the list). /// </summary> public void Refresh() { isReadonly = TriState.NotAssigned; isFixedSize = TriState.NotAssigned; count = -1; age++; }
internal ServicePoint(string host, int port, TimerThread.Queue defaultIdlingQueue, int defaultConnectionLimit, string lookupString, bool userChangedLimit, bool proxyServicePoint) { GlobalLog.Print("ServicePoint#" + ValidationHelper.HashString(this) + "::.ctor(" + lookupString+")"); if (Logging.On) Logging.Enter(Logging.Web, this, "ServicePoint", host + ":" + port); m_ProxyServicePoint = proxyServicePoint; m_ConnectionName = "ByHost:"+host+":"+port.ToString(CultureInfo.InvariantCulture); m_IdlingQueue = defaultIdlingQueue; m_ConnectionLimit = defaultConnectionLimit; m_HostLoopbackGuess = TriState.Unspecified; m_LookupString = lookupString; m_UserChangedLimit = userChangedLimit; m_ConnectionGroupList = new Hashtable(10); m_ConnectionLeaseTimeout = System.Threading.Timeout.Infinite; m_ReceiveBufferSize = -1; m_Host = host; m_Port = port; m_HostMode = true; // upon creation, the service point should be idle, by default m_IdleSince = DateTime.Now; m_ExpiringTimer = m_IdlingQueue.CreateTimer(ServicePointManager.IdleServicePointTimeoutDelegate, this); m_IdleConnectionGroupTimeoutDelegate = new TimerThread.Callback(IdleConnectionGroupTimeoutCallback); }
public AsyncTriState(TriState newValue) { Value = newValue; }
private void CompleteStartRequest(bool onSubmitThread, HttpWebRequest request, TriState needReConnect) { GlobalLog.Enter("Connection#" + ValidationHelper.HashString(this) + "::CompleteStartRequest", ValidationHelper.HashString(request)); GlobalLog.ThreadContract(ThreadKinds.Unknown, "Connection#" + ValidationHelper.HashString(this) + "::CompleteStartRequest"); if (needReConnect == TriState.True) { // Socket is not alive. GlobalLog.Print("Connection#" + ValidationHelper.HashString(this) + "::CompleteStartRequest() Queue StartConnection Delegate "); try { if (request.Async) { CompleteStartConnection(true, request); } else if (onSubmitThread) { CompleteStartConnection(false, request); } // else - fall through and wake up other thread } catch (Exception exception) { GlobalLog.Print("Connection#" + ValidationHelper.HashString(this) + "::CompleteStartRequest(): exception: " + exception.ToString()); if (NclUtilities.IsFatal(exception)) throw; // // Should not be here because CompleteStartConnection and below tries to catch everything // GlobalLog.Assert(exception.ToString()); } // If neeeded wake up other thread where SubmitRequest was called if (!request.Async) { GlobalLog.Print("Connection#" + ValidationHelper.HashString(this) + "::CompleteStartRequest() Invoking Async Result"); request.ConnectionAsyncResult.InvokeCallback(new AsyncTriState(needReConnect)); } GlobalLog.Leave("Connection#" + ValidationHelper.HashString(this) + "::CompleteStartRequest", "needReConnect"); return; } // // From now on the request.SetRequestSubmitDone must be called or it may hang // For a [....] request the write side reponse windowwas opened in HttpWebRequest.SubmitRequest if (request.Async) request.OpenWriteSideResponseWindow(); ConnectStream writeStream = new ConnectStream(this, request); // Call the request to let them know that we have a write-stream, this might invoke Send() call if (request.Async || onSubmitThread) { request.SetRequestSubmitDone(writeStream); } else { GlobalLog.Print("Connection#" + ValidationHelper.HashString(this) + "::CompleteStartRequest() Invoking Async Result"); request.ConnectionAsyncResult.InvokeCallback(writeStream); } GlobalLog.Leave("Connection#" + ValidationHelper.HashString(this) + "::CompleteStartRequest"); }
public static string FormatPercent(object Expression, int NumDigitsAfterDecimal, TriState IncludeLeadingDigit, TriState UseParensForNegativeNumbers, TriState GroupDigits) { }
private void InternalWriteStartNextRequest(HttpWebRequest request, ref bool calledCloseConnection, ref TriState startRequestResult, ref HttpWebRequest nextRequest, ref ConnectionReturnResult returnResult) { GlobalLog.ThreadContract(ThreadKinds.Unknown, "Connection#" + ValidationHelper.HashString(this) + "::InternalWriteStartNextRequest"); lock(this) { GlobalLog.Print("Connection#" + ValidationHelper.HashString(this) + "::WriteStartNextRequest() setting WriteDone:" + m_WriteDone.ToString() + " to true"); m_WriteDone = true; // // If we're not doing keep alive, and the read on this connection // has already completed, now is the time to close the // connection. // //need to wait for read to set the error if (!m_KeepAlive || m_Error != WebExceptionStatus.Success || !CanBePooled) { GlobalLog.Print("Connection#" + ValidationHelper.HashString(this) + "::WriteStartNextRequest() m_WriteList.Count:" + m_WriteList.Count); if (m_ReadDone) { // We could be closing because of an unexpected keep-alive // failure, ie we pipelined a few requests and in the middle // the remote server stopped doing keep alive. In this // case m_Error could be success, which would be misleading. // So in that case we'll set it to connection closed. if (m_Error == WebExceptionStatus.Success) { // Only reason we could have gotten here is because // we're not keeping the connection alive. m_Error = WebExceptionStatus.KeepAliveFailure; } // PrepareCloseConnectionSocket is called with the critical section // held. Note that we know since it's not a keep-alive // connection the read half wouldn't have posted a receive // for this connection, so it's OK to call PrepareCloseConnectionSocket now. PrepareCloseConnectionSocket(ref returnResult); calledCloseConnection = true; Close(); } else { if (m_Error!=WebExceptionStatus.Success) { GlobalLog.Print("Connection#" + ValidationHelper.HashString(this) + "::WriteStartNextRequest() a Failure, m_Error = " + m_Error.ToString()); } } } else { // If we're pipelining, we get get the next request going // as soon as the write is done. Otherwise we have to wait // until both read and write are done. GlobalLog.Print("Connection#" + ValidationHelper.HashString(this) + "::WriteStartNextRequest() Non-Error m_WriteList.Count:" + m_WriteList.Count + " m_WaitList.Count:" + m_WaitList.Count); if (m_Pipelining || m_ReadDone) { nextRequest = CheckNextRequest(); } if (nextRequest != null) { // This codepath doesn't handle the case where the server has closed the Connection because we // just finished using it and didn't get a Connection: close header. startRequestResult = StartRequest(nextRequest, false); GlobalLog.Assert(startRequestResult != TriState.Unspecified, "WriteStartNextRequest got TriState.Unspecified from StartRequest, things are about to hang!"); } } } // lock }
public static string FormatCurrency(object o, int NumDigitsAfterDecimal, TriState IncludeLeadingDigit, TriState UseParensForNegativeNumbers, TriState GroupDigits) { // 07/31/2006 Paul. We will always format with thousands separator and zero decimal places. //string sCurrencySymbol = System.Globalization.CultureInfo.CurrentCulture.NumberFormat.CurrencySymbol; if ( o == null || o is DateTime ) throw(new Exception("Invalid currency expression")); string sValue = String.Format("{0:$#,#}", o); return sValue; }
// // constructors // internal ServicePoint(Uri address, TimerThread.Queue defaultIdlingQueue, int defaultConnectionLimit, string lookupString, bool userChangedLimit, bool proxyServicePoint) { GlobalLog.Print("ServicePoint#" + ValidationHelper.HashString(this) + "::.ctor(" + lookupString+")"); if (Logging.On) Logging.Enter(Logging.Web, this, "ServicePoint", address.DnsSafeHost + ":" + address.Port); m_ProxyServicePoint = proxyServicePoint; m_Address = address; m_ConnectionName = address.Scheme; m_Host = address.DnsSafeHost; m_Port = address.Port; m_IdlingQueue = defaultIdlingQueue; m_ConnectionLimit = defaultConnectionLimit; m_HostLoopbackGuess = TriState.Unspecified; m_LookupString = lookupString; m_UserChangedLimit = userChangedLimit; m_UseNagleAlgorithm = ServicePointManager.UseNagleAlgorithm; m_Expect100Continue = ServicePointManager.Expect100Continue; m_ConnectionGroupList = new Hashtable(10); m_ConnectionLeaseTimeout = System.Threading.Timeout.Infinite; m_ReceiveBufferSize = -1; m_UseTcpKeepAlive = ServicePointManager.s_UseTcpKeepAlive; m_TcpKeepAliveTime = ServicePointManager.s_TcpKeepAliveTime; m_TcpKeepAliveInterval = ServicePointManager.s_TcpKeepAliveInterval; // it would be safer to make sure the server is 1.1 // but assume it is at the beginning, and update it later m_Understands100Continue = true; m_HttpBehaviour = HttpBehaviour.Unknown; // upon creation, the service point should be idle, by default m_IdleSince = DateTime.Now; m_ExpiringTimer = m_IdlingQueue.CreateTimer(ServicePointManager.IdleServicePointTimeoutDelegate, this); m_IdleConnectionGroupTimeoutDelegate = new TimerThread.Callback(IdleConnectionGroupTimeoutCallback); }
internal HttpWebRequest(Uri uri, ServicePoint servicePoint) { if(Logging.On)Logging.Enter(Logging.Web, this, "HttpWebRequest", uri); CheckConnectPermission(uri, false); m_StartTimestamp = NetworkingPerfCounters.GetTimestamp(); NetworkingPerfCounters.Instance.Increment(NetworkingPerfCounterName.HttpWebRequestCreated); // OOPS, This ctor can also be called with FTP scheme but then it should only allowed if going through the proxy // Something to think about... //if ((object)uri.Scheme != (object)Uri.UriSchemeHttp && (object)uri.Scheme != (object)Uri.UriSchemeHttps) //throw new ArgumentOutOfRangeException("uri"); GlobalLog.Print("HttpWebRequest#" + ValidationHelper.HashString(this) + "::.ctor(" + uri.ToString() + ")"); // // internal constructor, HttpWebRequest cannot be created directly // but only through WebRequest.Create() method // set defaults // _HttpRequestHeaders = new WebHeaderCollection(WebHeaderCollectionType.HttpWebRequest); _Proxy = WebRequest.InternalDefaultWebProxy; _HttpWriteMode = HttpWriteMode.Unknown; _MaximumAllowedRedirections = 50; _Timeout = WebRequest.DefaultTimeout; _TimerQueue = WebRequest.DefaultTimerQueue; _ReadWriteTimeout = DefaultReadWriteTimeout; _MaximumResponseHeadersLength = DefaultMaximumResponseHeadersLength; _ContentLength = -1; _originalContentLength = -1; _OriginVerb = KnownHttpVerb.Get; _OriginUri = uri; _Uri = _OriginUri; _ServicePoint = servicePoint; _RequestIsAsync = TriState.Unspecified; m_ContinueTimeout = DefaultContinueTimeout; m_ContinueTimerQueue = s_ContinueTimerQueue; SetupCacheProtocol(_OriginUri); #if HTTP_HEADER_EXTENSIONS_SUPPORTED _NextExtension = 10; #endif // HTTP_HEADER_EXTENSIONS_SUPPORTED if(Logging.On)Logging.Exit(Logging.Web, this, "HttpWebRequest", null); }
/// <summary> /// Generate boiler-plate code to create an Xml iterator that controls a nested iterator. /// </summary> /// <remarks> /// Iterator iter; /// iter.Create(filter [, orSelf]); /// ...nested iterator... /// navInput = nestedNested; /// goto LabelCall; /// LabelNext: /// navInput = null; /// LabelCall: /// switch (iter.MoveNext(navInput)) { /// case IteratorState.NoMoreNodes: goto LabelNextCtxt; /// case IteratorState.NextInputNode: goto LabelNextNested; /// } /// </remarks> private void CreateContainerIterator(QilUnary ndDod, string iterName, Type iterType, MethodInfo methCreate, MethodInfo methNext, XmlNodeKindFlags kinds, QilName ndName, TriState orSelf) { // Iterator iter; LocalBuilder locIter = _helper.DeclareLocal(iterName, iterType); Label lblOnEndNested; QilLoop ndLoop = (QilLoop)ndDod.Child; Debug.Assert(ndDod.NodeType == QilNodeType.DocOrderDistinct && ndLoop != null); // iter.Create(filter [, orSelf]); _helper.Emit(OpCodes.Ldloca, locIter); LoadSelectFilter(kinds, ndName); if (orSelf != TriState.Unknown) _helper.LoadBoolean(orSelf == TriState.True); _helper.Call(methCreate); // Generate nested iterator (branch to lblOnEndNested when iteration is complete) lblOnEndNested = _helper.DefineLabel(); StartNestedIterator(ndLoop, lblOnEndNested); StartBinding(ndLoop.Variable); EndBinding(ndLoop.Variable); EndNestedIterator(ndLoop.Variable); _iterCurr.Storage = _iterNested.Storage; GenerateContainerIterator(ndDod, locIter, lblOnEndNested, methNext, typeof(XPathNavigator)); }
// // PERF: // removed some double initializations. // perf went from: // clocks per instruction CPI: 9,098.72 to 1,301.14 // %app exclusive time: 2.92 to 0.43 // /// <devdoc> /// <para> /// Basic Constructor for HTTP Protocol Class, Initializes to basic header state. /// </para> /// </devdoc> internal HttpWebRequest(Uri uri, ServicePoint servicePoint) { if(Logging.On)Logging.Enter(Logging.Web, this, "HttpWebRequest", uri); (new WebPermission(NetworkAccess.Connect, uri)).Demand(); // OOPS, This ctor can also be called with FTP scheme but then it should only allowed if going through the proxy // Something to think about... //if ((object)uri.Scheme != (object)Uri.UriSchemeHttp && (object)uri.Scheme != (object)Uri.UriSchemeHttps) //throw new ArgumentOutOfRangeException("uri"); GlobalLog.Print("HttpWebRequest#" + ValidationHelper.HashString(this) + "::.ctor(" + uri.ToString() + ")"); // // internal constructor, HttpWebRequest cannot be created directly // but only through WebRequest.Create() method // set defaults // _HttpRequestHeaders = new WebHeaderCollection(WebHeaderCollectionType.HttpWebRequest); _Proxy = WebRequest.InternalDefaultWebProxy; _HttpWriteMode = HttpWriteMode.Unknown; _MaximumAllowedRedirections = 50; _Timeout = WebRequest.DefaultTimeout; _TimerQueue = WebRequest.DefaultTimerQueue; _ReadWriteTimeout = DefaultReadWriteTimeout; _MaximumResponseHeadersLength = DefaultMaximumResponseHeadersLength; _ContentLength = -1; _OriginVerb = KnownHttpVerb.Get; _OriginUri = uri; _Uri = _OriginUri; _ServicePoint = servicePoint; _RequestIsAsync = TriState.Unspecified; SetupCacheProtocol(_OriginUri); if(Logging.On)Logging.Exit(Logging.Web, this, "HttpWebRequest", null); }
internal ServicePoint(string host, int port, TimerThread.Queue defaultIdlingQueue, int defaultConnectionLimit, string lookupString, bool userChangedLimit, bool proxyServicePoint) { this.m_HostName = string.Empty; this.m_ProxyServicePoint = proxyServicePoint; this.m_ConnectionName = "ByHost:" + host + ":" + port.ToString(CultureInfo.InvariantCulture); this.m_IdlingQueue = defaultIdlingQueue; this.m_ConnectionLimit = defaultConnectionLimit; this.m_HostLoopbackGuess = TriState.Unspecified; this.m_LookupString = lookupString; this.m_UserChangedLimit = userChangedLimit; this.m_ConnectionGroupList = new Hashtable(10); this.m_ConnectionLeaseTimeout = -1; this.m_ReceiveBufferSize = -1; this.m_Host = host; this.m_Port = port; this.m_HostMode = true; this.m_IdleSince = DateTime.Now; this.m_ExpiringTimer = this.m_IdlingQueue.CreateTimer(ServicePointManager.IdleServicePointTimeoutDelegate, this); }
internal HttpListenerRequest(HttpListenerContext httpContext, RequestContextBase memoryBlob) { if (Logging.On) Logging.PrintInfo(Logging.HttpListener, this, ".ctor", "httpContext#" + ValidationHelper.HashString(httpContext) + " memoryBlob# " + ValidationHelper.HashString((IntPtr) memoryBlob.RequestBlob)); if(Logging.On)Logging.Associate(Logging.HttpListener, this, httpContext); m_HttpContext = httpContext; m_MemoryBlob = memoryBlob; m_BoundaryType = BoundaryType.None; // Set up some of these now to avoid refcounting on memory blob later. m_RequestId = memoryBlob.RequestBlob->RequestId; m_ConnectionId = memoryBlob.RequestBlob->ConnectionId; m_SslStatus = memoryBlob.RequestBlob->pSslInfo == null ? SslStatus.Insecure : memoryBlob.RequestBlob->pSslInfo->SslClientCertNegotiated == 0 ? SslStatus.NoClientCert : SslStatus.ClientCert; if (memoryBlob.RequestBlob->pRawUrl != null && memoryBlob.RequestBlob->RawUrlLength > 0) { m_RawUrl = Marshal.PtrToStringAnsi((IntPtr) memoryBlob.RequestBlob->pRawUrl, memoryBlob.RequestBlob->RawUrlLength); } UnsafeNclNativeMethods.HttpApi.HTTP_COOKED_URL cookedUrl = memoryBlob.RequestBlob->CookedUrl; if (cookedUrl.pHost != null && cookedUrl.HostLength > 0) { m_CookedUrlHost = Marshal.PtrToStringUni((IntPtr)cookedUrl.pHost, cookedUrl.HostLength / 2); } if (cookedUrl.pAbsPath != null && cookedUrl.AbsPathLength > 0) { m_CookedUrlPath = Marshal.PtrToStringUni((IntPtr)cookedUrl.pAbsPath, cookedUrl.AbsPathLength / 2); } if (cookedUrl.pQueryString != null && cookedUrl.QueryStringLength > 0) { m_CookedUrlQuery = Marshal.PtrToStringUni((IntPtr)cookedUrl.pQueryString, cookedUrl.QueryStringLength / 2); } m_Version = new Version(memoryBlob.RequestBlob->Version.MajorVersion, memoryBlob.RequestBlob->Version.MinorVersion); m_ClientCertState = ListenerClientCertState.NotInitialized; m_KeepAlive = TriState.Unspecified; GlobalLog.Print("HttpListenerContext#" + ValidationHelper.HashString(this) + "::.ctor() RequestId:" + RequestId + " ConnectionId:" + m_ConnectionId + " RawConnectionId:" + memoryBlob.RequestBlob->RawConnectionId + " UrlContext:" + memoryBlob.RequestBlob->UrlContext + " RawUrl:" + m_RawUrl + " Version:" + m_Version.ToString() + " Secure:" + m_SslStatus.ToString()); if(Logging.On)Logging.PrintInfo(Logging.HttpListener, this, ".ctor", "httpContext#"+ ValidationHelper.HashString(httpContext)+ " RequestUri:" + ValidationHelper.ToString(RequestUri) + " Content-Length:" + ValidationHelper.ToString(ContentLength64) + " HTTP Method:" + ValidationHelper.ToString(HttpMethod)); // Log headers if(Logging.On) { StringBuilder sb = new StringBuilder("HttpListenerRequest Headers:\n"); for (int i=0; i<Headers.Count; i++) { sb.Append("\t"); sb.Append(Headers.GetKey(i)); sb.Append(" : "); sb.Append(Headers.Get(i)); sb.Append("\n"); } Logging.PrintInfo(Logging.HttpListener, this, ".ctor", sb.ToString()); } }
TriState Buy(double magicIndex, double Lots, int StopLossMethod, double stopLossValue, int TakeProfitMethod, double takeProfitValue, double Slippage, double MaxOpenTrades, double MaxFrequencyMins, string TradeComment) { double? stopLossPips, takeProfitPips; int numberOfOpenTrades = 0; var res = new TriState(); foreach (Position pos in Positions.FindAll("FxProQuant_" + magicIndex.ToString("F0"), Symbol)) { numberOfOpenTrades++; } if (MaxOpenTrades > 0 && numberOfOpenTrades >= MaxOpenTrades) return res; if (MaxFrequencyMins > 0) { if (((TimeSpan)(Server.Time - LastTradeExecution)).TotalMinutes < MaxFrequencyMins) return res; foreach (Position pos in Positions.FindAll("FxProQuant_" + magicIndex.ToString("F0"), Symbol)) { if (((TimeSpan)(Server.Time - pos.EntryTime)).TotalMinutes < MaxFrequencyMins) return res; } } int pipAdjustment = (int)(Symbol.PipSize / Symbol.TickSize); if (stopLossValue > 0) { if (StopLossMethod == 0) stopLossPips = stopLossValue / pipAdjustment; else if (StopLossMethod == 1) stopLossPips = stopLossValue; else stopLossPips = (Symbol.Ask - stopLossValue) / Symbol.PipSize; } else stopLossPips = null; if (takeProfitValue > 0) { if (TakeProfitMethod == 0) takeProfitPips = takeProfitValue / pipAdjustment; else if (TakeProfitMethod == 1) takeProfitPips = takeProfitValue; else takeProfitPips = (takeProfitValue - Symbol.Ask) / Symbol.PipSize; } else takeProfitPips = null; Slippage /= pipAdjustment; long volume = Symbol.NormalizeVolume(Lots * 100000, RoundingMode.ToNearest); if (!ExecuteMarketOrder(TradeType.Buy, Symbol, volume, "FxProQuant_" + magicIndex.ToString("F0"), stopLossPips, takeProfitPips, Slippage, TradeComment).IsSuccessful) { Thread.Sleep(400); return false; } LastTradeExecution = Server.Time; return true; }
// Constructor public CodeBlock(Bookmark bookmark, TriState hasBraces) : base(bookmark) { HasBraces = hasBraces; }
/// <include file='doc\PropertyDescriptor.uex' path='docs/doc[@for="PropertyDescriptor.CanResetValue"]/*' /> /// <devdoc> /// <para> /// When overridden in a derived class, indicates whether /// resetting the <paramref name="component "/>will change the value of the /// <paramref name="component"/>. /// </para> /// </devdoc> public override bool CanResetValue(object component) { Debug.Assert(component is Array, "MergePropertyDescriptor::CanResetValue called with non-array value"); if (canReset == TriState.Unknown) { canReset = TriState.Yes; Array a = (Array)component; for (int i = 0; i < descriptors.Length; i++) { if (!descriptors[i].CanResetValue(GetPropertyOwnerForComponent(a, i))) { canReset = TriState.No; break; } } } return (canReset == TriState.Yes); }
// Parse a brace enclosed statement block ast.CodeBlock ParseStatementBlock(TriState BracesInOutput) { var bmk = t.GetBookmark(); // Opening brace t.SkipRequired(Token.openBrace); // Statements var code = new ast.CodeBlock(bmk, BracesInOutput); ParseStatements(code); // Closing brace t.SkipRequired(Token.closeBrace); return code; }