当前位置: 首页>>代码示例>>C#>>正文


C# AppContext类代码示例

本文整理汇总了C#中AppContext的典型用法代码示例。如果您正苦于以下问题:C# AppContext类的具体用法?C# AppContext怎么用?C# AppContext使用的例子?那么, 这里精选的类代码示例或许可以为您提供帮助。


AppContext类属于命名空间,在下文中一共展示了AppContext类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。

示例1: ReportForm

        public ReportForm()
        {
            _db = new AppContext();
            _fieldRepository = new InterpolatedFieldRepository(_db);

            InitializeComponent();
        }
开发者ID:shoaib-ijaz,项目名称:geosoft,代码行数:7,代码来源:ReportForm.cs

示例2: Start

 public void Start()
 {
     AppContext app = new AppContext();
     app.AddObject<IMessageOutput>(this);
     _comm = new CommunicationStarter(app);
     _comm.Connect();
 }
开发者ID:scrato,项目名称:IDD_Test,代码行数:7,代码来源:Program.cs

示例3: ManageCustomersForm

 public ManageCustomersForm()
 {
     InitializeComponent();
     _db = new AppContext();
     _customerRepository = new CustomerRepository(_db);
     _searchCustomer = new Repository.Models.Customer();
 }
开发者ID:shoaib-ijaz,项目名称:geosoft,代码行数:7,代码来源:ManageCustomersForm.cs

示例4: AppContext

        public AppContext(string filepath)
        {
            Context = this;
            if (Settings.Default.RecentFileList == null)
            {
                Settings.Default.RecentFileList = new StringCollection();
                Settings.Default.Save();
            }

            var diagramForm = new DiagramForm();

            MainForm = diagramForm;
            diagramForm.Show();
            if (string.IsNullOrEmpty(filepath))
            {
                LoadLastFile(diagramForm);
            }
            else
            {
                try
                {
                    diagramForm.OpenFileByPath(filepath);
                }
                catch (Exception exception)
                {
                    MessageBox.Show(string.Format("{0}:{1}{2}", DesignerResources.FileCouldntBeOpened, Environment.NewLine, exception.Message), DesignerResources.Error, MessageBoxButtons.OK, MessageBoxIcon.Error);
                }
            }
            diagramForm.Focus();
        }
开发者ID:Bruhankovi4,项目名称:Emotyper,代码行数:30,代码来源:AppContext.cs

示例5: ReportLogoControl

        public ReportLogoControl()
        {
            InitializeComponent();

            _db = new AppContext();
            _settingRepository = new ReportSettingRepository(_db);
        }
开发者ID:shoaib-ijaz,项目名称:geosoft,代码行数:7,代码来源:ReportLogoControl.cs

示例6: CreateDatabse

        public static bool CreateDatabse()
        {
            try
            {
                if (!Directory.Exists(DatabaseDirectory))
                {
                    Directory.CreateDirectory(DatabaseDirectory);
                }

                AppContext db = new AppContext();
                db.Database.CreateIfNotExists();

                if (db.Database.Exists())
                {
                    Database.SetInitializer<AppContext>(new AppContextInitializer());
                    return true;
                }

                return false;
            }
            catch (Exception ex)
            {
                throw ex;
            }
        }
开发者ID:shoaib-ijaz,项目名称:geosoft,代码行数:25,代码来源:Connection.cs

示例7: AuthenticateUser

        public bool AuthenticateUser(string username, string password, UserTypeEnum userType)
        {
            LoggedUser = null;
            UserType = null;

            AppContext ctx = new AppContext();

            switch (userType)
            {
                case UserTypeEnum.Administrator:
                    AdministratorRepository adminRepo = new AdministratorRepository(new AppContext());
                    LoggedUser = unitOfWork.AdminRepository.GetByUsername(username);
                    break;
                case UserTypeEnum.Student:
                    StudentRepository studentRepo = new StudentRepository(new AppContext());
                    LoggedUser = unitOfWork.StudentRepository.GetByUsername(username);
                    break;
                case UserTypeEnum.Teacher:
                    TeacherRepository teacherRepo = new TeacherRepository(new AppContext());
                    LoggedUser = unitOfWork.TeacherRepository.GetByUsername(username);
                    break;
            }

            if (LoggedUser != null)
            {
                if (PasswordHasher.Equals(password, LoggedUser.Salt, LoggedUser.Hash))
                {
                    UserType = userType;
                    return true;
                }
                LoggedUser = null;
            }

            return false;
        }
开发者ID:bobi95,项目名称:UniSystemMVC,代码行数:35,代码来源:AuthenticationService.cs

示例8: GetOne

        public static MvcContext GetOne( IMember objOwner, int appId )
        {
            IWebContext webContext = MockWebContext.New( 1, "http://localhost/", new System.IO.StringWriter() );

            MvcContext ctx = new MvcContext( webContext );

            // route
            Route route = new wojilu.Web.Mvc.Routes.Route();
            route.setAppId( appId ); // 为了让生成的link链接中有appId,必须设置此项
            ctx.utils.setRoute( route );

            // viewer: 某些地方需要判断viewer
            ViewerContext viewer = new ViewerContext();
            viewer.obj = new User();
            ctx.utils.setViewerContext( viewer );

            // owner
            OwnerContext owner = new OwnerContext();
            owner.Id = objOwner.Id;
            owner.obj = objOwner;
            ctx.utils.setOwnerContext( owner );

            // app
            IAppContext app = new AppContext();
            app.Id = appId;
            app.obj = BlogApp.findById( appId );
            app.setAppType( typeof( BlogApp ) ); // 如果要使用alang语言包,必须设置此项
            ctx.utils.setAppContext( app );

            return ctx;
        }
开发者ID:LeoLcy,项目名称:cnblogsbywojilu,代码行数:31,代码来源:MockContext.cs

示例9: Setup

        public void Setup()
        {
            using (FullInputContext inputcontext = new FullInputContext(""))
            {
                _appContext = new AppContext(TestConfig.GetConfig().GetRipleyServerPath());
                _siteOptionList = new SiteOptionList();
                _siteOptionList.CreateFromDatabase(inputcontext.ReaderCreator, inputcontext.dnaDiagnostics);
            }
            
            DnaTestURLRequest request = new DnaTestURLRequest("haveyoursay");
            request.SetCurrentUserNormal();
            IInputContext inputContext = DnaMockery.CreateDatabaseInputContext();
            using (IDnaDataReader dataReader = inputContext.CreateDnaDataReader(""))
            {
                SetSiteID(dataReader, "h2g2");

                _includeContentFromOtherSites = _siteOptionList.GetValueBool(_siteId, "PersonalSpace", "IncludeContentFromOtherSites");

                //Create a post on h2g2
                SetForumID(dataReader);
                request = new DnaTestURLRequest("h2g2");
                request.SetCurrentUserNormal();
                int id = request.CurrentUserID;
                request.RequestPage("AddThread?subject=test&body=blahblah&post=1&skin=purexml&forum=" + Convert.ToString(_forumId));

                //Create a post on have your say.
                SetSiteID(dataReader, "haveyoursay");
                SetForumID(dataReader);
                request = new DnaTestURLRequest("haveyoursay");
                request.SetCurrentUserNormal();
                request.RequestPage("AddThread?subject=test&body=blahblah&post=1&skin=purexml&forum=" + Convert.ToString(_forumId));
            }
        }
开发者ID:rocketeerbkw,项目名称:DNA,代码行数:33,代码来源:UserPageTests.cs

示例10: DeOpsMutex

        public DeOpsMutex(AppContext context, string[] args)
        {
            try
            {
                string name = "DeOps" + Application.ProductVersion;

                TheMutex = new Mutex(true, name, out First);

                string objectName = "SingleInstanceProxy";
                string objectUri = "ipc://" + name + "/" + objectName;

                if (First)
                {
                    IpcChannel = new IpcServerChannel(name);
                    ChannelServices.RegisterChannel(IpcChannel, false);
                    RemotingConfiguration.RegisterWellKnownServiceType(typeof(IpcObject), objectName, WellKnownObjectMode.Singleton);

                    IpcObject obj = new IpcObject();
                    obj.NewInstance += context.SecondInstanceStarted;

                    RemotingServices.Marshal(obj, objectName);
                }

                else
                {
                    IpcChannel = new IpcClientChannel();
                    ChannelServices.RegisterChannel(IpcChannel, false);

                    IpcObject obj = Activator.GetObject(typeof(IpcObject), objectUri) as IpcObject;

                    obj.SignalNewInstance(args);
                }
            }
            catch { }
        }
开发者ID:RoelofSol,项目名称:DeOps,代码行数:35,代码来源:Startup.cs

示例11: Login

        public async Task<ActionResult> Login(LoginModel model)
        {
            if (!ModelState.IsValid)
            {
                return View(model);
            }

            var appContext = new AppContext();
            var user = await appContext.Users.Find(x => x.Email == model.Email).SingleOrDefaultAsync();
            if (user == null)
            {
                ModelState.AddModelError("Email", "Email address has not been registered.");
                return View(model);
            }

            var claims = new[]
                {
                    new Claim(ClaimTypes.Name, user.Name),
                    new Claim(ClaimTypes.Email, user.Email)
                };
            var identity = new ClaimsIdentity(claims, "ApplicationCookie");

            var context = Request.GetOwinContext();
            var authManager = context.Authentication;

            authManager.SignIn(identity);

            return Redirect(GetRedirectUrl(model.ReturnUrl));
        }
开发者ID:hperantunes,项目名称:simple-ideas-csharp,代码行数:29,代码来源:AccountController.cs

示例12: IgnoreFieldsControl

        public IgnoreFieldsControl()
        {
            _db = new AppContext();
            _preferenceRepository = new AppPreferencesRepository(_db);

            InitializeComponent();
        }
开发者ID:shoaib-ijaz,项目名称:geosoft,代码行数:7,代码来源:IgnoreFieldsControl.cs

示例13: GetAvatar

        public ActionResult GetAvatar(int size)
        {
            string uid = Session["currentUserId"].ToString();
            AccountModel user = null;
            byte[] avatar = null;

            using (var db = new AppContext())
            {
                user = db.Accounts.Where(a => a.WeiboId == uid).ToList().First();
            }

            using (var client = new WebClient())
            {
                switch (size)
                {
                    case 50:
                        avatar = client.DownloadData(user.Avatar50Url);
                        break;
                    case 180:
                    default:
                        avatar = client.DownloadData(user.Avatar180Url);
                        break;
                }
            }

            return File(avatar, "image/jpeg");
        }
开发者ID:JasonSun,项目名称:Lookback,代码行数:27,代码来源:AccountController.cs

示例14: RangeRulesControl

        public RangeRulesControl()
        {
            _db = new AppContext();
            _preferenceRepository = new AppPreferencesRepository(_db);

            InitializeComponent();
        }
开发者ID:shoaib-ijaz,项目名称:geosoft,代码行数:7,代码来源:RangeRulesControl.cs

示例15: FileReaderForm

 public FileReaderForm()
 {
     _db = new AppContext();
     _preferenceRepository = new AppPreferencesRepository(_db);
     rangeList = _preferenceRepository.GetFieldRangeList();
     InitializeComponent();
 }
开发者ID:shoaib-ijaz,项目名称:geosoft,代码行数:7,代码来源:FileReaderForm.cs


注:本文中的AppContext类示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。