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


C# ITypeDescriptor类代码示例

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


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

示例1: Retrieve

        /// <summary>
        /// Retrieves the value itself or the value of one of its item, depending on the given <see cref="Index"/>.
        /// </summary>
        /// <param name="value">The value on which this method applies.</param>
        /// <param name="index">The index of the item to retrieve. If <see cref="Index.Empty"/> is passed, this method will return the value itself.</param>
        /// <param name="descriptor">The descriptor of the type of <paramref name="value"/>.</param>
        /// <returns>The value itself or the value of one of its item.</returns>
        public static object Retrieve(object value, Index index, ITypeDescriptor descriptor)
        {
            if (index.IsEmpty)
                return value;

            if (value == null) throw new ArgumentNullException(nameof(value));

            var collectionDescriptor = descriptor as CollectionDescriptor;
            if (collectionDescriptor != null)
            {
                return collectionDescriptor.GetValue(value, index.Int);
            }
            var dictionaryDescriptor = descriptor as DictionaryDescriptor;
            if (dictionaryDescriptor != null)
            {
                return dictionaryDescriptor.GetValue(value, index.Value);
            }

            // Try with the concrete type descriptor
            var objectDescriptor = TypeDescriptorFactory.Default.Find(value.GetType());
            if (objectDescriptor != descriptor)
            {
                return Retrieve(value, index, objectDescriptor);
            }

            throw new NotSupportedException("Unable to retrieve the value at the given index, this collection is unsupported");
        }
开发者ID:Kryptos-FR,项目名称:xenko-reloaded,代码行数:34,代码来源:Content.cs

示例2: ObjectContext

 /// <summary>
 /// Initializes a new instance of the <see cref="ObjectContext"/> struct.
 /// </summary>
 /// <param name="serializerContext">The serializer context.</param>
 /// <param name="instance">The instance.</param>
 /// <param name="descriptor">The descriptor.</param>
 public ObjectContext(SerializerContext serializerContext, object instance, ITypeDescriptor descriptor)
     : this()
 {
     SerializerContext = serializerContext;
     Instance = instance;
     Descriptor = descriptor;
 }
开发者ID:vasily-kirichenko,项目名称:SharpYaml,代码行数:13,代码来源:ObjectContext.cs

示例3: TransformForSerialization

        /// <inheritdoc/>
        protected override object TransformForSerialization(ITypeDescriptor descriptor, object collection)
        {
            var dictionaryDescriptor = (DictionaryDescriptor)descriptor;
            var instance = CreatEmptyContainer(descriptor);

            CollectionItemIdentifiers identifier;
            if (!CollectionItemIdHelper.TryGetCollectionItemIds(collection, out identifier))
            {
                identifier = new CollectionItemIdentifiers();
            }
            var keyWithIdType = typeof(KeyWithId<>).MakeGenericType(dictionaryDescriptor.KeyType);
            foreach (var item in dictionaryDescriptor.GetEnumerator(collection))
            {
                ItemId id;
                if (!identifier.TryGet(item.Key, out id))
                {
                    id = ItemId.New();
                    identifier.Add(item.Key, id);
                }
                var keyWithId = Activator.CreateInstance(keyWithIdType, id, item.Key);
                instance.Add(keyWithId, item.Value);
            }

            return instance;
        }
开发者ID:Kryptos-FR,项目名称:xenko-reloaded,代码行数:26,代码来源:DictionaryWithIdsSerializer.cs

示例4: VisitCollectionItem

 /// <inheritdoc/>
 public override void VisitCollectionItem(IEnumerable collection, CollectionDescriptor descriptor, int index, object item, ITypeDescriptor itemDescriptor)
 {
     if (CurrentPath.Match(MemberPath))
         VisitAssetMember(item, itemDescriptor);
     else
         base.VisitCollectionItem(collection, descriptor, index, item, itemDescriptor);
 }
开发者ID:Kryptos-FR,项目名称:xenko-reloaded,代码行数:8,代码来源:AssetMemberVisitorBase.cs

示例5: FlexiPlainTextSerializationContext

 public FlexiPlainTextSerializationContext(
     IFlexiPlainTextSerializer serializer,
     ITypeDescriptor typeDescriptor,
     TypeResolver typeResolver,
     Func<Type, CreateInstanceContext, object> createInstanceWith = null)
     : base(serializer, typeDescriptor, typeResolver, createInstanceWith)
 { }
开发者ID:squaredinfinity,项目名称:Foundation,代码行数:7,代码来源:FlexiPlainTextSerializationContext.cs

示例6: ContentBase

 protected ContentBase(ITypeDescriptor descriptor, bool isPrimitive, IReference reference)
 {
     if (descriptor == null) throw new ArgumentNullException(nameof(descriptor));
     Reference = reference;
     Descriptor = descriptor;
     IsPrimitive = isPrimitive;
 }
开发者ID:Kryptos-FR,项目名称:xenko-reloaded,代码行数:7,代码来源:ContentBase.cs

示例7: VisitArrayItem

 /// <inheritdoc/>
 public override void VisitArrayItem(Array array, ArrayDescriptor descriptor, int index, object item, ITypeDescriptor itemDescriptor)
 {
     if (CurrentPath.Match(MemberPath))
         VisitAssetMember(item, itemDescriptor);
     else
         base.VisitArrayItem(array, descriptor, index, item, itemDescriptor);
 }
开发者ID:Kryptos-FR,项目名称:xenko-reloaded,代码行数:8,代码来源:AssetMemberVisitorBase.cs

示例8: TryCreate

        public override IYamlSerializable TryCreate(SerializerContext context, ITypeDescriptor typeDescriptor)
        {
            if (CanVisit(typeDescriptor.Type))
                return this;

            return null;
        }
开发者ID:h78hy78yhoi8j,项目名称:xenko,代码行数:7,代码来源:EntityGroupAssetSerializer.cs

示例9: ObjectContext

 /// <summary>
 /// Initializes a new instance of the <see cref="ObjectContext"/> struct.
 /// </summary>
 /// <param name="serializerContext">The serializer context.</param>
 /// <param name="instance">The instance.</param>
 /// <param name="descriptor">The descriptor.</param>
 public ObjectContext(SerializerContext serializerContext, object instance, ITypeDescriptor descriptor) : this()
 {
     SerializerContext = serializerContext;
     Instance = instance;
     Descriptor = descriptor;
     Properties = new PropertyContainer();
 }
开发者ID:Kryptos-FR,项目名称:xenko-reloaded,代码行数:13,代码来源:ObjectContext.cs

示例10: ObjectContent

 public ObjectContent(object value, ITypeDescriptor descriptor, bool isPrimitive, IReference reference)
     : base(descriptor, isPrimitive, reference)
 {
     if (reference is ObjectReference)
         throw new ArgumentException($"An {nameof(ObjectContent)} cannot contain an {nameof(ObjectReference)}");
     this.value = value;
 }
开发者ID:Kryptos-FR,项目名称:xenko-reloaded,代码行数:7,代码来源:ObjectContent.cs

示例11: Unbinder

        public Unbinder(ITypeDescriptor typeDescriptor,
		                ITypeSimplicityEvaluator typeSimplicityEvaluator,
		                IValueUnbinder valueUnbinder)
        {
            _typeDescriptor = typeDescriptor;
            _typeSimplicityEvaluator = typeSimplicityEvaluator;
            _valueUnbinder = valueUnbinder;
        }
开发者ID:mhinze,项目名称:unbound,代码行数:8,代码来源:Unbinder.cs

示例12: 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

示例13: ContentBase

 protected ContentBase(ITypeDescriptor descriptor, bool isPrimitive, IReference reference)
 {
     if (descriptor == null) throw new ArgumentNullException("descriptor");
     this.reference = reference;
     Descriptor = descriptor;
     IsPrimitive = isPrimitive;
     SerializeFlags = ViewModelContentSerializeFlags.SerializeValue;
     ShouldProcessReference = true;
 }
开发者ID:h78hy78yhoi8j,项目名称:xenko,代码行数:9,代码来源:ContentBase.cs

示例14: VisitDictionaryKeyValue

        public override void VisitDictionaryKeyValue(object dictionary, DictionaryDescriptor descriptor, object key, ITypeDescriptor keyDescriptor, object value, ITypeDescriptor valueDescriptor)
        {
            // TODO: CurrentPath is valid only for value, not key
            //if (ProcessObject(key, keyDescriptor.Type)) key = null;
            if (ProcessObject(value, valueDescriptor.Type)) return;

            Visit(value, valueDescriptor);
            //base.VisitDictionaryKeyValue(dictionary, descriptor, key, keyDescriptor, value, valueDescriptor);
        }
开发者ID:Kryptos-FR,项目名称:xenko-reloaded,代码行数:9,代码来源:UnloadableObjectRemover.cs

示例15: CreateDataContextTypeStack

 protected override IDataContextStack CreateDataContextTypeStack(ITypeDescriptor viewModelType, ITypeDescriptor wrapperType = null, IDataContextStack parentDataContextStack = null)
 {
     var dataContextTypeStack = new DataContextStack(ResolvedTypeDescriptor.ToSystemType(viewModelType), parentDataContextStack as DataContextStack);
     if (wrapperType != null)
     {
         dataContextTypeStack.RootControlType = ResolvedTypeDescriptor.ToSystemType(wrapperType);
     }
     return dataContextTypeStack;
 }
开发者ID:darilek,项目名称:dotvvm,代码行数:9,代码来源:DefaultControlTreeResolver.cs


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