當前位置: 首頁>>代碼示例>>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;未經允許,請勿轉載。