public override void ViewDidLoad () { base.ViewDidLoad (); // Perform any additional setup after loading the view, typically from a nib. //MessageHandler MyTextView.Text=MyTextView.Text + "\n"+"Call Handler to get SystemVersion"; string sv=main.GetSystemVersion(); main.Primarylogger.Info ("SystemVersion is:" + sv); MyTextView.Text=MyTextView.Text + "\n"+"SystemVersion is:" + sv+"\n"; //Listener FunctionContext fctx=new FunctionContext("RLOG"); fctx.setStringParam (0,"Hello"); main.mmc.DispatchToListeners (fctx); fctx = new FunctionContext ("ADD"); main.mmc.DispatchToListeners (fctx); MyTextView.Text = MyTextView.Text + "\n" + "Dispatch messagge to increase the counter..."; //Calling EnterpriseFunction int p=main.mmc.CallFunction<int>(PrintCounter.NAME); MyTextView.Text=MyTextView.Text+"\n"+"Total Counter is "+p+"\n"; //Sample Singleton by PCL MyTextView.Text=MyTextView.Text+"\n"+"Singleton SampleResult invoked from PCL:"+main.iss.SampleResult(); ISampleSingleton issios = CallerCoreMobile.RegisterAsSingleton<ISampleSingleton>("CallerCoreSample.iOS.SampleSingleton", "1", "2"); MyTextView.Text=MyTextView.Text+"\n"+"Singleton SampleResult invoked from IOS:"+issios.SampleResult()+"\n\n"; //Calling EnterpriseFunction Async CheckConnButton.TouchUpInside+= async (sender, e) => { await Test(); }; }
public override int Compile(FunctionContext context) { context.Line(FileName, Line); if (context.Name != null) { var callExpression = Value as CallExpression; if (callExpression != null) { var identifierExpression = callExpression.Method as IdentifierExpression; if (identifierExpression != null && context.Identifier(identifierExpression.Name) == context.Name) { callExpression.CompileTailCall(context); return 0; } } } if (Value != null) CompileCheck(context, Value, 1); else context.LoadUndefined(); context.Return(); return 0; }
public override void ViewDidLoad () { base.ViewDidLoad (); // Perform any additional setup after loading the view, typically from a nib. //MessageHandler MyTextView.Text=$"{MyTextView.Text}{System.Environment.NewLine}Call Handler to obtain SystemVersion"; string sv=main.GetSystemVersion(); main.Primarylogger.Info ($"SystemVersion is:{sv}"); MyTextView.Text=$"{MyTextView.Text}{System.Environment.NewLine}SystemVersion is:{sv}{System.Environment.NewLine}"; //Listener FunctionContext fctx = new FunctionContext().AddType(MyListenerTypes.RLOG); fctx.setStringParam (0,"Hello"); main.mmc.DispatchToListeners (fctx); fctx = new FunctionContext().AddType(MyListenerTypes.ADD); main.mmc.DispatchToListeners (fctx); MyTextView.Text =$"{MyTextView.Text}{System.Environment.NewLine}Dispatch messagge to increase the counter..."; //Calling EnterpriseFunction int p=main.mmc.CallFunction<int>(PrintCounter.NAME); MyTextView.Text=$"{MyTextView.Text}{System.Environment.NewLine}Total Counter is {p}{System.Environment.NewLine}"; //Sample Singleton by PCL MyTextView.Text=$"{MyTextView.Text}{System.Environment.NewLine}Singleton SampleResult invoked from PCL:{main.iss.SampleResult()}"; ISampleSingleton issios = CallerCoreMobile.RegisterAsSingleton<ISampleSingleton>("CallerCoreSample.iOS.SampleSingleton", "1", "2"); MyTextView.Text=$"{MyTextView.Text}{System.Environment.NewLine}Singleton SampleResult invoked from Droid:{issios.SampleResult()}{System.Environment.NewLine}{System.Environment.NewLine}"; //Calling EnterpriseFunction Async CheckConnButton.TouchUpInside+= async (sender, e) => { await Test(); }; }
public override int Compile(FunctionContext context) { context.Line(FileName, Line); context.LoadNull(); return 1; }
public override int Compile(FunctionContext context) { context.Line(FileName, Line); var start = context.MakeLabel("forStart"); var increment = context.MakeLabel("forContinue"); var end = context.MakeLabel("forEnd"); if (Initializer != null) CompileCheck(context, Initializer, 0); context.Bind(start); if (Condition != null) CompileCheck(context, Condition, 1); context.JumpFalse(end); context.PushLoop(increment, end); CompileCheck(context, Block, 0); context.PopLoop(); context.Bind(increment); if (Increment != null) CompileCheck(context, Increment, 0); context.Jump(start); context.Bind(end); return 0; }
public static void CompileCheck(FunctionContext context, Expression expression, int requiredStack) { var stack = expression.Compile(context); if (stack != requiredStack) throw new MondCompilerException(expression.FileName, expression.Line, "Bad stack state"); }
public override object execute(IInfoContext info, FunctionContext context) { MainCorePcl mainAdapter = (MainCorePcl)info; log("This counter is "+mainAdapter.Counter()); return mainAdapter.Counter(); }
public override int Compile(FunctionContext context) { context.PushScope(); var stack = base.Compile(context); context.PopScope(); return stack; }
public override int Compile(FunctionContext context) { context.Line(FileName, Line); CompileCheck(context, Left, 1); context.LoadField(context.String(Name)); return 1; }
public override int Compile(FunctionContext context) { context.Line(FileName, Line); CompileCheck(context, Left, 1); CompileCheck(context, Index, 1); context.LoadArray(); return 1; }
public override int Compile(FunctionContext context) { context.Line(FileName, Line); var isStatement = Parent is IBlockStatementExpression; if (Name == null && isStatement) throw new MondCompilerException(FileName, Line, "Function is never used"); IdentifierOperand identifier = null; if (Name != null) { if (!context.DefineIdentifier(Name, true)) throw new MondCompilerException(FileName, Line, "Identifier '{0}' was previously defined in this scope", Name); identifier = context.Identifier(Name); } var functionContext = context.MakeFunction(Name); functionContext.Function(FileName, Name); context.PushFrame(); for (var i = 0; i < Arguments.Count; i++) { var name = Arguments[i]; if (!functionContext.DefineArgument(i, name)) throw new MondCompilerException(FileName, Line, "Identifier '{0}' was previously defined in this scope", name); } functionContext.Bind(functionContext.Label); functionContext.Enter(); Block.Compile(functionContext); functionContext.LoadUndefined(); functionContext.Return(); context.PopFrame(); context.Closure(functionContext.Label); if (identifier != null) { if (!isStatement) // statements should leave nothing on the stack context.Dup(); context.Store(identifier); if (isStatement) return 0; } return 1; }
public void CompileTailCall(FunctionContext context) { context.Line(FileName, Line); foreach (var argument in Arguments) { CompileCheck(context, argument, 1); } context.TailCall(Arguments.Count, context.Label); }
public override int Compile(FunctionContext context) { context.Line(FileName, Line); var target = context.BreakLabel(); if (target == null) throw new MondCompilerException(FileName, Line, "Unresolved jump"); context.Jump(target); return 0; }
public override int Compile(FunctionContext context) { context.Line(FileName, Line); if (Value) context.LoadTrue(); else context.LoadFalse(); return 1; }
public override int Compile(FunctionContext context) { context.Line(FileName, Line); foreach (var value in Values) { CompileCheck(context, value, 1); } context.NewArray(Values.Count); return 1; }
public override int Compile(FunctionContext context) { context.Line(FileName, Line); var isAssignment = false; var stack = 0; switch (Operation) { case TokenType.Increment: context.Load(context.Number(1)); CompileCheck(context, Right, 1); context.BinaryOperation(TokenType.Add); isAssignment = true; break; case TokenType.Decrement: context.Load(context.Number(1)); CompileCheck(context, Right, 1); context.BinaryOperation(TokenType.Subtract); isAssignment = true; break; case TokenType.Subtract: case TokenType.LogicalNot: CompileCheck(context, Right, 1); context.UnaryOperation(Operation); stack++; break; default: throw new NotSupportedException(); } if (isAssignment) { var storable = Right as IStorableExpression; if (storable == null) throw new MondCompilerException(FileName, Line, "The left-hand side of an assignment must be storable"); // TODO: better message var needResult = !(Parent is BlockExpression); if (needResult) { context.Dup(); stack++; } storable.CompileStore(context); } return stack; }
public override object addContextToQueue(FunctionContext fctx) { log (LogLevel.Debug,"[Command] " + fctx.type); if (fctx.type.CompareTo ("RLOG") == 0) { if (fctx.getParam (0) != null) { log("Received: "+ (string)fctx.getParam (0)); } } if (fctx.type.CompareTo ("ADD") == 0) { mainAdapter.Add (); } return null; }
public WorkerTask(CallerCoreMobile main, IInfoContext info, string functionName, FunctionContext context) { this.main = main; this.info = info; this.functionName = functionName; this.Logger = main.getLogger(); if (context != null) this.context = new FunctionContext(context); else this.context = null; asyncWorkerID++; // asyncWorkerID = worker.asyncWorkers++; }
public virtual async Task<object> addContextToGenericAsyncQueue(FunctionContext fctx){ await Task.Yield (); log(LogLevel.Debug,"Executing method addContextToAsyncQueue by Regular implementation"); var result=addContextToQueue(fctx); if (result!=null) return result; else return default(object); /* return await Task.Run<object>(() => { var result=addContextToQueue(fctx); if (result!=null) return result; else return default(object); });*/ }
public override int Compile(FunctionContext context) { context.Line(FileName, Line); foreach (var argument in Arguments) { CompileCheck(context, argument, 1); } CompileCheck(context, Method, 1); context.Call(Arguments.Count); return 1; }
public virtual object addContextToQueue(FunctionContext fctx){ log(LogLevel.Debug,"Executing method addContextToQueue by Async implementation"); var task= Task.Run<object>(() => addContextToGenericAsyncQueue(fctx)); try { return task.Result; } catch (AggregateException ae) { ae.Handle((x) => { throw x; }); return null; } }
protected override void OnCreate(Bundle savedInstanceState) { base.OnCreate (savedInstanceState); // Set our view from the "main" layout resource SetContentView (Resource.Layout.Main); TextView MyTextView = FindViewById<TextView>(Resource.Id.textView); MyTextView.MovementMethod = new Android.Text.Method.ScrollingMovementMethod(); MyTextView.Text = "Working.."; main = new MainCoreDroid (); main.Init (); //MessageHandler MyTextView.Text=$"{MyTextView.Text}{System.Environment.NewLine}Call Handler to obtain SystemVersion"; string sv=main.GetSystemVersion(); main.Primarylogger.Info ($"SystemVersion is:{sv}"); MyTextView.Text=$"{MyTextView.Text}{System.Environment.NewLine}SystemVersion is:{sv}{System.Environment.NewLine}"; //Listener FunctionContext fctx=new FunctionContext().AddType(MyListenerTypes.RLOG); fctx.setStringParam (0,"Hello"); main.mmc.DispatchToListeners (fctx); fctx = new FunctionContext ().AddType(MyListenerTypes.ADD); main.mmc.DispatchToListeners (fctx); MyTextView.Text =$"{MyTextView.Text}{System.Environment.NewLine}Dispatch messagge to increase the counter..."; //Calling EnterpriseFunction int p=main.mmc.CallFunction<int>(PrintCounter.NAME); MyTextView.Text=$"{MyTextView.Text}{System.Environment.NewLine}Total Counter is {p}{System.Environment.NewLine}"; //Sample Singleton by PCL MyTextView.Text=$"{MyTextView.Text}{System.Environment.NewLine}Singleton SampleResult invoked from PCL:{main.iss.SampleResult()}"; ISampleSingleton issios = CallerCoreMobile.RegisterAsSingleton<ISampleSingleton>("CallerCoreSample.Droid.SampleSingleton", "1", "2"); MyTextView.Text=$"{MyTextView.Text}{System.Environment.NewLine}Singleton SampleResult invoked from Droid:{issios.SampleResult()}{System.Environment.NewLine}{System.Environment.NewLine}"; // Get our button from the layout resource, // and attach an event to it Button button = FindViewById<Button> (Resource.Id.myButton); button.Click += async delegate { this.RunOnUiThread(() => {MyTextView.Text=$"{MyTextView.Text}Calling EnterpriseFunction...";}); bool con=await main.mmc.CallFunctionAsync<bool> (Connectivity.NAME); main.Primarylogger.Info ("Connectitivity is:" + con); this.RunOnUiThread(() => {MyTextView.Text=$"{MyTextView.Text}{System.Environment.NewLine}Connectitivity invoked from Droid is {con}";}); bool conpcl=await main.TestConnectivityPCL(); main.Primarylogger.Info ("Connectitivity is:" + conpcl); this.RunOnUiThread(() => {MyTextView.Text=$"{MyTextView.Text}{System.Environment.NewLine}Connectitivity invoked from PCL is {conpcl}{System.Environment.NewLine}";}); }; }
public override int Compile(FunctionContext context) { foreach (var statement in Statements) { var stack = statement.Compile(context); while (stack > 0) { context.Drop(); stack--; } } return 0; }
public override int Compile(FunctionContext context) { context.Line(FileName, Line); context.NewObject(); foreach (var value in Values) { context.Dup(); CompileCheck(context, value.Value, 1); context.Swap(); context.StoreField(context.String(value.Key)); } return 1; }
public override int Compile(FunctionContext context) { context.Line(FileName, Line); var falseLabel = context.MakeLabel("ternaryFalse"); var endLabel = context.MakeLabel("ternaryEnd"); CompileCheck(context, Condition, 1); context.JumpFalse(falseLabel); CompileCheck(context, IfTrue, 1); context.Jump(endLabel); context.Bind(falseLabel); CompileCheck(context, IfFalse, 1); context.Bind(endLabel); return 1; }
public override int Compile(FunctionContext context) { context.Line(FileName, Line); var start = context.MakeLabel("doWhileStart"); var end = context.MakeLabel("doWhileEnd"); context.Bind(start); context.PushLoop(start, end); CompileCheck(context, Block, 0); context.PopLoop(); CompileCheck(context, Condition, 1); context.JumpTrue(start); context.Bind(end); return 0; }
public void CompileStore(FunctionContext context) { var identifier = context.Identifier(Name); /*if (identifier == null) throw new MondCompilerException(FileName, Line, "Undefined identifier '{0}'", Name);*/ if (identifier == null) { context.LoadGlobal(); context.StoreField(context.String(Name)); } else { if (identifier.IsReadOnly) throw new MondCompilerException(FileName, Line, "Can not modify '{0}' because it is readonly", Name); context.Store(identifier); } }
public override int Compile(FunctionContext context) { context.Line(FileName, Line); var identifier = context.Identifier(Name); /*if (identifier == null) throw new MondCompilerException(FileName, Line, "Undefined identifier '{0}'", Name);*/ if (identifier == null) { context.LoadGlobal(); context.LoadField(context.String(Name)); } else { context.Load(identifier); } return 1; }
public override int Compile(FunctionContext context) { context.Line(FileName, Line); var branchLabels = new List<LabelOperand>(Branches.Count); for (var i = 0; i < Branches.Count; i++) { branchLabels.Add(context.MakeLabel("ifBranch_" + i)); } var branchElse = context.MakeLabel("ifElse"); var branchEnd = context.MakeLabel("ifEnd"); for (var i = 0; i < Branches.Count; i++) { var branch = Branches[i]; CompileCheck(context, branch.Condition, 1); context.JumpTrue(branchLabels[i]); } context.Jump(branchElse); for (var i = 0; i < Branches.Count; i++) { var branch = Branches[i]; context.Bind(branchLabels[i]); CompileCheck(context, branch.Block, 0); context.Jump(branchEnd); } context.Bind(branchElse); if (Else != null) CompileCheck(context, Else.Block, 0); context.Bind(branchEnd); return 0; }
public override int Compile(FunctionContext context) { context.Line(FileName, Line); foreach (var declaration in Declarations) { var name = declaration.Name; if (!context.DefineIdentifier(name)) throw new MondCompilerException(FileName, Line, "Identifier '{0}' was previously defined in this scope", name); if (declaration.Initializer != null) { var identifier = context.Identifier(name); CompileCheck(context, declaration.Initializer, 1); context.Store(identifier); } } return 0; }
public static void EnumerableGenericInputFunction <T>([EventHubTrigger("test", Connection = "EventHubConnectionAppSetting")] IEnumerable <T> input, FunctionContext context) { throw new NotImplementedException(); }
/// <inheritdoc/> public async Task <HttpResponseData> RenderOpenApiDocument(HttpRequestData req, string version, string extension, FunctionContext ctx) { var log = ctx.GetLogger(nameof(OpenApiTriggerFunction)); log.LogInformation($"{version}.{extension} was requested."); var fi = new FileInfo(ctx.FunctionDefinition.PathToAssembly); var request = new HttpRequestObject(req); var result = default(string); var response = default(HttpResponseData); try { var auth = await this._context .SetApplicationAssemblyAsync(fi.Directory.FullName, appendBin : false) .AuthorizeAsync(request) .ConfigureAwait(false); if (!auth.IsNullOrDefault()) { response = req.CreateResponse(auth.StatusCode); response.Headers.Add("Content-Type", auth.ContentType); await response.WriteStringAsync(auth.Payload).ConfigureAwait(false); return(response); } result = await this._context .Document .InitialiseDocument() .AddMetadata(this._context.OpenApiConfigurationOptions.Info) .AddServer(request, this._context.HttpSettings.RoutePrefix, this._context.OpenApiConfigurationOptions) .AddNamingStrategy(this._context.NamingStrategy) .AddVisitors(this._context.GetVisitorCollection()) .Build(this._context.ApplicationAssembly, this._context.GetOpenApiVersionType(version)) .ApplyDocumentFilters(this._context.GetDocumentFilterCollection()) .RenderAsync(this._context.GetOpenApiSpecVersion(version), this._context.GetOpenApiFormat(extension)) .ConfigureAwait(false); response = req.CreateResponse(HttpStatusCode.OK); response.Headers.Add("Content-Type", this._context.GetOpenApiFormat(extension).GetContentType()); await response.WriteStringAsync(result).ConfigureAwait(false); } catch (Exception ex) { log.LogError(ex.Message); result = ex.Message; if (this._context.IsDevelopment) { result += "\r\n\r\n"; result += ex.StackTrace; } response = req.CreateResponse(HttpStatusCode.InternalServerError); response.Headers.Add("Content-Type", ContentTypeText); await response.WriteStringAsync(result).ConfigureAwait(false); } return(response); }
public static void HashSetInputFunction([EventHubTrigger("test", Connection = "EventHubConnectionAppSetting")] HashSet <string> input, FunctionContext context) { throw new NotImplementedException(); }
/// <summary> /// Check whether commands implemented by the current driver have a corresponding extension declaring the /// support of them. /// </summary> /// <typeparam name="T"> /// The type of the KhronosApi to inspect for commands. /// </typeparam> /// <param name="version"> /// The <see cref="KhronosVersion"/> currently implemented by the current context on this thread. /// </param> /// <param name="extensions"> /// The <see cref="ExtensionsCollection"/> that specifies the extensions supported by the driver. /// </param> protected static void CheckExtensionCommands <T>(KhronosVersion version, ExtensionsCollection extensions, bool enableExtensions) where T : KhronosApi { if (version == null) { throw new ArgumentNullException(nameof(version)); } if (extensions == null) { throw new ArgumentNullException(nameof(extensions)); } #if NETSTANDARD1_1 || NETSTANDARD1_4 || NETCORE throw new NotImplementedException(); #else FunctionContext functionContext = GetFunctionContext(typeof(T)); Debug.Assert(functionContext != null); LogComment($"Checking commands for {version}"); Dictionary <string, List <Type> > hiddenVersions = new Dictionary <string, List <Type> >(); Dictionary <string, bool> hiddenExtensions = new Dictionary <string, bool>(); foreach (FieldInfo fi in functionContext.Delegates) { Delegate fiDelegateType = (Delegate)fi.GetValue(null); bool commandDefined = fiDelegateType != null; bool supportedByFeature = false; #if DEBUG_VERBOSE string commandName = fi.Name.Substring(3); #endif // Get the delegate type Type delegateType = fi.DeclaringType?.GetNestedType(fi.Name.Substring(1), BindingFlags.Public | BindingFlags.NonPublic); if (delegateType == null) { continue; // Support fields names not in sync with delegate types } // TODO Why not use 'fi' directly for getting attributes? They should be in sync IEnumerable <object> requiredByFeatureAttributes = delegateType.GetCustomAttributes(typeof(RequiredByFeatureAttribute), false); foreach (RequiredByFeatureAttribute requiredByFeatureAttribute in requiredByFeatureAttributes) { supportedByFeature |= requiredByFeatureAttribute.IsSupported(version, extensions); } // Find the underlying extension RequiredByFeatureAttribute hiddenVersionAttrib = null; RequiredByFeatureAttribute hiddenExtensionAttrib = null; foreach (RequiredByFeatureAttribute requiredByFeatureAttribute in requiredByFeatureAttributes) { if (!requiredByFeatureAttribute.IsSupportedApi(version.Api)) { // Version attribute if (hiddenVersionAttrib == null) { hiddenVersionAttrib = requiredByFeatureAttribute; } } else { // Extension attribute if (hiddenExtensionAttrib == null) { hiddenExtensionAttrib = requiredByFeatureAttribute; } } } if (commandDefined != supportedByFeature) { #if DEBUG_VERBOSE string supportString = "any feature"; if (hiddenVersionAttrib != null) { supportString = hiddenVersionAttrib.FeatureName; if (hiddenExtensionAttrib != null) { supportString += " or "; } } if (hiddenExtensionAttrib != null) { if (hiddenVersionAttrib == null) { supportString = string.Empty; } supportString += hiddenExtensionAttrib.FeatureName; } #endif if (commandDefined) { #if DEBUG_VERBOSE LogComment("The command {0} is defined, but {1} support is not advertised.", commandName, supportString); #endif if (hiddenVersionAttrib != null && hiddenExtensionAttrib == null) { List <Type> versionDelegates; if (!hiddenVersions.TryGetValue(hiddenVersionAttrib.FeatureName, out versionDelegates)) { hiddenVersions.Add(hiddenVersionAttrib.FeatureName, versionDelegates = new List <Type>()); } versionDelegates.Add(delegateType); } if (hiddenExtensionAttrib != null) { // Eventually leave to false for incomplete extensions if (!hiddenExtensions.ContainsKey(hiddenExtensionAttrib.FeatureName)) { hiddenExtensions.Add(hiddenExtensionAttrib.FeatureName, true); } } } else { #if DEBUG_VERBOSE LogComment("The command {0} is not defined, but required by some feature.", commandName); #endif } } // Partial extensions are not supported if (hiddenExtensionAttrib != null && !commandDefined && hiddenExtensions.ContainsKey(hiddenExtensionAttrib.FeatureName)) { hiddenExtensions[hiddenExtensionAttrib.FeatureName] = false; } } if (hiddenExtensions.Count > 0) { LogComment($"Found {hiddenExtensions.Count} experimental extensions:"); foreach (KeyValuePair <string, bool> hiddenExtension in hiddenExtensions) { LogComment(string.Format($"- {0}: {1}", hiddenExtension.Key, hiddenExtension.Value ? "experimental" : "experimental (partial, unsupported)")); } } if (hiddenVersions.Count > 0) { LogComment($"Found {hiddenVersions.Count} experimental version commands:"); foreach (KeyValuePair <string, List <Type> > hiddenVersion in hiddenVersions) { LogComment($"- {hiddenVersion.Key}"); foreach (Type delegateType in hiddenVersion.Value) { LogComment($" > {delegateType.Name}"); } } } if (enableExtensions) { bool sync = false; foreach (KeyValuePair <string, bool> hiddenExtension in hiddenExtensions) { if (!hiddenExtension.Value) { continue; // Do not enable partial extension } extensions.EnableExtension(hiddenExtension.Key); sync = true; } if (sync) { extensions.SyncMembers(version); } } #endif }
public Task Run([TimerTrigger("0 */5 * * * *")] TimerInfo myTimer, FunctionContext context) { return(_scheduledTasksProvider.ExecuteAllScheduledTasks()); }
/// <inheritdoc/> public async Task <HttpResponseData> RenderOAuth2Redirect(HttpRequestData req, FunctionContext ctx) { var log = ctx.GetLogger(nameof(OpenApiTriggerFunction)); log.LogInformation("The oauth2-redirect.html page was requested."); var fi = new FileInfo(ctx.FunctionDefinition.PathToAssembly); var request = new HttpRequestObject(req); var result = default(string); var response = default(HttpResponseData); try { await this._context .SetApplicationAssemblyAsync(fi.Directory.FullName, appendBin : false) .ConfigureAwait(false); result = await this._context .SwaggerUI .AddServer(request, this._context.HttpSettings.RoutePrefix, this._context.OpenApiConfigurationOptions) .BuildOAuth2RedirectAsync(this._context.PackageAssembly) .RenderOAuth2RedirectAsync("oauth2-redirect.html", this._context.GetDocumentAuthLevel(), this._context.GetSwaggerAuthKey()) .ConfigureAwait(false); response = req.CreateResponse(HttpStatusCode.OK); response.Headers.Add("Content-Type", ContentTypeHtml); await response.WriteStringAsync(result).ConfigureAwait(false); } catch (Exception ex) { log.LogError(ex.Message); result = ex.Message; if (this._context.IsDevelopment) { result += "\r\n\r\n"; result += ex.StackTrace; } response = req.CreateResponse(HttpStatusCode.InternalServerError); response.Headers.Add("Content-Type", ContentTypeText); await response.WriteStringAsync(result).ConfigureAwait(false); } return(response); }
public override FunctionNode VisitFunction([NotNull] FunctionContext context) { return(InnerVisitFunction(context.blockFunction(), context.lambdaFunction())); }
public static void BinaryInputFunction([EventHubTrigger("test", Connection = "EventHubConnectionAppSetting", IsBatched = false)] byte[] input, FunctionContext context) { throw new NotImplementedException(); }
public static void StringDoubleArrayInputFunction([EventHubTrigger("test", Connection = "EventHubConnectionAppSetting")] string[][] input, FunctionContext context) { throw new NotImplementedException(); }
public async Task <SignalRMessage> Run([EventGridTrigger] EventGridEvent eventGridEvent, FunctionContext context) { var @event = await _eventGridMessageDeserializer.DeserializeAsync(eventGridEvent); var eventModel = await _eventStoreClient.SaveEventAsync(@event); return(new SignalRMessage { Target = nameof(SavedInEventStoreEvent), Arguments = new object[] { new SavedInEventStoreEvent { Id = eventModel.Id.ToString(), EventType = eventModel.EventType, EventName = eventModel.EventName, Timestamp = eventModel.Timestamp, EventData = eventModel.EventData, Source = eventModel.Source } } }); }
public override int Compile(FunctionContext context) { context.Position(Token); return(context.LoadUndefined()); }
public static void Run([WarmupTrigger] object warmupContext, FunctionContext context) { var logger = context.GetLogger("Warmup"); logger.LogInformation("Function App instance is now warm!"); }
internal bool TrySetBreakpoint(string scriptFile, FunctionContext functionContext) { Diagnostics.Assert(SequencePointIndex == -1, "shouldn't be trying to set on a pending breakpoint"); if (!scriptFile.Equals(this.Script, StringComparison.OrdinalIgnoreCase)) { return(false); } // A quick check to see if the breakpoint is within the scriptblock. bool couldBeInNestedScriptBlock; var scriptBlock = functionContext._scriptBlock; if (scriptBlock != null) { var ast = scriptBlock.Ast; if (!ast.Extent.ContainsLineAndColumn(Line, Column)) { return(false); } var sequencePoints = functionContext._sequencePoints; if (sequencePoints.Length == 1 && sequencePoints[0] == scriptBlock.Ast.Extent) { // If there was no real executable code in the function (e.g. only function definitions), // we added the entire scriptblock as a sequence point, but it shouldn't be allowed as a breakpoint. return(false); } couldBeInNestedScriptBlock = CheckBreakpointInScript.IsInNestedScriptBlock(((IParameterMetadataProvider)ast).Body, this); } else { couldBeInNestedScriptBlock = false; } int sequencePointIndex; var sequencePoint = FindSequencePoint(functionContext, Line, Column, out sequencePointIndex); if (sequencePoint != null) { // If the bp could be in a nested script block, we want to be careful and get the bp in the correct script block. // If it's a simple line bp (no column specified), then the start line must match the bp line exactly, otherwise // we assume the bp is in the nested script block. if (!couldBeInNestedScriptBlock || (sequencePoint.StartLineNumber == Line && Column == 0)) { SetBreakpoint(functionContext, sequencePointIndex); return(true); } } // Before using heuristics, make sure the breakpoint isn't in a nested function/script block. if (couldBeInNestedScriptBlock) { return(false); } // Not found. First, we check if the line/column is before any real code. If so, we'll // move the breakpoint to the first interesting sequence point (could be a dynamicparam, // begin, process, end, or clean block.) if (scriptBlock != null) { var ast = scriptBlock.Ast; var bodyAst = ((IParameterMetadataProvider)ast).Body; if ((bodyAst.DynamicParamBlock == null || bodyAst.DynamicParamBlock.Extent.IsAfter(Line, Column)) && (bodyAst.BeginBlock == null || bodyAst.BeginBlock.Extent.IsAfter(Line, Column)) && (bodyAst.ProcessBlock == null || bodyAst.ProcessBlock.Extent.IsAfter(Line, Column)) && (bodyAst.EndBlock == null || bodyAst.EndBlock.Extent.IsAfter(Line, Column)) && (bodyAst.CleanBlock == null || bodyAst.CleanBlock.Extent.IsAfter(Line, Column))) { SetBreakpoint(functionContext, 0); return(true); } } // Still not found. Try fudging a bit, but only if it's a simple line breakpoint. if (Column == 0 && FindSequencePoint(functionContext, Line + 1, 0, out sequencePointIndex) != null) { SetBreakpoint(functionContext, sequencePointIndex); return(true); } return(false); }
public async Task Invoke(FunctionContext context, FunctionExecutionDelegate next) { await next(context); AddOutputBindings(context); }
public static void ListPocoInputFunction <T>([EventHubTrigger("test", Connection = "EventHubConnectionAppSetting")] List <Poco> input, FunctionContext context) { throw new NotImplementedException(); }
public static void IntListInputFunction([EventHubTrigger("test", Connection = "EventHubConnectionAppSetting")] int[] input, FunctionContext context) { throw new NotImplementedException(); }
private ExprContext expr(int _p) { ParserRuleContext _parentctx = Context; int _parentState = State; ExprContext _localctx = new ExprContext(Context, _parentState); ExprContext _prevctx = _localctx; int _startState = 2; EnterRecursionRule(_localctx, 2, RULE_expr, _p); int _la; try { int _alt; EnterOuterAlt(_localctx, 1); { State = 34; ErrorHandler.Sync(this); switch (Interpreter.AdaptivePredict(TokenStream, 2, Context)) { case 1: { _localctx = new UnaryContext(_localctx); Context = _localctx; _prevctx = _localctx; State = 9; ((UnaryContext)_localctx).sign = TokenStream.LT(1); _la = TokenStream.LA(1); if (!(_la == T__2 || _la == T__3)) { ((UnaryContext)_localctx).sign = ErrorHandler.RecoverInline(this); } else { ErrorHandler.ReportMatch(this); Consume(); } State = 10; expr(16); } break; case 2: { _localctx = new ParenthesisContext(_localctx); Context = _localctx; _prevctx = _localctx; State = 11; Match(T__14); State = 12; expr(0); State = 13; Match(T__15); } break; case 3: { _localctx = new FunctionContext(_localctx); Context = _localctx; _prevctx = _localctx; State = 15; ((FunctionContext)_localctx).name = Match(NAME); State = 16; Match(T__14); State = 25; ErrorHandler.Sync(this); _la = TokenStream.LA(1); if ((((_la) & ~0x3f) == 0 && ((1L << _la) & ((1L << T__2) | (1L << T__3) | (1L << T__14) | (1L << STRING) | (1L << CELLREF) | (1L << BOOLEAN) | (1L << NUMBER) | (1L << NAME) | (1L << ERROR))) != 0)) { { State = 17; expr(0); State = 22; ErrorHandler.Sync(this); _la = TokenStream.LA(1); while (_la == T__16) { { { State = 18; Match(T__16); State = 19; expr(0); } } State = 24; ErrorHandler.Sync(this); _la = TokenStream.LA(1); } } } State = 27; Match(T__15); } break; case 4: { _localctx = new StringContext(_localctx); Context = _localctx; _prevctx = _localctx; State = 28; Match(STRING); } break; case 5: { _localctx = new CellRefContext(_localctx); Context = _localctx; _prevctx = _localctx; State = 29; Match(CELLREF); } break; case 6: { _localctx = new BooleanContext(_localctx); Context = _localctx; _prevctx = _localctx; State = 30; Match(BOOLEAN); } break; case 7: { _localctx = new NumberContext(_localctx); Context = _localctx; _prevctx = _localctx; State = 31; Match(NUMBER); } break; case 8: { _localctx = new NameContext(_localctx); Context = _localctx; _prevctx = _localctx; State = 32; Match(NAME); } break; case 9: { _localctx = new ErrorContext(_localctx); Context = _localctx; _prevctx = _localctx; State = 33; Match(ERROR); } break; } Context.Stop = TokenStream.LT(-1); State = 61; ErrorHandler.Sync(this); _alt = Interpreter.AdaptivePredict(TokenStream, 4, Context); while (_alt != 2 && _alt != global::Antlr4.Runtime.Atn.ATN.INVALID_ALT_NUMBER) { if (_alt == 1) { if (ParseListeners != null) { TriggerExitRuleEvent(); } _prevctx = _localctx; { State = 59; ErrorHandler.Sync(this); switch (Interpreter.AdaptivePredict(TokenStream, 3, Context)) { case 1: { _localctx = new RangeContext(new ExprContext(_parentctx, _parentState)); PushNewRecursionContext(_localctx, _startState, RULE_expr); State = 36; if (!(Precpred(Context, 17))) { throw new FailedPredicateException(this, "Precpred(Context, 17)"); } State = 37; Match(T__1); State = 38; expr(18); } break; case 2: { _localctx = new PowContext(new ExprContext(_parentctx, _parentState)); PushNewRecursionContext(_localctx, _startState, RULE_expr); State = 39; if (!(Precpred(Context, 14))) { throw new FailedPredicateException(this, "Precpred(Context, 14)"); } State = 40; Match(T__5); State = 41; expr(15); } break; case 3: { _localctx = new MulDivContext(new ExprContext(_parentctx, _parentState)); PushNewRecursionContext(_localctx, _startState, RULE_expr); State = 42; if (!(Precpred(Context, 13))) { throw new FailedPredicateException(this, "Precpred(Context, 13)"); } State = 43; ((MulDivContext)_localctx).op = TokenStream.LT(1); _la = TokenStream.LA(1); if (!(_la == T__6 || _la == T__7)) { ((MulDivContext)_localctx).op = ErrorHandler.RecoverInline(this); } else { ErrorHandler.ReportMatch(this); Consume(); } State = 44; expr(14); } break; case 4: { _localctx = new AddSubContext(new ExprContext(_parentctx, _parentState)); PushNewRecursionContext(_localctx, _startState, RULE_expr); State = 45; if (!(Precpred(Context, 12))) { throw new FailedPredicateException(this, "Precpred(Context, 12)"); } State = 46; ((AddSubContext)_localctx).op = TokenStream.LT(1); _la = TokenStream.LA(1); if (!(_la == T__2 || _la == T__3)) { ((AddSubContext)_localctx).op = ErrorHandler.RecoverInline(this); } else { ErrorHandler.ReportMatch(this); Consume(); } State = 47; expr(13); } break; case 5: { _localctx = new ConcatenateContext(new ExprContext(_parentctx, _parentState)); PushNewRecursionContext(_localctx, _startState, RULE_expr); State = 48; if (!(Precpred(Context, 11))) { throw new FailedPredicateException(this, "Precpred(Context, 11)"); } State = 49; Match(T__8); State = 50; expr(12); } break; case 6: { _localctx = new EqualityContext(new ExprContext(_parentctx, _parentState)); PushNewRecursionContext(_localctx, _startState, RULE_expr); State = 51; if (!(Precpred(Context, 10))) { throw new FailedPredicateException(this, "Precpred(Context, 10)"); } State = 52; ((EqualityContext)_localctx).op = TokenStream.LT(1); _la = TokenStream.LA(1); if (!(_la == T__0 || _la == T__9)) { ((EqualityContext)_localctx).op = ErrorHandler.RecoverInline(this); } else { ErrorHandler.ReportMatch(this); Consume(); } State = 53; expr(11); } break; case 7: { _localctx = new RelationalContext(new ExprContext(_parentctx, _parentState)); PushNewRecursionContext(_localctx, _startState, RULE_expr); State = 54; if (!(Precpred(Context, 9))) { throw new FailedPredicateException(this, "Precpred(Context, 9)"); } State = 55; ((RelationalContext)_localctx).op = TokenStream.LT(1); _la = TokenStream.LA(1); if (!((((_la) & ~0x3f) == 0 && ((1L << _la) & ((1L << T__10) | (1L << T__11) | (1L << T__12) | (1L << T__13))) != 0))) { ((RelationalContext)_localctx).op = ErrorHandler.RecoverInline(this); } else { ErrorHandler.ReportMatch(this); Consume(); } State = 56; expr(10); } break; case 8: { _localctx = new PercentageContext(new ExprContext(_parentctx, _parentState)); PushNewRecursionContext(_localctx, _startState, RULE_expr); State = 57; if (!(Precpred(Context, 15))) { throw new FailedPredicateException(this, "Precpred(Context, 15)"); } State = 58; Match(T__4); } break; } } } State = 63; ErrorHandler.Sync(this); _alt = Interpreter.AdaptivePredict(TokenStream, 4, Context); } } } catch (RecognitionException re) { _localctx.exception = re; ErrorHandler.ReportError(this, re); ErrorHandler.Recover(this, re); } finally { UnrollRecursionContexts(_parentctx); } return(_localctx); }
public static void EnumerableNestedBinaryClassInputFunction([EventHubTrigger("test", Connection = "EventHubConnectionAppSetting")] EnumerableBinaryNestedTestClass input, FunctionContext context) { throw new NotImplementedException(); }
internal static void InvokePipeline(object input, bool ignoreInput, CommandParameterInternal[][] pipeElements, CommandBaseAst[] pipeElementAsts, CommandRedirection[][] commandRedirections, FunctionContext funcContext) { PipelineProcessor pipelineProcessor = new PipelineProcessor(); System.Management.Automation.ExecutionContext context = funcContext._executionContext; Pipe pipe = funcContext._outputPipe; try { if (context.Events != null) { context.Events.ProcessPendingActions(); } if ((input == AutomationNull.Value) && !ignoreInput) { AddNoopCommandProcessor(pipelineProcessor, context); } CommandProcessorBase commandProcessor = null; CommandRedirection[] redirections = null; for (int i = 0; i < pipeElements.Length; i++) { redirections = (commandRedirections != null) ? commandRedirections [i] : null; commandProcessor = AddCommand(pipelineProcessor, pipeElements [i], pipeElementAsts [i], redirections, context); } if ((commandProcessor != null) && !commandProcessor.CommandRuntime.OutputPipe.IsRedirected) { pipelineProcessor.LinkPipelineSuccessOutput(pipe ?? new Pipe(new ArrayList())); if (redirections != null) { foreach (CommandRedirection redirection in redirections) { if (redirection is MergingRedirection) { redirection.Bind(pipelineProcessor, commandProcessor, context); } } } } context.PushPipelineProcessor(pipelineProcessor); try { pipelineProcessor.SynchronousExecuteEnumerate(input, null, true); } finally { context.PopPipelineProcessor(false); } } finally { context.QuestionMarkVariableValue = !pipelineProcessor.ExecutionFailed; pipelineProcessor.Dispose(); } }
public virtual decimal?ConvertAmountToCurrency(FunctionContext context, string fromCuryID, string toCuryID, string rateType, DateTime?effectiveDate, decimal?value) { return(engine.ConvertAmountToCurrency(fromCuryID, toCuryID, rateType, effectiveDate, value)); }
public override int Compile(FunctionContext context) { context.Position(Token); return(context.Load(context.Number(Value))); }
public static HttpResponseData Run([HttpTrigger(AuthorizationLevel.Anonymous, "get", "post", Route = null)] HttpRequestData req, FunctionContext executionContext) { var logger = executionContext.GetLogger("FunctionApp.Function4"); logger.LogInformation("message logged"); var response = req.CreateResponse(HttpStatusCode.OK); response.Headers.Add("Date", "Mon, 18 Jul 2016 16:06:00 GMT"); response.Headers.Add("Content", "Content - Type: text / html; charset = utf - 8"); response.WriteString("Welcome to .NET 5!!"); return(response); }
public static async Task <HttpResponseData> Run([HttpTrigger(AuthorizationLevel.Function, "get")] HttpRequestData req, FunctionContext context) { var log = context.GetLogger(nameof(GetAppCenterApiKeys)); log.LogInformation("Retrieving Client Id"); if (string.IsNullOrWhiteSpace(_iOS)) { var notFoundResponse = req.CreateResponse(HttpStatusCode.NotFound); await notFoundResponse.WriteStringAsync($"{nameof(_iOS)} Not Found").ConfigureAwait(false); return(notFoundResponse); } else if (string.IsNullOrWhiteSpace(_android)) { var notFoundResponse = req.CreateResponse(HttpStatusCode.NotFound); await notFoundResponse.WriteStringAsync($"{nameof(_android)} Not Found").ConfigureAwait(false); return(notFoundResponse); } else { var response = req.CreateResponse(HttpStatusCode.OK); var appCenterApiKeyDtoJson = JsonConvert.SerializeObject(new AppCenterApiKeyDTO(_iOS, _android)); await response.WriteStringAsync(appCenterApiKeyDtoJson).ConfigureAwait(false); return(response); } }
public static void ConcurrentDictionaryInputFunction([EventHubTrigger("test", Connection = "EventHubConnectionAppSetting", IsBatched = false)] ConcurrentDictionary <string, string> input, FunctionContext context) { throw new NotImplementedException(); }
public static void EnumerableNestedStringGenericClass2InputFunction([EventHubTrigger("test", Connection = "EventHubConnectionAppSetting")] EnumerableStringNestedGenericTestClass2 <string, int> input, FunctionContext context) { throw new NotImplementedException(); }
public object CreateInstance(Type instanceType, FunctionContext context) { ArgumentNullException.ThrowIfNull(instanceType, nameof(instanceType)); return(_container.GetInstance(instanceType)); }
public static void LookupInputFunction([EventHubTrigger("test", Connection = "EventHubConnectionAppSetting", IsBatched = false)] Lookup <string, int> input, FunctionContext context) { throw new NotImplementedException(); }
/// <summary> /// Link delegates fields using import declarations. /// </summary> /// <param name="path"> /// A <see cref="String"/> that specifies the assembly file path containing the import functions. /// </param> /// <param name="functionContext"> /// A <see cref="FunctionContext"/> mapping a <see cref="MethodInfo"/> with the relative function name. /// </param> /// <param name="function"> /// A <see cref="FieldInfo"/> that specifies the underlying function field to be updated. /// </param> /// <param name="getAddress"> /// A <see cref="GetAddressDelegate"/> used for getting function pointers. This parameter is dependent on the currently running platform. /// </param> /// <exception cref="ArgumentNullException"> /// Exception thrown if <paramref name="path"/>, <paramref name="function"/> or <paramref name="getAddress"/> is null. /// </exception> private static void BindAPIFunction(string path, FunctionContext functionContext, FieldInfo function, GetAddressDelegate getAddress) { if (path == null) { throw new ArgumentNullException("path"); } if (functionContext == null) { throw new ArgumentNullException("functionContext"); } if (function == null) { throw new ArgumentNullException("function"); } if (getAddress == null) { throw new ArgumentNullException("getAddress"); } Attribute[] aliasOfAttributes = Attribute.GetCustomAttributes(function, typeof(AliasOfAttribute)); string importName = function.Name.Substring(1); // Delegate name always prefixes with 'p' IntPtr importAddress = IntPtr.Zero; // Manages aliases (load external symbol) if (aliasOfAttributes.Length > 0) { for (int i = 0; i < aliasOfAttributes.Length; i++) { AliasOfAttribute aliasOfAttribute = (AliasOfAttribute)aliasOfAttributes[i]; if ((importAddress = getAddress(path, aliasOfAttribute.SymbolName)) != IntPtr.Zero) { break; } } } else { importAddress = getAddress(path, importName); } if (importAddress != IntPtr.Zero) { Delegate delegatePtr; // Try to load external symbol if ((delegatePtr = Marshal.GetDelegateForFunctionPointer(importAddress, function.FieldType)) == null) { MethodInfo methodInfo; if (functionContext.Imports.TryGetValue(importName, out methodInfo) == true) { delegatePtr = Delegate.CreateDelegate(function.FieldType, methodInfo); } } if (delegatePtr != null) { function.SetValue(null, delegatePtr); } } else { function.SetValue(null, null); // Function not implemented } }
public FakeHttpRequestData(FunctionContext functionContext, Uri url, Stream body = null) : base(functionContext) { Url = url; Body = body ?? new MemoryStream(); }
public FakeHttpResponseData(FunctionContext functionContext) : base(functionContext) { }