Composite.Data.DynamicTypes.DataTypeDescriptor.AddSuperInterface C# (CSharp) Метод

AddSuperInterface() приватный Метод

Adds an interface the data type should inherit from
private AddSuperInterface ( Type interfaceType, bool addInheritedFields ) : void
interfaceType System.Type
addInheritedFields bool
Результат void
        internal void AddSuperInterface(Type interfaceType, bool addInheritedFields)
        {
            if (_superInterfaces.Contains(interfaceType) || interfaceType == typeof (IData))
            {
                return;
            }

            _superInterfaces.Add(interfaceType);

            if (addInheritedFields)
            {
                foreach (PropertyInfo propertyInfo in interfaceType.GetProperties())
                {
                    if (propertyInfo.Name == nameof(IPageData.PageId) && interfaceType == typeof (IPageData))
                    {
                        continue;
                    }

                    DataFieldDescriptor dataFieldDescriptor = ReflectionBasedDescriptorBuilder.BuildFieldDescriptor(propertyInfo, true);

                    this.Fields.Add(dataFieldDescriptor);
                }
            }

            foreach (string propertyName in interfaceType.GetKeyPropertyNames())
            {
                if (KeyPropertyNames.Contains(propertyName)) continue;

                PropertyInfo property = ReflectionBasedDescriptorBuilder.FindProperty(interfaceType, propertyName);

                if (DynamicTypeReflectionFacade.IsKeyField(property))
                {
                    this.KeyPropertyNames.Add(propertyName, false);
                }
            }

            foreach (var dataScopeIdentifier in DynamicTypeReflectionFacade.GetDataScopes(interfaceType))
            {
                if (!this.DataScopes.Contains(dataScopeIdentifier))
                {
                    this.DataScopes.Add(dataScopeIdentifier);
                }
            }

            var superInterfaces = interfaceType.GetInterfaces().Where(t => typeof (IData).IsAssignableFrom(t));
            foreach (Type superSuperInterfaceType in superInterfaces)
            {
                AddSuperInterface(superSuperInterfaceType, addInheritedFields);
            }
        }

Same methods

DataTypeDescriptor::AddSuperInterface ( Type interfaceType ) : void

Usage Example

Пример #1
0
        /// <summary>
        /// Clones the data type description.
        /// </summary>
        /// <returns>A clone</returns>
        public DataTypeDescriptor Clone()
        {
            var dataTypeDescriptor = new DataTypeDescriptor(this.DataTypeId, this.Namespace, this.Name, this.TypeManagerTypeName, this.IsCodeGenerated)
            {
                Title = this.Title,
                BuildNewHandlerTypeName = this.BuildNewHandlerTypeName,
                LabelFieldName          = this.LabelFieldName,
                InternalUrlPrefix       = this.InternalUrlPrefix,
                Searchable = this.Searchable
            };

            foreach (DataTypeAssociationDescriptor dataTypeAssociationDescriptor in this.DataAssociations)
            {
                dataTypeDescriptor.DataAssociations.Add(dataTypeAssociationDescriptor.Clone());
            }

            dataTypeDescriptor.DataScopes = new List <DataScopeIdentifier>(this.DataScopes);

            foreach (DataFieldDescriptor dataFieldDescriptor in this.Fields)
            {
                if (!dataFieldDescriptor.Inherited)
                {
                    dataTypeDescriptor.Fields.Add(dataFieldDescriptor.Clone());
                }
            }


            foreach (string keyPropertyName in this.KeyPropertyNames)
            {
                dataTypeDescriptor.KeyPropertyNames.Add(keyPropertyName, false);
            }

            foreach (string storeSortOrderFieldNames in this.StoreSortOrderFieldNames)
            {
                dataTypeDescriptor.StoreSortOrderFieldNames.Add(storeSortOrderFieldNames, false);
            }

            foreach (Type superInterface in this.SuperInterfaces)
            {
                dataTypeDescriptor.AddSuperInterface(superInterface);
            }

            return(dataTypeDescriptor);
        }
All Usage Examples Of Composite.Data.DynamicTypes.DataTypeDescriptor::AddSuperInterface