本文整理汇总了C#中UserContext类的典型用法代码示例。如果您正苦于以下问题:C# UserContext类的具体用法?C# UserContext怎么用?C# UserContext使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。
UserContext类属于命名空间,在下文中一共展示了UserContext类的20个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于我们的系统推荐出更棒的C#代码示例。
示例1: GetCommand
public ICommand GetCommand(CommandType commandType, UserContext userContext, ResourceType entityType, EntityMetadata entityMetadata, string membershipId)
{
if (entityType.Name == "CommandInvocation")
{
CommandType commandType1 = commandType;
switch (commandType1)
{
case CommandType.Create:
case CommandType.Read:
case CommandType.Delete:
{
return new GICommand(commandType, this.runspaceStore, entityType, userContext, membershipId);
}
case CommandType.Update:
{
throw new NotImplementedException();
}
default:
{
throw new NotImplementedException();
}
}
}
else
{
throw new NotImplementedException();
}
}
开发者ID:nickchal,项目名称:pash,代码行数:28,代码来源:GICommandManager.cs
示例2: OnReceive
private void OnReceive(UserContext context)
{
Console.WriteLine("Received Data From :" + context.ClientAddress);
string jsonString = context.DataFrame.ToString();
ParseIncoming(new AlchemySession(context), jsonString);
}
开发者ID:akurdyukov,项目名称:NancySelfHost,代码行数:7,代码来源:AlchemyWebSocketServer.cs
示例3: ProcessedRequestHandler
public static void ProcessedRequestHandler(object source, DataServiceProcessingPipelineEventArgs args)
{
TraceHelper.Current.DebugMessage("QuotaSystem.ProcessedRequestHandler entered");
if (args != null)
{
args.OperationContext.Trace();
}
UserContext userContext = new UserContext(CurrentRequestHelper.Identity, CurrentRequestHelper.Certificate);
if (DataServiceController.Current.IsRequestProcessingStarted(userContext))
{
try
{
DataServiceController.Current.SetRequestProcessingState(userContext, false);
UserDataCache.UserDataEnvelope userDataEnvelope = DataServiceController.Current.UserDataCache.Get(userContext);
using (userDataEnvelope)
{
userDataEnvelope.Data.Usage.RequestProcessed();
}
TraceHelper.Current.RequestProcessingEnd();
}
finally
{
DataServiceController.Current.UserDataCache.TryUnlockKey(userContext);
TraceHelper.Current.DebugMessage("QuotaSystem.ProcessedRequestHandler exited");
}
return;
}
else
{
TraceHelper.Current.DebugMessage("QuotaSystem.ProcessedRequestHandler IsRequestProcessingStarted returned false");
return;
}
}
开发者ID:nickchal,项目名称:pash,代码行数:33,代码来源:QuotaSystem.cs
示例4: ReceivedMsg
private void ReceivedMsg(UserContext context)
{
string message = context.DataFrame.ToString();
if (message.Contains("left"))
{
bool dblClick = false;
if (message.Contains("dbl"))
{
dblClick = true;
}
MouseController.MouseLeft(dblClick);
}
else if (message.Contains("right"))
{
MouseController.MouseRight();
}
else if (message.Contains("key"))
{
HandleKeyIn(message);
}
else
{
string move = context.DataFrame.ToString();
string[] XandY = move.Split(',');
int mX = Int32.Parse(XandY[0]);
int mY = Int32.Parse(XandY[1]);
int[] mousePos = MouseController.GetMousePosition();
mX = mousePos[0] + mX;
mY = mousePos[1] + mY;
MouseController.moveMouse(mX, mY);
}
}
开发者ID:jamest222,项目名称:MouseControl,代码行数:34,代码来源:Websocket.cs
示例5: SignIn
public virtual void SignIn(User user, bool createPersistentCookie) {
var now = DateTime.UtcNow.ToLocalTime();
var ticket = new FormsAuthenticationTicket(
1,
user.Username,
now,
now.Add(_expirationTimeSpan),
createPersistentCookie, user.Username,
FormsAuthentication.FormsCookiePath);
var encryptedTicket = FormsAuthentication.Encrypt(ticket);
var cookie = new HttpCookie(FormsAuthentication.FormsCookieName, encryptedTicket);
cookie.HttpOnly = true;
if (ticket.IsPersistent) {
cookie.Expires = ticket.Expiration;
}
cookie.Secure = FormsAuthentication.RequireSSL;
cookie.Path = FormsAuthentication.FormsCookiePath;
if (FormsAuthentication.CookieDomain != null) {
cookie.Domain = FormsAuthentication.CookieDomain;
}
_httpContext.Response.Cookies.Add(cookie);
_cachedUser = user;
var userContext = new UserContext { User = user };
foreach(var authenticationEventHandler in _authenticationEventHandlers) {
authenticationEventHandler.SignIn(userContext);
}
}
开发者ID:hsb0307,项目名称:Nut.NET,代码行数:33,代码来源:FormsAuthenticationService.cs
示例6: QuotaCheckAndUpdate
public bool QuotaCheckAndUpdate(UserContext userContext, UserQuota quota)
{
bool flag;
lock (this.syncObject)
{
if (this.CheckConcurrentRequestQuota(quota.MaxConcurrentRequests))
{
if (this.CheckRequestPerTimeSlotQuota(quota.MaxRequestsPerTimeSlot, quota.TimeSlotSize))
{
Usage usage = this;
usage.concurrentRequests = usage.concurrentRequests + 1;
this.requests.Increment(quota.TimeSlotSize);
TraceHelper.Current.UserQuotaSucceeded(userContext.Name);
TraceHelper.Current.DebugMessage(string.Concat("Usage.QuotaCheckAndUpdate called. Concurrent requests = ", this.concurrentRequests));
flag = true;
}
else
{
DataServiceController.Current.QuotaSystem.UserQuotaViolation.Increment();
TraceHelper.Current.UserQuotaViolation(userContext.Name, "MaxRequestPerTimeSlot quota violation");
DataServiceController.Current.PerfCounters.UserQuotaViolationsPerSec.Increment();
flag = false;
}
}
else
{
DataServiceController.Current.QuotaSystem.UserQuotaViolation.Increment();
TraceHelper.Current.UserQuotaViolation(userContext.Name, "MaxConcurrentRequest quota violation");
DataServiceController.Current.PerfCounters.UserQuotaViolationsPerSec.Increment();
flag = false;
}
}
return flag;
}
开发者ID:nickchal,项目名称:pash,代码行数:34,代码来源:Usage.cs
示例7: OnDisconnect
public static void OnDisconnect(UserContext context)
{
Console.WriteLine("Client Disconnection From : " + context.ClientAddress);
if (presenter != null && presenter.ClientAddress == context.ClientAddress)
{
Console.WriteLine("Oh shit we lost the tv.");
// Reset everything.
// Fuck this whole thing needs to be rewritten
presenter = null;
acceptingPlayers = true;
players.ForEach(x => x.Send(JsonConvert.SerializeObject(new { Type = CommandType.End }), false, true));
players.Clear();
}
//throw new Exception("Yeah nar we don't handle disconnects");
/*var remove = players.FirstOrDefault(x => x.ClientAddress.Equals(context.ClientAddress));
if (remove != null)
{
players.Remove(remove);
Console.WriteLine(context.ClientAddress);
}*/
}
开发者ID:samshute,项目名称:CultSpiders,代码行数:25,代码来源:Program.cs
示例8: OnReceive
public static void OnReceive(UserContext context)
{
string data = string.Empty;
try
{
mCounter++;
data = context.DataFrame.ToString();
Console.WriteLine("Data Received From [" + context.ClientAddress.ToString() + "] - " + data + " (" + data.Length.ToString() + " - " + mCounter.ToString() + ")");
}
catch (Exception ex)
{
Console.WriteLine(ex.Message.ToString());
}
//context.Send("Hello2");
if (data == "PING")
{
context.Send("PONG!");
}
else if (data == "abc")
{
string sendData = new string('x', 32768);
context.Send(sendData);
}
else
{
//context.Send("Echo back: " + data);
}
}
开发者ID:vbguyny,项目名称:Alchemy-Websockets,代码行数:30,代码来源:Program.cs
示例9: PresentationRepository
public PresentationRepository()
{
this.context = new UserContext();
this.dbSet = context.Set<PresentationModel>();
this.dbSetTag = context.Set<Tag>();
this.dbRatings = context.Set<RatingsModel>();
}
开发者ID:sensato-wise,项目名称:presentations-net,代码行数:7,代码来源:PresentationRepository.cs
示例10: exportUploadSettingsToXml
public static XElement exportUploadSettingsToXml(this IUserSettings settings, UserContext context)
{
return new XElement("uploadSettings",
new XElement("maxWidth", settings.maxUploadImageWidth),
new XElement("maxHeight", settings.maxUploadImageHeight)
);
}
开发者ID:penartur,项目名称:FLocal,代码行数:7,代码来源:IUserSettings.cs
示例11: ReferredEntityInstance
public ReferredEntityInstance(DSResource resource, UserContext userContext, ResourceType type, EntityMetadata metadata, string membershipId)
{
this.userContext = userContext;
this.resourceType = type;
this.metadata = metadata;
this.membershipId = membershipId;
this.resource = resource;
}
开发者ID:nickchal,项目名称:pash,代码行数:8,代码来源:ReferredEntityInstance.cs
示例12: SaveOrUpdateUser
public void SaveOrUpdateUser(User user)
{
using (var db = new UserContext())
{
db.Users.AddOrUpdate(user);
db.SaveChanges();
}
}
开发者ID:VolodymyrGladchenko,项目名称:Testing-Task,代码行数:8,代码来源:DataAccess.cs
示例13: Build
public void Build(Microsoft.Management.Odata.Schema.Schema logicalSchema, Microsoft.Management.Odata.Schema.Schema userSchema, UserContext userContext, string membershipId)
{
Envelope<PSRunspace, UserContext> envelope = this.runspaceStore.Borrow(userContext, membershipId);
using (envelope)
{
this.Build(logicalSchema, userSchema, envelope.Item.Runspace);
}
}
开发者ID:nickchal,项目名称:pash,代码行数:8,代码来源:PSSchemaBuilder.cs
示例14: OnDisconnect
public static void OnDisconnect(UserContext context)
{
Console.WriteLine("Client Disconnected : " + context.ClientAddress.ToString());
// Remove the connection Object from the thread-safe collection
UserContext uc;
UserContexts.TryRemove(context.ClientAddress.ToString(), out uc);
}
开发者ID:vbguyny,项目名称:Alchemy-Websockets,代码行数:8,代码来源:Program.cs
示例15: OnConnect
/// <summary>
/// Event fired when a client connects to the Alchemy Websockets server instance.
/// Adds the client to the online users list.
/// </summary>
/// <param name="context">The user's connection context</param>
public static void OnConnect(UserContext context)
{
Console.WriteLine("Client Connection From : " + context.ClientAddress);
var me = new User {Context = context};
OnlineUsers.TryAdd(me, String.Empty);
}
开发者ID:simboyz,项目名称:Alchemy-Websockets-Example,代码行数:13,代码来源:Program.cs
示例16: OnDisconnect
static void OnDisconnect(UserContext context)
{
lock (ActiveContexts)
{
Write("Disconnected", context);
ActiveContexts.Remove(context);
}
}
开发者ID:epicvrvs,项目名称:Voiddekk,代码行数:8,代码来源:Program.cs
示例17: PlayerController
public PlayerController(
IPlayerQueries playerQueries, IPlayerCommands playerCommands, IPlayerActions playerActions, UserContext userContext)
: base(userContext)
{
_playerQueries = playerQueries;
_playerCommands = playerCommands;
_playerActions = playerActions;
}
开发者ID:kimx,项目名称:Examples,代码行数:9,代码来源:PlayerController.cs
示例18: OnConnected
public static void OnConnected(UserContext context)
{
Utilities.Logger.Debug("New websocket connection : " + context.ClientAddress.ToString());
var client = new WebClientConnection(context);
lock (Clients)
{
Clients.Add(new WebClientConnection(context));
}
}
开发者ID:Emudofus,项目名称:ArkaliaCore,代码行数:9,代码来源:WebServer.cs
示例19: OnConnect
static void OnConnect(UserContext context)
{
lock (ActiveContexts)
{
Write("Connected", context);
ActiveContexts.Add(context);
new Thread(() => HandleClient(context)).Start();
}
}
开发者ID:epicvrvs,项目名称:Voiddekk,代码行数:9,代码来源:Program.cs
示例20: CreateRole
public override void CreateRole(string roleName)
{
var newRole = new Role() { Name = roleName };
using (var context = new UserContext())
{
context.Roles.Add(newRole);
context.SaveChanges();
}
}
开发者ID:zzhukanton,项目名称:BSU.ASP1501.Project,代码行数:9,代码来源:CustomRoleProvider.cs
注:本文中的UserContext类示例整理自Github/MSDocs等源码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。 |
请发表评论