本文整理汇总了C#中AppContext类的典型用法代码示例。如果您正苦于以下问题:C# AppContext类的具体用法?C# AppContext怎么用?C# AppContext使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。
AppContext类属于命名空间,在下文中一共展示了AppContext类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。
示例1: ReportForm
public ReportForm()
{
_db = new AppContext();
_fieldRepository = new InterpolatedFieldRepository(_db);
InitializeComponent();
}
示例2: Start
public void Start()
{
AppContext app = new AppContext();
app.AddObject<IMessageOutput>(this);
_comm = new CommunicationStarter(app);
_comm.Connect();
}
示例3: ManageCustomersForm
public ManageCustomersForm()
{
InitializeComponent();
_db = new AppContext();
_customerRepository = new CustomerRepository(_db);
_searchCustomer = new Repository.Models.Customer();
}
示例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();
}
示例5: ReportLogoControl
public ReportLogoControl()
{
InitializeComponent();
_db = new AppContext();
_settingRepository = new ReportSettingRepository(_db);
}
示例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;
}
}
示例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;
}
示例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;
}
示例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));
}
}
示例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 { }
}
示例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));
}
示例12: IgnoreFieldsControl
public IgnoreFieldsControl()
{
_db = new AppContext();
_preferenceRepository = new AppPreferencesRepository(_db);
InitializeComponent();
}
示例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");
}
示例14: RangeRulesControl
public RangeRulesControl()
{
_db = new AppContext();
_preferenceRepository = new AppPreferencesRepository(_db);
InitializeComponent();
}
示例15: FileReaderForm
public FileReaderForm()
{
_db = new AppContext();
_preferenceRepository = new AppPreferencesRepository(_db);
rangeList = _preferenceRepository.GetFieldRangeList();
InitializeComponent();
}