Here are the examples of the csharp api System.Action.Invoke(bool) taken from open source projects. By voting up you can indicate which examples are most useful and appropriate.
783 Examples
19
View Source File : DbContextSync.cs
License : MIT License
Project Creator : 2881099
License : MIT License
Project Creator : 2881099
internal void ExecCommand() {
if (isExecCommanding) return;
if (_actions.Any() == false) return;
isExecCommanding = true;
ExecCommandInfo oldinfo = null;
var states = new List<object>();
Func<string, int> dbContextBetch = methodName => {
if (_dicExecCommandDbContextBetch.TryGetValue(oldinfo.stateType, out var trydic) == false)
trydic = new Dictionary<string, Func<object, object[], int>>();
if (trydic.TryGetValue(methodName, out var tryfunc) == false) {
var arrType = oldinfo.stateType.MakeArrayType();
var dbsetType = oldinfo.dbSet.GetType().BaseType;
var dbsetTypeMethod = dbsetType.GetMethod(methodName, BindingFlags.NonPublic | BindingFlags.Instance, null, new[] { arrType }, null);
var returnTarget = Expression.Label(typeof(int));
var parm1DbSet = Expression.Parameter(typeof(object));
var parm2Vals = Expression.Parameter(typeof(object[]));
var var1Vals = Expression.Variable(arrType);
tryfunc = Expression.Lambda<Func<object, object[], int>>(Expression.Block(
new[] { var1Vals },
Expression.replacedign(var1Vals, Expression.Convert(global::FreeSql.Internal.Utils.GetDataReaderValueBlockExpression(arrType, parm2Vals), arrType)),
Expression.Return(returnTarget, Expression.Call(Expression.Convert(parm1DbSet, dbsetType), dbsetTypeMethod, var1Vals)),
Expression.Label(returnTarget, Expression.Default(typeof(int)))
), new[] { parm1DbSet, parm2Vals }).Compile();
trydic.Add(methodName, tryfunc);
}
return tryfunc(oldinfo.dbSet, states.ToArray());
};
Action funcDelete = () => {
_affrows += dbContextBetch("DbContextBetchRemove");
states.Clear();
};
Action funcInsert = () => {
_affrows += dbContextBetch("DbContextBetchAdd");
states.Clear();
};
Action<bool> funcUpdate = isLiveUpdate => {
var affrows = 0;
if (isLiveUpdate) affrows = dbContextBetch("DbContextBetchUpdateNow");
else affrows = dbContextBetch("DbContextBetchUpdate");
if (affrows == -999) { //最后一个元素已被删除
states.RemoveAt(states.Count - 1);
return;
}
if (affrows == -998 || affrows == -997) { //没有执行更新
var laststate = states[states.Count - 1];
states.Clear();
if (affrows == -997) states.Add(laststate); //保留最后一个
}
if (affrows > 0) {
_affrows += affrows;
var islastNotUpdated = states.Count != affrows;
var laststate = states[states.Count - 1];
states.Clear();
if (islastNotUpdated) states.Add(laststate); //保留最后一个
}
};
while (_actions.Any() || states.Any()) {
var info = _actions.Any() ? _actions.Dequeue() : null;
if (oldinfo == null) oldinfo = info;
var isLiveUpdate = false;
if (_actions.Any() == false && states.Any() ||
info != null && oldinfo.actionType != info.actionType ||
info != null && oldinfo.stateType != info.stateType) {
if (info != null && oldinfo.actionType == info.actionType && oldinfo.stateType == info.stateType) {
//最后一个,合起来发送
states.Add(info.state);
info = null;
}
switch (oldinfo.actionType) {
case ExecCommandInfoType.Insert:
funcInsert();
break;
case ExecCommandInfoType.Delete:
funcDelete();
break;
}
isLiveUpdate = true;
}
if (isLiveUpdate || oldinfo.actionType == ExecCommandInfoType.Update) {
if (states.Any())
funcUpdate(isLiveUpdate);
}
if (info != null) {
states.Add(info.state);
oldinfo = info;
}
}
isExecCommanding = false;
}
19
View Source File : WebUtil.cs
License : MIT License
Project Creator : 404Lcc
License : MIT License
Project Creator : 404Lcc
public static IEnumerator Upload(string url, string field, byte[] bytes, string name, string mime, Action<bool> complete = null, Action<string> error = null)
{
WWWForm form = new WWWForm();
form.AddBinaryData(field, bytes, name, mime);
url = Uri.EscapeUriString(url);
UnityWebRequest webRequest = UnityWebRequest.Post(url, form);
yield return webRequest.SendWebRequest();
if (webRequest.result == UnityWebRequest.Result.ConnectionError || webRequest.result == UnityWebRequest.Result.ProtocolError)
{
LogUtil.Log(webRequest.error);
error?.Invoke(webRequest.error);
}
else
{
complete?.Invoke(true);
}
}
19
View Source File : TipsWindow.cs
License : MIT License
Project Creator : 404Lcc
License : MIT License
Project Creator : 404Lcc
public void OnCancel()
{
Callback?.Invoke(false);
OnHideTipsWindow();
}
19
View Source File : WebUtil.cs
License : MIT License
Project Creator : 404Lcc
License : MIT License
Project Creator : 404Lcc
public static IEnumerator Upload(string url, string field, byte[] bytes, string name, string mime, Action<bool> complete = null, Action<string> error = null)
{
WWWForm form = new WWWForm();
form.AddBinaryData(field, bytes, name, mime);
url = Uri.EscapeUriString(url);
UnityWebRequest webRequest = UnityWebRequest.Post(url, form);
yield return webRequest.SendWebRequest();
if (webRequest.isNetworkError || webRequest.isHttpError)
{
LogUtil.Log(webRequest.error);
error?.Invoke(webRequest.error);
}
else
{
complete?.Invoke(true);
}
}
19
View Source File : TipsWindow.cs
License : MIT License
Project Creator : 404Lcc
License : MIT License
Project Creator : 404Lcc
public void OnConfirm()
{
Callback?.Invoke(true);
OnHideTipsWindow();
}
19
View Source File : CaravanArrivalAction_VisitOnline.cs
License : Apache License 2.0
Project Creator : AantCoder
License : Apache License 2.0
Project Creator : AantCoder
private void attack(Caravan caravan)
{
Find.TickManager.Pause();
Action<bool> att = (testMode) =>
{
if (GameAttacker.Create())
{
GameAttacker.Get.Start(caravan, (BaseOnline)сaravanOnline, testMode);
}
};
GameUtils.ShowDialodOKCancel("OCity_Caravan_Go_Attack_Target".Translate() + " " + сaravanOnline.Label
, "OCity_Caravan_Confirm_Attack_TestBattle_Possible".Translate()
, () => att(false)
, () => { }
, null
, "OCity_Caravan_Practive".Translate()
, () => att(true)
);
}
19
View Source File : NonNativeKeyboard.cs
License : Apache License 2.0
Project Creator : abist-co-ltd
License : Apache License 2.0
Project Creator : abist-co-ltd
public void Shift(bool newShiftState)
{
m_IsShifted = newShiftState;
OnKeyboardShifted(m_IsShifted);
if (m_IsCapslocked && !newShiftState)
{
m_IsCapslocked = false;
}
}
19
View Source File : InputSimulationWindow.cs
License : Apache License 2.0
Project Creator : abist-co-ltd
License : Apache License 2.0
Project Creator : abist-co-ltd
private void DrawHandGUI(string name,
bool isAlwaysVisible, Action<bool> setAlwaysVisible,
Vector3 position, Action<Vector3> setPosition,
Vector3 rotation, Action<Vector3> setRotation,
Action reset)
{
using (new GUILayout.VerticalScope(EditorStyles.helpBox))
{
GUILayout.Label($"{name} Hand:");
bool newIsAlwaysVisible = EditorGUILayout.Toggle("Always Visible", isAlwaysVisible);
Vector3 newPosition = EditorGUILayout.Vector3Field("Position", position);
Vector3 newRotation = DrawRotationGUI("Rotation", rotation);
bool resetHand = GUILayout.Button("Reset");
if (newIsAlwaysVisible != isAlwaysVisible)
{
setAlwaysVisible(newIsAlwaysVisible);
}
if (newPosition != position)
{
setPosition(newPosition);
}
if (newRotation != rotation)
{
setRotation(newRotation);
}
if (resetHand)
{
reset();
}
}
}
19
View Source File : SerializedShardDatabase.cs
License : GNU Affero General Public License v3.0
Project Creator : ACEmulator
License : GNU Affero General Public License v3.0
Project Creator : ACEmulator
public void SaveBiota(ACE.Enreplacedy.Models.Biota biota, ReaderWriterLockSlim rwLock, Action<bool> callback)
{
_queue.Add(new Task(() =>
{
var result = BaseDatabase.SaveBiota(biota, rwLock);
callback?.Invoke(result);
}));
}
19
View Source File : SerializedShardDatabase.cs
License : GNU Affero General Public License v3.0
Project Creator : ACEmulator
License : GNU Affero General Public License v3.0
Project Creator : ACEmulator
public void SaveBiotasInParallel(IEnumerable<(ACE.Enreplacedy.Models.Biota biota, ReaderWriterLockSlim rwLock)> biotas, Action<bool> callback)
{
_queue.Add(new Task(() =>
{
var result = BaseDatabase.SaveBiotasInParallel(biotas);
callback?.Invoke(result);
}));
}
19
View Source File : SerializedShardDatabase.cs
License : GNU Affero General Public License v3.0
Project Creator : ACEmulator
License : GNU Affero General Public License v3.0
Project Creator : ACEmulator
public void RemoveBiota(uint id, Action<bool> callback)
{
_queue.Add(new Task(() =>
{
var result = BaseDatabase.RemoveBiota(id);
callback?.Invoke(result);
}));
}
19
View Source File : SerializedShardDatabase.cs
License : GNU Affero General Public License v3.0
Project Creator : ACEmulator
License : GNU Affero General Public License v3.0
Project Creator : ACEmulator
public void RemoveBiota(uint id, Action<bool> callback, Action<TimeSpan, TimeSpan> performanceResults)
{
var initialCallTime = DateTime.UtcNow;
_queue.Add(new Task(() =>
{
var taskStartTime = DateTime.UtcNow;
var result = BaseDatabase.RemoveBiota(id);
var taskCompletedTime = DateTime.UtcNow;
callback?.Invoke(result);
performanceResults?.Invoke(taskStartTime - initialCallTime, taskCompletedTime - taskStartTime);
}));
}
19
View Source File : SerializedShardDatabase.cs
License : GNU Affero General Public License v3.0
Project Creator : ACEmulator
License : GNU Affero General Public License v3.0
Project Creator : ACEmulator
public void IsCharacterNameAvailable(string name, Action<bool> callback)
{
_queue.Add(new Task(() =>
{
var result = BaseDatabase.IsCharacterNameAvailable(name);
callback?.Invoke(result);
}));
}
19
View Source File : SerializedShardDatabase.cs
License : GNU Affero General Public License v3.0
Project Creator : ACEmulator
License : GNU Affero General Public License v3.0
Project Creator : ACEmulator
public void SaveCharacter(Character character, ReaderWriterLockSlim rwLock, Action<bool> callback)
{
_queue.Add(new Task(() =>
{
var result = BaseDatabase.SaveCharacter(character, rwLock);
callback?.Invoke(result);
}));
}
19
View Source File : SerializedShardDatabase.cs
License : GNU Affero General Public License v3.0
Project Creator : ACEmulator
License : GNU Affero General Public License v3.0
Project Creator : ACEmulator
public void RenameCharacter(Character character, string newName, ReaderWriterLockSlim rwLock, Action<bool> callback)
{
_queue.Add(new Task(() =>
{
var result = BaseDatabase.RenameCharacter(character, newName, rwLock);
callback?.Invoke(result);
}));
}
19
View Source File : SerializedShardDatabase.cs
License : GNU Affero General Public License v3.0
Project Creator : ACEmulator
License : GNU Affero General Public License v3.0
Project Creator : ACEmulator
public void AddCharacterInParallel(ACE.Enreplacedy.Models.Biota biota, ReaderWriterLockSlim biotaLock, IEnumerable<(ACE.Enreplacedy.Models.Biota biota, ReaderWriterLockSlim rwLock)> possessions, Character character, ReaderWriterLockSlim characterLock, Action<bool> callback)
{
_queue.Add(new Task(() =>
{
var result = BaseDatabase.AddCharacterInParallel(biota, biotaLock, possessions, character, characterLock);
callback?.Invoke(result);
}));
}
19
View Source File : SerializedShardDatabase.cs
License : GNU Affero General Public License v3.0
Project Creator : ACEmulator
License : GNU Affero General Public License v3.0
Project Creator : ACEmulator
public void RemoveBiotasInParallel(IEnumerable<uint> ids, Action<bool> callback, Action<TimeSpan, TimeSpan> performanceResults)
{
var initialCallTime = DateTime.UtcNow;
_queue.Add(new Task(() =>
{
var taskStartTime = DateTime.UtcNow;
var result = BaseDatabase.RemoveBiotasInParallel(ids);
var taskCompletedTime = DateTime.UtcNow;
callback?.Invoke(result);
performanceResults?.Invoke(taskStartTime - initialCallTime, taskCompletedTime - taskStartTime);
}));
}
19
View Source File : Player_Move.cs
License : GNU Affero General Public License v3.0
Project Creator : ACEmulator
License : GNU Affero General Public License v3.0
Project Creator : ACEmulator
public void CreateMoveToChain(WorldObject target, Action<bool> callback, float? useRadius = null, bool rotate = true)
{
if (FastTick)
{
CreateMoveToChain2(target, callback, useRadius, rotate);
return;
}
var thisMoveToChainNumber = GetNextMoveToChainNumber();
if (target.Location == null)
{
StopExistingMoveToChains();
log.Error($"{Name}.CreateMoveToChain({target.Name}): target.Location is null");
callback(false);
return;
}
// fix bug in magic combat mode after walking to target,
// crouch animation steps out of range
if (useRadius == null)
useRadius = target.UseRadius ?? 0.6f;
if (CombatMode == CombatMode.Magic)
useRadius = Math.Max(0.0f, useRadius.Value - 0.2f);
// already within use distance?
var withinUseRadius = CurrentLandblock.WithinUseRadius(this, target.Guid, out var targetValid, useRadius);
if (withinUseRadius)
{
if (rotate)
{
// send TurnTo motion
var rotateTime = Rotate(target);
var actionChain = new ActionChain();
actionChain.AddDelaySeconds(rotateTime);
actionChain.AddAction(this, () =>
{
lastCompletedMove = thisMoveToChainNumber;
callback(true);
});
actionChain.EnqueueChain();
}
else
{
lastCompletedMove = thisMoveToChainNumber;
callback(true);
}
return;
}
if (target.WeenieType == WeenieType.Portal)
MoveToPosition(target.Location);
else
MoveToObject(target, useRadius);
moveToChainStartTime = DateTime.UtcNow;
MoveToChain(target, thisMoveToChainNumber, callback, useRadius);
}
19
View Source File : Player_Move.cs
License : GNU Affero General Public License v3.0
Project Creator : ACEmulator
License : GNU Affero General Public License v3.0
Project Creator : ACEmulator
public void MoveToChain(WorldObject target, int thisMoveToChainNumber, Action<bool> callback, float? useRadius = null)
{
if (thisMoveToChainNumber != moveToChainCounter)
{
if (thisMoveToChainNumber > lastCompletedMove)
lastCompletedMove = thisMoveToChainNumber;
callback(false);
return;
}
// Break loop if CurrentLandblock == null (we portaled or logged out)
if (CurrentLandblock == null)
{
StopExistingMoveToChains(); // This increments our moveToChainCounter and thus, should stop any additional actions in this chain
callback(false);
return;
}
// Have we timed out?
if (moveToChainStartTime + defaultMoveToTimeout <= DateTime.UtcNow)
{
StopExistingMoveToChains(); // This increments our moveToChainCounter and thus, should stop any additional actions in this chain
callback(false);
return;
}
// Are we within use radius?
var success = CurrentLandblock.WithinUseRadius(this, target.Guid, out var targetValid, useRadius);
// If one of the items isn't on a landblock
if (!targetValid)
{
StopExistingMoveToChains(); // This increments our moveToChainCounter and thus, should stop any additional actions in this chain
callback(false);
return;
}
if (!success)
{
// target not reached yet
var actionChain = new ActionChain();
actionChain.AddDelaySeconds(0.1f);
actionChain.AddAction(this, () => MoveToChain(target, thisMoveToChainNumber, callback, useRadius));
actionChain.EnqueueChain();
}
else
{
if (thisMoveToChainNumber > lastCompletedMove)
lastCompletedMove = thisMoveToChainNumber;
callback(true);
}
}
19
View Source File : Player_Move2.cs
License : GNU Affero General Public License v3.0
Project Creator : ACEmulator
License : GNU Affero General Public License v3.0
Project Creator : ACEmulator
public void CreateMoveToChain2(WorldObject target, Action<bool> callback, float? useRadius = null, bool rotate = true)
{
if (IsPlayerMovingTo2)
StopExistingMoveToChains2();
if (MoveToParams != null)
CheckMoveToParams();
if (target.Location == null)
{
log.Error($"{Name}.MoveTo({target.Name}): target.Location is null");
callback(false);
return;
}
if (useRadius == null)
useRadius = target.UseRadius ?? 0.6f;
var withinUseRadius = CurrentLandblock.WithinUseRadius(this, target.Guid, out var targetValid, useRadius);
if (withinUseRadius)
{
if (rotate)
CreateTurnToChain2(target, callback, useRadius);
else
callback(true);
return;
}
// send command to client
MoveToObject(target);
// start on server
// forward this to PhysicsObj.MoveManager.MoveToManager
var mvp = GetMoveToParams(target, useRadius);
if (!PhysicsObj.IsMovingOrAnimating)
//PhysicsObj.UpdateTime = PhysicsTimer.CurrentTime - PhysicsGlobals.MinQuantum;
PhysicsObj.UpdateTime = PhysicsTimer.CurrentTime;
IsPlayerMovingTo2 = true;
MoveToParams = new MoveToParams(callback, target, useRadius);
PhysicsObj.MoveToObject(target.PhysicsObj, mvp);
//PhysicsObj.LastMoveWasAutonomous = false;
PhysicsObj.update_object();
}
19
View Source File : Player_Move2.cs
License : GNU Affero General Public License v3.0
Project Creator : ACEmulator
License : GNU Affero General Public License v3.0
Project Creator : ACEmulator
public void CreateTurnToChain2(WorldObject target, Action<bool> callback, float? useRadius = null, bool stopCompletely = false, bool alwaysTurn = false)
{
if (IsPlayerMovingTo2)
StopExistingMoveToChains2();
if (MoveToParams != null)
CheckMoveToParams();
var rotateTarget = target.Wielder ?? target;
if (rotateTarget.Location == null)
{
log.Error($"{Name}.TurnTo({target.Name}): target.Location is null");
callback(false);
return;
}
if (DebugPlayerMoveToStatePhysics)
Console.WriteLine("*** CreateTurnToChain ***");
// send command to client
TurnToObject(rotateTarget, stopCompletely);
// start on server
// forward this to PhysicsObj.MoveManager.MoveToManager
var mvp = GetTurnToParams(stopCompletely);
if (!PhysicsObj.IsMovingOrAnimating)
//PhysicsObj.UpdateTime = PhysicsTimer.CurrentTime - PhysicsGlobals.MinQuantum;
PhysicsObj.UpdateTime = PhysicsTimer.CurrentTime;
IsPlayerMovingTo2 = true;
MoveToParams = new MoveToParams(callback, target, useRadius);
PhysicsObj.MovementManager.MoveToManager.AlwaysTurn = alwaysTurn;
PhysicsObj.TurnToObject(rotateTarget.PhysicsObj, mvp);
//PhysicsObj.LastMoveWasAutonomous = false;
PhysicsObj.update_object();
PhysicsObj.MovementManager.MoveToManager.AlwaysTurn = false;
}
19
View Source File : PeerView.cs
License : MIT License
Project Creator : adrenak
License : MIT License
Project Creator : adrenak
void Start() {
speakerToggle.onValueChanged.AddListener(value =>
OnIncomingModified?.Invoke(value));
micToggle.onValueChanged.AddListener(value =>
OnOutgoingModified?.Invoke(value));
}
19
View Source File : KoiSystem.cs
License : GNU General Public License v3.0
Project Creator : Aekras1a
License : GNU General Public License v3.0
Project Creator : Aekras1a
public void Login(string koiId)
{
try
{
#if DEBUG || __TRACE
const string PACK_URI = @"http://ki.no-ip.info/koi/{0}/koi.pack";
#else
const string PACK_URI = @"https://ki-host.appspot.com/KoiVM/koi/{0}/koi.pack";
#endif
var pack = new Uri(string.Format(PACK_URI, koiId));
var client = new WebClient();
var file = Path.Combine(KoiInfo.KoiDirectory, "koi.pack");
client.DownloadProgressChanged += (sender, e) =>
{
var progressValue = (double) e.BytesReceived / e.TotalBytesToReceive;
if(e.TotalBytesToReceive == -1)
progressValue = 0;
Progress(progressValue);
};
client.DownloadFileCompleted += (sender, e) =>
{
if(e.Error != null)
if(File.Exists(file))
File.Delete(file);
Finish(e.Error == null);
};
if(File.Exists(file))
File.Delete(file);
client.DownloadFileAsync(pack, file);
}
catch
{
Finish(false);
}
}
19
View Source File : PromiseControl.cs
License : Apache License 2.0
Project Creator : akkadotnet
License : Apache License 2.0
Project Creator : akkadotnet
public virtual void PerformStop()
{
_setStageKeepGoing(true);
_completeStageOutlet(_shape.Outlet);
OnStop();
}
19
View Source File : FixedShaderNodeView.cs
License : MIT License
Project Creator : alelievr
License : MIT License
Project Creator : alelievr
public override void Enable(bool fromInspector)
{
base.Enable(fromInspector);
if (!fromInspector)
{
if (fixedShaderNode.material != null && !owner.graph.IsObjectInGraph(fixedShaderNode.material))
{
if (owner.graph.IsExternalSubreplacedet(fixedShaderNode.material))
{
fixedShaderNode.material = new Material(fixedShaderNode.material);
fixedShaderNode.material.hideFlags = HideFlags.HideInHierarchy | HideFlags.HideInInspector;
}
if (fixedShaderNode.material.shader.name != ShaderNode.DefaultShaderName)
owner.graph.AddObjectToGraph(fixedShaderNode.material);
}
if (fixedShaderNode.shader != null)
lastModified = File.GetLastWriteTime(replacedetDatabase.GetreplacedetPath(fixedShaderNode.shader));
var lastWriteDetector = schedule.Execute(DetectShaderChanges);
lastWriteDetector.Every(200);
InitializeDebug();
onPortDisconnected += ResetMaterialPropertyToDefault;
}
if (fixedShaderNode.displayMaterialInspector)
{
Action<bool> safeMaterialGUI = (bool init) => {
// Copy fromInspector to avoid having the same value (lambda capture fromInspector pointer)
bool f = fromInspector;
if (!init)
MaterialGUI(f);
};
safeMaterialGUI(true);
var materialIMGUI = new IMGUIContainer(() => safeMaterialGUI(false));
materialIMGUI.AddToClreplacedList("MaterialInspector");
MixtureEditorUtils.ScheduleAutoHide(materialIMGUI, owner);
controlsContainer.Add(materialIMGUI);
}
}
19
View Source File : ToolbarView.cs
License : MIT License
Project Creator : alelievr
License : MIT License
Project Creator : alelievr
void DrawImGUIButtonList(List< ToolbarButtonData > buttons)
{
foreach (var button in buttons.ToList())
{
if (!button.visible)
continue;
switch (button.type)
{
case ElementType.Button:
if (GUILayout.Button(button.content, EditorStyles.toolbarButton) && button.buttonCallback != null)
button.buttonCallback();
break;
case ElementType.Toggle:
EditorGUI.BeginChangeCheck();
button.value = GUILayout.Toggle(button.value, button.content, EditorStyles.toolbarButton);
if (EditorGUI.EndChangeCheck() && button.toggleCallback != null)
button.toggleCallback(button.value);
break;
case ElementType.DropDownButton:
if (EditorGUILayout.DropdownButton(button.content, FocusType.Preplacedive, EditorStyles.toolbarDropDown))
button.buttonCallback();
break;
case ElementType.Separator:
EditorGUILayout.Separator();
EditorGUILayout.Space(button.size);
break;
case ElementType.Custom:
button.customDrawFunction();
break;
case ElementType.FlexibleSpace:
GUILayout.FlexibleSpace();
break;
}
}
}
19
View Source File : App.Impl.cs
License : MIT License
Project Creator : alexanderdna
License : MIT License
Project Creator : alexanderdna
void IInventoryNotifier.OnLatestBlock(Block block)
{
var publicKey = this.publicKey;
var address = this.address;
if (publicKey is null || address is null) return;
if (hasRelatedAddress(block, publicKey, address))
callback(true);
else
callback(false);
}
19
View Source File : App.Impl.cs
License : MIT License
Project Creator : alexanderdna
License : MIT License
Project Creator : alexanderdna
void IInventoryNotifier.OnBlocks(IList<Block> blocks)
{
var publicKey = this.publicKey;
var address = this.address;
if (publicKey is null || address is null) return;
for (int i = 0, c = blocks.Count; i < c; ++i)
{
if (hasRelatedAddress(blocks[i], publicKey, address))
{
callback(true);
break;
}
}
callback(false);
}
19
View Source File : App.Impl.cs
License : MIT License
Project Creator : alexanderdna
License : MIT License
Project Creator : alexanderdna
void IInventoryNotifier.OnMempool(IList<PendingTransaction> pendingTransactions)
{
var publicKey = this.publicKey;
var address = this.address;
if (publicKey is null || address is null) return;
for (int i = 0, c = pendingTransactions.Count; i < c; ++i)
{
if (hasRelatedAddress(pendingTransactions[i].Tx, publicKey, address))
{
callback(true);
break;
}
}
callback(false);
}
19
View Source File : TcpServer.cs
License : MIT License
Project Creator : alexwahl
License : MIT License
Project Creator : alexwahl
private void CancelComm()
{
tcpListener.Stop();
Enabled?.Invoke(false);
}
19
View Source File : TcpServer.cs
License : MIT License
Project Creator : alexwahl
License : MIT License
Project Creator : alexwahl
public void Start()
{
this.tcpListener = new TcpListener(IPAddress.Any, 4532);
this.cancel_listen = new CancellationTokenSource();
this.task_connectionHandler = ListenForClientConnection(cancel_listen.Token);
Enabled?.Invoke(true);
}
19
View Source File : TcpServer.cs
License : MIT License
Project Creator : alexwahl
License : MIT License
Project Creator : alexwahl
private void connection_lost()
{
Connected?.Invoke(false);
}
19
View Source File : TcpServer.cs
License : MIT License
Project Creator : alexwahl
License : MIT License
Project Creator : alexwahl
private void Connection_established()
{
Connected?.Invoke(true);
}
19
View Source File : Benchmark.cs
License : Apache License 2.0
Project Creator : alexyakunin
License : Apache License 2.0
Project Creator : alexyakunin
private void RunOnce()
{
if (MustWarmup) {
Action.Invoke(true);
SubtractAction?.Invoke(true);
MustWarmup = false;
}
if (MustGC)
GC.Collect();
var elapsed = TimeSpan.Zero;
var stopwatch = new Stopwatch();
stopwatch.Start();
try {
Action.Invoke(false);
}
finally {
stopwatch.Stop();
elapsed += stopwatch.Elapsed;
}
if (SubtractAction != null) {
if (MustGC)
GC.Collect();
stopwatch.Reset();
stopwatch.Start();
try {
SubtractAction.Invoke(false);
}
finally {
stopwatch.Stop();
elapsed -= stopwatch.Elapsed * SubtractActionFactor;
}
}
Timings.Add(elapsed);
}
19
View Source File : LicenseManager.cs
License : Apache License 2.0
Project Creator : Algoryx
License : Apache License 2.0
Project Creator : Algoryx
public static void ActivateAsync( int licenseId,
string licensePreplacedword,
string targetDirectory,
Action<bool> onDone )
{
if ( IsBusy ) {
Debug.LogWarning( $"AGXUnity.LicenseManager: Unable to activate license with id {licenseId} - activation is still in progress." );
onDone?.Invoke( false );
return;
}
var licenseFilename = IO.Environment.FindUniqueFilename( $"{targetDirectory}/agx{GetLicenseExtension( LicenseInfo.LicenseType.Service )}" );
s_activationTask = Task.Run( () =>
{
var success = false;
try {
success = agx.Runtime.instance().activateAgxLicense( licenseId,
licensePreplacedword,
licenseFilename );
UpdateLicenseInformation();
}
catch ( Exception e ) {
Debug.LogException( e );
success = false;
}
onDone?.Invoke( success );
} );
}
19
View Source File : LicenseManager.cs
License : Apache License 2.0
Project Creator : Algoryx
License : Apache License 2.0
Project Creator : Algoryx
public static void RefreshAsync( string filename,
Action<bool> onDone )
{
var isBusy = IsBusy;
var seemsValid = !string.IsNullOrEmpty( filename ) &&
!isBusy &&
File.Exists( filename ) &&
GetLicenseType( filename ) == LicenseInfo.LicenseType.Service;
if ( !seemsValid ) {
var warning = $"AGXUnity.LicenseManager: Unable to refresh license file \"{filename}\" - ";
if ( string.IsNullOrEmpty( filename ) )
warning += "the license file is null or empty.";
else if ( isBusy )
warning += "the license manager is busy activating or refreshing another license.";
else if ( !File.Exists( filename ) )
warning += "the license file doesn't exist.";
else
warning += "the license file doesn't support refresh.";
Debug.LogWarning( warning );
onDone?.Invoke( false );
return;
}
s_refreshTask = Task.Run( () =>
{
var success = false;
try {
success = agx.Runtime.instance().loadLicenseFile( filename, true );
UpdateLicenseInformation();
}
catch ( Exception e ) {
Debug.LogException( e );
success = false;
}
onDone?.Invoke( success );
} );
}
19
View Source File : AnnotationPackageListControl.cs
License : MIT License
Project Creator : AlturosDestinations
License : MIT License
Project Creator : AlturosDestinations
public void RefreshDataGrid()
{
this.dataGridView1.Invoke((MethodInvoker)delegate
{
this.dataGridView1.Refresh();
});
this.DirtyUpdated?.Invoke(this._annotationPackages.Any(o => o.IsDirty));
}
19
View Source File : IOs8AnalogInputCard.cs
License : GNU General Public License v3.0
Project Creator : alvaroyurrita
License : GNU General Public License v3.0
Project Creator : alvaroyurrita
void SubscribeInDigitalOutChanged()
{
IOPorts[0].DigitalOutput_Changed += (port, state) => { if (o1_F_Changed != null) o1_F_Changed(state ?? false); };
IOPorts[1].DigitalOutput_Changed += (port, state) => { if (o2_F_Changed != null) o2_F_Changed(state ?? false); };
IOPorts[2].DigitalOutput_Changed += (port, state) => { if (o3_F_Changed != null) o3_F_Changed(state ?? false); };
IOPorts[3].DigitalOutput_Changed += (port, state) => { if (o4_F_Changed != null) o4_F_Changed(state ?? false); };
IOPorts[4].DigitalOutput_Changed += (port, state) => { if (o5_F_Changed != null) o5_F_Changed(state ?? false); };
IOPorts[5].DigitalOutput_Changed += (port, state) => { if (o6_F_Changed != null) o6_F_Changed(state ?? false); };
IOPorts[6].DigitalOutput_Changed += (port, state) => { if (o7_F_Changed != null) o7_F_Changed(state ?? false); };
IOPorts[7].DigitalOutput_Changed += (port, state) => { if (o8_F_Changed != null) o8_F_Changed(state ?? false); };
}
19
View Source File : IOs8AnalogInputCard.cs
License : GNU General Public License v3.0
Project Creator : alvaroyurrita
License : GNU General Public License v3.0
Project Creator : alvaroyurrita
void SubscribeInPUDisableChanged()
{
IOPorts[0].PullUpResistorDisabled_Changed += (port, state) => { if (pu_disable1_F_Changed != null) pu_disable1_F_Changed(state ?? false); };
IOPorts[1].PullUpResistorDisabled_Changed += (port, state) => { if (pu_disable2_F_Changed != null) pu_disable2_F_Changed(state ?? false); };
IOPorts[2].PullUpResistorDisabled_Changed += (port, state) => { if (pu_disable3_F_Changed != null) pu_disable3_F_Changed(state ?? false); };
IOPorts[3].PullUpResistorDisabled_Changed += (port, state) => { if (pu_disable4_F_Changed != null) pu_disable4_F_Changed(state ?? false); };
IOPorts[4].PullUpResistorDisabled_Changed += (port, state) => { if (pu_disable5_F_Changed != null) pu_disable5_F_Changed(state ?? false); };
IOPorts[5].PullUpResistorDisabled_Changed += (port, state) => { if (pu_disable6_F_Changed != null) pu_disable6_F_Changed(state ?? false); };
IOPorts[6].PullUpResistorDisabled_Changed += (port, state) => { if (pu_disable7_F_Changed != null) pu_disable7_F_Changed(state ?? false); };
IOPorts[7].PullUpResistorDisabled_Changed += (port, state) => { if (pu_disable8_F_Changed != null) pu_disable8_F_Changed(state ?? false); };
}
19
View Source File : IOs8AnalogInputCard.cs
License : GNU General Public License v3.0
Project Creator : alvaroyurrita
License : GNU General Public License v3.0
Project Creator : alvaroyurrita
void SubscribeInDigitalInChanged()
{
IOPorts[0].DigitalInput_Changed += (port, state) => { if (di1_Changed != null) di1_Changed(state??false); };
IOPorts[1].DigitalInput_Changed += (port, state) => { if (di2_Changed != null) di2_Changed(state ?? false); };
IOPorts[2].DigitalInput_Changed += (port, state) => { if (di3_Changed != null) di3_Changed(state ?? false); };
IOPorts[3].DigitalInput_Changed += (port, state) => { if (di4_Changed != null) di4_Changed(state ?? false); };
IOPorts[4].DigitalInput_Changed += (port, state) => { if (di5_Changed != null) di5_Changed(state ?? false); };
IOPorts[5].DigitalInput_Changed += (port, state) => { if (di6_Changed != null) di6_Changed(state ?? false); };
IOPorts[6].DigitalInput_Changed += (port, state) => { if (di7_Changed != null) di7_Changed(state ?? false); };
IOPorts[7].DigitalInput_Changed += (port, state) => { if (di8_Changed != null) di8_Changed(state ?? false); };
}
19
View Source File : Relays8Card.cs
License : GNU General Public License v3.0
Project Creator : alvaroyurrita
License : GNU General Public License v3.0
Project Creator : alvaroyurrita
void SubscribeRelayChanged()
{
Relays[0].RelayStateChanged += (rly, value) => { if (A1_F_Changed != null) A1_F_Changed(value); };
Relays[1].RelayStateChanged += (rly, value) => { if (A2_F_Changed != null) A2_F_Changed(value); };
Relays[2].RelayStateChanged += (rly, value) => { if (A3_F_Changed != null) A3_F_Changed(value); };
Relays[3].RelayStateChanged += (rly, value) => { if (A4_F_Changed != null) A4_F_Changed(value); };
Relays[4].RelayStateChanged += (rly, value) => { if (A5_F_Changed != null) A5_F_Changed(value); };
Relays[5].RelayStateChanged += (rly, value) => { if (A6_F_Changed != null) A6_F_Changed(value); };
Relays[6].RelayStateChanged += (rly, value) => { if (A7_F_Changed != null) A7_F_Changed(value); };
Relays[7].RelayStateChanged += (rly, value) => { if (A8_F_Changed != null) A8_F_Changed(value); };
}
19
View Source File : DigitalInputs2Card.cs
License : GNU General Public License v3.0
Project Creator : alvaroyurrita
License : GNU General Public License v3.0
Project Creator : alvaroyurrita
void SubscribeDigitalInputPortStateChanged()
{
DigitalInputPorts[0].State_Changed += (port, state) => { if (I1_F_Changed != null) I1_F_Changed(state); };
DigitalInputPorts[1].State_Changed += (port, state) => { if (I2_F_Changed != null) I2_F_Changed(state); };
}
19
View Source File : Relays2Card.cs
License : GNU General Public License v3.0
Project Creator : alvaroyurrita
License : GNU General Public License v3.0
Project Creator : alvaroyurrita
void SubscribeRelayChanged()
{
Relays[0].RelayStateChanged += (rly, value) => { if (A1_F_Changed != null) A1_F_Changed(value); };
Relays[1].RelayStateChanged += (rly, value) => { if (A2_F_Changed != null) A2_F_Changed(value); };
}
19
View Source File : TwoWaySerialDriver.cs
License : GNU General Public License v3.0
Project Creator : alvaroyurrita
License : GNU General Public License v3.0
Project Creator : alvaroyurrita
void _ComPort_PropertyChanged(ComPort ReceivingComPort, ComPortPropertyEventArgs args)
{
switch (args.Property)
{
case eComPortProperty.CTS:
if (cts_Changed != null) cts_Changed(cts);
break;
default:
break;
}
}
19
View Source File : SettingForm.cs
License : MIT License
Project Creator : AmazingDM
License : MIT License
Project Creator : AmazingDM
private void BindCheckBox(CheckBox control, Action<bool> save, bool value)
{
control.Checked = value;
_saveActions.Add(control, c => save.Invoke(((CheckBox) c).Checked));
}
19
View Source File : SettingForm.cs
License : MIT License
Project Creator : AmazingDM
License : MIT License
Project Creator : AmazingDM
private void BindRadioBox(RadioButton control, Action<bool> save, bool value)
{
control.Checked = value;
_saveActions.Add(control, c => save.Invoke(((RadioButton) c).Checked));
}
19
View Source File : ServerForm.cs
License : MIT License
Project Creator : AmazingDM
License : MIT License
Project Creator : AmazingDM
protected void CreateCheckBox(string name, string remark, Action<bool> save, bool value)
{
_controlLines++;
var checkBox = new CheckBox
{
AutoSize = true,
Location = new Point(120, ControlLineHeight * _controlLines),
Name = $"{name}CheckBox",
Checked = value,
Text = remark
};
_saveActions.Add(checkBox, o => save.Invoke((bool) o));
ConfigurationGroupBox.Controls.AddRange(
new Control[]
{
checkBox
}
);
}
19
View Source File : SongDownloader.cs
License : MIT License
Project Creator : andruzzzhka
License : MIT License
Project Creator : andruzzzhka
public IEnumerator DownloadSongCoroutine(Song songInfo, Action<bool> downloadedCallback, Action<float> progressChangedCallback)
{
songInfo.songQueueState = SongQueueState.Downloading;
if (SongCore.Collections.songWithHashPresent(songInfo.hash.ToUpper()))
{
songInfo.downloadingProgress = 1f;
yield return new WaitForSeconds(0.1f);
songInfo.songQueueState = SongQueueState.Downloaded;
songDownloaded?.Invoke(songInfo);
downloadedCallback?.Invoke(true);
yield break;
}
UnityWebRequest www;
bool timeout = false;
float time = 0f;
UnityWebRequestAsyncOperation asyncRequest;
try
{
www = GetRequestForUrl(songInfo.downloadURL);
asyncRequest = www.SendWebRequest();
}
catch (Exception e)
{
Plugin.log.Error(e);
songInfo.songQueueState = SongQueueState.Error;
songInfo.downloadingProgress = 1f;
downloadedCallback?.Invoke(false);
yield break;
}
while ((!asyncRequest.isDone || songInfo.downloadingProgress < 1f) && songInfo.songQueueState != SongQueueState.Error)
{
yield return null;
time += Time.deltaTime;
if (time >= 5f && asyncRequest.progress <= float.Epsilon)
{
www.Abort();
timeout = true;
Plugin.log.Error("Connection timed out!");
}
songInfo.downloadingProgress = asyncRequest.progress;
progressChangedCallback?.Invoke(asyncRequest.progress);
}
if (songInfo.songQueueState == SongQueueState.Error && (!asyncRequest.isDone || songInfo.downloadingProgress < 1f))
www.Abort();
if (www.isNetworkError || www.isHttpError || timeout || songInfo.songQueueState == SongQueueState.Error)
{
songInfo.songQueueState = SongQueueState.Error;
Plugin.log.Error("Unable to download song! " + (www.isNetworkError ? $"Network error: {www.error}" : (www.isHttpError ? $"HTTP error: {www.error}" : "Unknown error")));
downloadedCallback?.Invoke(false);
}
else
{
Plugin.log.Debug("Received response from BeatSaver.com...");
string customSongsPath = "";
byte[] data = www.downloadHandler.data;
Stream zipStream = null;
try
{
customSongsPath = CustomLevelPathHelper.customLevelsDirectoryPath;
if (!Directory.Exists(customSongsPath))
{
Directory.CreateDirectory(customSongsPath);
}
zipStream = new MemoryStream(data);
Plugin.log.Debug("Downloaded zip!");
}
catch (Exception e)
{
Plugin.log.Critical(e);
songInfo.songQueueState = SongQueueState.Error;
downloadedCallback?.Invoke(false);
yield break;
}
yield return new WaitWhile(() => _extractingZip); //because extracting several songs at once sometimes hangs the game
Task extract = ExtractZipAsync(songInfo, zipStream, customSongsPath);
yield return new WaitWhile(() => !extract.IsCompleted);
songDownloaded?.Invoke(songInfo);
downloadedCallback?.Invoke(true);
}
}
19
View Source File : RoomCreationFlowCoordinator.cs
License : MIT License
Project Creator : andruzzzhka
License : MIT License
Project Creator : andruzzzhka
public void PacketReceived(NetIncomingMessage msg)
{
msg.Position = 0;
if ((CommandType)msg.ReadByte() == CommandType.CreateRoom)
{
_mainRoomCreationViewController.SetCreateButtonInteractable(true);
Client.Instance.MessageReceived -= PacketReceived;
_createdRoomId = msg.ReadUInt32();
DismissViewController(_mainRoomCreationViewController, null, true);
SetLeftScreenViewController(null);
didFinishEvent?.Invoke(true);
PluginUI.instance.serverHubFlowCoordinator.doNotUpdate = true;
PluginUI.instance.serverHubFlowCoordinator.JoinRoom(_selectedServerHub.ip, _selectedServerHub.port, _createdRoomId, _roomSettings.UsePreplacedword, _roomSettings.Preplacedword);
}
}
19
View Source File : RoomCreationFlowCoordinator.cs
License : MIT License
Project Creator : andruzzzhka
License : MIT License
Project Creator : andruzzzhka
protected override void BackButtonWasPressed(ViewController topViewController)
{
if (topViewController == _serverHubsViewController)
didFinishEvent?.Invoke(false);
else if (topViewController == _mainRoomCreationViewController)
{
DismissViewController(_mainRoomCreationViewController);
SetLeftScreenViewController(null);
}
else if (topViewController == _presetsListViewController)
_presetsListViewController_didFinishEvent(null);
}
See More Examples