Here are the examples of the csharp api System.Action.Invoke(dynamic) taken from open source projects. By voting up you can indicate which examples are most useful and appropriate.
26 Examples
19
Source : Gazorator.cs
with MIT License
from bjorkstromm
with MIT License
from bjorkstromm
public virtual Task ProcessAsync(string filePath)
{
var razorGenerator = new CSharpScriptRazorGenerator(Path.GetDirectoryName(filePath));
var csharpScript = razorGenerator.Generate(filePath);
var viewBag = new DynamicViewBag(ViewBag);
ConfigureViewBag?.Invoke(viewBag);
var razorContentGenerator = new RazorContentGenerator(Output, References, viewBag);
return razorContentGenerator.Generate(csharpScript);
}
19
Source : Gazorator.cs
with MIT License
from bjorkstromm
with MIT License
from bjorkstromm
public override Task ProcessAsync(string filePath)
{
var razorGenerator = new CSharpScriptRazorGenerator(Path.GetDirectoryName(filePath));
var csharpScript = razorGenerator.Generate(filePath);
var viewBag = new DynamicViewBag(ViewBag);
ConfigureViewBag?.Invoke(viewBag);
var razorContentGenerator = new RazorContentGenerator<TModel>(_model, Output, References, viewBag);
return razorContentGenerator.Generate(csharpScript);
}
19
Source : ClayTests.cs
with MIT License
from bleroy
with MIT License
from bleroy
public dynamic New(string shapeName, Action<dynamic> initialize) {
var item = new Clay(new PropBehavior());
initialize(item);
return item;
}
19
Source : BasFunction.cs
with MIT License
from CheshireCaat
with MIT License
from CheshireCaat
private void RunFunction(
string functionName,
Params functionParams,
Action<dynamic> onResult,
Action<Exception> onError)
{
Id = Rand.NextInt(1, 1000000);
Client.Send("start_thread", new Params {{"thread_id", Id}});
Client.SendAsync<string>("run_task",
new Params
{
["params"] = functionParams.ToJson(),
["function_name"] = functionName,
["thread_id"] = Id
}, result =>
{
var response = result.FromJson<Response>();
if (!response.Success)
{
onError(new FunctionException(response.Message));
}
else
{
onResult(response.Result);
}
Client.Send("stop_thread", new Params {{"thread_id", Id}});
});
}
19
Source : BasThread.cs
with MIT License
from CheshireCaat
with MIT License
from CheshireCaat
private void RunFunction(
string functionName,
Params functionParams,
Action<dynamic> onResult,
Action<Exception> onError)
{
if (Id != 0 && IsRunning)
{
onError(new AlreadyRunningException());
}
if (Id == 0)
{
Id = Rand.NextInt(1, 1000000);
Client.Send("start_thread", new Params {{"thread_id", Id}});
}
Client.SendAsync<string>("run_task",
new Params
{
["params"] = functionParams.ToJson(),
["function_name"] = functionName,
["thread_id"] = Id
}, result =>
{
var response = result.FromJson<Response>();
IsRunning = false;
if (!response.Success)
{
onError(new FunctionException(response.Message));
}
else
{
onResult(response.Result);
}
});
IsRunning = true;
}
19
Source : pythonengine.cs
with MIT License
from CoFlows
with MIT License
from CoFlows
public static void With(PyObject obj, Action<dynamic> Body)
{
// Behavior described here:
// https://docs.python.org/2/reference/datamodel.html#with-statement-context-managers
IntPtr type = Runtime.PyNone;
IntPtr val = Runtime.PyNone;
IntPtr traceBack = Runtime.PyNone;
PythonException ex = null;
try
{
PyObject enterResult = obj.InvokeMethod("__enter__");
Body(enterResult);
}
catch (PythonException e)
{
ex = e;
type = ex.PyType;
val = ex.PyValue;
traceBack = ex.PyTB;
}
var exitResult = obj.InvokeMethod("__exit__", new PyObject(type), new PyObject(val), new PyObject(traceBack));
if (ex != null && !exitResult.IsTrue()) throw ex;
}
19
Source : SafeIDispatch.cs
with MIT License
from dahall
with MIT License
from dahall
public void Invoke(Action<dynamic> action) => action.Invoke(Item);
19
Source : SettingsFile.cs
with MIT License
from darkalfx
with MIT License
from darkalfx
public static void Write(Action<dynamic> modifyFunc)
{
lock (_lock)
{
modifyFunc(_cachedSettings);
File.WriteAllText(FilePath, JsonConvert.SerializeObject(_cachedSettings));
}
}
19
Source : DataExtensions.cs
with MIT License
from dcomartin
with MIT License
from dcomartin
public static void Attributes(this Data data, Action<dynamic> attributes) {
var value = new Attributes();
attributes(value as dynamic);
data.Attributes = value;
}
19
Source : GenerateSerializerGenerationTests.cs
with MIT License
from kevin-montrose
with MIT License
from kevin-montrose
private static ImmutableArray<dynamic> Create(System.Reflection.TypeInfo rowType, params Action<dynamic>[] callbacks)
{
var builder = ImmutableArray.CreateBuilder<dynamic>();
foreach (var callback in callbacks)
{
var row = Activator.CreateInstance(rowType);
callback(row);
builder.Add(row);
}
return builder.ToImmutable();
}
19
Source : CustomClasses.cs
with GNU General Public License v3.0
from KillzXGaming
with GNU General Public License v3.0
from KillzXGaming
public void Undo()
{
_act.Invoke(_arg);
}
19
Source : LambdaController.cs
with Apache License 2.0
from luyikk
with Apache License 2.0
from luyikk
public Task Ask(Action<dynamic> action, dynamic arg)
{
action?.Invoke(arg);
return Task.CompletedTask;
}
19
Source : LambdaController.cs
with Apache License 2.0
from luyikk
with Apache License 2.0
from luyikk
public void Tell(Action<dynamic> action, dynamic arg)
{
action?.Invoke(arg);
}
19
Source : DelegateCommand.cs
with MIT License
from maikebing
with MIT License
from maikebing
private void Execute(object parameter)
{
_executeMethod(parameter);
}
19
Source : ScriptContext.cs
with MIT License
from microsoft
with MIT License
from microsoft
public dynamic CreateObject (Action<dynamic> populator = null)
{
var wrapped = new WrappedObject (JSValue.CreateObject (underlyingContext));
populator?.Invoke (wrapped);
return wrapped;
}
19
Source : ScriptContext.cs
with MIT License
from microsoft
with MIT License
from microsoft
public dynamic CreateObject (Action<dynamic> populator = null)
{
var o = Bridge.CreateObject ();
populator?.Invoke (o);
return o;
}
19
Source : ConstructorCallReplacementTests.cs
with MIT License
from philiplaureano
with MIT License
from philiplaureano
private void RunTest(Action<MethodCallRegistryBuilder, ManualResetEvent> configureBuilder,
Action<dynamic> act, int numberOfExpectedArgs)
{
var wasReplacementCalled = new ManualResetEvent(false);
// Intercept the target constructor
var builder = new MethodCallRegistryBuilder();
configureBuilder(builder, wasReplacementCalled);
var modifiedInstance =
typeof(SampleClreplacedWithMultipleConstructorCalls).AddInterceptionHooksAndCreateInstance();
replacedert.True(modifiedInstance is IModifiedType);
if (modifiedInstance is IModifiedType modifiedType)
{
modifiedType.IsInterceptionEnabled = true;
modifiedType.MethodCallProvider = builder.Build();
}
dynamic targetInstance = modifiedInstance;
act(targetInstance);
replacedert.True(wasReplacementCalled.WaitOne(TimeSpan.FromMilliseconds(200)));
int actualNumberOfArgs = targetInstance.NumberOfConstructorArgsUsed;
replacedert.Equal(numberOfExpectedArgs, actualNumberOfArgs);
}
19
Source : MethodCallInterceptionTests.cs
with MIT License
from philiplaureano
with MIT License
from philiplaureano
private void TestMethodCallInterception<TTargetType>(Action<dynamic> executeModifiedTypeInstance)
{
// Inject the hooks into the replacedembly
var targetreplacedembly = typeof(TTargetType).replacedembly.Location;
replacedert.True(File.Exists(targetreplacedembly));
var bytes = File.ReadAllBytes(Path.GetFullPath(targetreplacedembly));
var modifiedreplacedembly = bytes.ToModifiedreplacedemblyWithInterceptionHooksInstalled();
// Pull the modified type out of the replacedembly and instantiate it
var targetType = modifiedreplacedembly.GetType(t => t.Name == typeof(TTargetType).Name)
.ValueOrFailure();
// Keep track of whether or not the interceptor was called instead of the original method
var wasInterceptorCalled = new ManualResetEvent(false);
object MethodCallReplacement(IInvocationInfo info)
{
wasInterceptorCalled.Set();
return null;
}
Func<IInvocationInfo, object> implementation = MethodCallReplacement;
var methodCall = implementation.ToMethodCall();
var targetInstance = Activator.CreateInstance(targetType);
replacedert.True(targetInstance is IModifiedType);
var provider = A.Fake<IMethodCallProvider>();
A.CallTo(() => provider.GetReplacement(A<object>.Ignored, A<MethodBase>.Ignored, A<MethodBase>.Ignored))
.Returns(methodCall);
var modifiedInstance = (IModifiedType)targetInstance;
modifiedInstance.MethodCallProvider = provider;
// Enable interception
dynamic target = targetInstance;
target.IsInterceptionEnabled = true;
executeModifiedTypeInstance(target);
replacedert.True(wasInterceptorCalled.WaitOne(2000));
}
19
Source : MethodCallReplacementTests.cs
with MIT License
from philiplaureano
with MIT License
from philiplaureano
private static void TestMethodCallReplacement(Type originalType, Action<dynamic> executeModifiedType,
Action verifyResults,
IMethodCall methodCall)
{
var provider = A.Fake<IMethodCallProvider>();
A.CallTo(() => provider.GetReplacement(A<object>.Ignored, A<MethodBase>.Ignored,
A<MethodBase>.Ignored))
.Returns(methodCall);
var targetreplacedembly = originalType.replacedembly.Location;
replacedert.True(File.Exists(targetreplacedembly));
var bytes = File.ReadAllBytes(Path.GetFullPath(targetreplacedembly));
var modifiedreplacedembly = bytes.ToModifiedreplacedemblyWithInterceptionHooksInstalled();
var targetType = modifiedreplacedembly.GetType(t => t.Name == originalType.Name)
.ValueOrFailure();
var targetInstance = Activator.CreateInstance(targetType);
replacedert.True(targetInstance is IModifiedType);
var modifiedInstance = (IModifiedType)targetInstance;
modifiedInstance.MethodCallProvider = provider;
// Enable interception
dynamic target = targetInstance;
target.IsInterceptionEnabled = true;
executeModifiedType(target);
verifyResults();
}
19
Source : DialogService.cs
with MIT License
from radzenhq
with MIT License
from radzenhq
public void Close(dynamic result = null)
{
var dialog = dialogs.LastOrDefault();
if (dialog != null)
{
OnClose?.Invoke(result);
dialogs.Remove(dialog);
}
var task = tasks.LastOrDefault();
if (task != null && task.Task != null && !task.Task.IsCompleted)
{
tasks.Remove(task);
task.SetResult(result);
}
}
19
Source : StoreFacade.cs
with Apache License 2.0
from sapiens
with Apache License 2.0
from sapiens
public void GenerateReadModel(string operationName, Action<dynamic> modelUpdater, Action<IConfigReadModelGeneration> config = null)
{
operationName.MustNotBeEmpty();
var conf=new ReadModelGenerationConfig(operationName);
config?.Invoke(conf);
void HandleCommit(Commit commit,Action<dynamic> updater)
{
var evs = Utils.UnpackEvents(commit.Timestamp, commit.EventData, _settings.EventMappers);
foreach (var ev in evs)
{
EventStore.Logger.Debug("Updating readmodel from {@event}",ev);
updater((dynamic) ev);
}
}
using (var operation = new BatchOperation(_store,conf))
{
Optional<Commit> commit;
do
{
commit = operation.GetNextCommit();
if (commit.HasValue)
{
HandleCommit(commit.Value, modelUpdater);
}
} while (commit.HasValue);
}
}
19
Source : TestVisualScriptCompiler.cs
with MIT License
from stride3d
with MIT License
from stride3d
private static void TestAndCompareOutput(VisualScriptreplacedet visualScriptreplacedet, string expectedOutput, Action<dynamic> testCode)
{
// Compile
var compilerResult = VisualScriptCompiler.Generate(visualScriptreplacedet, new VisualScriptCompilerOptions
{
Clreplaced = "TestClreplaced",
});
using (var textWriter = new StringWriter())
{
Console.SetOut(textWriter);
// Create clreplaced
var testInstance = CreateInstance(new[] { compilerResult.SyntaxTree });
// Execute method
testCode(testInstance);
// Check output
textWriter.Flush();
replacedert.Equal(expectedOutput, textWriter.ToString());
// Restore Console.Out
var standardOutput = new StreamWriter(Console.OpenStandardOutput());
standardOutput.AutoFlush = true;
Console.SetOut(standardOutput);
}
}
19
Source : Tests.cs
with MIT License
from tom-englert
with MIT License
from tom-englert
private void Test(string clreplacedName, int throttleTreshold, Action<dynamic> method, Func<dynamic, int> numberOfCalls)
{
var target = _replacedembly.GetInstance("replacedemblyToProcess." + clreplacedName);
for (var outer = 0; outer < 3; outer++)
{
for (var i = 0; i < throttleTreshold; i++)
{
replacedert.Equal(outer, numberOfCalls(target));
method(target);
}
replacedert.Equal(outer + 1, numberOfCalls(target));
}
}
19
Source : RegistrationManager.cs
with MIT License
from traceless0929
with MIT License
from traceless0929
public void InvokeCallBack(int? ackId, string value)
{
Action<dynamic> target = null;
if (ackId.HasValue)
{
if (this.callBackRegistry.TryRemove(ackId.Value, out target)) // use TryRemove - callbacks are one-shot event registrations
{
Task.Run(() => target.Invoke(value));
}
}
}
19
Source : RegistrationManager.cs
with MIT License
from traceless0929
with MIT License
from traceless0929
public void InvokeCallBack(int? ackId, JsonEncodedEventMessage value)
{
Action<dynamic> target = null;
if (ackId.HasValue)
{
if (this.callBackRegistry.TryRemove(ackId.Value, out target))
{
Task.Run(() => target.Invoke(value));
//target.BeginInvoke(value, target.EndInvoke, null);
}
}
}
19
Source : JsonLogicTests.cs
with MIT License
from yavuztor
with MIT License
from yavuztor
public static object Dynamic(Action<dynamic> ctor)
{
var value = new System.Dynamic.ExpandoObject();
ctor(value);
return value;
}