Пример #1
0
        public static void Regist(VoidFunc mvcNormalInit, Type httpErrorControllerType, Assembly webAssembly)
        {
            //AddProtableMessageHandler();
            Exception nhibernateException = null;
            mvcNormalInit();
            try
            {
                NHConfig.Instance.Regist(); //初始化NH配置
            }
            catch (Exception ex)
            {
                LogManager.GetLogger(typeof(MvcWebConfig)).Fatal("nhibernate mapping error.", ex);
                nhibernateException = ex;
            }

            NHibernateMvcRegister.Regist(); //修改MVC ModelHandler等配置
            ExtenderModelType();

            //
            GlobalConfiguration.Configuration.DependencyResolver = new CastleDependcyResolver();

            //新的Attribute,用于JquerUI spinner控件一起用
            DataAnnotationsModelValidatorProvider.RegisterAdapter(typeof(JqStepAttribute),
                typeof(StepAttributeAdapter));

            //把ControllerFactory和castle联系起来
            ChangeControllerFacotry(httpErrorControllerType, webAssembly);
            //Web MemberShip的加密方法

            User.ValidateUserPolicy = new WebValidateUserPolicy(Membership.Provider);

            //加入Assembly合并模块是,插入到第二为,因为第一位是ReferenceFactory
            SeajsModuleFactory.Instance.Add(new CombineModuleAsssemblyFactory(), 1);
            SeajsModuleBundleMessageHandle.HandlAllBundle();
        }
Пример #2
0
        public ParseRule(string regex, VoidFunc<Match> parseAction)
        {
            ArgumentValidator.ThrowIfNullOrEmpty(regex, "regex");
            ArgumentValidator.ThrowIfNull(parseAction, "parseAction");

            this.m_regex = new Regex(regex, RegexOptions.IgnorePatternWhitespace | RegexOptions.Compiled | RegexOptions.ExplicitCapture);
            this.m_parseAction = parseAction;
        }
Пример #3
0
 internal HighlightedOutputWriter(ICodeFormatter codeFormatter, bool asynchrounous)
 {
     this.m_windows = new Queue<InputWindow>(2);
     this.m_modesQueue = new Queue<List<KeyValuePair<int, HighlightMode>>>(2);
     this.m_codeFormatter = codeFormatter;
     this.m_posCurrent = 0;
     this.m_drainModesQueue = this.DrainModesQueue;
     this.m_asynchrounous = asynchrounous;
 }
Пример #4
0
        public static void Do(VoidFunc func, int msDelay)
        {
            Timer delayTimer = new Timer();
            delayTimer.Tag = func;

            delayTimer.Tick += new EventHandler(DelayHook);

            delayTimer.Interval = msDelay;
            delayTimer.Start();
        }
		public static void CheckAuthentication(VoidFunc init, VoidFunc close)
		{
			SettingsManager.ForceLogin = true;

			if (TpAuthenticationManager.Instance.IsAuthenticatedWithLoginForm)
			{
				init();
			}
			else
			{
				close();
			}
		}
Пример #6
0
        public SlidingWindowReader(TextReader reader)
        {
            ArgumentValidator.ThrowIfNull(reader, "reader");

            this.m_buffer = new char[WindowSize + 250];
            this.m_readBlockDelegate = reader.ReadBlock;
            this.m_queueMoreWindows = this.QueueMoreWindows;
            this.m_lineEnds = new List<int>((WindowSize + CntSafetyMargin)/40);
            this.m_inputWindowQueue = new Queue<InputWindow>(4);
            this.m_windowIsReady = new ManualResetEvent(false);
            this.m_windowBuilder = new StringBuilder(4 + CntSafetyMargin + 256);

            this.m_readBlockResult = this.m_readBlockDelegate.BeginInvoke(this.m_buffer, 0, WindowSize, null, null);
            this.m_queueMoreWindowsResult = this.m_queueMoreWindows.BeginInvoke(null, null);

            this.AdvanceWindow();
        }
	static int Main ()
	{
		int y = 0;
		int r;
		
		//
		// The following tests body-style lambda
		//
		increment = (int x) => { return x + 1; };
		r = increment (4);
		Console.WriteLine ("Should be 5={0}", r);
		if (r != 5)
			return 1;

		//
		// This tests the body of a lambda being an expression
		//
		func = (int x) => x + 1;
		r = func (10);
		Console.WriteLine ("Should be 11={0}", r);
		if (r != 11)
			return 2;
		
		//
		// The following tests that the body is a statement
		//
		nothing = (int x) => { y = x; };
		nothing (10);
		Console.WriteLine ("Should be 10={0}", y);
		if (y != 10)
			return 3;

		nothing = (int x) => { new X (x); };
		nothing (314);
		if (instantiated_value != 314)
			return 4;
		
		Console.WriteLine ("All tests pass");
		return 0;
	}
Пример #8
0
        // For more information on Bundling, visit http://go.microsoft.com/fwlink/?LinkId=254725
        public static void RegisterBundles(BundleCollection bundles)
        {
            BundleTable.EnableOptimizations = false;

            OrnamentContext.Configuration.SetSeajsCombine(false);
            bundles.UseCdn = true;
            var registryParty = new VoidFunc<BundleCollection>[]
            {
                GlobalStyle,
                CodeStyle,
                Fx,
                RegistryCtrl,
                Comp,
                SeajsModules
            };

            foreach (var item in registryParty)
            {
                item.Invoke(bundles);
            }

            var manager = new ScriptsFolderManager();
            manager.RegisterBundles(bundles);
        }
		public static void CheckAuthentication(VoidFunc close)
		{
			CheckAuthentication(() => { }, close);
		}
Пример #10
0
 public void Create(IProjectDao dao)
 {
     var p = new Project(Product)
         {
             Name = Name,
         };
     dao.SaveOrUpdate(p);
     var _roleDao = OrnamentContext.Current.MemberShipFactory().CreateRoleDao();
     var addMethod = new VoidFunc<IPerformer[], Role>((performers, role) =>
         {
             _roleDao.SaveOrUpdate(role);
             _roleDao.Flush();
             foreach (IPerformer performer in performers)
             {
                 var member = (IMember)performer;
                 member.AddRole(role);
             }
         });
     addMethod(Testers, p.Tester);
     addMethod(Developers, p.Developer);
     addMethod(TesterManager, p.TestManager);
     addMethod(DeveloperManager, p.DeveloperManager);
 }
Пример #11
0
 public static extern int setOSCEvents(IntNPtrPassFunc RoundStart, IntFunc Countdown, IntFunc Holding, IntFunc HoldFail,
     VoidFunc Timeout, ThreeIntFunc ShapeCompleted, TwoIntFunc ShapeStatus, PlayerStatusFunc PlayerStatus);
Пример #12
0
        static void Main(string[] args)
        {
            SetUpOSCPort();

            logger = new Logger("./log/log.txt");

            AllocFunc allocGlobalFunc = new AllocFunc(Program.allocGlobal);
            TweetFunc TweetPictureDel = new TweetFunc(Program.TweetPicture); DontThrowOutMaDelegates.Add(TweetPictureDel);
            PtrPassFunc FullPictureDel = new PtrPassFunc(Program.SaveWholePicture); DontThrowOutMaDelegates.Add(FullPictureDel);
            PtrPassFunc SkeletonLogDel = new PtrPassFunc(Program.SkeletonLog); DontThrowOutMaDelegates.Add(SkeletonLogDel);
            int ret = setTweetback(allocGlobalFunc, TweetPictureDel, FullPictureDel,SkeletonLogDel);
            IntNPtrPassFunc RoundStartDel = new IntNPtrPassFunc(Program.RoundStart); DontThrowOutMaDelegates.Add(RoundStartDel);
            IntFunc CountdownDel = new IntFunc(Program.Countdown); DontThrowOutMaDelegates.Add(CountdownDel);
            IntFunc HoldingDel = new IntFunc(Program.Holding); DontThrowOutMaDelegates.Add(HoldingDel);
            IntFunc HoldFailDel = new IntFunc(Program.HoldingFail); DontThrowOutMaDelegates.Add(HoldFailDel);
            VoidFunc TimeoutDel = new VoidFunc(Program.Timeout); DontThrowOutMaDelegates.Add(TimeoutDel);
            ThreeIntFunc ShapeCompletedDel = new ThreeIntFunc(Program.ShapeCompleted); DontThrowOutMaDelegates.Add(ShapeCompletedDel);
            TwoIntFunc ShapeStatusDel = new TwoIntFunc(Program.ShapeStatus); DontThrowOutMaDelegates.Add(ShapeStatusDel);
            PlayerStatusFunc PlayerStatusDel = new PlayerStatusFunc(Program.PlayerStatus); DontThrowOutMaDelegates.Add(PlayerStatusDel);
            ret = setOSCEvents(RoundStartDel, CountdownDel, HoldingDel, HoldFailDel, TimeoutDel, ShapeCompletedDel, ShapeStatusDel, PlayerStatusDel);

            GameStart();

            Action KinectLoop = new Action(openKinectWindow);
            KinectLoop.BeginInvoke(null, null);

            bool run = true;

            //Console.WriteLine("Type -1 and press ENTER to start game.");

            while (run)
            {
                string input = Console.ReadLine();
                try
                {
                    int number = Convert.ToInt32(input);
                    numericCommand(number);
                    
                }
                catch
                {
                    //string commands.
                    switch (input)
                    {
                        case "s":
                            GameID++;
                            startGame(GameID,GameLength);
                            Console.WriteLine("Starting Game " + GameID);
                            break;
                        case "e":
                            endGame();
                            break;
                    }
                }
                input = "";

                //yes, this is an infinite loop. Behold!
            }

        }
Пример #13
0
        private void AddParsingRule(string regex, VoidFunc<Match> parseAction)
        {
            bool substituted;

            do {
                substituted = false;
                foreach (string substitution in m_regexSubstitutions.Keys) {
                    string newRegex = regex.Replace(substitution, m_regexSubstitutions[substitution]);
                    if (newRegex != regex) {
                        substituted = true;
                    }

                    regex = newRegex;
                }
            } while (substituted);

            ParseRule rule = new ParseRule(regex, parseAction);
            this.m_parseRules.Add(rule);
        }
Пример #14
0
 public static void InAMoment(VoidFunc func)
 {
     Do(func, 1);
 }