当前位置: 首页>>代码示例>>C#>>正文


C# IServiceProvider.Get方法代码示例

本文整理汇总了C#中IServiceProvider.Get方法的典型用法代码示例。如果您正苦于以下问题:C# IServiceProvider.Get方法的具体用法?C# IServiceProvider.Get怎么用?C# IServiceProvider.Get使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在IServiceProvider的用法示例。


在下文中一共展示了IServiceProvider.Get方法的5个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。

示例1: ProvideValue

		public override object ProvideValue( IServiceProvider serviceProvider )
		{
			var designMode = DesignerProperties.GetIsInDesignMode( DependencyObject.Value );
			try
			{
				// Retrieve target information
				var service = serviceProvider.Get<IProvideValueTarget>();
				if ( service?.TargetObject != null )
				{
					// In a template the TargetObject is a SharedDp (internal WPF class)
					// In that case, the markup extension itself is returned to be re-evaluated later
					switch ( service.TargetObject.GetType().FullName )
					{
						case "System.Windows.SharedDp":
							return this;
						default:
							var property = factory( serviceProvider );
							if ( property != null )
							{
								var value = designMode ? designTimeFactory( property.Reference.PropertyType ) : GetValue( new MarkupServiceProvider( serviceProvider, service.TargetObject, property ) );
								var result = service.TargetProperty == null ? property.SetValue( value ) : value;
								return result;
							}
							break;
					}
				}
				return null;
			}
			catch ( Exception e )
			{
				var exception = designMode ? new Exception( e.ToString() ) : e;
				throw exception;
			}
		}
开发者ID:DevelopersWin,项目名称:VoteReporter,代码行数:34,代码来源:MarkupExtensionBase.cs

示例2: DetermineContext

		protected virtual object DetermineContext( IServiceProvider serviceProvider )
		{
			var types = Types.Select( serviceProvider.Get<IXamlSchemaContextProvider>().SchemaContext.GetXamlType ).ToArray();
			var context = serviceProvider.Get<IAmbientProvider>().GetFirstAmbientValue( types );
			return context;
		}
开发者ID:DevelopersWin,项目名称:VoteReporter,代码行数:6,代码来源:NextExtension.cs

示例3: ProvideValue

		public override object ProvideValue( IServiceProvider serviceProvider )
		{
			var result = serviceProvider.Get<IRootObjectProvider>().With( x => x.RootObject.GetType().Assembly.GetName().Version );
			return result;
		}
开发者ID:DevelopersWin,项目名称:VoteReporter,代码行数:5,代码来源:AssemblyVersionExtension.cs

示例4: CreateAssembly

		public void CreateAssembly( [Service]IParameterizedSource<Assembly, AssemblyInformation> factory, IServiceProvider container, [Service]Assembly sut )
		{
			var fromFactory = ApplicationAssembly.Default.Get();
			var fromContainer = container.Get<Assembly>();
			Assert.Same( fromFactory, fromContainer );
			

			Assert.Same( fromContainer, sut );

			var fromProvider = factory.Get( fromFactory );
			Assert.NotNull( fromProvider );

			var assembly = GetType().Assembly;
			Assert.Equal( assembly.From<AssemblyTitleAttribute, string>( attribute => attribute.Title ), fromProvider.Title );
			Assert.Equal( assembly.From<AssemblyCompanyAttribute, string>( attribute => attribute.Company ), fromProvider.Company );
			Assert.Equal( assembly.From<AssemblyCopyrightAttribute, string>( attribute => attribute.Copyright ), fromProvider.Copyright );
			Assert.Equal( assembly.From<DebuggableAttribute, string>( attribute => "DEBUG" ), fromProvider.Configuration );
			Assert.Equal( assembly.From<AssemblyDescriptionAttribute, string>( attribute => attribute.Description ), fromProvider.Description );
			Assert.Equal( assembly.From<AssemblyProductAttribute, string>( attribute => attribute.Product ), fromProvider.Product );
			Assert.Equal( assembly.GetName().Version, fromProvider.Version );
		}
开发者ID:DevelopersWin,项目名称:VoteReporter,代码行数:21,代码来源:DefaultsTests.cs

示例5: Get

		public override IMarkupProperty Get( IServiceProvider parameter )
		{
			var reference = propertyFactory( parameter );
			var result = reference.IsAssigned() ? new CollectionMarkupProperty( (IList)parameter.Get<IProvideValueTarget>().TargetObject, reference ) : null;
			return result;
		}
开发者ID:DevelopersWin,项目名称:VoteReporter,代码行数:6,代码来源:CollectionMarkupPropertyFactory.cs


注:本文中的IServiceProvider.Get方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。