コード例 #1
0
        /// <inheritdoc/>
        public override bool CanAttach(ITypeDescriptor typeDescriptor, MemberDescriptorBase memberDescriptor)
        {
            var type = typeDescriptor.GetInnerCollectionType();
            var isNullableStruct = type.IsNullable() && Nullable.GetUnderlyingType(type).IsStruct();
            var isAbstractOrClass = type.IsAbstract || type.IsClass;
            //var isCollection = (typeDescriptor is CollectionDescriptor) || (typeDescriptor is DictionaryDescriptor);

            //var result = isNullableStruct || (isAbstractOrClass && !isCollection);
            var result = isNullableStruct || isAbstractOrClass;
            return result;
        }
コード例 #2
0
        /// <inheritdoc/>
        public override bool CanAttach(ITypeDescriptor typeDescriptor, MemberDescriptorBase memberDescriptor)
        {
            var type              = typeDescriptor.GetInnerCollectionType();
            var isNullableStruct  = type.IsNullable() && Nullable.GetUnderlyingType(type).IsStruct();
            var isAbstractOrClass = type.IsAbstract || type.IsClass;
            //var isCollection = (typeDescriptor is CollectionDescriptor) || (typeDescriptor is DictionaryDescriptor);

            //var result = isNullableStruct || (isAbstractOrClass && !isCollection);
            var result = isNullableStruct || isAbstractOrClass;

            return(result);
        }
コード例 #3
0
        private IEnumerable <KeyValuePair <string, List <SingleObservableNode> > > GetCommonChildrenInList()
        {
            var             allChildNodes = new Dictionary <string, List <SingleObservableNode> >();
            ITypeDescriptor singleType    = null;

            foreach (var singleNode in CombinedNodes)
            {
                var descriptor = TypeDescriptorFactory.Default.Find(singleNode.Type);
                if (singleType != null && singleType != descriptor)
                {
                    return(null);
                }

                singleType = descriptor;
            }

            // If we're in a collection of value type, use usual name-based combination (which should actually be index-based)
            if (singleType.GetInnerCollectionType().IsValueType)
            {
                return(GetCommonChildren());
            }

            if (GroupByType)
            {
                return(null);
            }
            return(GetCommonChildren());
            //// When the collection are not of
            //foreach (var observableNode in singleNode.Children)
            //{
            //    var child = (SingleObservableNode)observableNode;
            //    var list = allChildNodes.GetOrCreateValue(child.Name);
            //    list.Add(child);
            //}

            //return allChildNodes.Where(x => ShouldCombine(x.Value, CombinedNodes.Count, x.Key));
        }
コード例 #4
0
        /// <summary>
        /// Indicates if the given type descriptor represents a reference type, or a collection of reference types.
        /// </summary>
        /// <param name="typeDescriptor">The type descriptor to analyze.</param>
        /// <returns>True if the type descriptor represents a reference type, false otherwise.</returns>
        /// <remarks>A reference type is either an <see cref="AssetReference"/> or a content type registered in the <see cref="AssetRegistry"/>.</remarks>
        public static bool ContainsReferenceType(ITypeDescriptor typeDescriptor)
        {
            var type = typeDescriptor.GetInnerCollectionType();

            return(typeof(AssetReference).IsAssignableFrom(type) || AssetRegistry.IsContentType(type));
        }