本文整理汇总了C#中RegistrationType类的典型用法代码示例。如果您正苦于以下问题:C# RegistrationType类的具体用法?C# RegistrationType怎么用?C# RegistrationType使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。
RegistrationType类属于命名空间,在下文中一共展示了RegistrationType类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。
示例1: GetLifetimeManager
private static LifetimeManager GetLifetimeManager(RegistrationType registrationType)
{
if (RegistrationType.Singleton == registrationType) {
return new ContainerControlledLifetimeManager();
}
return new TransientLifetimeManager();
}
示例2: ServiceLocatorRegistrationAttribute
public ServiceLocatorRegistrationAttribute(Type interfaceType, RegistrationType registrationType, object tag = null)
{
Argument.IsNotNull("InterfaceType", interfaceType);
InterfaceType = interfaceType;
RegistrationType = registrationType;
Tag = tag;
}
示例3: DependencyInjectionBehaviorAttribute
/// <summary>
/// Initializes a new instance of the <see cref="DependencyInjectionBehaviorAttribute" /> class.
/// </summary>
/// <param name="contractType">Type of the contract.</param>
/// <param name="registrationType">Type of the registration.</param>
/// <param name="tag">The tag.</param>
public DependencyInjectionBehaviorAttribute(Type contractType,
RegistrationType registrationType = RegistrationType.Singleton, object tag = null)
{
ContractType = contractType;
RegistrationType = registrationType;
Tag = tag;
_serviceLocator = this.GetDependencyResolver().Resolve<IServiceLocator>();
}
示例4: ServiceLocatorRegistrationBehaviorAttribute
/// <summary>
/// Initializes a new instance of the <see cref="ServiceLocatorRegistrationBehaviorAttribute" /> class.
/// </summary>
/// <param name="contractType">Type of the contract.</param>
/// <param name="registrationType">Type of the registration.</param>
/// <param name="tag">The tag.</param>
public ServiceLocatorRegistrationBehaviorAttribute(Type contractType,
RegistrationType registrationType = RegistrationType.Singleton, object tag = null)
{
Argument.IsNotNull("registrationType", registrationType);
ContractType = contractType;
RegistrationType = registrationType;
Tag = tag;
}
示例5: RegistrationInfo
/// <summary>
/// Initializes a new instance of the <see cref="RegistrationInfo" /> class.
/// </summary>
/// <param name="declaringType">Type of the declaring.</param>
/// <param name="implementingType">Type of the implementing.</param>
/// <param name="registrationType">Type of the registration.</param>
/// <param name="isTypeInstantiatedForSingleton">If set to <c>true</c> there already is an instance of this singleton registration.</param>
/// <exception cref="ArgumentNullException">The <paramref name="declaringType" /> is <c>null</c>.</exception>
/// <exception cref="ArgumentNullException">The <paramref name="implementingType" /> is <c>null</c>.</exception>
internal RegistrationInfo(Type declaringType, Type implementingType, RegistrationType registrationType, bool isTypeInstantiatedForSingleton = false)
{
Argument.IsNotNull("declaringType", declaringType);
Argument.IsNotNull("implementingType", implementingType);
DeclaringType = declaringType;
ImplementingType = implementingType;
RegistrationType = registrationType;
IsTypeInstantiatedForSingleton = isTypeInstantiatedForSingleton;
}
示例6: TypeRegisteredEventArgs
/// <summary>
/// Initializes a new instance of the <see cref="TypeRegisteredEventArgs" /> class.
/// </summary>
/// <param name="serviceType">Type of the service.</param>
/// <param name="serviceImplementationType">Type of the service implementation.</param>
/// <param name="tag">The tag.</param>
/// <param name="registrationType">Type of the registration.</param>
/// <exception cref="ArgumentNullException">The <paramref name="serviceType"/> is <c>null</c>.</exception>
/// <exception cref="ArgumentNullException">The <paramref name="serviceImplementationType"/> is <c>null</c>.</exception>
public TypeRegisteredEventArgs(Type serviceType, Type serviceImplementationType, object tag, RegistrationType registrationType)
{
Argument.IsNotNull("serviceType", serviceType);
Argument.IsNotNull("serviceImplementationType", serviceImplementationType);
ServiceType = serviceType;
ServiceImplementationType = serviceImplementationType;
Tag = tag;
RegistrationType = registrationType;
}
示例7: ExecuteIfExists
/// <summary>
/// Executes the CustomUnregisterFunction if it exists for a type.
/// </summary>
/// <param name="type">The type.</param>
/// <param name="registrationType">Type of the registration.</param>
public static void ExecuteIfExists(Type type, RegistrationType registrationType)
{
// Does the type have the attribute?
var methodWithAttribute = type.GetMethods(BindingFlags.Static | BindingFlags.NonPublic | BindingFlags.Public | BindingFlags.FlattenHierarchy)
.FirstOrDefault(m => m.GetCustomAttributes(typeof (CustomUnregisterFunctionAttribute), false).Any());
// Do we have a method? If so, invoke it.
if (methodWithAttribute != null)
methodWithAttribute.Invoke(null, new object[] { type, registrationType });
}
示例8: RegisterInContainerAttribute
public RegisterInContainerAttribute(Type interfaceType, string name, RegistrationType registrationType)
{
if (interfaceType == null) {
throw new ArgumentNullException("interfaceType");
}
this.InterfaceType = interfaceType;
this.Name = name;
this.RegistrationType = registrationType;
}
示例9: InstanceProvider
/// <summary>
/// Initializes a new instance of the <see cref="InstanceProvider" /> class.
/// </summary>
/// <param name="serviceLocator">The service locator.</param>
/// <param name="contractType">Type of the contract.</param>
/// <param name="serviceType">Type of the service.</param>
/// <param name="tag">The tag.</param>
/// <param name="registrationType">Type of the registration.</param>
public InstanceProvider(IServiceLocator serviceLocator, Type contractType, Type serviceType, object tag = null, RegistrationType registrationType = RegistrationType.Singleton)
{
Argument.IsNotNull("serviceLocator", serviceLocator);
Argument.IsNotNull("contractType", contractType);
Argument.IsNotNull("serviceType", serviceType);
_serviceLocator = serviceLocator;
_contractType = contractType;
_log.Debug("Register the contract type '{0}' for service type '{1}'", _contractType.Name, serviceType.Name);
_serviceLocator.RegisterTypeIfNotYetRegistered(_contractType, serviceType, tag, registrationType);
}
示例10: ServiceLocatorRegistration
/// <summary>
/// Initializes a new instance of the <see cref="ServiceLocatorRegistration" /> class.
/// </summary>
/// <param name="declaringType">Type of the declaring.</param>
/// <param name="implementingType">Type of the implementing.</param>
/// <param name="tag">The tag.</param>
/// <param name="registrationType">Type of the registration.</param>
/// <param name="createServiceFunc">The create service function.</param>
public ServiceLocatorRegistration(Type declaringType, Type implementingType, object tag, RegistrationType registrationType, Func<ServiceLocatorRegistration, object> createServiceFunc)
{
Argument.IsNotNull("createServiceFunc", createServiceFunc);
CreateServiceFunc = createServiceFunc;
DeclaringType = declaringType;
DeclaringTypeName = declaringType.AssemblyQualifiedName;
ImplementingType = implementingType;
ImplementingTypeName = implementingType.AssemblyQualifiedName;
Tag = tag;
RegistrationType = registrationType;
}
示例11: RegisteredTypeInfo
public RegisteredTypeInfo(Type declaringType, Type implementingType, object tag, RegistrationType registrationType, object originalContainer)
{
Argument.IsNotNull("declaringType", declaringType);
Argument.IsNotNull("implementingType", implementingType);
Argument.IsNotNull("originalContainer", originalContainer);
DeclaringType = declaringType;
DeclaringTypeName = declaringType.AssemblyQualifiedName;
ImplementingType = implementingType;
ImplementingTypeName = implementingType.AssemblyQualifiedName;
Tag = tag;
RegistrationType = registrationType;
OriginalContainer = originalContainer;
}
示例12: InstallServer
/// <summary>
/// Installs a SharpShell server at the specified path.
/// </summary>
/// <param name="path">The path to the SharpShell server.</param>
/// <param name="registrationType">Type of the registration.</param>
/// <param name="codeBase">if set to <c>true</c> install from codebase rather than GAC.</param>
private void InstallServer(string path, RegistrationType registrationType, bool codeBase)
{
// Validate the path.
if (File.Exists(path) == false)
{
outputService.WriteError("File '" + path + "' does not exist.", true);
return;
}
// Try and load the server types.
IEnumerable<ISharpShellServer> serverTypes = null;
try
{
serverTypes = LoadServerTypes(path);
}
catch (Exception e)
{
outputService.WriteError("An unhandled exception occured when loading the SharpShell");
outputService.WriteError("Server Types from the specified assembly. Is it a SharpShell");
outputService.WriteError("Server Assembly?");
System.Diagnostics.Trace.Write(e);
Logging.Error("An unhandled exception occured when loading a SharpShell server.", e);
}
// Install each server type.
foreach (var serverType in serverTypes)
{
// Inform the user we're going to install the server.
outputService.WriteMessage("Preparing to install (" + registrationType + "): " + serverType.DisplayName, true);
// Install the server.
try
{
SharpShell.ServerRegistration.ServerRegistrationManager.InstallServer(serverType, registrationType, codeBase);
SharpShell.ServerRegistration.ServerRegistrationManager.RegisterServer(serverType, registrationType);
}
catch (Exception e)
{
outputService.WriteError("Failed to install and register the server.");
Logging.Error("An unhandled exception occured installing and registering the server " + serverType.DisplayName, e);
continue;
}
outputService.WriteSuccess(" " + serverType.DisplayName + " installed and registered.", true);
}
}
示例13: DoRegister
/// <summary>
/// Actually performs registration. The ComRegisterFunction decorated method will call this function
/// internally with the flag appropriate for the operating system processor architecture.
/// However, this function can also be called manually if needed.
/// </summary>
/// <param name="type">The type of object to register, this must be a SharpShellServer derived class.</param>
/// <param name="registrationType">Type of the registration.</param>
internal static void DoRegister(Type type, RegistrationType registrationType)
{
// Get the assoication data.
var assocationAttributes = type.GetCustomAttributes(typeof(COMServerAssociationAttribute), true)
.OfType<COMServerAssociationAttribute>().ToList();
// Get the server type.
var serverType = ServerTypeAttribute.GetServerType(type);
// Register the server associations, if there are any.
if (assocationAttributes.Any())
{
ServerRegistrationManager.RegisterServerAssociations(
type.GUID, serverType, type.Name, assocationAttributes, registrationType);
}
// Execute the custom register function, if there is one.
CustomRegisterFunctionAttribute.ExecuteIfExists(type, registrationType);
}
示例14: CustomRegisterFunction
internal static void CustomRegisterFunction(Type serverType, RegistrationType registrationType)
{
// Register preview handlers via the registrar.
PreviewHandlerRegistrar.Register(serverType, registrationType);
}
示例15: CustomUnregisterFunction
internal static void CustomUnregisterFunction(Type serverType, RegistrationType registrationType)
{
// Open the local machine.
using (var localMachineBaseKey = registrationType == RegistrationType.OS64Bit
? RegistryKey.OpenBaseKey(RegistryHive.LocalMachine, RegistryView.Registry64) :
RegistryKey.OpenBaseKey(RegistryHive.LocalMachine, RegistryView.Registry32))
{
// Open the ShellIconOverlayIdentifiers.
using (var overlayIdentifiers = localMachineBaseKey
.OpenSubKey(@"Software\Microsoft\Windows\CurrentVersion\Explorer\ShellIconOverlayIdentifiers",
RegistryKeyPermissionCheck.ReadWriteSubTree, RegistryRights.Delete | RegistryRights.EnumerateSubKeys | RegistryRights.ReadKey))
{
// If we don't have the key, we've got a problem.
if (overlayIdentifiers == null)
throw new InvalidOperationException("Cannot open the ShellIconOverlayIdentifiers key.");
// Delete the overlay key.
if (overlayIdentifiers.GetSubKeyNames().Any(skn => skn == (" " + serverType.Name)))
overlayIdentifiers.DeleteSubKey(" " + serverType.Name);
}
}
}