本文整理汇总了C#中ServiceCreatorCallback类的典型用法代码示例。如果您正苦于以下问题:C# ServiceCreatorCallback类的具体用法?C# ServiceCreatorCallback怎么用?C# ServiceCreatorCallback使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。
ServiceCreatorCallback类属于命名空间,在下文中一共展示了ServiceCreatorCallback类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。
示例1: SampleDesignerHost
public SampleDesignerHost(IServiceProvider parentProvider)
{
this.serviceContainer = new ServiceContainer(parentProvider);
this.designerTable = new Hashtable();
this.sites = new Hashtable(CaseInsensitiveHashCodeProvider.Default, CaseInsensitiveComparer.Default);
this.loadingDesigner = false;
this.transactionCount = 0;
this.reloading = false;
this.serviceContainer.AddService(typeof(IDesignerHost), this);
this.serviceContainer.AddService(typeof(IContainer), this);
this.serviceContainer.AddService(typeof(IComponentChangeService), this);
this.serviceContainer.AddService(typeof(IExtenderProviderService), this);
this.serviceContainer.AddService(typeof(IDesignerEventService), this);
CodeDomComponentSerializationService codeDomComponentSerializationService = new CodeDomComponentSerializationService(this.serviceContainer);
if (codeDomComponentSerializationService != null)
{
this.serviceContainer.RemoveService(typeof(ComponentSerializationService), false);
this.serviceContainer.AddService(typeof(ComponentSerializationService), codeDomComponentSerializationService);
}
ServiceCreatorCallback callback = new ServiceCreatorCallback(this.OnCreateService);
this.serviceContainer.AddService(typeof(IToolboxService), callback);
this.serviceContainer.AddService(typeof(ISelectionService), callback);
this.serviceContainer.AddService(typeof(ITypeDescriptorFilterService), callback);
this.serviceContainer.AddService(typeof(IMenuCommandService), callback);
this.serviceContainer.AddService(typeof(IDesignerSerializationService), callback);
((IExtenderProviderService) this).AddExtenderProvider(new SampleNameExtenderProvider(this));
((IExtenderProviderService) this).AddExtenderProvider(new SampleInheritedNameExtenderProvider(this));
}
示例2: AddService
/// <summary>
/// Adds the specified service to the service container.
/// </summary>
/// <param name="serviceType">The type of service to add.</param>
/// <param name="callback">A callback object that is used to create the service. This allows a service to be declared as available, but delays the creation of the object until the service is requested.</param>
public void AddService(Type serviceType, ServiceCreatorCallback callback)
{
Guard.NotNull(() => serviceType, serviceType);
Guard.NotNull(() => callback, callback);
this.services.Add(serviceType, callback);
}
示例3: CommonPackage
internal CommonPackage()
{
IServiceContainer container = this as IServiceContainer;
ServiceCreatorCallback callback = new ServiceCreatorCallback(CreateService);
//container.AddService(GetLanguageServiceType(), callback, true);
container.AddService(GetLibraryManagerType(), callback, true);
}
示例4: ArgumentNullException
public void AddService
(Type serviceType, ServiceCreatorCallback callback,
bool promote)
{
// Validate the parameters.
if(serviceType == null)
{
throw new ArgumentNullException("serviceType");
}
if(callback == null)
{
throw new ArgumentNullException("callback");
}
// Promote the service to the parent if necessary.
if(promote && parentProvider != null)
{
IServiceContainer parent;
parent = (IServiceContainer)(parentProvider.GetService
(typeof(IServiceContainer)));
if(parent != null)
{
parent.AddService(serviceType, callback, promote);
return;
}
}
// Add the service to this container.
table[serviceType] = callback;
}
示例5: PlotterServicePackage
/// <summary>
/// Default constructor of the package.
/// The package is not yet sited inside Visual Studio, so this is the place
/// for any setup that doesn't need the VS environment.
/// Here we register our service, so that it will be available to any other
/// packages by the time their Initialize is called.
/// </summary>
public PlotterServicePackage()
{
Debug.WriteLine(string.Format(CultureInfo.CurrentCulture, "Entering constructor for: {0}", this.ToString()));
var serviceContainer = this as IServiceContainer;
var serviceCreator = new ServiceCreatorCallback(CreatePlotterService);
serviceContainer.AddService(typeof(SPlotter2DService), serviceCreator, true);
}
示例6: VsExtAutoShelvePackage
/// <summary>
/// Default constructor of the package.
/// Inside this method you can place any initialization code that does not require
/// any Visual Studio service because at this point the package object is created but
/// not sited yet inside Visual Studio environment. The place to do all the other
/// initialization is the Initialize method.
/// </summary>
public VsExtAutoShelvePackage()
{
Trace.WriteLine(string.Format(CultureInfo.CurrentCulture, "Entering constructor for: {0}", this));
IServiceContainer serviceContainer = this as IServiceContainer;
ServiceCreatorCallback callback = new ServiceCreatorCallback(CreateService);
serviceContainer.AddService(typeof(SAutoShelveService), callback, true);
//serviceContainer.AddService(typeof(SMyLocalService), callback);
}
示例7: AddService
public void AddService(Type serviceType, ServiceCreatorCallback callback, bool shouldDisposeServiceInstance)
{
// Create the description of this service. Note that we don't do any validation
// of the parameter here because the constructor of ServiceData will do it for us.
ServiceData service = new ServiceData(serviceType, null, callback, shouldDisposeServiceInstance);
// Now add the service desctription to the dictionary.
AddService(service);
}
示例8: PythonConsolePackage
/// <summary>
/// Default constructor of the package.
/// Inside this method you can place any initialization code that does not require
/// any Visual Studio service, because at this point the package object is created but
/// not sited yet inside the Visual Studio environment. The place to do all the other
/// initialization is the Initialize method.
/// </summary>
public PythonConsolePackage()
{
// This package has to proffer the IronPython engine provider as a Visual Studio
// service. Note that for performance reasons we don't actually create any object here,
// but instead we register a callback function that will create the object the first
// time this package will receive a request for the service.
IServiceContainer container = this as IServiceContainer;
ServiceCreatorCallback callback = new ServiceCreatorCallback(CreateService);
container.AddService(typeof(IPythonEngineProvider), callback, true);
}
示例9: ServiceCreatorCallback
void IPackage.Initialize(IServiceProvider serviceProvider)
{
this._serviceProvider = serviceProvider;
IServiceContainer service = (IServiceContainer) this._serviceProvider.GetService(typeof(IServiceContainer));
if (service != null)
{
ServiceCreatorCallback callback = new ServiceCreatorCallback(this.OnCreateService);
service.AddService(typeof(IClassViewService), callback);
}
}
示例10: PythonConsolePackage
/// <summary>
/// Default constructor of the package.
/// Inside this method you can place any initialization code that does not require
/// any Visual Studio service, because at this point the package object is created but
/// not sited yet inside the Visual Studio environment. The place to do all the other
/// initialization is the Initialize method.
/// </summary>
public PythonConsolePackage()
{
Trace.WriteLine(string.Format(CultureInfo.CurrentCulture, "Entering constructor for: {0}", this.ToString()));
// This package has to proffer the IronPython engine provider as a Visual Studio
// service. Note that for performance reasons we don't actually create any object here,
// but instead we register a callback function that will create the object the first
// time this package will receive a request for the service.
IServiceContainer container = this as IServiceContainer;
ServiceCreatorCallback callback = new ServiceCreatorCallback(CreateService);
container.AddService(typeof(IPythonEngineProvider), callback, true);
}
示例11: ServiceData
public ServiceData(Type serviceType, object instance, ServiceCreatorCallback callback, bool shouldDispose) {
Utilities.ArgumentNotNull("serviceType", serviceType);
if ((null == instance) && (null == callback)) {
throw new ArgumentNullException("instance");
}
this.serviceType = serviceType;
this.instance = instance;
this.creator = callback;
this.shouldDispose = shouldDispose;
}
示例12: SharpOnlyPkgPackage
/// <summary>
/// Default constructor of the package.
/// Inside this method you can place any initialization code that does not require
/// any Visual Studio service because at this point the package object is created but
/// not sited yet inside Visual Studio environment. The place to do all the other
/// initialization is the Initialize method.
/// </summary>
public SharpOnlyPkgPackage()
{
Trace.WriteLine(string.Format(CultureInfo.CurrentCulture, "Entering constructor for: {0}", this.ToString()));
// Init service...
IServiceContainer serviceContainer = this as IServiceContainer;
ServiceCreatorCallback callback =
new ServiceCreatorCallback(CreateService);
serviceContainer.AddService(typeof(MSBuildTaskService), callback, true);
serviceContainer.AddService(typeof(SharpBuildService), callback, true);
serviceContainer.AddService(typeof(SharpBuildDeployService), callback, true);
}
示例13: AddService
/// <summary>
/// Adds the specified service to the service container.
/// </summary>
/// <param name="serviceType">The type of service to add.</param>
/// <param name="callback">A callback object that is used to create the service. This allows a service to be declared as available, but delays the creation of the object until the service is requested.</param>
public void AddService(Type serviceType, ServiceCreatorCallback callback)
{
if (serviceType == null)
throw new ArgumentNullException("serviceType");
if (callback == null)
throw new ArgumentNullException("callback");
if (_services.Contains(serviceType))
throw new ArgumentException("Service already exists.", "serviceType");
_services[serviceType] = callback;
}
示例14: DesignSurface
public DesignSurface(IServiceProvider parentProvider)
{
this._parentProvider = parentProvider;
this._serviceContainer = new DesignSurfaceServiceContainer(this._parentProvider);
ServiceCreatorCallback callback = new ServiceCreatorCallback(this.OnCreateService);
this.ServiceContainer.AddService(typeof(ISelectionService), callback);
this.ServiceContainer.AddService(typeof(IExtenderProviderService), callback);
this.ServiceContainer.AddService(typeof(IExtenderListService), callback);
this.ServiceContainer.AddService(typeof(ITypeDescriptorFilterService), callback);
this.ServiceContainer.AddService(typeof(IReferenceService), callback);
this.ServiceContainer.AddService(typeof(DesignSurface), this);
this._host = new DesignerHost(this);
}
示例15: AddService
public void AddService(string serviceName, ServiceCreatorCallback creatorCallback, bool promote)
{
Require.NotNullOrEmptyString("serviceName", serviceName); // $NON-NLS-1
if (this.servicesByName.ContainsKey(serviceName))
throw RuntimeFailure.ServiceAlreadyExists("serviceName", serviceName);
this.servicesByName.Add(serviceName, creatorCallback);
if (promote) {
IServiceContainerExtension ice = this.ParentContainer as IServiceContainerExtension;
if (ice != null)
ice.AddService(serviceName, creatorCallback, true);
}
}