public void Configure(IApplicationBuilder app, IWebHostEnvironment env) { app.UseRouting(); app.UseEndpoints(endpoints => { endpoints.MapPost("/", async context => { try { using var reader = new StreamReader(context.Request.Body); var data = await reader.ReadToEndAsync(); var handler = new FunctionHandler(); var result = await handler.Handle(data); await context.Response.WriteAsync(result); } catch (Exception ex) { context.Response.StatusCode = (int)HttpStatusCode.InternalServerError; await context.Response.WriteAsync(ex.Message); } }); }); }
public bool Validate() { if (Value == null) { throw new Exception("请设置Value,Value不能为NULL"); } if (FunctionHandler == null) { throw new Exception("请设置FunctionHandler,FunctionHandler不能为NULL"); } else { if (Args == null) { Args = new Dictionary <string, object>(); } Args["_value"] = Value; string errorMsg = FunctionHandler.Invoke(Args); if (string.IsNullOrEmpty(errorMsg)) { return(true); } else { this.ErrorMessage = errorMsg; return(false); } } }
public NameHandler(State s) { logger = Log.ForContext <NameHandler>(); variables = s.Variables; functions = s.Functions; namespaces = s.Namespaces; }
FunctionHandler activationFunction; //The activation functions that will be used public NeuralNetwork(int inputNodes, int hiddenNodes, int outPutnodes, double lr, FunctionHandler activationFunction) { //Asign the amount of nodes specified this.inputNodes = inputNodes; this.hiddenNodes = hiddenNodes; this.outPutnodes = outPutnodes; this.lr = lr; this.activationFunction = activationFunction; //Create weight matrices weights_InHid = new Matrix(this.hiddenNodes, this.inputNodes); weights_HidOut = new Matrix(this.outPutnodes, this.hiddenNodes); //Randomize starting values in weight matrices weights_InHid.randomize(); weights_HidOut.randomize(); //Create new matrices for the biases for each connection bias_Hidden = new Matrix(hiddenNodes, 1); bias_Out = new Matrix(outPutnodes, 1); //Randomize the bias matrices bias_Hidden.randomize(); bias_Out.randomize(); }
static void Main(string[] args) { string buffer = getStdin(); FunctionHandler f = new FunctionHandler(); f.Handle(buffer); }
public void Configure(IApplicationBuilder app, IHostingEnvironment env) { if (env.IsDevelopment()) { app.UseDeveloperExceptionPage(); } app.Run(async(context) => { var functionHandler = new FunctionHandler(); try { var response = functionHandler.Handle(context.Request); context.Response.StatusCode = response.statusCode; foreach (KeyValuePair <string, string> entry in response.headers) { HeaderDictionaryExtensions.Append(context.Response.Headers, entry.Key, entry.Value); } await context.Response.WriteAsync(response.body); } catch (Exception ex) { Console.Write(ex); context.Response.StatusCode = (int)HttpStatusCode.InternalServerError; await context.Response.WriteAsync(ex.Message); } }); }
private void BtnGenerate_Click(object sender, RoutedEventArgs e) { if (checkIfAllFieldsFill()) { TxtQuery.Text = FunctionHandler.makeQueryAddFunction(getTableName(), TxtKeyName1.Text.ToString(), TxtEventTime1.Text.ToString(), TxtEventValue1.Text.ToString(), TxtFrom1.Text.ToString(), TxtWhere1.Text.ToString(), ChkNumber1.IsChecked.Value); } }
public void populateListView() { List <string> listItemsFac = new List <string>(); List <string> listItemsDim = new List <string>(); List <string> listItemsFun = new List <string>(); DataSet dimensions = DimensionHandler.getDimensions(Application.Current.Resources["ProjectPrefix"].ToString()); DataSet facts = FactHandler.getFacts(Application.Current.Resources["ProjectPrefix"].ToString()); DataSet functions = FunctionHandler.getFunctions(Application.Current.Resources["ProjectPrefix"].ToString()); foreach (DataRow row in dimensions.Tables["result"].Rows) { listItemsDim.Add(row[0].ToString()); } foreach (DataRow row in facts.Tables["result"].Rows) { listItemsFac.Add(row[0].ToString()); } foreach (DataRow row in functions.Tables["result"].Rows) { listItemsFun.Add(row[0].ToString()); } listViewFacts.ItemsSource = listItemsFac; listViewDim.ItemsSource = listItemsDim; listViewFun.ItemsSource = listItemsFun; }
internal Context() { mImplementPtr = ConversationAPI.CreateContext(); IntPtr global = ConversationAPI.GetContextGlobalSave(ImplementPtr); if (global != IntPtr.Zero) { mGlobalSave = new Save(global); } IntPtr player = ConversationAPI.GetContextPlayerSave(ImplementPtr); if (player != IntPtr.Zero) { mPlayerSave = new Save(player); } // 长期持有自己的delegate防止被gc mFunctionHandler = new FunctionHandler(OnFunctoinCall); mProcessHandler = new FunctionHandler(OnProcessCall); mFunctionQuery = new FunctionQuery(OnFunctoinQuery); mProcessQuery = new FunctionQuery(OnProcessQuery); ConversationAPI.SetFunctionHandler(ImplementPtr, mFunctionHandler); ConversationAPI.SetProcessHandler(ImplementPtr, mProcessHandler); ConversationAPI.SetFunctionQuery(ImplementPtr, mFunctionQuery); ConversationAPI.SetProcessQuery(ImplementPtr, mProcessQuery); }
public static IEnumerator Scale(FunctionHandler function, float duration, GameObject obj, params object[] param) { Vector3 point = GetParam <Vector3>(true, param); Action action = GetParam <Action>(param); Timer time = GetParam <Timer>(param); bool cicle = GetParam <bool>(param); Vector3 startScale = obj.transform.localScale; do { float timer = 0; if (action == Action.Straight) { while (timer <= duration) { obj.transform.localScale = Vector3.Lerp(startScale, point, function(timer / duration)); yield return(timer += TimeScale(time)); } } else { while (timer <= duration) { obj.transform.localScale += Vector3.Lerp(Vector3.zero, point, function(timer / duration)); yield return(timer += TimeScale(time)); } } yield return(true); } while (cicle); }
/// <summary> /// 重写以实现从方法信息中提取模块信息 /// </summary> /// <param name="method">方法信息</param> /// <param name="typeInfo">所在类型模块信息</param> /// <param name="index">序号</param> /// <returns>提取到的模块信息</returns> protected override ModuleInfo GetModule(MethodInfo method, ModuleInfo typeInfo, int index) { ModuleInfoAttribute infoAttr = method.GetAttribute <ModuleInfoAttribute>(); ModuleInfo info = new ModuleInfo() { Name = infoAttr.Name ?? method.GetDescription() ?? method.Name, Code = infoAttr.Code ?? method.Name, Order = infoAttr.Order > 0 ? infoAttr.Order : index + 1 }; string controller = method.DeclaringType?.Name.Replace("Controller", ""); info.Position = $"{typeInfo.Position}.{controller}"; //依赖的功能 string area = method.DeclaringType.GetAttribute <AreaAttribute>(true)?.RouteValue; List <IFunction> dependOnFunctions = new List <IFunction>() { FunctionHandler.GetFunction(area, controller, method.Name) }; DependOnFunctionAttribute[] dependOnAttrs = method.GetAttributes <DependOnFunctionAttribute>(); foreach (DependOnFunctionAttribute dependOnAttr in dependOnAttrs) { string darea = dependOnAttr.Area == null ? area : dependOnAttr.Area == string.Empty ? null : dependOnAttr.Area; string dcontroller = dependOnAttr.Controller ?? controller; IFunction function = FunctionHandler.GetFunction(darea, dcontroller, dependOnAttr.Action); if (function == null) { throw new OsharpException($"功能“{area}/{controller}/{method.Name}”的依赖功能“{darea}/{dcontroller}/{dependOnAttr.Action}”无法找到"); } dependOnFunctions.Add(function); } info.DependOnFunctions = dependOnFunctions.ToArray(); return(info); }
private static void FirstEvolution() { // delegate used as a function pointer FunctionHandler handler = new FunctionHandler(DisplayMessage); handler(25); }
public JObject Main(JObject args) { try { var size = args.ContainsKey("size") ? int.Parse(args["size"].ToString()) : 50; var max = args.ContainsKey("max") ? int.Parse(args["max"].ToString()) : 5000; var seed = args.ContainsKey("seed") ? int.Parse(args["seed"].ToString()) : -1; args["hasCallback"] = args.ContainsKey("callback"); args["startTimestamp"] = Util.GetUnixTimestamp(); var repo = new CloudObjectStorageRepository(args); var hndlr = new FunctionHandler(repo); var id = hndlr.CreateMatrix(size, max, seed); args["id"] = id; args["size"] = size; args["max"] = max; Console.WriteLine(args.ToString()); return(args); } catch (Exception e) { var j = new JObject(); j["error"] = e.ToString(); return(j); } }
static void Main(string[] args) { FunctionHandler f = new FunctionHandler(sigmoid, dSigmoid); NeuralNetwork nn = new NeuralNetwork(2, 2, 1, 0.1f, f); test(nn); }
public void ExtractHtml() { var message = File.OpenText("encoded.txt").ReadToEnd(); FunctionHandler handler = new FunctionHandler(); var result = handler.Handle(message); Assert.Contains("Purchase Order 16487645-2", result); }
static void Main(string[] args) { string buffer = getStdin(); var context = new DefaultFunctionContext(); FunctionHandler f = new FunctionHandler(context); f.Handle(buffer); }
public void Test1() { var fh = new FunctionHandler(); var res = fh.Handle("This is my input"); var expected = "Hi there - your input was: This is my input\n"; Assert.Equal(res, expected); }
public ShowFunction(string tableName) { InitializeComponent(); table = tableName; TxtTableName.Text = tableName.Substring(tableName.LastIndexOf('_') + 1); DataSet queryres = FunctionHandler.getFirstHundredFunction(tableName); resultQuery.ItemsSource = queryres.Tables["result"].DefaultView; }
public TestMultiplication(ITestOutputHelper @out) { _out = @out; Console.SetOut(new XUnitTestWriter(@out)); repo = new MockRepository(); hndlr = new FunctionHandler(repo); }
public FunctionHandlerTest() { _handler = new FunctionHandler(); _mockRequest = CreateMockRequest(new TestBodyData { }, new Dictionary <string, StringValues> { { "param1", "" } }); }
public void Configure(IApplicationBuilder app, IHostingEnvironment env) { if (env.IsDevelopment()) { app.UseDeveloperExceptionPage(); } var function = new FunctionHandler(); app.Run(function.Handle); }
public Handler() { bucketName = Environment.GetEnvironmentVariable("DATA_BUCKET_NAME"); region = Environment.GetEnvironmentVariable("DATA_BUCKET_REGION"); s3Client = new AmazonS3Client(RegionEndpoint.GetBySystemName(region)); transferUtility = new TransferUtility(s3Client); serializer = new JsonSerializer(); _mulRepository = new S3MatrixMulRepository(transferUtility, serializer, bucketName); handler = new FunctionHandler(_mulRepository); }
public static Report BuildReport([ActivityTrigger] ReportContext ctx, ILogger log) { var repo = new InMemoryMatrixMulRepository(); repo.StoreCalculation("an_id", ctx.Calculation); repo.StoreResultMatrix("an_id", ctx.Result); var hndlr = new FunctionHandler(repo); log.LogInformation($"Building Report"); return(hndlr.GenerateReport(ctx.CallbackURL, ctx.StartTime, "an_id", ctx.WorkerCount)); }
static void Main(string[] args) { string buffer = Console.In.ReadToEnd(); FunctionHandler f = new FunctionHandler(); string responseValue = f.Handle(buffer); if (responseValue != null) { Console.Write(responseValue); } }
public static Matrix SerialMultiply([ActivityTrigger] MatrixCalculation calculation, ILogger log) { var repo = new InMemoryMatrixMulRepository(); repo.StoreCalculation("an_id", calculation); var hndlr = new FunctionHandler(repo); log.LogInformation("Serially multiplying two matrices"); hndlr.SerialMultiply("an_id"); return(repo.GetResultMatrix("an_id")); }
/// <summary> /// Executes to delegate function for data table projection. /// </summary> /// <param name="dataTable">The table to project.</param> /// <param name="conversionType">The type to convert to.</param> /// <param name="function">The delegate function to execute.</param> /// <returns>The array of data entities.</returns> private Object ListGenericTypeProjector( DataTable dataTable, Type conversionType, FunctionHandler <Object, DataTable, Type> function) { if (dataTable == null) { throw new ArgumentNullException("dataTable"); } // Call the function delegate with table parameter // to execute the method. return(function(dataTable, conversionType)); }
/// <summary> /// Executes to delegate function for data table projection. /// </summary> /// <typeparam name="TEntity">The entity type to examine.</typeparam> /// <param name="table">The table to project.</param> /// <param name="function">The delegate function to execute.</param> /// <returns>The array of data entities.</returns> private TEntity[] Projector <TEntity>(DataTable table, FunctionHandler <TEntity[], DataTable> function) where TEntity : class, new() { if (table == null) { throw new ArgumentNullException("table"); } // Call the function delegate with table parameter // to execute the method. return(function(table)); }
/// <summary> /// 初始化一个<see cref="WebApiFrameworkInitializer"/>类型的新实例 /// </summary> public WebApiFrameworkInitializer() { DatabaseInitializer = new DatabaseInitializer(); EntityInfoHandler = new EntityInfoHandler() { IocResolver = new IocResolver() }; FunctionHandler = new FunctionHandler() { IocResolver = new IocResolver() }; }
private void SetButtonFunctionss() { DataSet testowy = FunctionHandler.getFunctions(Application.Current.Resources["ProjectPrefix"].ToString()); foreach (DataRow row in testowy.Tables["result"].Rows) { Button c = new Button(); c.Content = row[0].ToString(); c.Click += ShowFunction_Click; this.FunctionContainer.Children.Add(c); } }
public static IEnumerator Move(FunctionHandler function, float duration, GameObject obj, params object[] param) { Vector3 point = GetParam <Vector3>(true, param); Space space = GetParam <Space>(param); Action action = GetParam <Action>(param); Timer time = GetParam <Timer>(param); bool cicle = GetParam <bool>(param); Rigidbody rigidBody = obj.GetComponent <Rigidbody>(); Vector3 startPosition = GetStartPosition(obj, space); do { float timer = 0; if (space == Space.World) { if (action == Action.Straight) { while (timer <= duration) { rigidBody.transform.position = Vector3.Lerp(startPosition, point, function(timer / duration)); yield return(timer += TimeScale(time)); } } else { while (timer <= duration) { rigidBody.velocity += Vector3.Lerp(Vector3.zero, point, function(timer / duration)); yield return(timer += TimeScale(time)); } } } else if (action == Action.Straight) { while (timer <= duration) { rigidBody.transform.localPosition = Vector3.Lerp(startPosition, point, function(timer / duration)); yield return(timer += TimeScale(time)); } } else { while (timer <= duration) { rigidBody.velocity += Vector3.Lerp(Vector3.zero, point, function(timer / duration)); yield return(timer += TimeScale(time)); } } yield return(true); } while (cicle); }
public static IEnumerator UnscaledImageChangeColor(FunctionHandler function, float duration, Image image, Color color) { Color startColor = image.color; float timer = 0; while (timer <= duration) { image.color = Color.Lerp(startColor, color, function(timer / duration)); timer += Time.unscaledDeltaTime; yield return(null); } //ВОЗМОЖНО СТОИТ ВОЗВРАЩАТЬ НА МЕСТО ТУТ ВО ВСЕХ ФУНЦИЯХ ЕСЛИ НУЖНО }
/// <summary> /// 初始化一个<see cref="WebApiFrameworkInitializer"/>类型的新实例 /// </summary> public WebApiFrameworkInitializer() { PlatformToken = PlatformToken.WebApi; DataConfigReseter = new DataConfigReseter(); DatabaseInitializer = new DatabaseInitializer(); EntityInfoHandler = new EntityInfoHandler() { IocResolver = new IocResolver() }; FunctionHandler = new FunctionHandler() { IocResolver = new IocResolver() }; }
/// <summary> /// 初始化一个<see cref="WebApiInitializeOptions"/>类型的新实例 /// </summary> public WebApiInitializeOptions(IBasicLoggingInitializer basicLoggingInitializer, IIocInitializer iocInitializer) { basicLoggingInitializer.CheckNotNull("basicLoggingInitializer"); iocInitializer.CheckNotNull("iocInitializer"); PlatformToken = PlatformToken.WebApi; DataConfigReseter = new DataConfigReseter(); DatabaseInitializer = new DatabaseInitializer(); EntityInfoHandler = new EntityInfoHandler() { IocResolver = new WebApiIocResolver() }; FunctionHandler = new FunctionHandler() { IocResolver = new WebApiIocResolver() }; BasicLoggingInitializer = basicLoggingInitializer; IocInitializer = iocInitializer; }
/// <summary> /// Creates a function value from a native .net function. /// </summary> public static FunctionValue Create(FunctionHandler Function) { return new _NativeFunction() { Function = Function }; }
public FunctionServer(FunctionHandler handler) : this(handler, 5454) { }
public FunctionServer(FunctionHandler handler, int port) { this.handler = handler; this.port = port; }
public Handler(FunctionHandler handler, Socket socket) { this.handler = handler; this.socket = socket; this.stream = new NetworkStream(socket); }
public override void Initialize(){ try{ logger.get("comdiv.sys").debug(() => "initialize interpreter"); interpreter = new Interpreter(); } catch (Exception ex){ logger.get("comdiv.sys").Error("cannot launch interpreter", ex); return; } Console.WriteLine("in initialize"); base.Initialize(); var md = Metadata = Metadata ?? Container.get<IMetadataHelper>().GetMeta(Type, Alias); SetDefault("id", "scaffolder"); ComponentParams["boo"] = interpreter; ComponentParams["nameRoot"] = NameRoot; SetDefault("path", string.Format("database/objects/{0}", NameRoot)); SetDefault("hiddens", new object[]{}); SetDefault("groupby", md.GroupBy); SetDefault("commands", md.Commands); SetDefault("ioc.getid", null); SetDefault("mode", "table"); SetDefault("targetObject", null); SetDefault("propertyRender", "writeoutproperty"); if (md.CustomRender.hasContent()){ ComponentParams["propertyRender"] = md.CustomRender; } ComponentParams["props"] = md.GetVisibleProperties(); ComponentParams["checked"] = new FunctionHandler<bool, string>(x => x ? " checked='checked' " : string.Empty); }
private void InitDisruptorObjects() { ringBuffer = new RingBuffer<FunctionEntry>(new FunctionEntryFactory(), SIZE, new SingleThreadedStrategy(), new YieldingStrategy<FunctionEntry>()); stepOneConsumerBarrier = ringBuffer.CreateConsumerBarrier(); stepOneFunctionHandler = new FunctionHandler(FunctionStep.ONE); stepOneBatchConsumer = new BatchConsumer<FunctionEntry>(stepOneConsumerBarrier, stepOneFunctionHandler); stepTwoConsumerBarrier = ringBuffer.CreateConsumerBarrier(stepOneBatchConsumer); stepTwoFunctionHandler = new FunctionHandler(FunctionStep.TWO); stepTwoBatchConsumer = new BatchConsumer<FunctionEntry>(stepTwoConsumerBarrier, stepTwoFunctionHandler); stepThreeConsumerBarrier = ringBuffer.CreateConsumerBarrier(stepTwoBatchConsumer); stepThreeFunctionHandler = new FunctionHandler(FunctionStep.THREE); stepThreeBatchConsumer = new BatchConsumer<FunctionEntry>(stepThreeConsumerBarrier, stepThreeFunctionHandler); producerBarrier = ringBuffer.CreateProducerBarrier(stepThreeBatchConsumer); }