本文整理汇总了C#中ServiceContext类的典型用法代码示例。如果您正苦于以下问题:C# ServiceContext类的具体用法?C# ServiceContext怎么用?C# ServiceContext使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。
ServiceContext类属于命名空间,在下文中一共展示了ServiceContext类的20个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于我们的系统推荐出更棒的C#代码示例。
示例1: ServiceBusQueueCommunicationListener
/// <summary>
/// Creates a new instance, using the init parameters of a <see cref="StatefulService"/>
/// </summary>
/// <param name="receiver">(Required) Processes incoming messages.</param>
/// <param name="context">(Optional) The context that was used to init the Reliable Service that uses this listener.</param>
/// <param name="serviceBusQueueName">The name of the monitored Service Bus Queue</param>
/// <param name="serviceBusSendConnectionString">(Optional) A Service Bus connection string that can be used for Sending messages.
/// (Returned as Service Endpoint.) When not supplied, an App.config appSettings value with key 'Microsoft.ServiceBus.ConnectionString.Receive'
/// is used.</param>
/// <param name="serviceBusReceiveConnectionString">(Optional) A Service Bus connection string that can be used for Receiving messages.
/// When not supplied, an App.config appSettings value with key 'Microsoft.ServiceBus.ConnectionString.Receive'
/// is used.</param>
public ServiceBusQueueCommunicationListener(IServiceBusMessageReceiver receiver, ServiceContext context, string serviceBusQueueName, string serviceBusSendConnectionString = null, string serviceBusReceiveConnectionString = null)
: base(receiver, context, serviceBusSendConnectionString, serviceBusReceiveConnectionString)
{
if (string.IsNullOrWhiteSpace(serviceBusQueueName)) throw new ArgumentOutOfRangeException(nameof(serviceBusQueueName));
ServiceBusQueueName = serviceBusQueueName;
}
开发者ID:yonglehou,项目名称:ServiceFabric.ServiceBus,代码行数:19,代码来源:ServiceBusQueueCommunicationListener.cs
示例2: CreateDomainManager
public void CreateDomainManager()
{
var context = new ServiceContext();
_domainManager = new DomainManager();
context.Add(_domainManager);
context.ServiceManager.StartServices();
}
开发者ID:nahugrau,项目名称:nunit,代码行数:7,代码来源:DomainManagerTests.cs
示例3: CreateServiceContext
public void CreateServiceContext()
{
var services = new ServiceContext();
_runtimeService = new RuntimeFrameworkService();
services.Add(_runtimeService);
services.ServiceManager.StartServices();
}
开发者ID:alfeg,项目名称:nunit,代码行数:7,代码来源:RuntimeFrameworkServiceTests.cs
示例4: Main
static void Main(string[] args)
{
var ctx = new ServiceContext();
var service = new AgentService();
service.Launch(12000);
ctx.Run();
}
开发者ID:hyg19831230,项目名称:MailSystem.Prototype,代码行数:7,代码来源:Program.cs
示例5: WebHostCommunicationListener
public WebHostCommunicationListener(ServiceContext serviceContext, string appPath, string endpointName, Func<string, ServiceCancellation, IWebHost> build)
{
this.serviceContext = serviceContext;
this.endpointName = endpointName;
this.build = build;
this.appPath = appPath;
}
开发者ID:Azure-Samples,项目名称:service-fabric-dotnet-iot,代码行数:7,代码来源:WebHostCommunicationListener.cs
示例6: OrleansCommunicationListener
/// <summary>
/// Initializes a new instance of the <see cref="OrleansCommunicationListener" /> class.
/// </summary>
/// <param name="context">The context.</param>
/// <param name="configuration">The configuration.</param>
public OrleansCommunicationListener(ServiceContext context, ClusterConfiguration configuration)
{
this.configuration = configuration;
if (this.configuration == null)
{
this.configuration = new ClusterConfiguration();
this.configuration.StandardLoad();
}
this.SiloName = Regex.Replace(context.ServiceName.PathAndQuery.Trim('/'), "[^a-zA-Z0-9_]", "_") + "_" +
context.ReplicaOrInstanceId.ToString("X");
// Gather configuration from Service Fabric.
var activation = context.CodePackageActivationContext;
var endpoints = activation.GetEndpoints();
var siloEndpoint = GetEndpoint(endpoints, "OrleansSiloEndpoint");
var gatewayEndpoint = GetEndpoint(endpoints, "OrleansProxyEndpoint");
// Set the endpoints according to Service Fabric configuration.
var nodeConfig = this.configuration.Defaults;
if (string.IsNullOrWhiteSpace(nodeConfig.HostNameOrIPAddress))
{
nodeConfig.HostNameOrIPAddress = context.NodeContext.IPAddressOrFQDN;
}
nodeConfig.Port = siloEndpoint.Port;
nodeConfig.ProxyGatewayEndpoint = new IPEndPoint(nodeConfig.Endpoint.Address, gatewayEndpoint.Port);
}
开发者ID:osjimenez,项目名称:orleans,代码行数:33,代码来源:OrleansCommunicationListener.cs
示例7: CreateServiceContext
public void CreateServiceContext()
{
var services = new ServiceContext();
_projectService = new ProjectService();
services.Add(_projectService);
services.ServiceManager.StartServices();
}
开发者ID:JohanLarsson,项目名称:nunit,代码行数:7,代码来源:ProjectServiceTests.cs
示例8: SetConfigurationValue
public static void SetConfigurationValue(ServiceContext context, string package, string section, string name, string value)
{
MockCodePackageActivationContext mockContext = context.CodePackageActivationContext as MockCodePackageActivationContext;
if (mockContext == null)
{
throw new ArgumentException("MockCodePackageActivationContext expected");
}
ConfigurationPackage config;
if (!mockContext.GetConfigurationPackageNames().Contains(package))
{
config = CreateConfigurationPackage();
mockContext.AddConfigurationPackage(package, config);
}
else
{
config = mockContext.GetConfigurationPackageObject(package);
}
System.Fabric.Description.ConfigurationSettings settings = config.Settings;
if (!settings.Sections.Contains(section))
{
ConfigurationSection newSection = (ConfigurationSection)Activator.CreateInstance(typeof(ConfigurationSection), nonPublic: true);
typeof(ConfigurationSection).GetProperty("Name").SetValue(newSection, section);
settings.Sections.Add(newSection);
}
var s = settings.Sections[section];
ConfigurationProperty p = (ConfigurationProperty) Activator.CreateInstance(typeof(ConfigurationProperty), nonPublic: true);
typeof(ConfigurationProperty).GetProperty("Name").SetValue(p, name);
typeof(ConfigurationProperty).GetProperty("Value").SetValue(p, value);
s.Parameters.Add(p);
}
开发者ID:xinyanmsft,项目名称:SFStartupHttp,代码行数:35,代码来源:MockConfigurationPackage.cs
示例9: CreateServiceContext
public void CreateServiceContext()
{
var services = new ServiceContext();
_factory = new CoreTestRunnerFactory();
services.Add(_factory);
services.ServiceManager.StartServices();
}
开发者ID:JohanLarsson,项目名称:nunit,代码行数:7,代码来源:CoreTestRunnerFactoryTests.cs
示例10: SetUp
public void SetUp()
{
var services = new ServiceContext();
services.Add(new Services.SettingsService());
recentFiles = new RecentFilesService();
services.Add(recentFiles);
}
开发者ID:balaghanta,项目名称:nunit-framework,代码行数:7,代码来源:RecentFilesTests.cs
示例11: OwinCommunicationListener
public OwinCommunicationListener(Action<IAppBuilder> startup, ServiceContext serviceContext, ServiceEventSource eventSource, string endpointName, string appRoot)
{
if (startup == null)
{
throw new ArgumentNullException(nameof(startup));
}
if (serviceContext == null)
{
throw new ArgumentNullException(nameof(serviceContext));
}
if (endpointName == null)
{
throw new ArgumentNullException(nameof(endpointName));
}
if (eventSource == null)
{
throw new ArgumentNullException(nameof(eventSource));
}
this.startup = startup;
this.serviceContext = serviceContext;
this.endpointName = endpointName;
this.eventSource = eventSource;
this.appRoot = appRoot;
}
开发者ID:yangtaokm,项目名称:AliSF,代码行数:28,代码来源:OwinCommunicationListener.cs
示例12: GetService
public static AggregationCategorizationService GetService(Cache cache, String userId)
{
try
{
if (cache["AggCatService_" + userId] == null)
{
string certificateFile = System.Configuration.ConfigurationManager.AppSettings["PrivateKeyPath"];
string password = System.Configuration.ConfigurationManager.AppSettings["PrivateKeyPassword"];
X509Certificate2 certificate = new X509Certificate2(certificateFile, password);
string consumerKey = System.Configuration.ConfigurationManager.AppSettings["ConsumerKey"];
string consumerSecret = System.Configuration.ConfigurationManager.AppSettings["ConsumerSecret"];
string issuerId = System.Configuration.ConfigurationManager.AppSettings["SAMLIdentityProviderID"];
SamlRequestValidator samlValidator = new SamlRequestValidator(certificate, consumerKey, consumerSecret, issuerId, userId);
ServiceContext ctx = new ServiceContext(samlValidator);
cache.Add("AggCatService_" + userId, new AggregationCategorizationService(ctx), null, DateTime.Now.AddMinutes(50),
Cache.NoSlidingExpiration, CacheItemPriority.High, null);
}
return (AggregationCategorizationService)cache["AggCatService_" + userId];
}
catch (Exception ex)
{
throw new Exception("Unable to create AggCatService: " + ex.Message);
}
}
开发者ID:tarandhupar,项目名称:IPP_Sample_Code,代码行数:28,代码来源:AggCatService.cs
示例13: CreateInternalListener
private ICommunicationListener CreateInternalListener(ServiceContext context)
{
// Partition replica's URL is the node's IP, port, PartitionId, ReplicaId, Guid
EndpointResourceDescription internalEndpoint = context.CodePackageActivationContext.GetEndpoint("ProcessingServiceEndpoint");
// Multiple replicas of this service may be hosted on the same machine,
// so this address needs to be unique to the replica which is why we have partition ID + replica ID in the URL.
// HttpListener can listen on multiple addresses on the same port as long as the URL prefix is unique.
// The extra GUID is there for an advanced case where secondary replicas also listen for read-only requests.
// When that's the case, we want to make sure that a new unique address is used when transitioning from primary to secondary
// to force clients to re-resolve the address.
// '+' is used as the address here so that the replica listens on all available hosts (IP, FQDM, localhost, etc.)
string uriPrefix = String.Format(
"{0}://+:{1}/{2}/{3}-{4}/",
internalEndpoint.Protocol,
internalEndpoint.Port,
context.PartitionId,
context.ReplicaOrInstanceId,
Guid.NewGuid());
string nodeIP = FabricRuntime.GetNodeContext().IPAddressOrFQDN;
// The published URL is slightly different from the listening URL prefix.
// The listening URL is given to HttpListener.
// The published URL is the URL that is published to the Service Fabric Naming Service,
// which is used for service discovery. Clients will ask for this address through that discovery service.
// The address that clients get needs to have the actual IP or FQDN of the node in order to connect,
// so we need to replace '+' with the node's IP or FQDN.
string uriPublished = uriPrefix.Replace("+", nodeIP);
return new HttpCommunicationListener(uriPrefix, uriPublished, this.ProcessInternalRequest);
}
开发者ID:smartpcr,项目名称:service-fabric-dotnet-getting-started,代码行数:32,代码来源:Processing.cs
示例14: GetDefaultInstitutions
public InstitutionModel GetDefaultInstitutions()
{
InstitutionModel model = new InstitutionModel();
//Demo purposes only. The OAuth tokens returned by the SAML assertion are valid for 1 hour and do not need to be requested before each API call.
SamlRequestValidator validator = new SamlRequestValidator(AggCatAppSettings.Certificate,
AggCatAppSettings.ConsumerKey,
AggCatAppSettings.ConsumerSecret,
AggCatAppSettings.SamlIdentityProviderId,
AggCatAppSettings.CustomerId);
ServiceContext ctx = new ServiceContext(validator);
AggregationCategorizationService svc = new AggregationCategorizationService(ctx);
try
{
List<Institution> institutions = svc.GetInstitutions().institution.ToList<Institution>();
model.Institutions = institutions;
model.Error = null;
model.Success = true;
}
catch (AggregationCategorizationException ex)
{
model.Institutions = null;
model.Error = ex.ToString();
model.Success = false;
}
return model;
}
开发者ID:tarandhupar,项目名称:IPP_Sample_Code,代码行数:28,代码来源:ServiceOperations.cs
示例15: GetInstitutionDetails
internal InstitutionModel GetInstitutionDetails(InstitutionModel institutionModel)
{
try
{
//Demo purposes only. The OAuth tokens returned by the SAML assertion are valid for 1 hour and do not need to be requested before each API call.
SamlRequestValidator validator = new SamlRequestValidator(AggCatAppSettings.Certificate,
AggCatAppSettings.ConsumerKey,
AggCatAppSettings.ConsumerSecret,
AggCatAppSettings.SamlIdentityProviderId,
AggCatAppSettings.CustomerId);
ServiceContext ctx = new ServiceContext(validator);
AggregationCategorizationService svc = new AggregationCategorizationService(ctx);
institutionModel.InstitutionDetail = svc.GetInstitutionDetails(institutionModel.InstitutionId);
institutionModel.Success = true;
institutionModel.Error = null;
}
catch (AggregationCategorizationException ex)
{
institutionModel.InstitutionDetail = null;
institutionModel.Success = false;
institutionModel.Error = ex.ToString();
}
return institutionModel;
}
开发者ID:tarandhupar,项目名称:IPP_Sample_Code,代码行数:25,代码来源:ServiceOperations.cs
示例16: WebSocketApp
public WebSocketApp(IVisualObjectsBox visualObjectBox, string appRoot, string webSocketRoot, ServiceContext initParams)
{
this.visualObjectBox = visualObjectBox;
this.appRoot = string.IsNullOrWhiteSpace(appRoot) ? string.Empty : appRoot.TrimEnd('/') + '/';
this.webSocketRoot = string.IsNullOrWhiteSpace(webSocketRoot) ? string.Empty : webSocketRoot.TrimEnd('/') + '/';
this.serviceContext = initParams;
}
开发者ID:smartpcr,项目名称:service-fabric-dotnet-getting-started,代码行数:7,代码来源:WebSocketApp.cs
示例17: Run
/// <summary>
/// Run the sample.
/// </summary>
/// <param name="serverConfig">configuration for the server.</param>
/// <param name="promptToDelete">
/// whether or not to prompt the user to delete created records.
/// </param>
public void Run(ServerConnection.Configuration serverConfig, bool promptToDelete)
{
using (_serviceProxy = new OrganizationServiceProxy(serverConfig.OrganizationUri, serverConfig.HomeRealmUri,
serverConfig.Credentials, serverConfig.DeviceCredentials))
{
using (_context = new ServiceContext(_serviceProxy))
{
// This statement is required to enable early-bound type support.
_serviceProxy.EnableProxyTypes();
// This statments checks whether Standard Email templates are present
var emailTemplateId = (
from emailTemplate in _context.TemplateSet
where emailTemplate.Title == "Contact Reconnect"
select emailTemplate.Id
).FirstOrDefault();
if (emailTemplateId != Guid.Empty)
{
CreateRequiredRecords();
// Perform the bulk delete. If you want to perform a recurring delete
// operation, then leave this as it is. Otherwise, pass in false as the
// first parameter.
PerformBulkDelete(true, promptToDelete);
}
else
{
throw new ArgumentException("Standard Email Templates are missing");
}
}
}
}
开发者ID:cesugden,项目名称:Scripts,代码行数:40,代码来源:BulkDeleteOperations.cs
示例18: CreateServiceContext
public void CreateServiceContext()
{
var services = new ServiceContext();
_settingsService = new SettingsService(false);
services.Add(_settingsService);
services.ServiceManager.StartServices();
}
开发者ID:alfeg,项目名称:nunit,代码行数:7,代码来源:SettingsServiceTests.cs
示例19: ConvertEngineResultToXml
public void ConvertEngineResultToXml()
{
ServiceContext services = new ServiceContext();
services.Add(new ExtensionService());
ResultService resultService = new ResultService();
services.Add(resultService);
services.ServiceManager.StartServices();
StringBuilder sb = new StringBuilder();
using (StringWriter writer = new StringWriter(sb))
{
var nunit2Writer = resultService.GetResultWriter("nunit2", null);
Assert.NotNull(nunit2Writer, "Unable to get nunit2 result writer");
nunit2Writer.WriteResultFile(EngineResult.Xml, writer);
}
_doc = new XmlDocument();
_doc.LoadXml(sb.ToString());
_topNode = _doc.SelectSingleNode("/test-results");
Assert.NotNull(_topNode, "Test-results element not found");
_envNode = _topNode.SelectSingleNode("environment");
Assert.NotNull(_envNode, "Environment element not found");
_cultureNode = _topNode.SelectSingleNode("culture-info");
Assert.NotNull(_topNode, "CultureInfo element not found");
_fixtureNode = _topNode.SelectSingleNode("descendant::test-suite[@name='MockTestFixture']");
Assert.NotNull(_fixtureNode, "MockTestFixture element not found");
}
开发者ID:roboticai,项目名称:nunit,代码行数:31,代码来源:NUnit2XmlResultWriterTests.cs
示例20: CreateServiceContext
public void CreateServiceContext()
{
_services = new ServiceContext();
_services.Add(new ProjectService());
_factory = new DefaultTestRunnerFactory();
_services.Add(_factory);
_services.ServiceManager.StartServices();
}
开发者ID:JohanLarsson,项目名称:nunit,代码行数:8,代码来源:DefaultTestRunnerFactoryTests.cs
注:本文中的ServiceContext类示例整理自Github/MSDocs等源码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。 |
请发表评论