本文整理汇总了C#中UserContext.GetRepository方法的典型用法代码示例。如果您正苦于以下问题:C# UserContext.GetRepository方法的具体用法?C# UserContext.GetRepository怎么用?C# UserContext.GetRepository使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类UserContext
的用法示例。
在下文中一共展示了UserContext.GetRepository方法的1个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。
示例1: connect
private void connect()
{
// Validate 0 < port < 65536
if (Options.Port < 1 || Options.Port > 65535)
{
throw new ArgumentOutOfRangeException("port", Options.Port,
"SAS metadata server port number must be in the range 1...65535.");
}
// Get an object factory and make a connection to the SAS metadata server connection.
if (Options.Verbose)
{
Console.WriteLine("Attempting to connect to SAS metadata server {0}:{1} as user '{2}'.",
Options.Host, Options.Port, Options.User);
}
Login login;
// TODO: support IWA with new option that leaves login as null.
login = new Login(Options.User, Options.Password, Options.AuthDomain);
try
{
userContext = new UserContext();
userContext.SetOmrCredentials(login, Options.Host, Options.Port);
Repository repository = userContext.GetRepository();
iomi = (SASOMI.IOMI)repository.IOmi;
if (Options.Verbose)
{
Console.WriteLine("Successfully connected to SAS metadata server as '{0}' ({1})",
userContext.GetUserName(), userContext.ResolvedIdentity);
}
}
catch (UserContextException)
{
// Log the connection failure and rethrow (to be handled higher up).
Console.WriteLine("ERROR: Failed to connect to the SAS metadata server.");
throw;
}
}