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


C# PropertyDescriptorCollection.Cast方法代码示例

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


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

示例1: Index

		public IEnumerable<AbstractField> Index(object val, PropertyDescriptorCollection properties, Field.Store defaultStorage)
		{
			return from property in properties.Cast<PropertyDescriptor>()
			       where property.Name != Constants.DocumentIdFieldName
			       from field in CreateFields(property.Name, property.GetValue(val), defaultStorage)
			       select field;
		}
开发者ID:denno-secqtinstien,项目名称:ravendb,代码行数:7,代码来源:AnonymousObjectToLuceneDocumentConverter.cs

示例2: Index

		public static IEnumerable<AbstractField> Index(object val, PropertyDescriptorCollection properties, IndexDefinition indexDefinition, Field.Store defaultStorage)
		{
			return (from property in properties.Cast<PropertyDescriptor>()
			        let name = property.Name
					where name != Constants.DocumentIdFieldName
			        let value = property.GetValue(val)
			        from field in CreateFields(name, value, indexDefinition, defaultStorage)
			        select field);
		}
开发者ID:philiphoy,项目名称:ravendb,代码行数:9,代码来源:AnonymousObjectToLuceneDocumentConverter.cs

示例3: Index

 public static IEnumerable<AbstractField> Index(object val, PropertyDescriptorCollection properties, IndexDefinition indexDefinition, Field.Store defaultStorage)
 {
     return (from property in properties.Cast<PropertyDescriptor>()
             let name = property.Name
             where name != "__document_id"
             let value = property.GetValue(val)
             where value != null
             select Createfield(name, value, indexDefinition, defaultStorage));
 }
开发者ID:kenegozi,项目名称:ravendb,代码行数:9,代码来源:AnonymousObjectToLuceneDocumentConverter.cs

示例4: Index

 public IEnumerable<Field> Index(object val, PropertyDescriptorCollection properties, IndexDefinition indexDefinition)
 {
     return (from property in properties.Cast<PropertyDescriptor>()
             let name = property.Name
             where name != "__document_id"
             let value = property.GetValue(val)
             where value != null
             select new Field(name, ToIndexableString(value, indexDefinition.GetIndex(name)), indexDefinition.GetStorage(name), indexDefinition.GetIndex(name)));
 }
开发者ID:torkelo,项目名称:ravendb,代码行数:9,代码来源:AnonymousObjectToLuceneDocumentConverter.cs

示例5: Patch

 PropertyDescriptorCollection Patch(PropertyDescriptorCollection original)
 {
     return new PropertyDescriptorCollection(original.Cast<PropertyDescriptor>().Select(x => {
         var control = instance as Control;
         if(control != null && (BindingOperations.IsBoundProperty(control, x) || !SerializeHelper.CanSerializeProperty(control, x)))
             return new BoundPropertyDescriptor(x);
         return x;
     }).ToArray());
 }
开发者ID:VitalyTVA,项目名称:WinMVVM,代码行数:9,代码来源:BoundElementTypeDescriptionProvider.cs

示例6: Filter

			PropertyDescriptorCollection Filter(PropertyDescriptorCollection properties)
			{
				PropertyDescriptor property = properties[_parent._propertyName];
				if (property != null) {
					if ((properties as System.Collections.IDictionary).IsReadOnly) {
						properties = new PropertyDescriptorCollection(properties.Cast<PropertyDescriptor>().ToArray());
					}
					properties.Remove(property);
					properties.Add(new ShadowPropertyDescriptor(_parent, property));
				}
				return properties;
			}
开发者ID:modulexcite,项目名称:WpfDesigner,代码行数:12,代码来源:DummyValueInsteadOfNullTypeDescriptionProvider.cs

示例7: ValidateEntityAssociations

        /// <summary>
        /// This method validates the association attributes for the specified entity type
        /// </summary>
        /// <param name="entityType">Type of entity to validate its association attributes for</param>
        /// <param name="entityProperties">collection of entity property descriptors</param>
        private void ValidateEntityAssociations(Type entityType, PropertyDescriptorCollection entityProperties)
        {
            foreach (PropertyDescriptor pd in entityProperties)
            {
                // validate the association attribute (if any)
                AssociationAttribute assocAttrib = pd.Attributes[typeof(AssociationAttribute)] as AssociationAttribute;
                if (assocAttrib == null)
                {
                    continue;
                }

                string assocName = assocAttrib.Name;
                if (string.IsNullOrEmpty(assocName))
                {
                    throw new ArgumentException(string.Format(CultureInfo.CurrentCulture, Resource.InvalidAssociation_NameCannotBeNullOrEmpty, pd.Name, entityType));
                }
                if (string.IsNullOrEmpty(assocAttrib.ThisKey))
                {
                    throw new ArgumentException(string.Format(CultureInfo.CurrentCulture, Resource.InvalidAssociation_StringCannotBeNullOrEmpty, assocName, entityType, "ThisKey"));
                }
                if (string.IsNullOrEmpty(assocAttrib.OtherKey))
                {
                    throw new ArgumentException(string.Format(CultureInfo.CurrentCulture, Resource.InvalidAssociation_StringCannotBeNullOrEmpty, assocName, entityType, "OtherKey"));
                }

                // The number of keys in 'this' and 'other' must be the same
                if (assocAttrib.ThisKeyMembers.Count() != assocAttrib.OtherKeyMembers.Count())
                {
                    throw new InvalidOperationException(string.Format(CultureInfo.CurrentCulture, Resource.InvalidAssociation_Key_Count_Mismatch, assocName, entityType, assocAttrib.ThisKey, assocAttrib.OtherKey));
                }

                // check that all ThisKey members exist on this entity type
                foreach (string thisKey in assocAttrib.ThisKeyMembers)
                {
                    if (entityProperties[thisKey] == null)
                    {
                        throw new InvalidOperationException(string.Format(CultureInfo.CurrentCulture, Resource.InvalidAssociation_ThisKeyNotFound, assocName, entityType, thisKey));
                    }
                }

                // Verify that the association name is unique. In inheritance scenarios, self-referencing associations
                // on the base type should be inheritable by the derived types.
                Type otherEntityType = TypeUtility.GetElementType(pd.PropertyType);
                int otherMemberCount = entityProperties.Cast<PropertyDescriptor>().Count(p => p.Name != pd.Name && p.Attributes.OfType<AssociationAttribute>().Any(a => a.Name == assocAttrib.Name));
                bool isSelfReference = otherEntityType.IsAssignableFrom(entityType);
                if ((!isSelfReference && otherMemberCount > 0) || (isSelfReference && otherMemberCount > 1))
                {
                    throw new InvalidOperationException(string.Format(CultureInfo.CurrentCulture, Resource.InvalidAssociation_NonUniqueAssociationName, assocName, entityType));
                }

                // Verify that the type of FK associations return singletons.
                if (assocAttrib.IsForeignKey && (otherEntityType != pd.PropertyType))
                {
                    throw new InvalidOperationException(string.Format(
                        CultureInfo.CurrentCulture,
                        Resource.InvalidAssociation_FKNotSingleton,
                        assocName, entityType));
                }

                // Associations are not allowed to be marked as [Required], because we don't guarantee 
                // that we set the association on the server. In many cases it's possible that we simply 
                // associate entities based on FKs.
                if (pd.Attributes[typeof(RequiredAttribute)] != null)
                {
                    throw new InvalidOperationException(String.Format(CultureInfo.CurrentCulture, Resource.Entity_RequiredAssociationNotAllowed, entityType, pd.Name));
                }

                // Throw if the association member has a explicit RoundtripOriginalAttribute on it
                if (pd.ExplicitAttributes()[typeof(RoundtripOriginalAttribute)] != null)
                {
                    throw new InvalidOperationException(String.Format(CultureInfo.CurrentCulture, Resource.InvalidAssociation_RoundTripOriginal, pd.Name, entityType));
                }

                // if the other entity is also exposed by the service, perform additional validation
                if (this._entityTypes.Contains(otherEntityType))
                {
                    PropertyDescriptorCollection otherEntityProperties = TypeDescriptor.GetProperties(otherEntityType);
                    PropertyDescriptor otherMember = otherEntityProperties.Cast<PropertyDescriptor>().FirstOrDefault(p => p.Name != pd.Name && p.Attributes.OfType<AssociationAttribute>().Any(a => a.Name == assocName));
                    if (otherMember != null)
                    {
                        // Bi-directional association
                        // make sure IsForeignKey is set to true on one and only one side of the association
                        AssociationAttribute otherAssocAttrib = (AssociationAttribute)otherMember.Attributes[typeof(AssociationAttribute)];
                        if (otherAssocAttrib != null &&
                            !((assocAttrib.IsForeignKey != otherAssocAttrib.IsForeignKey)
                             && (assocAttrib.IsForeignKey || otherAssocAttrib.IsForeignKey)))
                        {
                            throw new InvalidOperationException(string.Format(CultureInfo.CurrentCulture, Resource.InvalidAssociation_IsFKInvalid, assocName, entityType));
                        }

                        Type otherMemberEntityType = TypeUtility.GetElementType(otherMember.PropertyType);

                        // Verify that the type of the corresponding association points back to this entity
                        // The type of the corresponding association can be one of the parents of the entity, but it cannot be one of its children.
                        if (!otherMemberEntityType.IsAssignableFrom(entityType))
//.........这里部分代码省略.........
开发者ID:OpenRIAServices,项目名称:OpenRiaServices,代码行数:101,代码来源:DomainServiceDescription.cs


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