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


C# ITypeDescriptor.GetPreferedType方法代码示例

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


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

示例1: InitFromItemDescriptor

 void InitFromItemDescriptor(ITypeDescriptor descriptor)
 {
     if (descriptor == _itemDescriptor && _name != null) return;
     _itemDescriptor = descriptor;
     if ((descriptor.Name?.Length ?? 0) == 0) return;
     _itemType = _itemDescriptor.GetPreferedType();
     Sealed = _itemDescriptor.Sealed;
     Name = $"List<{_itemDescriptor.Name}>";
 }
开发者ID:Xamarui,项目名称:BTDB,代码行数:9,代码来源:ListTypeDescriptor.cs

示例2: InitFromKeyValueDescriptors

 void InitFromKeyValueDescriptors(ITypeDescriptor keyDescriptor, ITypeDescriptor valueDescriptor)
 {
     if (_keyDescriptor == keyDescriptor && _valueDescriptor == valueDescriptor && _name != null) return;
     _keyDescriptor = keyDescriptor;
     _valueDescriptor = valueDescriptor;
     if ((_keyDescriptor.Name?.Length ?? 0) == 0 || (_valueDescriptor.Name?.Length ?? 0) == 0) return;
     _keyType = _keyDescriptor.GetPreferedType();
     _valueType = _valueDescriptor.GetPreferedType();
     Sealed = _keyDescriptor.Sealed && _valueDescriptor.Sealed;
     Name = $"Dictionary<{_keyDescriptor.Name}, {_valueDescriptor.Name}>";
 }
开发者ID:Xamarui,项目名称:BTDB,代码行数:11,代码来源:DictionaryTypeDescriptor.cs

示例3: InitFromItemDescriptor

 void InitFromItemDescriptor(ITypeDescriptor descriptor)
 {
     if (descriptor == _itemDescriptor) return;
     _itemDescriptor = descriptor;
     _itemType = _itemDescriptor.GetPreferedType();
     Sealed = _itemDescriptor.Sealed;
     Name = "List<" + _itemDescriptor.Name + ">";
 }
开发者ID:yonglehou,项目名称:BTDB,代码行数:8,代码来源:ListTypeDescriptor.cs

示例4: BuildComplexSaver

 Action<AbstractBufferedWriter, ITypeBinarySerializerContext, object> BuildComplexSaver(ITypeDescriptor descriptor)
 {
     var method = ILBuilder.Instance.NewMethod<Action<AbstractBufferedWriter, ITypeBinarySerializerContext, object>>(descriptor.Name + "Saver");
     var il = method.Generator;
     descriptor.GenerateSave(il, ilgen => ilgen.Ldarg(0), ilgen => ilgen.Ldarg(1), ilgen =>
     {
         ilgen.Ldarg(2);
         var type = descriptor.GetPreferedType();
         if (type != typeof(object))
         {
             ilgen.Castclass(type);
         }
     }, descriptor.GetPreferedType());
     il.Ret();
     return method.Create();
 }
开发者ID:klesta490,项目名称:BTDB,代码行数:16,代码来源:EventSerializer.cs

示例5: LoadAsType

 public Type LoadAsType(ITypeDescriptor descriptor, Type targetType)
 {
     return descriptor.GetPreferedType(targetType) ?? TypeNameMapper.ToType(descriptor.Name) ?? typeof(object);
 }
开发者ID:klesta490,项目名称:BTDB,代码行数:4,代码来源:EventSerializer.cs

示例6: InitFromKeyValueDescriptors

 void InitFromKeyValueDescriptors(ITypeDescriptor keyDescriptor, ITypeDescriptor valueDescriptor)
 {
     if (_keyDescriptor == keyDescriptor && _valueDescriptor == valueDescriptor) return;
     _keyDescriptor = keyDescriptor;
     _valueDescriptor = valueDescriptor;
     _keyType = _keyDescriptor.GetPreferedType();
     _valueType = _valueDescriptor.GetPreferedType();
     Sealed = _keyDescriptor.Sealed && _valueDescriptor.Sealed;
     Name = string.Format("Dictionary<{0}, {1}>", _keyDescriptor.Name, _valueDescriptor.Name);
 }
开发者ID:yonglehou,项目名称:BTDB,代码行数:10,代码来源:DictionaryTypeDescriptor.cs

示例7: NewSimpleSaver

 Action<AbstractBufferedWriter, object> NewSimpleSaver(ITypeDescriptor descriptor)
 {
     if (descriptor.AnyOpNeedsCtx()) return null;
     var method = ILBuilder.Instance.NewMethod<Action<AbstractBufferedWriter, object>>(descriptor.Name + "SimpleSaver");
     var il = method.Generator;
     descriptor.GenerateSave(il, ilgen => ilgen.Ldarg(0), null, ilgen =>
         {
             ilgen.Ldarg(1);
             var type = descriptor.GetPreferedType();
             if (type != typeof(object))
             {
                 ilgen.UnboxAny(type);
             }
         }, descriptor.GetPreferedType());
     il.Ret();
     return method.Create();
 }
开发者ID:Bobris,项目名称:BTDB,代码行数:17,代码来源:TypeSerializers.cs

示例8: LoadAsType

 public Type LoadAsType(ITypeDescriptor descriptor)
 {
     return descriptor.GetPreferedType() ?? NameToType(descriptor.Name) ?? typeof(object);
 }
开发者ID:Bobris,项目名称:BTDB,代码行数:4,代码来源:TypeSerializers.cs


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