• 设为首页
  • 点击收藏
  • 手机版
    手机扫一扫访问
    迪恩网络手机版
  • 关注官方公众号
    微信扫一扫关注
    公众号

C# DynamicTypes.DataTypeDescriptor类代码示例

原作者: [db:作者] 来自: [db:来源] 收藏 邀请

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



DataTypeDescriptor类属于Composite.Data.DynamicTypes命名空间,在下文中一共展示了DataTypeDescriptor类的20个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于我们的系统推荐出更棒的C#代码示例。

示例1: TryGetType

        internal static Type TryGetType(DataTypeDescriptor dataTypeDescriptor, bool forceReCompilation, out bool codeGenerationNeeded)
        {
            Verify.ArgumentNotNull(dataTypeDescriptor, "dataTypeDescriptor");
            codeGenerationNeeded = false;

            Type type;

            if (!forceReCompilation)
            {
                type = TypeManager.TryGetType(dataTypeDescriptor.GetFullInterfaceName());
                if (type != null) return type;

                if (!dataTypeDescriptor.IsCodeGenerated)
                {
                    type = TypeManager.TryGetType(dataTypeDescriptor.TypeManagerTypeName);
                    if (type != null) return type;
                }
            }

            if (!dataTypeDescriptor.IsCodeGenerated)
            {
                return null;
            }

            if (forceReCompilation)
            {
                type = TypeManager.TryGetType(dataTypeDescriptor.GetFullInterfaceName());
                if (type != null) return type;
            }

            codeGenerationNeeded = true;
            return null;
        }
开发者ID:DBailey635,项目名称:C1-CMS,代码行数:33,代码来源:InterfaceCodeManager.cs


示例2: GetType

        /// <summary>
        /// This method will return type given by the dataTypeDescriptor.
        /// If the data type does not exist, one will be dynamically
        /// runtime code generated.
        /// </summary>
        /// <param name="dataTypeDescriptor"></param>
        /// <param name="forceReCompilation">If this is true a new type will be compiled regardless if one already exists.</param>
        /// <returns></returns>
        public static Type GetType(DataTypeDescriptor dataTypeDescriptor, bool forceReCompilation = false)
        {
            bool codeGenerationNeeded;

            Type type = TryGetType(dataTypeDescriptor, forceReCompilation, out codeGenerationNeeded);
            if (type != null)
            {
                return type;
            }

            if (codeGenerationNeeded)
            {
                lock (_lock)
                {
                    type = TypeManager.TryGetType(dataTypeDescriptor.GetFullInterfaceName());
                    if (type != null) return type;

                    var codeGenerationBuilder = new CodeGenerationBuilder("DataInterface: " + dataTypeDescriptor.Name);
                    InterfaceCodeGenerator.AddAssemblyReferences(codeGenerationBuilder, dataTypeDescriptor);
                    InterfaceCodeGenerator.AddInterfaceTypeCode(codeGenerationBuilder, dataTypeDescriptor);

                    IEnumerable<Type> types = CodeGenerationManager.CompileRuntimeTempTypes(codeGenerationBuilder);

                    return types.Single();
                }
            }

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


示例3: AddAssemblyReferences

 /// <summary>
 /// Adds the assembly references required by the supplied <see cref="DataTypeDescriptor"/> to the supplied  <see cref="CodeGenerationBuilder"/>
 /// </summary>
 /// <param name="codeGenerationBuilder">Assembly refences is added to this builder</param>
 /// <param name="dataTypeDescriptor">Data type descriptor which may contain references to assemblies</param>
 public static void AddAssemblyReferences(CodeGenerationBuilder codeGenerationBuilder, DataTypeDescriptor dataTypeDescriptor)
 {
     foreach (Assembly assembly in GetReferencedAssemblies(dataTypeDescriptor))
     {
         codeGenerationBuilder.AddReference(assembly);
     }
 }
开发者ID:DBailey635,项目名称:C1-CMS,代码行数:12,代码来源:InterfaceCodeGenerator.cs


示例4: XmlDataTypeStore

        public XmlDataTypeStore(DataTypeDescriptor dataTypeDescriptor, Type dataProviderHelperType, Type dataIdClassType, IEnumerable<XmlDataTypeStoreDataScope> xmlDateTypeStoreDataScopes, bool isGeneratedDataType)
        {
            if (dataProviderHelperType == null) throw new ArgumentNullException("dataProviderHelperType");
            if (dataIdClassType == null) throw new ArgumentNullException("dataIdClassType");

            DataTypeDescriptor =  dataTypeDescriptor;
            DataProviderHelperType = dataProviderHelperType;
            DataIdClassType = dataIdClassType;
            IsGeneratedDataType = isGeneratedDataType;

            _xmlDateTypeStoreDataScopes = xmlDateTypeStoreDataScopes.Evaluate();

            var ordering = new List<Func<XElement, IComparable>>();
            foreach (string key in dataTypeDescriptor.KeyPropertyNames)
            {
                XName localKey = key;
                ordering.Add(f => (string)f.Attribute(localKey) ?? "");
            }
            Func<IEnumerable<XElement>, IOrderedEnumerable<XElement>> orderer = f => ordering.Skip(1).Aggregate(f.OrderBy(ordering.First()), Enumerable.ThenBy);

            foreach (XmlDataTypeStoreDataScope xmlDataTypeStoreDataScope in _xmlDateTypeStoreDataScopes)
            {
                DataScopeIdentifier dataScopeIdentifier = DataScopeIdentifier.Deserialize(xmlDataTypeStoreDataScope.DataScopeName);
                CultureInfo culture = CultureInfo.CreateSpecificCulture(xmlDataTypeStoreDataScope.CultureName);
                Type dataType = dataTypeDescriptor.GetInterfaceType();

                Action cacheFlush = () => DataEventSystemFacade.FireExternalStoreChangedEvent(dataType, dataScopeIdentifier.ToPublicationScope(), culture);
                XmlDataProviderDocumentCache.RegisterExternalFileChangeAction(xmlDataTypeStoreDataScope.Filename, cacheFlush);

                XmlDataProviderDocumentWriter.RegisterFileOrderer(xmlDataTypeStoreDataScope.Filename, orderer);
            }
        }
开发者ID:DBailey635,项目名称:C1-CMS,代码行数:32,代码来源:XmlDataTypeStore.cs


示例5: AddNew

        /// <summary>
        /// Create an invariant store
        /// </summary>
        /// <param name="providerName"></param>
        /// <param name="dataTypeDescriptor"></param>
        public static void AddNew(string providerName, DataTypeDescriptor dataTypeDescriptor)
        {
            var xmlDataProviderConfiguration = new XmlDataProviderConfiguration(providerName);

            string interfaceType = dataTypeDescriptor.TypeManagerTypeName;

            if (interfaceType != null)
            {
                object key = xmlDataProviderConfiguration.Section.Interfaces.GetKey(dataTypeDescriptor);

                if (key != null)
                {
                    Log.LogWarning(LogTitle, 
                        "Configuration file '{0}' already contains an interface type '{1} 'with id '{2}'. "
                        + "Possibly there are multiple AppDomain-s running.",
                        xmlDataProviderConfiguration.ConfigurationFilePath, dataTypeDescriptor, dataTypeDescriptor.DataTypeId);
                    return;
                }
            }

            XmlProviderInterfaceConfigurationElement configurationElement = BuildXmlProviderInterfaceConfigurationElement(dataTypeDescriptor);

            XmlDataProviderStoreManipulator.CreateStore(providerName, configurationElement);

            xmlDataProviderConfiguration.Section.Interfaces.Add(configurationElement);

            xmlDataProviderConfiguration.Save();
        }
开发者ID:hitesh97,项目名称:C1-CMS,代码行数:33,代码来源:InterfaceConfigurationManipulator.cs


示例6: Validate

        /// <summary>
        /// This method validates if the existing .NET runtime type match the recorded meta data (DataTypeDescriptor).
        /// In case there is a mismatch, changes might have been done to the runtime type and an update on 
        /// the existing store(s)could not be performed.
        /// </summary>
        /// <param name="interfaceType"></param>
        /// <param name="existingDataTypeDescriptor"></param>
        /// <param name="errorMessage"></param>
        /// <returns></returns>
        public static bool Validate(Type interfaceType, DataTypeDescriptor existingDataTypeDescriptor, out string errorMessage)
        {
            DataTypeDescriptor newDataTypeDescriptor;
            
            try
            {
                newDataTypeDescriptor  = DynamicTypeManager.BuildNewDataTypeDescriptor(interfaceType);
            }
            catch (Exception)
            {
                errorMessage = null;
                return true;
            }

            try
            {
                new DataTypeChangeDescriptor(existingDataTypeDescriptor, newDataTypeDescriptor);
            }
            catch (Exception ex)
            {
                errorMessage = ex.Message;
                return false;
            }

            errorMessage = null;
            return true;
        }
开发者ID:DBailey635,项目名称:C1-CMS,代码行数:36,代码来源:DataTypeValidator.cs


示例7: CreateCodeTypeDeclaration

        /// <summary>
        /// Given a <see cref="DataTypeDescriptor"/> creates a interface declaration inheriting from IData, a valid C1 Datatype.
        /// </summary>
        /// <param name="dataTypeDescriptor">A description of the data type to generate interface for</param>
        /// <returns>The generated interface</returns>
        public static CodeTypeDeclaration CreateCodeTypeDeclaration(DataTypeDescriptor dataTypeDescriptor)
        {
            try
            {
                var codeTypeDeclaration = new CodeTypeDeclaration(dataTypeDescriptor.Name)
                {
                    IsInterface = true
                };

                codeTypeDeclaration.BaseTypes.Add(new CodeTypeReference(typeof(IData)));

                var propertyNamesToSkip = new List<string>();

                foreach (Type superInterface in dataTypeDescriptor.SuperInterfaces)
                {
                    codeTypeDeclaration.BaseTypes.Add(new CodeTypeReference(superInterface));

                    propertyNamesToSkip.AddRange(superInterface.GetAllProperties().Select(p => p.Name));
                }

                AddInterfaceAttributes(codeTypeDeclaration, dataTypeDescriptor);
                AddInterfaceProperties(codeTypeDeclaration, dataTypeDescriptor, propertyNamesToSkip);

                return codeTypeDeclaration;
            }
            catch (Exception ex)
            {
                throw new InvalidOperationException(string.Format("Failed to generate interface for type '{0}'", dataTypeDescriptor.TypeManagerTypeName), ex);
            }
        }
开发者ID:DBailey635,项目名称:C1-CMS,代码行数:35,代码来源:InterfaceCodeGenerator.cs


示例8: EntityBaseClassGenerator

 public EntityBaseClassGenerator(DataTypeDescriptor dataTypeDescriptor, string entityBaseClassName, string dataIdClassName, string providerName)
 {
     _entityBaseClassName = entityBaseClassName;
     _dataIdClassName = dataIdClassName;
     _dataTypeDescriptor = dataTypeDescriptor;
     _providerName = providerName;
 }
开发者ID:hitesh97,项目名称:C1-CMS,代码行数:7,代码来源:EntityBaseClassGenerator.cs


示例9: MakeFileName

        internal static string MakeFileName(DataTypeDescriptor dataTypeDescriptor, DataScopeIdentifier dataScopeIdentifier, string cultureName)
        {
            string typeFullName = StringExtensionMethods.CreateNamespace(dataTypeDescriptor.Namespace, dataTypeDescriptor.Name, '.');

            string publicationScopePart = "";

            switch (dataScopeIdentifier.Name)
            {
                case DataScopeIdentifier.PublicName:
                    break;
                case DataScopeIdentifier.AdministratedName:
                    publicationScopePart = "_" + PublicationScope.Unpublished;
                    break;
                default:
                    throw new InvalidOperationException("Unsupported data scope identifier: '{0}'".FormatWith(dataScopeIdentifier.Name));
            }

            string cultureNamePart = "";

            if (cultureName != "")
            {
                cultureNamePart = "_" + cultureName;
            }

            return typeFullName + publicationScopePart + cultureNamePart + ".xml";
        }
开发者ID:DBailey635,项目名称:C1-CMS,代码行数:26,代码来源:NamesCreator.cs


示例10: AddLocale

 internal void AddLocale(DataTypeDescriptor typeDescriptor, CultureInfo cultureInfo)
 {
     foreach (DataScopeIdentifier dataScope in typeDescriptor.DataScopes)
     {
         CreateStore(typeDescriptor, dataScope, cultureInfo);
     }
 }
开发者ID:Orckestra,项目名称:C1-CMS,代码行数:7,代码来源:SqlDataProviderStoreManipulator.cs


示例11: AddDataType

        internal void AddDataType(DataTypeDescriptor dataTypeDescriptor, IEnumerable<SqlDataTypeStoreDataScope> sqlDataTypeStoreDataScopes)
        {
            Type interfaceType = DataTypeTypesManager.GetDataType(dataTypeDescriptor);
            if (interfaceType == null) return;

            IEnumerable<Tuple<string, string>> names;

            SqlProviderCodeGenerator codeGenerator = new SqlProviderCodeGenerator(_providerName);
            IEnumerable<CodeTypeDeclaration> codeTypeDeclarations = codeGenerator.CreateCodeDOMs(dataTypeDescriptor, sqlDataTypeStoreDataScopes, out names);
            codeTypeDeclarations.ForEach(f => _codeGenerationBuilder.AddType(_namespaceName, f));

            _entityClassNamesAndDataContextFieldNames.AddRange(names);
            
            _codeGenerationBuilder.AddReference(interfaceType.Assembly);

            // Property serializer for entity tokens and more
            string dataIdClassFullName = NamesCreator.MakeDataIdClassFullName(dataTypeDescriptor, _providerName);

            var keyPropertiesDictionary = new Dictionary<string, Type>();
            var keyPropertiesList = new List<Tuple<string, Type>>();
            foreach (var keyField in dataTypeDescriptor.KeyFields)
            {
                Verify.That(!keyPropertiesDictionary.ContainsKey(keyField.Name), "Key field with name '{0}' already present. Data type: {1}. Check for multiple [KeyPropertyName(...)] attributes", keyField.Name, dataTypeDescriptor.Namespace + "." + dataTypeDescriptor.Name);

                keyPropertiesDictionary.Add(keyField.Name, keyField.InstanceType);
                keyPropertiesList.Add(new Tuple<string, Type>(keyField.Name, keyField.InstanceType));
            }

            PropertySerializerTypeCodeGenerator.AddPropertySerializerTypeCode(_codeGenerationBuilder, dataIdClassFullName, keyPropertiesList);
        }
开发者ID:hitesh97,项目名称:C1-CMS,代码行数:30,代码来源:SqlDataProviderCodeBuilder.cs


示例12: RemoveLocale

 internal void RemoveLocale(string providerName, DataTypeDescriptor typeDescriptor, CultureInfo cultureInfo)
 {
     foreach (DataScopeIdentifier dataScope in typeDescriptor.DataScopes)
     {
         DropStore(typeDescriptor, dataScope, cultureInfo);
     }
 }
开发者ID:Orckestra,项目名称:C1-CMS,代码行数:7,代码来源:SqlDataProviderStoreManipulator.cs


示例13: CreateScopeData

 private void CreateScopeData(DataTypeDescriptor typeDescriptor, DataScopeIdentifier dataScope)
 {
     foreach (var cultureInfo in GetCultures(typeDescriptor))
     {
         CreateStore(typeDescriptor, dataScope, cultureInfo);
     }
 }
开发者ID:Orckestra,项目名称:C1-CMS,代码行数:7,代码来源:SqlDataProviderStoreManipulator.cs


示例14: AddPendingDataTypeDescritpor

        /// <summary>
        /// Use this method to register data type descriptors that have been validated and will be 
        /// intstalled.
        /// </summary>
        /// <param name="interfaceName"></param>
        /// <param name="dataTypeDescriptor"></param>
        public void AddPendingDataTypeDescritpor(string interfaceName, DataTypeDescriptor dataTypeDescriptor)
        {
            Verify.ArgumentNotNullOrEmpty(interfaceName, "interfaceName");
            Verify.ArgumentNotNull(dataTypeDescriptor, "dataTypeDescriptor");

            _pendingDataTypeDescriptors.Add(interfaceName, dataTypeDescriptor);
        }
开发者ID:DBailey635,项目名称:C1-CMS,代码行数:13,代码来源:PackageInstallerContext.cs


示例15: Validate

        /// <summary>
        /// 
        /// </summary>
        /// <param name="interfaceType"></param>
        /// <param name="existingDataTypeDescriptor">Use null to get existing data type descriptor</param>
        /// <param name="errorMessage"></param>
        /// <returns></returns>
        public static bool Validate(Type interfaceType, DataTypeDescriptor existingDataTypeDescriptor, out string errorMessage)
        {
            if (existingDataTypeDescriptor == null)
            {
                existingDataTypeDescriptor = DataMetaDataFacade.GetDataTypeDescriptor(interfaceType.GetImmutableTypeId());

                if (existingDataTypeDescriptor == null)
                {
                    errorMessage = null;
                    return true;
                }
            }

            errorMessage = _typeSpecificValidations.GetOrAdd(
                interfaceType,
                f =>
                {
                    string message;
                    bool isValid = DataTypeValidator.Validate(interfaceType, existingDataTypeDescriptor, out message);

                    if (isValid) return null;

                    var sb = new StringBuilder();
                    sb.AppendLine(string.Format("The data type interface '{0}' did not validate and can't be used at the moment.", interfaceType));
                    sb.AppendLine(message);

                    return sb.ToString();
                }
            );

            return errorMessage == null;
        }
开发者ID:DBailey635,项目名称:C1-CMS,代码行数:39,代码来源:DataTypeValidationRegistry.cs


示例16: AddNew

        internal static InterfaceConfigurationElement AddNew(string providerName, DataTypeDescriptor dataTypeDescriptor)
        {
            lock (_syncRoot)
            {
                var configuration = new SqlDataProviderConfiguration(providerName);

                if (configuration.Section.Interfaces.ContainsInterfaceType(dataTypeDescriptor.DataTypeId))
                {
                    Log.LogWarning(LogTitle,
                        "Configuration file '{0}' already contains an interface with data type ID '{1}', type name '{2}'. "
                         + "Possibly there are multiple AppDomain-s running.",
                            configuration.ConfigurationFilePath,
                            dataTypeDescriptor.DataTypeId,
                            dataTypeDescriptor);

                    return configuration.Section.Interfaces.Get(dataTypeDescriptor);
                }

                InterfaceConfigurationElement interfaceConfig = BuildInterfaceConfigurationElement(dataTypeDescriptor);

                configuration.Section.Interfaces.Add(interfaceConfig);

                configuration.Save();

                return interfaceConfig;
            }
        }
开发者ID:RuneAndersen,项目名称:C1-CMS,代码行数:27,代码来源:InterfaceConfigurationManipulator.cs


示例17: XmlProviderCodeGenerator

        public XmlProviderCodeGenerator(DataTypeDescriptor dataTypeDescriptor, string namespaceName)
        {
            _dataTypeDescriptor = dataTypeDescriptor;

            DataProviderHelperClassFullName = namespaceName + "." + NamesCreator.MakeDataProviderHelperClassName(dataTypeDescriptor);
            WrapperClassFullName = namespaceName + "." + NamesCreator.MakeWrapperClassName(dataTypeDescriptor);
            DataIdClassFullName = namespaceName + "." + NamesCreator.MakeDataIdClassName(dataTypeDescriptor);
        }
开发者ID:DBailey635,项目名称:C1-CMS,代码行数:8,代码来源:XmlProviderCodeGenerator.cs


示例18: SqlDataProviderHelperGenerator

 public SqlDataProviderHelperGenerator(DataTypeDescriptor dataTypeDescriptor, string sqlDataProviderHelperClassName, string dataIdClassName, string entityClassName, string dataContextFieldName)
 {
     _dataTypeDescriptor = dataTypeDescriptor;
     _sqlDataProviderHelperClassName = sqlDataProviderHelperClassName;
     _dataIdClassName = dataIdClassName;
     _entityClassName = entityClassName;
     _dataContextFieldName = dataContextFieldName;
 }
开发者ID:DBailey635,项目名称:C1-CMS,代码行数:8,代码来源:SqlDataProviderHelperGenerator.cs


示例19: AddInterfaceTypeCode

        /// <summary>
        /// Adds the source code defined by <see cref="DataTypeDescriptor"/> to the supplied  <see cref="CodeGenerationBuilder"/>
        /// </summary>
        /// <param name="codeGenerationBuilder">Source code is added to this builder</param>
        /// <param name="dataTypeDescriptor">Data type descriptor to convert into source code</param>
        public static void AddInterfaceTypeCode(CodeGenerationBuilder codeGenerationBuilder, DataTypeDescriptor dataTypeDescriptor)
        {
            var codeTypeDeclaration = CreateCodeTypeDeclaration(dataTypeDescriptor);

            var codeNamespace = new CodeNamespace(dataTypeDescriptor.Namespace);
            codeNamespace.Types.Add(codeTypeDeclaration);
            codeGenerationBuilder.AddNamespace(codeNamespace);
        }
开发者ID:DBailey635,项目名称:C1-CMS,代码行数:13,代码来源:InterfaceCodeGenerator.cs


示例20: GeneratedTypesHelper

        /// <exclude />
        public GeneratedTypesHelper(Type oldType)
        {
            Verify.ArgumentNotNull(oldType, "oldType");

            _oldType = oldType;
            _oldDataTypeDescriptor = DynamicTypeManager.GetDataTypeDescriptor(oldType);

            Initialize();
        }
开发者ID:RuneAndersen,项目名称:C1-CMS,代码行数:10,代码来源:GeneratedTypesHelper.cs



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


鲜花

握手

雷人

路过

鸡蛋
该文章已有0人参与评论

请发表评论

全部评论

专题导读
上一篇:
C# Api.Resource类代码示例发布时间:2022-05-24
下一篇:
C# Security.EntityToken类代码示例发布时间:2022-05-24
热门推荐
阅读排行榜

扫描微信二维码

查看手机版网站

随时了解更新最新资讯

139-2527-9053

在线客服(服务时间 9:00~18:00)

在线QQ客服
地址:深圳市南山区西丽大学城创智工业园
电邮:jeky_zhao#qq.com
移动电话:139-2527-9053

Powered by 互联科技 X3.4© 2001-2213 极客世界.|Sitemap