예제 #1
0
        public void Configuration(IAppBuilder app) {
            var serializer = CreateJsonSerializer();
            GlobalHost.DependencyResolver.Register(typeof(JsonSerializer), () => serializer);
            var resolver = new Resolver(serializer);
            GlobalHost.DependencyResolver.Register(typeof(IParameterResolver), () => resolver);
            app.UseCors(new MyCorsOptions());
            app.Map("/api/get-upload-folders", builder => builder.Run(InvokeGames));
            app.Map("/signalr", map => {
                var debug =
#if DEBUG
                    true;
#else
                    false;
#endif

                var hubConfiguration = new HubConfiguration {
                    EnableDetailedErrors = debug
                };

                // Run the SignalR pipeline. We're not using MapSignalR
                // since this branch is already runs under the "/signalr"
                // path.
                map.RunSignalR(hubConfiguration);
            });
        }
예제 #2
0
 private void BtnStart_Click(object sender, EventArgs e)
 {
     this.resolver.Input = BusinessConstants.BARCODE_SPECIAL_MARK + BusinessConstants.BARCODE_HEAD_NOTE + this.txtHuId.Text.Trim();
     resolver = TheClientMgr.ScanBarcode(resolver);
     this.txtHuId.Text = string.Empty;
     Databind();
 }
예제 #3
0
 public void TestCache() {
    Resolver<ContentType> resolver = new Resolver<ContentType>();
    resolver.Add(new ContentType("*.html", "text/html"));
    resolver.Add(new ContentType("*.jpg", "image/jpeg"));
    resolver.Add(new ContentType("/images/*", "image/jpeg"));
    resolver.Add(new ContentType("/log/**", "text/plain"));
    resolver.Add(new ContentType("*.exe", "application/octetstream"));
    resolver.Add(new ContentType("**.txt", "text/plain"));
    resolver.Add(new ContentType("/html/*", "text/html"));
    AssertEquals(7, resolver.Count);
    AssertEquals("image/jpeg", resolver.Resolve("image.jpg").Value);
    AssertEquals("text/plain", resolver.Resolve("README.txt").Value);
    int index = 0;
    for(int i = resolver.Count; i > 0; i--) {
       ContentType type = resolver[i - 1]; 
       if(type.Value.Equals("text/plain")) {
          index = i;
       }
    }
    resolver.RemoveAt(index);
    resolver.Add(new ContentType("*", "application/octetstream"));
    AssertEquals("application/octetstream", resolver.Resolve("README.txt").Value);
    AssertEquals("application/octetstream", resolver.Resolve("README.txt").Value);
    resolver.Add(new ContentType("README.*", "text/html"));
    resolver.Add(new ContentType("README.txt", "text/plain"));
    AssertEquals("text/plain", resolver.Resolve("README.txt").Value);
    AssertEquals("text/html", resolver.Resolve("README.jsp").Value);
 }
예제 #4
0
파일: Boot.cs 프로젝트: tanglebones/ch-ioc
        async Task IBoot.Run(CancellationToken token)
        {
            IResolver resolver = new Resolver(new[] {"CH.IoC."});
            _log = resolver.Resolve<ILog>();
            _log.Log(1, "Boot 1");

            var tasks =
                new[]
                    {
                        "isolated\\0",
                        "isolated\\1",
                        "isolated\\2"
                    }
                .Select(path => Run(path, token))
                .ToArray(); // force start

            foreach (var task in tasks)
            {
                try
                {
                    await task;
                }
                catch (Exception ex)
                {
                    _log.Log(2, "Boot 2: " + ex);
                }
            }

            while (!token.IsCancellationRequested)
            {
                await Task.Delay(10, token);
            }
        }
예제 #5
0
 Task IIsolated.Run(System.Threading.CancellationToken token)
 {
     IResolver resolver = new Resolver(new[] {"CH.IoC."});
     var log = resolver.Resolve<ILog>();
     log.Log("Isolated 4.0.0.0");
     return Task.Delay(1, token);
 }
예제 #6
0
        public UCPrintMonitor(User user, string moduleType)
        {
            InitializeComponent();
            this.resolver = new Resolver();
            this.resolver.UserCode = user.Code;
            this.resolver.ModuleType = moduleType;
            this.TheClientMgr = new ClientMgrWSSoapClient();
            this.dataGridView1.AutoGenerateColumns = false;

            this.resolver.Transformers = null;
            this.resolver.Result = string.Empty;
            this.resolver.BinCode = string.Empty;
            this.resolver.Code = string.Empty;
            this.resolver.CodePrefix = string.Empty;
            this.cacheReceiptNotes = new List<ReceiptNote>();

            //timer1_Tick(this, null);

            #region Printer
            foreach (string fPrinterName in LocalPrinter.GetLocalPrinters())
            {
                this.comboBoxPrint1.Items.Add(fPrinterName);
                this.comboBoxPrint2.Items.Add(fPrinterName);
                this.comboBoxPrint3.Items.Add(fPrinterName);
                this.comboBoxPrint4.Items.Add(fPrinterName);
                this.comboBoxPrint5.Items.Add(fPrinterName);
            }
            //this.comboBoxPrint1.SelectedItem = Settings.Default.DefaultPrintName1;
            #endregion
        }
예제 #7
0
 public int sceNetResolverCreate(int *PointerToResolverId, void *Buffer, int BufferLength)
 {
     var Resolver = new Resolver();
     var ResolverId = Resolvers.Create(Resolver);
     *PointerToResolverId = ResolverId;
     //throw(new NotImplementedException());
     return 0;
 }
예제 #8
0
        public static string Create(MethodReference mRef, Resolver resolver, ICode ast) {
            if (mRef.ContainsGenericParameters()) {
                throw new ArgumentException("Cannot create JS for method with open generic parameters");
            }
            var mDef = mRef.Resolve();
            if (mDef.IsAbstract) {
                throw new ArgumentException("Should never need to transcode an abstract method");
            }
            var tRef = mRef.DeclaringType;
            var tDef = tRef.Resolve();

            var v = new JsMethod(resolver);
            v.Visit(ast);
            var js = v.js.ToString();

            var sb = new StringBuilder();
            // Method declaration
            var methodName = resolver.MethodNames[mRef];
            //var parameterNames = mRef.Parameters.Select(x => v.parameters.ValueOrDefault(x).NullThru(y => resolver.LocalVarNames[y])).ToArray();
            // Match parameters, but have to do by position, as method built may be a custom method replacing a BCL method,
            // so parameters are not the same.
            var parameterNames = mRef.Parameters.Select(x => v.parameters.FirstOrDefault(y => y.Key.Sequence == x.Sequence).Value.NullThru(y => resolver.LocalVarNames[y])).ToArray();
            if (!mDef.IsStatic) {
                var thisName = v.vars.FirstOrDefault(x => x.ExprType == Expr.NodeType.VarThis).NullThru(x => resolver.LocalVarNames[x]);
                parameterNames = parameterNames.Prepend(thisName).ToArray();
            }
            var unusedParameterNameGen = new NameGenerator();
            parameterNames = parameterNames.Select(x => x ?? ("_" + unusedParameterNameGen.GetNewName())).ToArray();
            sb.AppendFormat("// {0}", mRef.FullName);
            sb.AppendLine();
            sb.AppendFormat("var {0} = function({1}) {{", methodName, string.Join(", ", parameterNames));
            // Variable declarations
            var declVars = v.vars
                .Select(x => new { name = resolver.LocalVarNames[x], type = x.Type })
                .Where(x => !parameterNames.Contains(x.name))
                .Select(x => {
                    var name = x.name;
                    if (x.type.IsValueType) {
                        name += " = " + DefaultValuer.Get(x.type, resolver.FieldNames);
                    }
                    return name;
                })
                .Distinct() // Bit of a hack, but works for now
                .ToArray();
            if (declVars.Any()) {
                sb.AppendLine();
                sb.Append(' ', tabSize);
                sb.AppendFormat("var {0};", string.Join(", ", declVars));
            }
            // Method body
            sb.AppendLine(js);
            // Method ending
            sb.AppendLine("};");

            var sbStr = sb.ToString();
            return sbStr;
        }
예제 #9
0
 /// <summary>
 /// Constructor.
 /// </summary>
 /// <param name="createdOnForeground"></param>
 public SDKEngine(bool createdOnForeground)
 {
     _appIsOnForeground = createdOnForeground;
     LayoutManager = LayoutManager.Instance;
     Resolver = new Resolver();
     _eventHistory = new EventHistory();
     _nextTimeToProcessDelayedActions = DateTimeOffset.MaxValue;
     UnresolvedActionCount = 0;
 }
예제 #10
0
        protected override bool ProcessCmdKey(ref Message msg, Keys keyData)
        {
            if (keyData == (Keys.Control | Keys.Enter))
            {
                this.btnShip_Click(null, null);
                return true;
            }
            else if (keyData == (Keys.Control | Keys.P))
            {
                this.PrintReceiver();
                return true;
            }

            if (this.tbBarCode.Focused)
            {
                if (keyData == Keys.Enter)
                {
                    this.OrderNoScan();
                    return true;
                }
                if (keyData == Keys.Escape)
                {
                    this.resolver.Input = BusinessConstants.BARCODE_SPECIAL_MARK + BusinessConstants.BARCODE_HEAD_CANCEL;
                    this.resolver = TheClientMgr.ScanBarcode(this.resolver);
                    this.DataBind();
                }
            }
            else if (this.btnShipReturn.Focused)
            {
                if (keyData == Keys.Enter)
                {
                    this.OrderConfirm();
                    return true;
                }
            }
            else if (this.gvList.Focused)
            {
                if (keyData == Keys.Enter)
                {
                    if (this.resolver != null && !this.resolver.IsScanHu)
                    {
                        int currentRowIndex = this.gvList.CurrentCell.RowIndex;
                        if (currentRowIndex == this.gvList.Rows.Count - 1)
                        {
                            this.gvHuList.ClearSelection();
                            this.btnShipReturn.Focus();
                        }
                    }
                    else
                    {
                        this.btnShipReturn.Focus();
                    }
                }
            }
            return base.ProcessCmdKey(ref msg, keyData);
        }
예제 #11
0
 static void Main(string[] args)
 {
     var resolver = new Resolver();
     resolver.Register<Shopper, Shopper>();
     //resolver.Register<ICreditCard, MasterCard>();
     resolver.Register<ICreditCard, Visa>();
     var shopper = resolver.Resolve<Shopper>();
     shopper.Charge();
     Console.Read();
 }
예제 #12
0
        public void TinyIocBasic()
        {
            var resolver = new Resolver();

            resolver.Container.Register<IJsonSerializer>(new JsonSerializer());
            //resolver.AddDynamic<IJsonSerializer>(() => new JsonSerializer());
            var serializer = resolver.GetService<IJsonSerializer>();

            Assert.IsNotNull(serializer);
        }
예제 #13
0
 public void TestMultipleConstructorsOfMaxSize()
 {
     Resolver r = new Resolver();
       Mock<IIocContainer> context = new Mock<IIocContainer>();
       try
       {
     r.ResolveDependency(typeof(MatchingConstructorCounts), context.Object);
     Assert.Fail();
       }
       catch (IocException) { }
 }
예제 #14
0
 public void TestMultipleIocConstructorAttributes()
 {
     Resolver r = new Resolver();
       Mock<IIocContainer> context = new Mock<IIocContainer>();
       try
       {
     r.ResolveDependency(typeof(BadConstructorAttributes), context.Object);
     Assert.Fail();
       }
       catch (IocException) { }
 }
예제 #15
0
 protected override bool ProcessCmdKey(ref Message msg, Keys keyData)
 {
     if (keyData == (Keys.Control | Keys.Enter))
     {
         this.Devanning();
         return true;
     }
     if (this.tbBarCode.Focused)
     {
         if (keyData == Keys.Enter)
         {
             this.BarCodeScan();
             return true;
         }
         if (keyData == Keys.Escape)
         {
             try
             {
                 if (this.resolver != null)
                 {
                     this.resolver.Input = BusinessConstants.BARCODE_SPECIAL_MARK + BusinessConstants.BARCODE_HEAD_CANCEL;
                     this.resolver = this.TheClientMgr.ScanBarcode(this.resolver);
                     this.BindTransformer();
                     return true;
                 }
                 else
                 {
                     return true;
                 }
             }
             catch (Exception)
             {
                 return true;
             }
         }
     }
     else if (this.btnDevanning.Focused)
     {
         if (keyData == Keys.Enter)
         {
             if (this.tbBarCode.Text.Trim() != string.Empty)
             {
                 this.BarCodeScan();
             }
             else
             {
                 this.Devanning();
             }
             return true;
         }
     }
     return base.ProcessCmdKey(ref msg, keyData);
 }
예제 #16
0
 public void TestPropertyAndMethodSetup()
 {
     Resolver r = new Resolver();
       Mock<IIocContainer> context = new Mock<IIocContainer>();
       object returnedObject = new object();
       string returnedString = "returnedString";
       context.Setup((c) => c.Resolve(typeof(object), String.Empty)).Returns(returnedObject);
       context.Setup((c) => c.Resolve(typeof(string), String.Empty)).Returns(returnedString);
       PropertyAndMethodInitialization result = (r.ResolveDependency(typeof(PropertyAndMethodInitialization), context.Object) as PropertyAndMethodInitialization);
       Assert.AreEqual(returnedObject, result.O);
       Assert.AreEqual(returnedString, result.S);
 }
예제 #17
0
        public void TestIoc()
        {
            Assert.DoesNotThrow(
                () =>
                    {
                        var r = new Resolver(new[] {"CH."});
                        var mf = r.Resolve<IMemcachedFactory>();
                        var mc = mf.Create(MemcachedSettings.Settings.Server("localhost", 17325));

                        mc.Stats();
                    });
        }
예제 #18
0
 public void TestNoResolution() {
    Resolver<ContentType> resolver = new Resolver<ContentType>();
    resolver.Add(new ContentType("*.html", "text/html"));
    resolver.Add(new ContentType("*.jpg", "image/jpeg"));
    resolver.Add(new ContentType("/images/*", "image/jpeg"));
    resolver.Add(new ContentType("/log/**", "text/plain"));
    resolver.Add(new ContentType("*.exe", "application/octetstream"));
    resolver.Add(new ContentType("**.txt", "text/plain"));
    resolver.Add(new ContentType("/html/*", "text/html"));
    AssertEquals(7, resolver.Count);
    AssertEquals("text/plain", resolver.Resolve("README.txt").Value);
    AssertEquals(null, resolver.Resolve("README"));
 }
예제 #19
0
 public void TestResolvingInterfaceThrowsException()
 {
     Resolver r = new Resolver();
       Mock<IIocContainer> context = new Mock<IIocContainer>();
       context.Setup(a => a.Resolve(typeof(IDisposable), String.Empty)).Callback(() =>
       {
     throw new IocException();
       });
       try
       {
     r.ResolveDependency(typeof(IDisposable), context.Object);
     Assert.Fail();
       }
       catch (IocException) { }
 }
예제 #20
0
        static void Main(string[] args)
        {
            //Shopper shopper = new Shopper(new MasterCard());
            //shopper.Charge();

            // configuration
            var container = new Resolver();
            container.Register<Shopper, Shopper>();
            //container.Register<ICreditCard, Visa>();

            // get to the Shoppa!
            Shopper shopper = container.Resolve<Shopper>();
            shopper.Charge();

            Console.ReadKey();
        }
예제 #21
0
        public UCBatchDevanning(User user, string moduleType)
        {
            InitializeComponent();
            this.resolver = new Resolver();
            this.resolver.UserCode = user.Code;
            this.resolver.ModuleType = moduleType;
            this.TheClientMgr = new ClientMgrWSSoapClient();
            this.dataGridView1.AutoGenerateColumns = false;

            this.resolver.Transformers = null;
            this.resolver.Result = string.Empty;
            this.resolver.BinCode = string.Empty;
            this.resolver.Code = string.Empty;
            this.resolver.CodePrefix = string.Empty;
            this.cacheReceiptNotes = new List<ReceiptNote>();
        }
예제 #22
0
        public AGSGameWindow(IGameSettings settings, IGameWindowSize windowSize, Resolver resolver)
        {
            _windowSize = windowSize;
            _gameWindow = new GameWindow(settings.WindowSize.Width, settings.WindowSize.Height, 
                                         GraphicsMode.Default, settings.Title);
            
            var updater = new ContainerBuilder();
            updater.RegisterType<AGSInput>().SingleInstance().As<IInput>();
            updater.RegisterInstance(_gameWindow);
            updater.Update(resolver.Container);

            _updateFrameArgs = new FrameEventArgs();
            _renderFrameArgs = new FrameEventArgs();
            _gameWindow.UpdateFrame += onUpdateFrame;
            _gameWindow.RenderFrame += onRenderFrame;
        }
예제 #23
0
 public void TestIdentifiedParemeterResolution()
 {
     Resolver r = new Resolver();
       Mock<IIocContainer> context = new Mock<IIocContainer>();
       object returnedObject = new object();
       string basicString = "basicString";
       string returnedString = "returnedString";
       int returnedInt = 300;
       context.Setup((c) => c.Resolve(typeof(object), String.Empty)).Returns(returnedObject);
       context.Setup((c) => c.Resolve(typeof(string), String.Empty)).Returns(basicString);
       context.Setup((c) => c.Resolve(typeof(string), StandardIdentifierConstruction.TestingIdentifier)).Returns(returnedString);
       context.Setup((c) => c.Resolve(typeof(int), String.Empty)).Returns(returnedInt);
       StandardIdentifierConstruction result = (StandardIdentifierConstruction)r.ResolveDependency(typeof(StandardIdentifierConstruction), context.Object);
       Assert.AreEqual(returnedObject, result.O);
       Assert.AreEqual(returnedString, result.S);
       Assert.AreEqual(returnedInt, result.I);
 }
예제 #24
0
파일: TacnyDriver.cs 프로젝트: ggrov/tacny
    public Program ReParse(bool runResolver)
    {
      var errorReporter = new ConsoleErrorReporter();
      var module = new LiteralModuleDecl(new DefaultModuleDecl(), null);
      var builtIns = new BuiltIns();
      var parseErrors = new Errors(errorReporter);
      var errorCount = Parser.Parse(_snapshot.GetText(), _filename, _filename, module, builtIns, parseErrors);
      var errString = Main.ParseIncludes(module, builtIns, new List<string>(), parseErrors);
      if (errorCount != 0 || errString != null) return null;

      var program = new Program(_filename, module, builtIns, errorReporter);
      if (!runResolver) return program;

      var r = new Resolver(program);
      r.ResolveProgram(program);
      return errorReporter.Count(ErrorLevel.Error) == 0 ? program : null;
    }
        public void GetFiltersDelegatesToResolver() {
            // Arrange
            var context = new ControllerContext();
            var descriptor = new Mock<ActionDescriptor>().Object;
            var filter = new Filter(new Object(), FilterScope.Action, null);
            var provider = new Mock<IFilterProvider>(MockBehavior.Strict);
            var resolver = new Resolver<IEnumerable<IFilterProvider>> { Current = new[] { provider.Object } };
            var collection = new FilterProviderCollection(resolver);
           
            provider.Setup(p => p.GetFilters(context, descriptor)).Returns(new[] { filter });

            // Act
            IEnumerable<Filter> result = collection.GetFilters(context, descriptor);

            // Assert
            Assert.AreSame(filter, result.Single());
        }
예제 #26
0
파일: Interpreter.cs 프로젝트: ggrov/tacny
    /// <summary>
    /// 
    /// </summary>
    /// <param name="program"></param>
    /// <param name="target"></param>
    /// <param name="erd"></param>
    ///  only used this to report error, local errors which are genereaed during searching should not use this

    /// <param name="r"></param>
    /// <returns></returns>
    public static MemberDecl FindAndApplyTactic(Program program, MemberDecl target, ErrorReporterDelegate erd, Resolver r = null) {
      Contract.Requires(program != null);
      Contract.Requires(target != null);
      Stopwatch watch = new Stopwatch();
      watch.Start();
      _i = new Interpreter(program);
      _errorReporterDelegate = erd;

      var result = _i.EvalTacticApplication(target, r);

      var p = new Printer(Console.Out);
      p.PrintMembers(new List<MemberDecl>() { result }, 0, "");

      watch.Stop();
      Console.WriteLine("Time Used: " + watch.Elapsed.TotalSeconds.ToString());

      _errorReporterDelegate = null;
      return result;
    }
예제 #27
0
 public UCBase(User user, string moduleType)
 {
     InitializeComponent();
     this.resolver = new Resolver();
     this.resolver.UserCode = user.Code;
     this.resolver.ModuleType = moduleType;
     this.gvHuList.AutoGenerateColumns = false;
     this.gvList.AutoGenerateColumns = false;
     this.TheClientMgr = new ClientMgrWSSoapClient();
     this.lblMessage.Text = string.Empty;
     this.enableCache = moduleType == BusinessConstants.TRANSFORMER_MODULE_TYPE_PICKLIST
                     || moduleType == BusinessConstants.TRANSFORMER_MODULE_TYPE_RECEIVE
                     //|| moduleType == BusinessConstants.TRANSFORMER_MODULE_TYPE_STOCKTAKING
                     ;
     if (this.enableCache)
     {
         this.originalResolver = new Resolver();
     }
     this.timerCtrl = new Timer();
     this.timerCtrl.Tick += new System.EventHandler(this.TimerCtrl_Tick);
     this.InitialAll();
 }
예제 #28
0
        public static bool Evaluate(Session session, string condition)
        {
            bool result = false;

            //			try
            //			{
                Resolver resolver = new Resolver (session);
                resolver.Parse (condition);
                result = (bool)resolver.Result;
            //				Console.WriteLine (condition);
            //				result = (bool)Evaluator.Evaluate (Test (session, condition) +";");
            //				result = (bool)Resolver.ParseString (session, condition);
            //				result = (bool)Resolver.
            //			}
            //			catch
            //			{
            //				throw new SorentoLib.Exceptions.RenderException ("EVALUATION FAILED");
            //				SorentoLib.Services.Logging.LogDebug ("Condition evaluation failed: "+ e);
            //			}

            return result;
        }
예제 #29
0
 public UCOnline(User user, string moduleType)
 {
     InitializeComponent();
     this.resolver = new Resolver();
     this.resolver.UserCode = user.Code;
     this.resolver.ModuleType = moduleType;
     this.maxRow = Convert.ToInt32(ConfigurationSettings.AppSettings["ScanOnline_MaxRow"]);
     this.dt = new DataTable();
     this.lblmessage.Text = string.Empty;
     if (moduleType == BusinessConstants.TRANSFORMER_MODULE_TYPE_ONLINE)
     {
         this.btnOnline.Text = "生产上线";
         this.lblWO.Text = "工单号";
         this.gvWODetail.Columns["WONo"].HeaderText = "工单号";
     }
     else if (moduleType == BusinessConstants.TRANSFORMER_MODULE_TYPE_PICKLISTONLINE)
     {
         this.btnOnline.Text = "拣货上线";
         this.lblWO.Text = "拣货单";
         this.gvWODetail.Columns["WONo"].HeaderText = "拣货单";
     }
 }
예제 #30
0
 public EvaluationWidget()
 {
     var interpreter = new Interpreter(value => readEvalPrintLoopView.Print(value.ToString()));
     var scope = new Scope();
     var resolver = new Resolver(scope, (type, expression) => {
         if(type != typeof(void)) {
             expression(interpreter);
         }
     });
     var context = new CompilationContext();
     var driver = new Driver((indentation, syntax) => syntax(resolver), context);
     var scrolledWindow = new ScrolledWindow();
     readEvalPrintLoopView = new ReadEvalPrintLoopView(text => {
         var column = 0;
         foreach(var character in text) {
             driver.Tokenize(new Character(character, new Location(null, 0, column)));
             column++;
         }
         driver.Tokenize(new Character('\n', new Location(null, 0, column)));
     });
     scrolledWindow.Add(readEvalPrintLoopView);
     PackStart(scrolledWindow);
     ShowAll();
 }