Here are the examples of the csharp api System.Action.Invoke(object) taken from open source projects. By voting up you can indicate which examples are most useful and appropriate.
784 Examples
19
Source : DelegateCommand.cs
with MIT License
from 944095635
with MIT License
from 944095635
public void Execute(object parameter)
{
if (executeAction == null)
{
return;
}
executeAction(parameter);
}
19
Source : ByteBuffer.cs
with MIT License
from a1q123456
with MIT License
from a1q123456
public void OnCompleted(Action<object> continuation, object state, short token, ValueTaskSourceOnCompletedFlags flags)
{
if ((flags & ValueTaskSourceOnCompletedFlags.FlowExecutionContext) != 0)
{
this.executionContext = ExecutionContext.Capture();
}
if ((flags & ValueTaskSourceOnCompletedFlags.UseSchedulingContext) != 0)
{
SynchronizationContext sc = SynchronizationContext.Current;
if (sc != null && sc.GetType() != typeof(SynchronizationContext))
{
this.scheduler = sc;
}
else
{
TaskScheduler ts = TaskScheduler.Current;
if (ts != TaskScheduler.Default)
{
this.scheduler = ts;
}
}
}
// Remember current state
this.state = state;
// Remember continuation to be executed on completed (if not already completed, in case of which
// continuation will be set to CallbackCompleted)
var previousContinuation = Interlocked.CompareExchange(ref this.continuation, continuation, null);
if (previousContinuation != null)
{
if (!ReferenceEquals(previousContinuation, CallbackCompleted))
{
throw new InvalidOperationException();
}
// Lost the race condition and the operation has now already completed.
// We need to invoke the continuation, but it must be asynchronously to
// avoid a stack dive. However, since all of the queueing mechanisms flow
// ExecutionContext, and since we're still in the same context where we
// captured it, we can just ignore the one we captured.
executionContext = null;
this.state = null; // we have the state in "state"; no need for the one in UserToken
InvokeContinuation(continuation, state, forceAsync: true);
}
cb.Add(() => continuation(state));
}
19
Source : ByteBuffer.cs
with MIT License
from a1q123456
with MIT License
from a1q123456
private void InvokeContinuation(Action<object> continuation, object state, bool forceAsync)
{
if (continuation == null)
return;
object scheduler = this.scheduler;
this.scheduler = null;
if (scheduler != null)
{
if (scheduler is SynchronizationContext sc)
{
sc.Post(s =>
{
var t = (Tuple<Action<object>, object>)s;
t.Item1(t.Item2);
}, Tuple.Create(continuation, state));
}
else
{
Debug.replacedert(scheduler is TaskScheduler, $"Expected TaskScheduler, got {scheduler}");
Task.Factory.StartNew(continuation, state, CancellationToken.None, TaskCreationOptions.DenyChildAttach, (TaskScheduler)scheduler);
}
}
else if (forceAsync)
{
ThreadPool.QueueUserWorkItem(continuation, state, preferLocal: true);
}
else
{
continuation(state);
}
}
19
Source : Amf3Reader.cs
with MIT License
from a1q123456
with MIT License
from a1q123456
public bool TryGetVectorObject(Span<byte> buffer, out object value, out int consumed)
{
value = default;
consumed = default;
if (!DataIsType(buffer, Amf3Type.VectorObject))
{
return false;
}
buffer = buffer.Slice(Amf3CommonValues.MARKER_LENGTH);
int arrayConsumed = 0;
if (!ReadVectorHeader(ref buffer, ref value, ref arrayConsumed, out var itemCount, out var isFixedSize, out var isRef))
{
return false;
}
if (isRef)
{
consumed = arrayConsumed;
return true;
}
if (!ReadVectorTypeName(ref buffer, out var typeName, out var typeNameConsumed))
{
return false;
}
var arrayBodyBuffer = buffer;
object resultVector = null;
Type elementType = null;
Action<object> addAction = null;
if (typeName == "*")
{
elementType = typeof(object);
var v = new Vector<object>();
_objectReferenceTable.Add(v);
v.IsFixedSize = isFixedSize;
resultVector = v;
addAction = v.Add;
}
else
{
if (!_registeredTypedObejectStates.TryGetValue(typeName, out var state))
{
return false;
}
elementType = state.Type;
var vectorType = typeof(Vector<>).MakeGenericType(elementType);
resultVector = Activator.CreateInstance(vectorType);
_objectReferenceTable.Add(resultVector);
vectorType.GetProperty("IsFixedSize").SetValue(resultVector, isFixedSize);
var addMethod = vectorType.GetMethod("Add");
addAction = o => addMethod.Invoke(resultVector, new object[] { o });
}
for (int i = 0; i < itemCount; i++)
{
if (!TryGetValue(arrayBodyBuffer, out var item, out var itemConsumed))
{
return false;
}
addAction(item);
arrayBodyBuffer = arrayBodyBuffer.Slice(itemConsumed);
arrayConsumed += itemConsumed;
}
value = resultVector;
consumed = typeNameConsumed + arrayConsumed;
return true;
}
19
Source : SoundEmitter.cs
with MIT License
from absurd-joy
with MIT License
from absurd-joy
public void Stop() {
// overrides everything
state = FadeState.Null;
StopAllCoroutines();
if ( audioSource != null ) {
audioSource.Stop();
}
if ( onFinished != null ) {
onFinished();
onFinished = null;
}
if ( onFinishedObject != null ) {
onFinishedObject( onFinishedParam );
onFinishedObject = null;
}
if ( playingSoundGroup != null ) {
playingSoundGroup.DecrementPlayCount();
playingSoundGroup = null;
}
}
19
Source : Command.cs
with GNU General Public License v3.0
from Acumatica
with GNU General Public License v3.0
from Acumatica
public void Execute(object parameter) => _actionToExecute(parameter);
19
Source : RelayCommand.cs
with BSD 2-Clause "Simplified" License
from adospace
with BSD 2-Clause "Simplified" License
from adospace
public void Execute(object parameter)
{
_execute(parameter);
}
19
Source : AduContactItem.cs
with GNU General Public License v3.0
from aduskin
with GNU General Public License v3.0
from aduskin
protected override void OnSelected(RoutedEventArgs e)
{
base.OnSelected(e);
ReadAction?.Invoke(Content);
}
19
Source : ThreadTaskManager.cs
with The Unlicense
from aeroson
with The Unlicense
from aeroson
private void ThreadExecutionLoop()
{
//Perform any initialization requested.
if (threadStart != null)
threadStart();
TaskEntry task;
while (true)
{
resetEvent.WaitOne();
while (true)
{
if (!taskData.TryDequeueFirst(out task))
{
bool gotSomething = false;
for (int i = 1; i < manager.workers.Count; i++)
{
if (TrySteal((index + i) % manager.workers.Count, out task))
{
gotSomething = true;
break;
}
}
if (!gotSomething)
break; //Nothing to steal and I'm broke! Guess I'll mosey on out
}
try
{
if (task.Task != null)
task.Task(task.Info);
if (Interlocked.Decrement(ref manager.tasksRemaining) == 0)
{
manager.allThreadsIdleNotifier.Set();
}
if (task.Task == null)
return;
}
catch (ArithmeticException arithmeticException)
{
throw new ArithmeticException(
"Some internal mulreplacedhreaded arithmetic has encountered an invalid state. Check for invalid enreplacedy momentums, velocities, and positions; propagating NaN's will generally trigger this exception in the getExtremePoint function.",
arithmeticException);
}
}
}
}
19
Source : SimpleLooper.cs
with The Unlicense
from aeroson
with The Unlicense
from aeroson
private void ThreadExecutionLoop()
{
//Perform any initialization requested.
if (threadStart != null)
threadStart(initializationInformation);
object information = null;
while (true)
{
Action<object> task = null;
lock (taskQueue)
{
if (taskQueue.Count > 0)
{
task = taskQueue.Dequeue();
if (task == null)
{
Dispose();
return;
}
information = taskInformationQueue.Dequeue();
}
}
if (task != null)
{
//Perform the task!
try
{
task(information);
}
catch (ArithmeticException arithmeticException)
{
throw new ArithmeticException(
"Some internal mulreplacedhreaded arithmetic has encountered an invalid state. Check for invalid enreplacedy momentums, velocities, and positions; propagating NaN's will generally trigger this exception in the getExtremePoint function.",
arithmeticException);
}
if (Interlocked.Decrement(ref manager.tasksRemaining) == 0)
{
manager.allThreadsIdleNotifier.Set();
resetEvent.WaitOne();
}
}
else
resetEvent.WaitOne();
}
}
19
Source : CollectionEx.cs
with Mozilla Public License 2.0
from agebullhu
with Mozilla Public License 2.0
from agebullhu
public static void ForEach(this IEnumerable em, Action<object> action, bool keepNull = true)
{
if (em == null)
return;
if (keepNull)
{
foreach (var t in em)
{
if (!Equals(t, null))
action(t);
}
}
else
{
foreach (var t in em)
{
action(t);
}
}
}
19
Source : CommandItem.cs
with Mozilla Public License 2.0
from agebullhu
with Mozilla Public License 2.0
from agebullhu
void DoAction(object arg)
{
if (DoConfirm && MessageBox.Show(ConfirmMessage ?? $"ȷ��ִ�С�{Caption ?? Name}��������?", "����༭", MessageBoxButton.YesNo) != MessageBoxResult.Yes)
{
return;
}
if (OnPrepare == null || OnPrepare(this))
Action?.Invoke(arg);
}
19
Source : CommandItem.cs
with Mozilla Public License 2.0
from agebullhu
with Mozilla Public License 2.0
from agebullhu
public override void Execute(object arg)
{
Action?.Invoke(arg);
}
19
Source : BaseCommand.cs
with MIT License
from aimore
with MIT License
from aimore
public void Execute(object parameter)
{
var nowTime = DateTime.UtcNow;
if (_actionFrequency == TimeSpan.Zero
|| Math.Abs((nowTime - _lastActionTime).TotalMilliseconds) >= _actionFrequency.TotalMilliseconds)
{
_lastActionTime = nowTime;
try
{
_action.Invoke(parameter);
}
catch (Exception ex)
{
_onExceptionAction?.Invoke(ex);
if (_shouldSuppressExceptions)
{
return;
}
throw ex;
}
}
}
19
Source : BaseViewModel.cs
with MIT License
from aimore
with MIT License
from aimore
protected ICommand RegCmd(Action<object> action, TimeSpan? actionFrequency = null, bool shouldSuppressExceptions = false, Action<Exception> onExceptionAction = null, Func<bool> canExecute = null, [CallerMemberName] string key = null)
=> RegCmd(new BaseCommand(p => action?.Invoke(p), actionFrequency, shouldSuppressExceptions, onExceptionAction, canExecute));
19
Source : PeriodTask.cs
with GNU General Public License v3.0
from aiportal
with GNU General Public License v3.0
from aiportal
private void ExecuteTask(Task task)
{
System.Diagnostics.Debug.replacedert(task != null);
try
{
task.Action(task.Action.Target);
task.LastEndTime = DateTime.Now;
}
catch (Exception ex)
{
TraceLogger.Instance.WriteException(ex);
if (OnException != null)
{
try
{
OnException(this, new TaskExceptionArgs() { TaskName = task.Name, Target = task.Action.Target, Exception = ex });
}
catch (Exception) { }
}
}
}
19
Source : PeriodTask.cs
with GNU General Public License v3.0
from aiportal
with GNU General Public License v3.0
from aiportal
private void ExecuteTask(Task task, object param)
{
Debug.replacedert(task != null);
try
{
task.Action(param);
}
catch (Exception ex)
{
TraceLog.WriteException(ex);
if (OnException != null)
{
try { OnException(this, new TaskExceptionArgs(task.Name, param, ex)); }
catch (Exception) { }
}
}
finally
{
task.LastEndTime = DateTime.Now;
}
}
19
Source : BaseCommand.cs
with MIT License
from aishang2015
with MIT License
from aishang2015
public void Execute(object parameter)
{
if (_execute != null && CanExecute(parameter))
{
_execute(parameter);
}
}
19
Source : KafkaConsumerActor.cs
with Apache License 2.0
from akkadotnet
with Apache License 2.0
from akkadotnet
private void Commit(IImmutableSet<TopicParreplacedionOffset> commitMap, Action<object> sendReply)
{
try
{
_commitRefreshing.UpdateRefreshDeadlines(commitMap.Select(tp => tp.TopicParreplacedion).ToImmutableHashSet());
var watch = Stopwatch.StartNew();
_consumer.Commit(commitMap);
watch.Stop();
if (watch.Elapsed >= _settings.CommitTimeWarning)
_log.Warning($"Kafka commit took longer than `commit-time-warning`: {watch.ElapsedMilliseconds} ms");
Self.Tell(new KafkaConsumerActorMetadata.Internal.Committed(commitMap));
sendReply(Akka.Done.Instance);
}
catch (Exception ex)
{
sendReply(new Status.Failure(ex));
}
// When many requestors, e.g. many parreplacedions with committableParreplacedionedSource the
// performance is much by collecting more requests/commits before performing the poll.
// That is done by sending a message to self, and thereby collect pending messages in mailbox.
if (_requestors.Count == 1)
{
Poll();
}
else if (!_delayedPoolInFlight)
{
_delayedPoolInFlight = true;
Self.Tell(_delayedPollMessage);
}
}
19
Source : FieldFactory.cs
with MIT License
from alelievr
with MIT License
from alelievr
public static INotifyValueChanged< T > CreateFieldSpecific< T >(T value, Action< object > onValueChanged, string label)
{
var fieldDrawer = CreateField< T >(value, label);
if (fieldDrawer == null)
return null;
fieldDrawer.value = value;
fieldDrawer.RegisterValueChangedCallback((e) => {
onValueChanged(e.newValue);
});
return fieldDrawer as INotifyValueChanged< T >;
}
19
Source : FieldFactory.cs
with MIT License
from alelievr
with MIT License
from alelievr
public static VisualElement CreateField(Type fieldType, object value, Action< object > onValueChanged, string label)
{
if (typeof(Enum).IsreplacedignableFrom(fieldType))
fieldType = typeof(Enum);
VisualElement field = null;
// Handle special cases here
if (fieldType == typeof(LayerMask))
{
// LayerMasks inherit from INotifyValueChanged<int> instead of INotifyValueChanged<LayerMask>
// so we can't register it inside our factory system :(
var layerField = new LayerMaskField(label, ((LayerMask)value).value);
layerField.RegisterValueChangedCallback(e => {
onValueChanged(new LayerMask{ value = e.newValue});
});
field = layerField;
}
else
{
try
{
var createFieldSpecificMethod = createFieldMethod.MakeGenericMethod(fieldType);
try
{
field = createFieldSpecificMethod.Invoke(null, new object[]{value, onValueChanged, label}) as VisualElement;
} catch {}
// handle the Object field case
if (field == null && (value == null || value is UnityEngine.Object))
{
createFieldSpecificMethod = createFieldMethod.MakeGenericMethod(typeof(UnityEngine.Object));
field = createFieldSpecificMethod.Invoke(null, new object[]{value, onValueChanged, label}) as VisualElement;
if (field is ObjectField objField)
{
objField.objectType = fieldType;
objField.value = value as UnityEngine.Object;
}
}
}
catch (Exception e)
{
Debug.LogError(e);
}
}
return field;
}
19
Source : ExposedParameterFieldFactory.cs
with MIT License
from alelievr
with MIT License
from alelievr
public VisualElement GetParameterValueField(ExposedParameter parameter, Action<object> valueChangedCallback)
{
serializedObject.Update();
int propIndex = FindPropertyIndex(parameter);
var field = new PropertyField(serializedParameters.GetArrayElementAtIndex(propIndex));
field.Bind(serializedObject);
VisualElement view = new VisualElement();
view.Add(field);
oldParameterValues[parameter] = parameter.value;
view.Add(new IMGUIContainer(() =>
{
if (oldParameterValues.TryGetValue(parameter, out var value))
{
if (parameter.value != null && !parameter.value.Equals(value))
valueChangedCallback(parameter.value);
}
oldParameterValues[parameter] = parameter.value;
}));
// Disallow picking scene objects when the graph is not linked to a scene
if (!this.graph.IsLinkedToScene())
{
var objectField = view.Q<ObjectField>();
if (objectField != null)
objectField.allowSceneObjects = false;
}
return view;
}
19
Source : ExposedParameterFieldFactory.cs
with MIT License
from alelievr
with MIT License
from alelievr
public VisualElement GetParameterSettingsField(ExposedParameter parameter, Action<object> valueChangedCallback)
{
serializedObject.Update();
int propIndex = FindPropertyIndex(parameter);
var serializedParameter = serializedParameters.GetArrayElementAtIndex(propIndex);
serializedParameter.managedReferenceValue = exposedParameterObject.parameters[propIndex];
var serializedSettings = serializedParameter.FindPropertyRelative(nameof(ExposedParameter.settings));
serializedSettings.managedReferenceValue = exposedParameterObject.parameters[propIndex].settings;
var settingsField = new PropertyField(serializedSettings);
settingsField.Bind(serializedObject);
VisualElement view = new VisualElement();
view.Add(settingsField);
// TODO: see if we can replace this with an event
oldParameterSettings[parameter] = parameter.settings;
view.Add(new IMGUIContainer(() =>
{
if (oldParameterSettings.TryGetValue(parameter, out var settings))
{
if (!settings.Equals(parameter.settings))
valueChangedCallback(parameter.settings);
}
oldParameterSettings[parameter] = parameter.settings;
}));
return view;
}
19
Source : DelayedChanges.cs
with MIT License
from alelievr
with MIT License
from alelievr
public void Update()
{
int i = 0;
foreach (var valKP in values)
{
var cd = valKP.Value;
if (cd.callback != null && !cd.called && GetTime() - cd.lastUpdate > delayedTime / 1000)
{
cd.called = true;
cd.callback(cd.value);
}
i++;
}
}
19
Source : AggregateRoot.cs
with MIT License
from alesimoes
with MIT License
from alesimoes
public void Raise(DomainEvent domainEvent)
{
handlers[domainEvent.GetType()](domainEvent);
domainEvents.Add(domainEvent);
}
19
Source : AggregateRoot.cs
with MIT License
from alesimoes
with MIT License
from alesimoes
public void Apply(DomainEvent domainEvent)
{
handlers[domainEvent.GetType()](domainEvent);
}
19
Source : EventRouter.cs
with Apache License 2.0
from alexeyzimarev
with Apache License 2.0
from alexeyzimarev
public void Route(object @event)
{
if (@event == null) throw new ArgumentNullException(nameof(@event));
Action<object> handler;
if (_handlers.TryGetValue(@event.GetType(), out handler))
{
handler(@event);
}
}
19
Source : DropDownButton.xaml.cs
with MIT License
from alexleen
with MIT License
from alexleen
private void AddAppenderItemOnClick(object sender, MouseButtonEventArgs e)
{
object dataContext = ((FrameworkElement)sender).DataContext;
ItemClick?.Invoke(dataContext);
Command?.Execute(dataContext);
}
19
Source : Command.cs
with MIT License
from alexleen
with MIT License
from alexleen
public void Execute(object parameter)
{
if (mExecuteWithParam != null)
{
mExecuteWithParam(parameter);
}
else
{
mExecute?.Invoke();
}
}
19
Source : ParserResultExtensions.cs
with MIT License
from allisterb
with MIT License
from allisterb
public static ParserResult<object> WithParsed(this ParserResult<object> result, Type t, Action<object> action)
{
Parsed<object> parsed = result as Parsed<object>;
if (parsed != null)
{
if (parsed.Value.GetType() == t)
{
action(parsed.Value);
}
}
return result;
}
19
Source : Property.cs
with MIT License
from Alprog
with MIT License
from Alprog
public Value SetValue(Value value, bool fakeExecution)
{
if (!CommandLine.EnsureType(value, PropertyType))
{
var format = "replacedignment expects {0} got {1}";
var message = String.Format(format, PropertyType.Name, value.Type.Name);
throw new TokenException(message, Token);
}
if (!fakeExecution)
{
Setter(value.Get());
}
return value;
}
19
Source : ServerForm.cs
with MIT License
from AmazingDM
with MIT License
from AmazingDM
private void ControlButton_Click(object sender, EventArgs e)
{
Utils.Utils.Componenreplacederator(this, component => Utils.Utils.ChangeControlForeColor(component, Color.Black));
var flag = true;
foreach (var pair in _checkActions.Where(pair => !pair.Value.Invoke(pair.Key.Text)))
{
Utils.Utils.ChangeControlForeColor(pair.Key, Color.Red);
flag = false;
}
if (!flag)
{
return;
}
foreach (var pair in _saveActions)
{
switch (pair.Key)
{
case CheckBox c:
pair.Value.Invoke(c.Checked);
break;
default:
pair.Value.Invoke(pair.Key.Text);
break;
}
}
if (Global.Settings.Server.IndexOf(Server) == -1)
Global.Settings.Server.Add(Server);
MessageBoxX.Show(i18N.Translate("Saved"));
Close();
}
19
Source : Command.cs
with GNU General Public License v3.0
from AndreiFedarets
with GNU General Public License v3.0
from AndreiFedarets
public void Execute(object parameter)
{
_executeFunc(parameter);
}
19
Source : SwipeActionContextMenuView.cs
with MIT License
from AndreiMisiukevich
with MIT License
from AndreiMisiukevich
private void OnContextMenuOpened(BaseContextMenuView menuView)
{
Device.BeginInvokeOnMainThread(() =>
{
if (ContextMenu.IsAutoCloseEnabled)
{
ContextMenu.ForceClose();
}
Moved?.Invoke(BindingContext);
MovedCommand?.Execute(BindingContext);
});
}
19
Source : RelayParameterizedCommand.cs
with MIT License
from angelsix
with MIT License
from angelsix
public void Execute(object parameter)
{
mAction(parameter);
}
19
Source : Dispatcher.cs
with GNU Lesser General Public License v3.0
from angturil
with GNU Lesser General Public License v3.0
from angturil
public static void RunAsync(Action<object> action, object state)
{
ThreadPool.QueueUserWorkItem(o => action(o), state);
}
19
Source : TypeSwitch.cs
with Apache License 2.0
from AntoineCharton
with Apache License 2.0
from AntoineCharton
public static void Do(object source, params CaseInfo[] cases)
{
var type = source.GetType();
foreach (var entry in cases)
{
if (entry.IsDefault || entry.Target.IsreplacedignableFrom(type))
{
entry.Action(source);
break;
}
}
}
19
Source : Command.cs
with GNU General Public License v3.0
from AnyStatus
with GNU General Public License v3.0
from AnyStatus
public void Execute(object parameter) => _execute(parameter);
19
Source : TestAmqpPeer.cs
with Apache License 2.0
from apache
with Apache License 2.0
from apache
public void ExpectSenderAttach(Action<object> sourceMatcher,
Action<object> targetMatcher,
bool refuseLink = false,
uint creditAmount = 100,
bool senderSettled = false,
Error error = null)
{
var attachMatcher = new FrameMatcher<Attach>()
.Withreplacedertion(attach => replacedert.IsNotNull(attach.LinkName))
.Withreplacedertion(attach => replacedert.AreEqual(attach.Role, Role.SENDER))
.Withreplacedertion(attach => replacedert.AreEqual(senderSettled ? SenderSettleMode.Settled : SenderSettleMode.Unsettled, attach.SndSettleMode))
.Withreplacedertion(attach => replacedert.AreEqual(attach.RcvSettleMode, ReceiverSettleMode.First))
.Withreplacedertion(attach => sourceMatcher(attach.Source))
.Withreplacedertion(attach => targetMatcher(attach.Target))
.WithOnComplete(context =>
{
var attach = new Attach()
{
Role = Role.RECEIVER,
OfferedCapabilities = null,
SndSettleMode = senderSettled ? SenderSettleMode.Settled : SenderSettleMode.Unsettled,
RcvSettleMode = ReceiverSettleMode.First,
Handle = context.Command.Handle,
LinkName = context.Command.LinkName,
Source = context.Command.Source
};
if (refuseLink)
attach.Target = null;
else
attach.Target = context.Command.Target;
lastInitiatedLinkHandle = context.Command.Handle;
if (context.Command.Target is Coordinator)
{
lastInitiatedCoordinatorLinkHandle = context.Command.Handle;
}
context.SendCommand(attach);
if (refuseLink)
{
var detach = new Detach { Closed = true, Handle = context.Command.Handle };
if (error != null)
{
detach.Error = error;
}
context.SendCommand(detach);
}
else
{
var flow = new Flow
{
NextIncomingId = 1,
IncomingWindow = 2048,
NextOutgoingId = 1,
OutgoingWindow = 2024,
LinkCredit = creditAmount,
Handle = context.Command.Handle,
DeliveryCount = context.Command.InitialDeliveryCount,
};
context.SendCommand(flow);
}
});
AddMatcher(attachMatcher);
}
19
Source : CustomField.cs
with GNU Lesser General Public License v3.0
from ApexGameTools
with GNU Lesser General Public License v3.0
from ApexGameTools
public void RenderField(AIInspectorState state)
{
EditorGUILayout.BeginHorizontal();
EditorGUILayout.LabelField(_label);
if (GUILayout.Button(SharedStyles.changeSelectionTooltip, SharedStyles.BuiltIn.changeButtonSmall))
{
Action<Type> cb = (selectedType) =>
{
if (_itemType.IsGenericType && selectedType.IsGenericType)
{
var genArgs = _itemType.GetGenericArguments();
selectedType = selectedType.GetGenericTypeDefinition().MakeGenericType(genArgs);
}
var old = _item;
_item = Activator.CreateInstance(selectedType);
_editorItem = ReflectMaster.Reflect(_item);
_setter(_item);
state.currentAIUI.undoRedo.Do(new CustomEditorFieldOperation(old, _item, _setter));
state.MarkDirty();
};
//We do not want the button click itself to count as a change.. same as above.
GUI.changed = false;
var screenPos = EditorGUIUtility.GUIToScreenPoint(Event.current.mousePosition);
AIEnreplacedySelectorWindow.Get(screenPos, _itemType, cb);
}
EditorGUILayout.EndHorizontal();
bool doDelete = false;
if (_item != null)
{
EditorGUILayout.BeginVertical("Box");
EditorGUILayout.BeginHorizontal(SharedStyles.BuiltIn.lisreplacedemHeader);
EditorGUILayout.LabelField(_editorItem.name, SharedStyles.BuiltIn.normalText);
if (GUILayout.Button(SharedStyles.deleteTooltip, SharedStyles.BuiltIn.deleteButtonSmall))
{
GUI.changed = false;
if (DisplayHelper.ConfirmDelete("item"))
{
doDelete = true;
}
}
EditorGUILayout.EndHorizontal();
_editorItem.Render(state);
EditorGUILayout.EndVertical();
}
EditorGUILayout.Separator();
//We do the delete outside any layout stuff to ensure we don't get weird warnings.
if (doDelete)
{
state.currentAIUI.undoRedo.Do(new CustomEditorFieldOperation(_item, null, _setter));
_setter(null);
_item = null;
_editorItem = null;
state.MarkDirty();
}
}
19
Source : CustomEditorFieldOperation.cs
with GNU Lesser General Public License v3.0
from ApexGameTools
with GNU Lesser General Public License v3.0
from ApexGameTools
void IUndoRedo.Do()
{
_setter(_newValue);
}
19
Source : CustomEditorFieldOperation.cs
with GNU Lesser General Public License v3.0
from ApexGameTools
with GNU Lesser General Public License v3.0
from ApexGameTools
void IUndoRedo.Undo()
{
_setter(_originalValue);
}
19
Source : ARViewPagerPageClickListener.cs
with Apache License 2.0
from AppRopio
with Apache License 2.0
from AppRopio
public void OnClick(View v)
{
object context;
if (_datacontextReference.TryGetTarget(out context))
{
_onClick?.Invoke(context);
}
}
19
Source : ActionItem.cs
with MIT License
from AristotelisChantzaras
with MIT License
from AristotelisChantzaras
public static Task Schedule(Action<object> action, object state = null, bool attachToParent = false)
{
// UWP doesn't support ThreadPool[.QueueUserWorkItem] so just use Task.Factory.StartNew
return Task.Factory.StartNew(s => action(s), state, (attachToParent) ? TaskCreationOptions.AttachedToParent : TaskCreationOptions.DenyChildAttach);
}
19
Source : UnityMessageManager.cs
with MIT License
from asmadsen
with MIT License
from asmadsen
void onRNMessage(string message)
{
if (message.StartsWith(MessagePrefix))
{
message = message.Replace(MessagePrefix, "");
}
else
{
return;
}
MessageHandler handler = MessageHandler.Deserialize(message);
if ("end".Equals(handler.seq))
{
// handle callback message
UnityMessage m;
if (waitCallbackMessageMap.TryGetValue(handler.id, out m))
{
waitCallbackMessageMap.Remove(handler.id);
if (m.callBack != null)
{
m.callBack(handler.getData<object>()); // todo
}
}
return;
}
if (OnRNMessage != null)
{
OnRNMessage(handler);
}
}
19
Source : SendingHeadersEvent.cs
with Apache License 2.0
from aspnet
with Apache License 2.0
from aspnet
internal void Fire()
{
IList<Tuple<Action<object>, object>> callbacks = Interlocked.Exchange(ref _callbacks, null);
if (callbacks == null)
{
return;
}
int count = callbacks.Count;
for (int index = 0; index != count; ++index)
{
Tuple<Action<object>, object> tuple = callbacks[count - index - 1];
tuple.Item1(tuple.Item2);
}
}
19
Source : ExceptionFilterStream.cs
with Apache License 2.0
from aspnet
with Apache License 2.0
from aspnet
public void TryInvoke()
{
if (_pending == 1)
{
if (Interlocked.CompareExchange(ref _pending, 0, 1) == 1)
{
_callback(_state);
}
}
}
19
Source : OwinHttpListenerResponse.cs
with Apache License 2.0
from aspnet
with Apache License 2.0
from aspnet
private void NotifyOnSendingHeaders()
{
IList<Tuple<Action<object>, object>> actions = Interlocked.Exchange(ref _onSendingHeadersActions, null);
Contract.replacedert(actions != null);
// Execute last to first. This mimics a stack unwind.
for (int i = actions.Count - 1; i >= 0; i--)
{
Tuple<Action<object>, object> actionPair = actions[i];
actionPair.Item1(actionPair.Item2);
}
}
19
Source : InMemoryProvider.cs
with Apache License 2.0
from asynkron
with Apache License 2.0
from asynkron
public Task<long> GetEventsAsync(string actorName, long indexStart, long indexEnd, Action<object> callback)
{
if (Events.TryGetValue(actorName, out var events))
{
foreach (var e in events.Where(e => e.Key >= indexStart && e.Key <= indexEnd))
{
callback(e.Value);
}
}
return Task.FromResult(0L);
}
19
Source : NonBlockingBoundedMailbox.cs
with Apache License 2.0
from asynkron
with Apache License 2.0
from asynkron
public void Push(object message)
{
if (SpinWait.SpinUntil(() => _messages.Count < _maxSize, _timeout))
{
//this will be racy, but best effort is good enough..
_messages.Enqueue(message);
}
else
_overflowAction(message);
}
See More Examples