當前位置: 首頁>>代碼示例>>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;未經允許,請勿轉載。