• 设为首页
  • 点击收藏
  • 手机版
    手机扫一扫访问
    迪恩网络手机版
  • 关注官方公众号
    微信扫一扫关注
    公众号

C# ITypeConverter类代码示例

原作者: [db:作者] 来自: [db:来源] 收藏 邀请

本文整理汇总了C#中ITypeConverter的典型用法代码示例。如果您正苦于以下问题:C# ITypeConverter类的具体用法?C# ITypeConverter怎么用?C# ITypeConverter使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。



ITypeConverter类属于命名空间,在下文中一共展示了ITypeConverter类的20个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于我们的系统推荐出更棒的C#代码示例。

示例1: ValueCalculatorFactory

        public ValueCalculatorFactory(ITypeConverter typeConverter)
        {
            if (typeConverter == null)
                throw new ArgumentNullException("typeConverter");

            _typeConverter = typeConverter;
        }
开发者ID:mparsin,项目名称:Elements,代码行数:7,代码来源:ValueCalculatorFactory.cs


示例2: FileFieldMapping

        /// <summary>
        /// Initializes a new instance of the <see cref="FileFieldMapping"/> class.
        /// </summary>
        /// <param name="property">
        /// The property.
        /// </param>
        /// <param name="nameExpression">
        /// The name expression.
        /// </param>
        /// <param name="contentExpression">
        /// The content expression.
        /// </param>
        /// <param name="locationExpression">
        /// The location expression.
        /// </param>
        /// <param name="typeConverter">
        /// The type converter.
        /// </param>
        /// <param name="fileManager">
        /// The file manager.
        /// </param>
        public FileFieldMapping(
            PropertyInfo property,
            MappingExpression nameExpression,
            MappingExpression contentExpression,
            MappingExpression locationExpression,
            ITypeConverter typeConverter,
            IFileManager fileManager)
        {
            if (property == null)
                throw new ArgumentNullException("property");

            if (!typeof(IFileProcess).IsAssignableFrom(property.PropertyType))
                throw new ArgumentException("The specified property is not a file field.");

            if (typeConverter == null)
                throw new ArgumentNullException("typeConverter");

            if (fileManager == null)
                throw new ArgumentNullException("fileManager");

            _property = property;
            _nameExpression = nameExpression;
            _contentExpression = contentExpression;
            _locationExpression = locationExpression;
            _typeConverter = typeConverter;
            _fileManager = fileManager;
        }
开发者ID:mparsin,项目名称:Elements,代码行数:48,代码来源:FileFieldMapping.cs


示例3: AddFactories

		protected virtual void AddFactories(IConfiguration facilityConfig, ITypeConverter converter)
		{
			if (facilityConfig != null)
			{
				foreach(IConfiguration config in facilityConfig.Children["factories"].Children)
				{
					String id = config.Attributes["id"];
					String creation = config.Attributes["creation"];
					String destruction = config.Attributes["destruction"];

					Type factoryType = (Type)
						converter.PerformConversion( config.Attributes["interface"], typeof(Type) );

					try
					{
						AddTypedFactoryEntry( 
							new FactoryEntry(id, factoryType, creation, destruction) );
					}
					catch(Exception)
					{
						string message = "Invalid factory entry in configuration";

						throw new ConfigurationErrorsException(message);
					}
				}
			}
		}
开发者ID:nats,项目名称:castle-1.0.3-mono,代码行数:27,代码来源:TypedFactoryFacility.cs


示例4: SingleCrossReferenceFieldMapping

        /// <summary>
        /// Initializes a new instance of the <see cref="SingleCrossReferenceFieldMapping"/> class.
        /// </summary>
        /// <param name="property">
        /// The property.
        /// </param>
        /// <param name="valueExpression">
        /// The value expression.
        /// </param>
        /// <param name="isKey">
        /// Specifies whether this is a key mapping.
        /// </param>
        /// <param name="typeConverter">
        /// The type converter.
        /// </param>
        /// <param name="dynamicTypeManager">
        /// The dynamic type manager.
        /// </param>
        /// <param name="runtimeDatabase">
        /// The runtime database.
        /// </param>
        /// <param name="childMappings">
        /// The child mappings.
        /// </param>
        public SingleCrossReferenceFieldMapping(
            PropertyInfo property,
            MappingExpression valueExpression,
            bool isKey,
            ITypeConverter typeConverter,
            IDynamicTypeManager dynamicTypeManager,
            IRuntimeDatabase runtimeDatabase,
            IEnumerable<IProcessFieldMapping> childMappings)
        {
            if (property == null)
                throw new ArgumentNullException("property");

            var crAttribute = property.GetCustomAttribute<CrossRefFieldAttribute>();
            if (crAttribute == null || crAttribute.AllowMultiple || !typeof(int?).IsAssignableFrom(property.PropertyType))
                throw new ArgumentException("The specified property is not a single cross reference field.");

            if (typeConverter == null)
                throw new ArgumentNullException("typeConverter");

            if (dynamicTypeManager == null)
                throw new ArgumentNullException("dynamicTypeManager");

            if (runtimeDatabase == null)
                throw new ArgumentNullException("runtimeDatabase");

            _property = property;
            _valueExpression = valueExpression;
            _isKey = isKey;
            _typeConverter = typeConverter;
            _dynamicTypeManager = dynamicTypeManager;
            _runtimeDatabase = runtimeDatabase;
            _childMappings = (childMappings ?? Enumerable.Empty<IProcessFieldMapping>()).ToArray();
            _referencedProcessName = crAttribute.ReferenceTableName;
        }
开发者ID:mparsin,项目名称:Elements,代码行数:58,代码来源:SingleCrossReferenceFieldMapping.cs


示例5: Init

		protected override void Init()
		{
			converter = (ITypeConverter) Kernel.GetSubSystem(SubSystemConstants.ConversionManagerKey);

			Kernel.ComponentModelCreated +=OnComponentModelCreated;
			Kernel.ComponentRegistered +=OnComponentRegistered;
		}
开发者ID:AGiorgetti,项目名称:Castle.InversionOfControl,代码行数:7,代码来源:StartableFacility.cs


示例6: ValueBuilder

        public ValueBuilder(CultureInfo cultureInfo, ITypeConverter typeConverter)
        {
            // register custom BooleanTypeConverter, this might be a bad idea.
            TypeConverterAttribute converterAttribute = new TypeConverterAttribute(typeof(CustomBooleanConverter));
            _typeDescriptorProvider = TypeDescriptor.AddAttributes(typeof(Boolean), converterAttribute);

            this._typeConverter = typeConverter;
            this._culture = cultureInfo;
            this._errorCollector = null;
            this._targetType = new Stack<Type>();
            this._errorHandlers = new Stack<EventHandler<ErrorEventArg>>();
            this.ResolveInterfaceType +=
                (sender, args) =>
                {
                    if (args.RealType != null)
                        return;

                    if (typeof(IEnumerable) == args.InterfaceType)
                        args.RealType = typeof(List<object>);
                    else
                    {
                        Type[] genArgs;
                        if (args.InterfaceType.IsOfGenericType(typeof(IEnumerable<>), out genArgs))
                            args.RealType = typeof(List<>).MakeGenericType(genArgs);
                        if (args.InterfaceType.IsOfGenericType(typeof(IList<>), out genArgs))
                            args.RealType = typeof(List<>).MakeGenericType(genArgs);
                        else if (args.InterfaceType.IsOfGenericType(typeof(IDictionary<,>), out genArgs))
                            args.RealType = typeof(Dictionary<,>).MakeGenericType(genArgs);
                        else if (args.InterfaceType.IsOfGenericType(typeof(ILookup<,>), out genArgs))
                            args.RealType = typeof(Lookup<,>).MakeGenericType(genArgs);
                    }
                };
        }
开发者ID:LBiNetherlands,项目名称:LBi.Cli.Arguments,代码行数:33,代码来源:ValueBuilder.cs


示例7: FormatParameters

        public static IDictionary<string, object> FormatParameters(
            IList<CommandActionParameter> source,
            IList<ParameterDescription> description,
            ITypeConverter converter)
        {
            // Determine parameter values
            Dictionary<string, object> result = new Dictionary<string, object>();

            foreach (CommandActionParameter param in source)
            {
                string name = param.Name;
                object value = param.Value;

                // Find the description of the parameter
                ParameterDescription expectedParam =
                    description.FirstOrDefault(p => p.Name == name);

                // Custom conversion
                value = converter.ConvertClrObject(value, expectedParam.Type);

                result.Add(name, value);
            }

            return result;
        }
开发者ID:CodingGorilla,项目名称:effort,代码行数:25,代码来源:DbCommandActionHelper.cs


示例8: Combine

 public static ITypeConverter Combine(ICustomAttributeProvider attributeProvider, ITypeConverter typeConverter)
 {
     var results = GetTypeConverters(attributeProvider);
     if (!results.Any())
         return typeConverter;
     else
         return new CombinedTypeConverter(results.Concat(new[] { typeConverter }).ToArray());
 }
开发者ID:kswoll,项目名称:sexy-http,代码行数:8,代码来源:TypeConverterAttribute.cs


示例9: CollectionConverterFixture

        /// <summary>
        /// Initializes a new instance of the <see cref="T:System.Object"/> class.
        /// </summary>
        public CollectionConverterFixture()
        {
            this.converter = new CollectionConverter();
            this.context = new BindingContext() { TypeConverters = new[] { new FallbackConverter() } };

            this.mockStringTypeConverter = A.Fake<ITypeConverter>();
            A.CallTo(() => mockStringTypeConverter.CanConvertTo(null, null)).WithAnyArguments().Returns(true);
            A.CallTo(() => mockStringTypeConverter.Convert(null, null, null)).WithAnyArguments().Returns(string.Empty);
        }
开发者ID:JulianRooze,项目名称:Nancy,代码行数:12,代码来源:CollectionConverterFixture.cs


示例10: TryConvertTo

 public bool TryConvertTo(ITypeConverter root, TypeConversionContext context, Type convertTo, object value, out object result)
 {
     if ((Context & context) == context)
     {
         return Converter.TryConvertTo(root, context, convertTo, value, out result);
     }
     result = null;
     return false;
 }
开发者ID:kswoll,项目名称:sexy-http,代码行数:9,代码来源:ContextBasedTypeConverter.cs


示例11: TryConvertTo

 public bool TryConvertTo(ITypeConverter root, TypeConversionContext context, Type convertTo, object value, out object result)
 {
     if (convertTo == typeof(string[]) && (value?.GetType().IsArray ?? false))
     {
         result = new[] { string.Join(",", ((Array)value).Cast<object>().Select(x => root.ConvertTo<string>(context, x))) };
         return true;
     }
     result = null;
     return false;
 }
开发者ID:kswoll,项目名称:sexy-http,代码行数:10,代码来源:ArrayAsCommaSeparatedStringConverter.cs


示例12: TryConvertTo

 public bool TryConvertTo(ITypeConverter root, TypeConversionContext context, Type convertTo, object value, out object result)
 {
     foreach (var typeConverter in typeConverters)
     {
         if (typeConverter.TryConvertTo(root, context, convertTo, value, out result))
             return true;
     }
     result = null;
     return false;
 }
开发者ID:kswoll,项目名称:sexy-http,代码行数:10,代码来源:CombinedTypeConverter.cs


示例13: RemotingInspector

		/// <summary>
		///   Initializes a new instance of the <see cref = "RemotingInspector" /> class.
		/// </summary>
		/// <param name = "converter">The converter.</param>
		/// <param name = "isServer">if set to <c>true</c> is a server.</param>
		/// <param name = "isClient">if set to <c>true</c> is a client.</param>
		/// <param name = "baseUri">The base URI.</param>
		/// <param name = "remoteRegistry">The remote registry.</param>
		/// <param name = "localRegistry">The local registry.</param>
		public RemotingInspector(ITypeConverter converter, bool isServer, bool isClient,
		                         String baseUri, RemotingRegistry remoteRegistry, RemotingRegistry localRegistry)
		{
			this.converter = converter;
			this.isServer = isServer;
			this.isClient = isClient;
			this.baseUri = baseUri;
			this.remoteRegistry = remoteRegistry;
			this.localRegistry = localRegistry;
		}
开发者ID:castleproject,项目名称:Windsor,代码行数:19,代码来源:RemotingInspector.cs


示例14: XmlSerializableDeserializerSelector

        public XmlSerializableDeserializerSelector(ICompositeObjectContextFactory objectContextFactory, ITypeConverter typeConverter)
        {
            if (objectContextFactory == null)
                throw new ArgumentNullException("objectContextFactory");
            if (typeConverter == null)
                throw new ArgumentNullException("typeConverter");

            _deserializer = new XmlSerializableDeserializer(objectContextFactory, typeConverter);
            _typeConverter = typeConverter;
        }
开发者ID:kimbirkelund,项目名称:SekhmetSerialization,代码行数:10,代码来源:XmlSerializableDeserializerSelector.cs


示例15: AddConverter

 public void AddConverter(ITypeConverter converter, int? index = null)
 {
     using (_lock.EnterWriteScope())
     {
         if (index != null)
             _converters.Insert(index.Value, converter);
         else
             _converters.Add(converter);
     }
 }
开发者ID:kimbirkelund,项目名称:SekhmetSerialization,代码行数:10,代码来源:CompositeTypeConverter.cs


示例16: TryConvertTo

 public bool TryConvertTo(ITypeConverter root, TypeConversionContext context, Type convertTo, object value, out object result)
 {
     if (convertTo.IsInstanceOfType(value))
     {
         result = value;
         return true;
     }
     result = null;
     return false;
 }
开发者ID:kswoll,项目名称:sexy-http,代码行数:10,代码来源:IdentityTypeConverter.cs


示例17: Add

		public void Add(ITypeConverter converter)
		{
			converter.Context = this;

			converters.Add(converter);

			if (!(converter is IKernelDependentConverter))
			{
				standAloneConverters.Add(converter);
			}
		}
开发者ID:ralescano,项目名称:castle,代码行数:11,代码来源:DefaultConversionManager.cs


示例18: CanonicalFunctionMapper

        public CanonicalFunctionMapper(ITypeConverter converter)
        {
            this.converter = new EdmTypeConverter(converter);
            this.mappings = new Dictionary<string, Func<EdmFunction, Expression[], Expression>>();

            this.AddStringMappings();
            this.AddDateTimeMappings();
            this.AddMathMappings();
            this.AddBitwiseMappings();
            this.AddMiscMappings();
        }
开发者ID:DeadlyEmbrace,项目名称:effort,代码行数:11,代码来源:CanonicalFunctions.cs


示例19: GetField

 public object GetField(string name, object ifNull, ITypeConverter converter)
 {
     var v = GetField(name, converter);
     if (v == null || v == DBNull.Value)
     {
         return ifNull;
     }
     else
     {
         return v;
     }
 }
开发者ID:daszat,项目名称:zetbox,代码行数:12,代码来源:Record.cs


示例20: Init

		protected override void Init()
		{
			converter = (ITypeConverter)Kernel.GetSubSystem(SubSystemConstants.ConversionManagerKey);
			Kernel.ComponentModelBuilder.AddContributor(new StartableContributor(converter));
			if(optimizeForSingleInstall)
			{
				Kernel.HandlersChanged += StartAll;
				Kernel.ComponentRegistered += CacheForStart;
				return;
			}
			Kernel.ComponentRegistered +=OnComponentRegistered;
		}
开发者ID:HEskandari,项目名称:Castle.InversionOfControl,代码行数:12,代码来源:StartableFacility.cs



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


鲜花

握手

雷人

路过

鸡蛋
该文章已有0人参与评论

请发表评论

全部评论

专题导读
上一篇:
C# ITypeDeclaration类代码示例发布时间:2022-05-24
下一篇:
C# IType类代码示例发布时间:2022-05-24
热门推荐
阅读排行榜

扫描微信二维码

查看手机版网站

随时了解更新最新资讯

139-2527-9053

在线客服(服务时间 9:00~18:00)

在线QQ客服
地址:深圳市南山区西丽大学城创智工业园
电邮:jeky_zhao#qq.com
移动电话:139-2527-9053

Powered by 互联科技 X3.4© 2001-2213 极客世界.|Sitemap