本文整理汇总了C#中CounterType类的典型用法代码示例。如果您正苦于以下问题:C# CounterType类的具体用法?C# CounterType怎么用?C# CounterType使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。
CounterType类属于命名空间,在下文中一共展示了CounterType类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。
示例1: ButtonToggler
/// <summary>
/// Create a new <see cref="ButtonToggler"/> actor.
/// </summary>
/// <param name="performanceCountersController">
/// The actor that controls the <see cref="PerformanceCounterMonitor"/>s for various performance counters.
/// </param>
/// <param name="button">
/// The button controlled by the <see cref="ButtonToggler"/>.
/// </param>
/// <param name="counterType">
/// The type of performance counter represented by the button.
/// </param>
/// <param name="isToggled">
/// Is the button currently toggled ("On")?
/// </param>
public ButtonToggler(IActorRef performanceCountersController, Button button, CounterType counterType, bool isToggled = false)
{
if (performanceCountersController == null)
throw new ArgumentNullException("performanceCountersController");
if (button == null)
throw new ArgumentNullException("button");
if (counterType == CounterType.Unknown)
throw new ArgumentOutOfRangeException(nameof(counterType), counterType, "Invalid performance counter type.");
_performanceCountersController = performanceCountersController;
_button = button;
_counterType = counterType;
_isToggled = isToggled;
Receive<Toggle>(_ =>
{
if (Flip())
{
_performanceCountersController.Tell(
new WatchCounterValue(_counterType)
);
}
else
{
_performanceCountersController.Tell(
new UnwatchCounterValue(_counterType)
);
}
});
}
示例2: AddCounter
public void AddCounter(int counterId, CounterType counterType)
{
if (this.m_provider == null)
{
throw new InvalidOperationException(System.SR.GetString("Perflib_InvalidOperation_NoActiveProvider", new object[] { this.m_providerGuid }));
}
if (!PerfProviderCollection.ValidateCounterType(counterType))
{
throw new ArgumentException(System.SR.GetString("Perflib_Argument_InvalidCounterType", new object[] { counterType }), "counterType");
}
if (this.m_instanceCreated)
{
throw new InvalidOperationException(System.SR.GetString("Perflib_InvalidOperation_AddCounterAfterInstance", new object[] { this.m_counterSet }));
}
lock (this.m_lockObject)
{
if (this.m_instanceCreated)
{
throw new InvalidOperationException(System.SR.GetString("Perflib_InvalidOperation_AddCounterAfterInstance", new object[] { this.m_counterSet }));
}
if (this.m_idToCounter.ContainsKey(counterId))
{
throw new ArgumentException(System.SR.GetString("Perflib_Argument_CounterAlreadyExists", new object[] { counterId, this.m_counterSet }), "CounterId");
}
this.m_idToCounter.Add(counterId, counterType);
}
}
示例3: WatchCounterValue
/// <summary>
/// Create a new <see cref="WatchCounterValue"/> request message.
/// </summary>
/// <param name="counterType">
/// The type of target counter.
/// </param>
public WatchCounterValue(CounterType counterType)
{
if (counterType == CounterType.Unknown)
throw new ArgumentOutOfRangeException(nameof(counterType), counterType, "Invalid performance counter type.");
CounterType = counterType;
}
示例4: TimeCondition
internal TimeCondition(ValueType valueType, CounterType counter, uint value, DayOfWeek dayOfWeek)
{
ValueType = valueType;
CounterType = counter;
Value = value;
DayOfWeek = dayOfWeek;
}
示例5: ButtonToggleActor
public ButtonToggleActor(IActorRef coordinator, Button myButton, CounterType myCounterType, bool isToggledOn = false)
{
this.coordinatorActor = coordinator;
this.myButton = myButton;
this.myCounterType = myCounterType;
this.isToggledOn = isToggledOn;
}
示例6: ButtonToggleActor
public ButtonToggleActor(IActorRef coordinatorActor, Button myButton, CounterType myCounterType, bool isToggledOn = false)
{
_coordinatorActor = coordinatorActor;
_myButton = myButton;
_isToggledOn = isToggledOn;
_myCounterType = myCounterType;
}
示例7: SubscribePerformanceCounter
/// <summary>
/// Create a new <see cref="SubscribePerformanceCounter"/> request message.
/// </summary>
/// <param name="counter">
/// The type of performance counter to subscribe to.
/// </param>
/// <param name="subscriber">
/// The actor to which notifications should be sent.
/// </param>
public SubscribePerformanceCounter(CounterType counter, IActorRef subscriber)
{
if (counter == CounterType.Unknown)
throw new ArgumentOutOfRangeException(nameof(counter), counter, "Invalid performance counter type.");
if (subscriber == null)
throw new ArgumentNullException(nameof(subscriber));
Counter = counter;
Subscriber = subscriber;
}
示例8: Remove
public void Remove(CounterType counterType, int? count = null)
{
var counters = _counters.Where(x => x.Type == counterType);
if (count != null)
{
counters = counters.Take(count.Value);
}
foreach (var counter in counters.ToArray())
{
Remove(counter);
}
}
示例9: Increment
public int Increment(int itemId, int contextItemId, CounterType type = CounterType.Visits, CounterStoreType store = CounterStoreType.Database) {
string key = String.Format("{0}.{1}.{2}", itemId, contextItemId, type);
object counterLock = _locks.GetOrAdd(key, new object());
lock (counterLock) {
int counts = 0;
switch (store) {
case CounterStoreType.Database:
CounterRecord counter = _repo.Value.Get(r => r.ForItemId == itemId &&
r.InContextOfItemId == contextItemId &&
r.Type == type);
if (counter == null) {
counter = new CounterRecord {
ForItemId = itemId,
InContextOfItemId = contextItemId,
Type = type,
Count = 0,
LastModified = DateTime.Now
};
_repo.Value.Create(counter);
_repo.Value.Flush();
}
counts = ++counter.Count;
counter.LastModified = DateTime.Now;
_repo.Value.Flush();
break;
case CounterStoreType.Session:
if (_context.Current() != null && _context.Current().Session != null) {
// ReSharper disable PossibleNullReferenceException
var dict = _context.Current().Session[SessionKey] as ConcurrentDictionary<string, SerializableCounter>;
// ReSharper restore PossibleNullReferenceException
SerializableCounter sessionCounter = dict.GetOrAdd(key, new SerializableCounter {
ForItemId = itemId,
InContextOfItemId = contextItemId,
Type = type,
Count = 0
});
counts = ++sessionCounter.Count;
}
break;
default:
break;
}
return counts;
}
}
示例10: Clicked
public static void Clicked(CounterType type)
{
switch (type)
{
case CounterType.Happy:
happyClicks++;
break;
case CounterType.Sad:
sadClicks++;
if (sadClicks >= 4)
{
sadClicks = 0;
GetHappier();
}
break;
default:
break;
}
}
示例11: ButtonToggleActor
public ButtonToggleActor(IActorRef coordinatorActor, Button myButton, CounterType myCounterType, bool isToggledOn = false)
{
if (coordinatorActor == null)
{
throw new ArgumentNullException(nameof(coordinatorActor));
}
if (myButton == null)
{
throw new ArgumentNullException(nameof(myButton));
}
if (!Enum.IsDefined(typeof (CounterType), myCounterType))
{
throw new ArgumentOutOfRangeException(nameof(myCounterType));
}
_coordinatorActor = coordinatorActor;
_myButton = myButton;
_isToggledOn = isToggledOn;
_myCounterType = myCounterType;
}
示例12: OnTriggerEnter
void OnTriggerEnter(Collider collider)
{
switch (collider.tag)
{
case "PerfectCounter":
counterType = CounterType.PerfectCounter;
break;
case "GoodCounter":
counterType = CounterType.GoodCounter;
break;
case "OkayCounter":
counterType = CounterType.OkayCounter;
break;
case "Player":
scoreManager.ManageChallenge("down");
missSound.Play();
battle.ResetPostions();
break;
}
}
示例13: Main
static void Main(string[] args)
{
_serverProcId = "IPCTestServer";
if (args.Any())
_counterType = (CounterType) int.Parse(args[0]);
else
_counterType = CounterType.CPU;
if(args.Length == 3)
_counterType |= (CounterType)int.Parse(args[2]);
ManualResetEvent resetEvent = new ManualResetEvent(false);
_IPCClientThread = new Thread(ClientThreadLoop);
_IPCClientThread.Start(resetEvent);
Console.ReadLine();
resetEvent.Set();
}
示例14: IncrementCounter
static public void IncrementCounter (CounterType which)
{
++counters [(int) which];
}
示例15: UnsubscribeCounter
public UnsubscribeCounter(CounterType counter, IActorRef subscriber)
{
Subscriber = subscriber;
Counter = counter;
}