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


C# DataTypeDescriptor.AddSuperInterface方法代码示例

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


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

示例1: FromXml

        internal static DataTypeDescriptor FromXml(XElement element, bool inheritedFieldsIncluded)
        {
            Verify.ArgumentNotNull(element, "element");
            if (element.Name != "DataTypeDescriptor") throw new ArgumentException("The xml is not correctly formatted.");


            Guid dataTypeId = (Guid) element.GetRequiredAttribute("dataTypeId");
            string name = element.GetRequiredAttributeValue("name");
            string @namespace = element.GetRequiredAttributeValue("namespace");

            bool isCodeGenerated = (bool) element.GetRequiredAttribute("isCodeGenerated");
            XAttribute cachableAttribute = element.Attribute("cachable");
            XAttribute buildNewHandlerTypeNameAttribute = element.Attribute("buildNewHandlerTypeName");
            XElement dataAssociationsElement = element.GetRequiredElement("DataAssociations");
            XElement dataScopesElement = element.GetRequiredElement("DataScopes");
            XElement keyPropertyNamesElement = element.GetRequiredElement("KeyPropertyNames");
            XElement versionKeyPropertyNamesElement = element.Element("VersionKeyPropertyNames");
            XElement superInterfacesElement = element.GetRequiredElement("SuperInterfaces");
            XElement fieldsElement = element.GetRequiredElement("Fields");
            XElement indexesElement = element.Element("Indexes");

            XAttribute titleAttribute = element.Attribute("title");
            XAttribute labelFieldNameAttribute = element.Attribute("labelFieldName");
            XAttribute internalUrlPrefixAttribute = element.Attribute("internalUrlPrefix");
            string typeManagerTypeName = (string) element.Attribute("typeManagerTypeName");

            bool cachable = cachableAttribute != null && (bool)cachableAttribute;

            var dataTypeDescriptor = new DataTypeDescriptor(dataTypeId, @namespace, name, isCodeGenerated)
            {
                Cachable = cachable
            };

            if (titleAttribute != null) dataTypeDescriptor.Title = titleAttribute.Value;
            if (labelFieldNameAttribute != null) dataTypeDescriptor.LabelFieldName = labelFieldNameAttribute.Value;
            if (internalUrlPrefixAttribute != null) dataTypeDescriptor.InternalUrlPrefix = internalUrlPrefixAttribute.Value;
            if (typeManagerTypeName != null)
            {
                typeManagerTypeName = TypeManager.FixLegasyTypeName(typeManagerTypeName);
                dataTypeDescriptor.TypeManagerTypeName = typeManagerTypeName;
            }
            if (buildNewHandlerTypeNameAttribute != null) dataTypeDescriptor.BuildNewHandlerTypeName = buildNewHandlerTypeNameAttribute.Value;


            foreach (XElement elm in dataAssociationsElement.Elements())
            {
                var dataTypeAssociationDescriptor = DataTypeAssociationDescriptor.FromXml(elm);

                dataTypeDescriptor.DataAssociations.Add(dataTypeAssociationDescriptor);
            }

            foreach (XElement elm in dataScopesElement.Elements("DataScopeIdentifier"))
            {
                string dataScopeName = elm.GetRequiredAttributeValue("name");
                if (DataScopeIdentifier.IsLegasyDataScope(dataScopeName))
                {
                    Log.LogWarning(LogTitle, "Ignored legacy data scope '{0}' on type '{1}.{2}' while deserializing DataTypeDescriptor. The '{0}' data scope is no longer supported.".FormatWith(dataScopeName, @namespace, name));
                    continue;
                }

                DataScopeIdentifier dataScopeIdentifier = DataScopeIdentifier.Deserialize(dataScopeName);

                dataTypeDescriptor.DataScopes.Add(dataScopeIdentifier);
            }

            foreach (XElement elm in superInterfacesElement.Elements("SuperInterface"))
            {
                string superInterfaceTypeName = elm.GetRequiredAttributeValue("type");

                if (superInterfaceTypeName.StartsWith("Composite.Data.ProcessControlled.IDeleteControlled"))
                {
                    Log.LogWarning(LogTitle, $"Ignored legacy super interface '{superInterfaceTypeName}' on type '{@namespace}.{name}' while deserializing DataTypeDescriptor. This super interface is no longer supported.");
                    continue;
                }
                
                Type superInterface;

                try
                {
                    superInterface = TypeManager.GetType(superInterfaceTypeName);
                }
                catch (Exception ex)
                {
                    throw XmlConfigurationExtensionMethods.GetConfigurationException($"Failed to load super interface '{superInterfaceTypeName}'", ex, elm);
                }

                dataTypeDescriptor.AddSuperInterface(superInterface, !inheritedFieldsIncluded);
            }

            foreach (XElement elm in fieldsElement.Elements())
            {
                var dataFieldDescriptor = DataFieldDescriptor.FromXml(elm);

                try
                {
                    dataTypeDescriptor.Fields.Add(dataFieldDescriptor);
                }
                catch (Exception ex)
                {
                    throw XmlConfigurationExtensionMethods.GetConfigurationException("Failed to add a data field: " + ex.Message, ex, elm);
//.........这里部分代码省略.........
开发者ID:Orckestra,项目名称:C1-CMS,代码行数:101,代码来源:DataTypeDescriptor.cs

示例2: CreateUpdatedDataTypeDescriptor

        //private DataFieldDescriptor BuildKeyFieldDescriptor()
        //{
        //    DataFieldDescriptor result;

        //    switch (_keyFieldType)
        //    {
        //        case KeyFieldType.Guid:
        //            result = BuildIdField();
        //            break;
        //        case KeyFieldType.RandomString4:
        //            result = new DataFieldDescriptor(Guid.NewGuid(), IdFieldName, StoreFieldType.String(22), typeof (string))
        //            {
        //                DefaultValue = DefaultValue.RandomString(4, true)
        //            };
        //            break;
        //        case KeyFieldType.RandomString8:
        //            result = new DataFieldDescriptor(Guid.NewGuid(), IdFieldName, StoreFieldType.String(22), typeof (string))
        //            {
        //                DefaultValue = DefaultValue.RandomString(8, false)
        //            };
        //            break;
        //        default: throw new InvalidOperationException("Not supported key field type value");
        //    }

        //    result.Position = -1;

        //    return result;
        //}


        private DataTypeDescriptor CreateUpdatedDataTypeDescriptor()
        {
            var dataTypeDescriptor = new DataTypeDescriptor(_oldDataTypeDescriptor.DataTypeId, _newTypeNamespace, _newTypeName, true);

            dataTypeDescriptor.DataScopes.Add(DataScopeIdentifier.Public);

            dataTypeDescriptor.Cachable = _cachable;


            Type[] indirectlyInheritedInterfaces =
            {
                typeof(IPublishControlled), typeof(ILocalizedControlled), 
                typeof(IPageData), typeof(IPageFolderData), typeof(IPageMetaData)
            };

            // Foreign interfaces should stay inherited
            foreach (var superInterface in _oldDataTypeDescriptor.SuperInterfaces)
            {
                if (!indirectlyInheritedInterfaces.Contains(superInterface))
                {
                    dataTypeDescriptor.AddSuperInterface(superInterface);
                }
            }


            if (_publishControlled && _dataAssociationType != DataAssociationType.Composition)
            {
                dataTypeDescriptor.AddSuperInterface(typeof(IPublishControlled));
            }

            if (_localizedControlled && _dataAssociationType != DataAssociationType.Composition)
            {
                dataTypeDescriptor.AddSuperInterface(typeof(ILocalizedControlled));
            }


            if (_oldDataTypeDescriptor.SuperInterfaces.Contains(typeof(IPageFolderData)))
            {
                dataTypeDescriptor.AddSuperInterface(typeof(IPageData));
                dataTypeDescriptor.AddSuperInterface(typeof(IPageFolderData));
            }
            else if (_oldDataTypeDescriptor.SuperInterfaces.Contains(typeof(IPageMetaData)))
            {
                dataTypeDescriptor.AddSuperInterface(typeof(IPageData));
                dataTypeDescriptor.AddSuperInterface(typeof(IPageMetaData));
            }
            else
            {
                //DataFieldDescriptor idDataFieldDescriptor =
                //    (from dfd in _oldDataTypeDescriptor.Fields
                //     where dfd.Name == KeyFieldName
                //     select dfd).Single();

                //dataTypeDescriptor.Fields.Add(idDataFieldDescriptor);
                //dataTypeDescriptor.KeyPropertyNames.Add(KeyFieldName);
                
            }

            dataTypeDescriptor.Title = _newTypeTitle;

            foreach (DataFieldDescriptor dataFieldDescriptor in _newDataFieldDescriptors)
            {
                dataTypeDescriptor.Fields.Add(dataFieldDescriptor);
            }

            if (KeyFieldName != null && !dataTypeDescriptor.KeyPropertyNames.Contains(KeyFieldName))
            {
                dataTypeDescriptor.KeyPropertyNames.Add(KeyFieldName);
            }

//.........这里部分代码省略.........
开发者ID:DBailey635,项目名称:C1-CMS,代码行数:101,代码来源:GeneratedTypesHelper.cs

示例3: Clone

        /// <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,
            };

            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;
        }
开发者ID:Orckestra,项目名称:C1-CMS,代码行数:47,代码来源:DataTypeDescriptor.cs

示例4: CreateNewDataTypeDescriptor

        private DataTypeDescriptor CreateNewDataTypeDescriptor(
            string typeNamespace,
            string typeName,
            string typeTitle,
            string labelFieldName,
            string internalUrlPrefix,
            bool cachable,
            bool publishControlled,
            bool localizedControlled,
            IEnumerable<DataFieldDescriptor> dataFieldDescriptors,
            DataFieldDescriptor foreignKeyDataFieldDescriptor,
            DataTypeAssociationDescriptor dataTypeAssociationDescriptor,
            DataFieldDescriptor compositionRuleForeignKeyDataFieldDescriptor)
        {
            Guid id = Guid.NewGuid();
            var dataTypeDescriptor = new DataTypeDescriptor(id, typeNamespace, typeName, true)
            {
                Cachable = cachable,
                Title = typeTitle,
                LabelFieldName = labelFieldName,
                InternalUrlPrefix = internalUrlPrefix
            };

            dataTypeDescriptor.DataScopes.Add(DataScopeIdentifier.Public);

            if (publishControlled && _dataAssociationType != DataAssociationType.Composition)
            {
                dataTypeDescriptor.AddSuperInterface(typeof(IPublishControlled));
            }

            if (localizedControlled)
            {
                dataTypeDescriptor.AddSuperInterface(typeof(ILocalizedControlled));
            }

            //bool addKeyField = true;
            if (_dataAssociationType == DataAssociationType.Aggregation)
            {
                dataTypeDescriptor.AddSuperInterface(typeof(IPageDataFolder));
            }
            else if (_dataAssociationType == DataAssociationType.Composition)
            {
                //addKeyField = false;
                dataTypeDescriptor.AddSuperInterface(typeof(IPageData));
                dataTypeDescriptor.AddSuperInterface(typeof(IPageRelatedData));
                dataTypeDescriptor.AddSuperInterface(typeof(IPageMetaData));
            }

            //if (addKeyField)
            //{
            //    var idDataFieldDescriptor = BuildKeyFieldDescriptor();

            //    dataTypeDescriptor.Fields.Add(idDataFieldDescriptor);
            //    dataTypeDescriptor.KeyPropertyNames.Add(IdFieldName);
            //}

            foreach (DataFieldDescriptor dataFieldDescriptor in dataFieldDescriptors)
            {
                dataTypeDescriptor.Fields.Add(dataFieldDescriptor);
            }

            if (_newKeyFieldName != null)
            {
                dataTypeDescriptor.KeyPropertyNames.Add(_newKeyFieldName);
            }

            int position = 100;
            if (_foreignKeyDataFieldDescriptor != null)
            {
                _foreignKeyDataFieldDescriptor.Position = position++;

                if (foreignKeyDataFieldDescriptor.Name != PageReferenceFieldName)
                {
                    dataTypeDescriptor.Fields.Add(foreignKeyDataFieldDescriptor);
                    dataTypeDescriptor.DataAssociations.Add(dataTypeAssociationDescriptor);
                }
            }


            return dataTypeDescriptor;
        }
开发者ID:DBailey635,项目名称:C1-CMS,代码行数:81,代码来源:GeneratedTypesHelper.cs


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