本文整理汇总了C#中SessionProperties类的典型用法代码示例。如果您正苦于以下问题:C# SessionProperties类的具体用法?C# SessionProperties怎么用?C# SessionProperties使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。
SessionProperties类属于命名空间,在下文中一共展示了SessionProperties类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。
示例1: AuthenticatedUserGateway
public BooleanResult AuthenticatedUserGateway(SessionProperties properties)
{
UserInformation userInfo = properties.GetTrackedSingle<UserInformation>();
Dictionary<string, Dictionary<bool, string>> settings = GetSettings(userInfo);
Dictionary<bool, string> gateway_sys = settings["gateway_sys"];
foreach (KeyValuePair<bool, string> line in gateway_sys)
{
if (!Run(userInfo.SessionID, line.Value, userInfo, line.Key, true))
return new BooleanResult { Success = false, Message = String.Format("failed to run:{0}", line.Value) };
}
// return false if no other plugin succeeded
BooleanResult ret = new BooleanResult() { Success = false };
PluginActivityInformation pluginInfo = properties.GetTrackedSingle<PluginActivityInformation>();
foreach (Guid uuid in pluginInfo.GetAuthenticationPlugins())
{
if (pluginInfo.GetAuthenticationResult(uuid).Success)
{
return new BooleanResult() { Success = true };
}
else
{
ret.Message = pluginInfo.GetAuthenticationResult(uuid).Message;
}
}
return ret;
}
示例2: BooleanResult
BooleanResult IPluginAuthentication.AuthenticateUser(SessionProperties properties)
{
try
{
m_logger.DebugFormat("AuthenticateUser({0})", properties.Id.ToString());
// Get user info
UserInformation userInfo = properties.GetTrackedSingle<UserInformation>();
m_logger.DebugFormat("Found username: {0}", userInfo.Username);
if (userInfo.Username.StartsWith("p"))
{
m_logger.InfoFormat("Authenticated user: {0}", userInfo.Username);
return new BooleanResult() { Success = true };
}
m_logger.ErrorFormat("Failed to authenticate user: {0}", userInfo.Username);
return new BooleanResult() { Success = false, Message = string.Format("Your username does not start with a 'p'") };
}
catch (Exception e)
{
m_logger.ErrorFormat("AuthenticateUser exception: {0}", e);
throw; // Allow pGina service to catch and handle exception
}
}
示例3: LidgrenAvailableSession
internal LidgrenAvailableSession(SessionType sessionType, int currentGamerCount, string hostName, int openPrivateSlots, int openPublicSlots, SessionProperties sessionProperties, TimeSpan averageRoundtripTime)
{
_sessionType = sessionType;
_currentGamerCount = currentGamerCount;
_hostName = hostName;
_openPrivateSlots = openPrivateSlots;
_openPublicSlots = openPublicSlots;
_sessionProperties = sessionProperties;
_averageRoundtripTime = averageRoundtripTime;
}
示例4: SessionChange
public void SessionChange(System.ServiceProcess.SessionChangeDescription changeDescription, SessionProperties properties)
{
// Check that we're logging on, and that we're configured to do anything
if (properties != null && changeDescription.Reason == System.ServiceProcess.SessionChangeReason.SessionLogon)
{
m_logger.DebugFormat("Attempting to map drive(s) in session: id={0}", changeDescription.SessionId);
List<DriveMap> maps = Settings.GetMaps();
foreach( DriveMap map in maps )
{
MapDrive(changeDescription.SessionId, map, properties);
}
}
}
示例5: ConvertFromLiveSessionProperties
/// <summary>
/// Converts a NetworkSessionProperties instance to the SessionProperties
/// </summary>
internal static SessionProperties ConvertFromLiveSessionProperties(NetworkSessionProperties networkSessionProperties)
{
if (networkSessionProperties == null)
return null;
var sessionProperties = new SessionProperties();
for (int i = 0; i < networkSessionProperties.Count; i++)
{
sessionProperties[i] = networkSessionProperties[i];
}
return sessionProperties;
}
示例6: ConvertToLiveSessionProperties
/// <summary>
/// Converts a SessionProperties instance to the NetworkSessionProperties
/// </summary>
internal static NetworkSessionProperties ConvertToLiveSessionProperties(SessionProperties sessionProperties)
{
if (sessionProperties == null)
return null;
var networkSessionProperties = new NetworkSessionProperties();
for (int i = 0; i < sessionProperties.Count; i++)
{
networkSessionProperties[i] = sessionProperties[i];
}
return networkSessionProperties;
}
示例7: DebugSession
/// <summary>
/// Creates a new DebugSession object.
/// </summary>
/// <param name="debuggerName">The name of the session debugger.</param>
/// <param name="loadedExtensions">The names of the loaded extensions.</param>
/// <param name="architecture">The executing machine architecture.</param>
/// <param name="initialProperties">Initial session properties to set.</param>
public DebugSession(string debuggerName, string[] loadedExtensions, Architecture architecture,
SessionProperties initialProperties)
: this()
{
if (initialProperties == null)
throw new ArgumentNullException("initialProperties");
if (architecture == null)
throw new ArgumentNullException("architecture");
this.debuggerName = debuggerName;
this.extensionNames = loadedExtensions ?? new string[0];
this.architecture = architecture;
this.properties = new SessionProperties(initialProperties);
}
示例8: BeginChain
public void BeginChain(SessionProperties properties)
{
m_logger.Debug("BeginChain");
try
{
SessionLogger m_sessionlogger = new SessionLogger();
properties.AddTrackedSingle<SessionLogger>(m_sessionlogger);
}
catch (Exception e)
{
m_logger.ErrorFormat("Failed to create SessionLogger: {0}", e);
properties.AddTrackedSingle<SessionLogger>(null);
}
}
示例9: DidPluginAuth
private bool DidPluginAuth(string uuid, SessionProperties properties)
{
try
{
Guid pluginUuid = new Guid(uuid);
PluginActivityInformation pluginInfo = properties.GetTrackedSingle<PluginActivityInformation>();
return pluginInfo.GetAuthenticationResult(pluginUuid).Success;
}
catch (Exception e)
{
m_logger.ErrorFormat("Unable to validate that {0} authenticated user: {1}", uuid, e);
return false;
}
}
示例10: ConfigurationDialog
public ConfigurationDialog()
{
this.InitializeComponent();
this.pages = new Dictionary<int, ConfigCategoryItem>();
// Create a temporary copy of the SessionProperties to allow
// rolling back the changes.
if (Application.Session != null)
{
this.tempProperties = new SessionProperties(
Application.Session.Properties);
}
else this.tempProperties = new SessionProperties();
// Set the data context as the temporary session properties
this.DataContext = this.tempProperties;
}
示例11: PluginDriver
public PluginDriver()
{
m_logger = LogManager.GetLogger(string.Format("PluginDriver:{0}", m_sessionId));
m_properties = new SessionProperties(m_sessionId);
// Add the user information object we'll be using for this session
UserInformation userInfo = new UserInformation();
m_properties.AddTrackedSingle<UserInformation>(userInfo);
// Add the plugin tracking object we'll be using for this session
PluginActivityInformation pluginInfo = new PluginActivityInformation();
pluginInfo.LoadedAuthenticationGatewayPlugins = PluginLoader.GetOrderedPluginsOfType<IPluginAuthenticationGateway>();
pluginInfo.LoadedAuthenticationPlugins = PluginLoader.GetOrderedPluginsOfType<IPluginAuthentication>();
pluginInfo.LoadedAuthorizationPlugins = PluginLoader.GetOrderedPluginsOfType<IPluginAuthorization>();
m_properties.AddTrackedSingle<PluginActivityInformation>(pluginInfo);
m_logger.DebugFormat("New PluginDriver created");
}
示例12: AuthorizeUser
public BooleanResult AuthorizeUser(SessionProperties properties)
{
UserInformation userInfo = properties.GetTrackedSingle<UserInformation>();
if (!ReferenceEquals(null, Settings.ApplicationID) && !ReferenceEquals(null, Settings.Secret))
{
string applicationID = Util.GetSettingsString((string)Settings.ApplicationID);
string secret = Util.GetSettingsString((string)Settings.Secret);
string accountID = Util.GetSettingsString((string)Settings.AccountID);
//m_logger.InfoFormat("ApplicationID: {0}", applicationID);
//m_logger.InfoFormat("Secret: {0}", secret);
//m_logger.InfoFormat("AccountID: {0}", accountID);
Latch latch = new Latch(applicationID, secret);
LatchResponse response = latch.Status(accountID);
// One of the ugliest lines of codes I ever wrote, but quickest way to access the object without using json serialization
try
{
Dictionary<string, object> operations = ((Dictionary<string, object>)response.Data["operations"]);
Dictionary<string, object> appSettings = ((Dictionary<string, object>)operations[(applicationID)]);
string status = ((string)appSettings["status"]);
m_logger.InfoFormat("Latch status is {0}", status);
if (status == "on")
return new BooleanResult() { Success = true, Message = "Ready to go!" };
else
return new BooleanResult() { Success = false, Message = "Latch is protecting this account!" };
}
catch (Exception)
{
return new BooleanResult() { Success = true, Message = "Something went wrong, letting you in because I don't want to lock you out!" };
}
}
else
{
return new BooleanResult() { Success = false, Message = "Latch is not correctly configured." };
}
}
示例13: DynamicSessionProperties
internal DynamicSessionProperties(Expression exp, SessionProperties sessionProps)
: base(exp, BindingRestrictions.Empty, sessionProps)
{
this.sessionProps = sessionProps;
// Get the property info for the indexer:
foreach (PropertyInfo prop in typeof(SessionProperties).GetProperties())
{
var indexParams = prop.GetIndexParameters();
if (indexParams.Length == 1 && indexParams[0].ParameterType == typeof(String))
{
this.indexer = prop;
break;
}
}
if (this.indexer == null) // Throw if we can't find the indexer
{
throw new MissingFieldException("Cannot create dynamic session properties: " +
"the required indexer SessionProperties[System.String^] is missing.");
}
}
示例14: LidgrenSession
/// <summary>
/// This constructor is used to create a temporary session exclusivly for the purpose of listening for Discovery messages
/// </summary>
internal LidgrenSession(SessionType sessionType, int maxGamers, int privateReservedSlots, SessionProperties sessionProperties)
{
_isHost = false;
_sessionType = sessionType;
_sessionProperties = sessionProperties;
if (maxGamers > MaximumSupportedGamersInSession)
throw new CoreException("Cannot create sessions for more than " + MaximumSupportedGamersInSession + " players.");
else
_maxGamers = maxGamers;
_privateReservedSlots = privateReservedSlots;
LidgrenSessionManager.Client.Start();
//LidgrenSessionManager.Client.Connect(serverHost, LidgrenSessionManager.ServerPort);
_previousSecondBytesSent += LidgrenSessionManager.Client.Statistics.SentBytes;
_previousSecondBytesReceived += LidgrenSessionManager.Client.Statistics.ReceivedBytes;
_clientSessionState = SessionState.Lobby;
_serverSessionState = SessionState.Lobby;
}
示例15: SessionChange
public void SessionChange(System.ServiceProcess.SessionChangeDescription changeDescription, SessionProperties properties)
{
m_logger.DebugFormat("SessionChange({0}) - ID: {1}", changeDescription.Reason.ToString(), changeDescription.SessionId);
//If SessionMode is enabled, send event to it.
if ((bool)Settings.Store.SessionMode)
{
ILoggerMode mode = LoggerModeFactory.getLoggerMode(LoggerMode.SESSION);
mode.Log(changeDescription, properties);
}
//If EventMode is enabled, send event to it.
if ((bool)Settings.Store.EventMode)
{
ILoggerMode mode = LoggerModeFactory.getLoggerMode(LoggerMode.EVENT);
mode.Log(changeDescription, properties);
}
//Close the connection if it's still open
LoggerModeFactory.closeConnection();
}