Наследование: ICustomizeCodeDomService
Пример #1
0
        public void CustomizeCodeDom(CodeCompileUnit codeUnit, IServiceProvider services)
        {
            if (UpdateMultiOptionSetAttributes)
            {
                new MultiOptionSetAttributeUpdater().CustomizeCodeDom(codeUnit, services);
            }
            if (UpdateEnumerableEntityProperties)
            {
                new EnumerableEntityPropertyUpdater().CustomizeCodeDom(codeUnit, services);
            }
            if (AddPrimaryAttributeConsts)
            {
                new PrimaryAttributeGenerator().CustomizeCodeDom(codeUnit, services);
            }
            if (GenerateConstructorsSansLogicalName)
            {
                new EntityConstructorsGenerator().CustomizeCodeDom(codeUnit, services);
            }
            if (GenerateAttributeNameConsts)
            {
                new RelationshipConstGenerator().CustomizeCodeDom(codeUnit, services);
                new AttributeConstGenerator().CustomizeCodeDom(codeUnit, services);
            }
            if (GenerateAnonymousTypeConstructor)
            {
                new AnonymousTypeConstructorGenerator().CustomizeCodeDom(codeUnit, services);
            }
            if (!GenerateEntityTypeCode)
            {
                new RemoveEntityTypeCodeService().CustomizeCodeDom(codeUnit, services);
            }

            var multiSelectCreated = false;

            if (GenerateEnumProperties)
            {
                var generator = new EnumPropertyGenerator(CreateBaseClasses, ReplaceOptionSetPropertiesWithEnum);
                generator.CustomizeCodeDom(codeUnit, services);
                multiSelectCreated = generator.MultiSelectEnumCreated;
            }

            if (GenerateOptionSetMetadataAttribute)
            {
                new OptionSetMetadataAttributeGenerator().CustomizeCodeDom(codeUnit, services);
            }

            if (CreateBaseClasses)
            {
                new EntityBaseClassGenerator(multiSelectCreated).CustomizeCodeDom(codeUnit, services);
            }
            if (AddDebuggerNonUserCode)
            {
                new MemberAttributes().CustomizeCodeDom(codeUnit, services);
            }
        }
        public void CustomizeCodeDom(CodeCompileUnit codeUnit, IServiceProvider services)
        {
            new MultiOptionSetAttributeUpdater().CustomizeCodeDom(codeUnit, services);
            if (UseXrmClient)
            {
                new CodeCustomization(Parameters).CustomizeCodeDom(codeUnit, services);
            }
            if (AddPrimaryAttributeConsts)
            {
                new PrimaryAttributeGenerator().CustomizeCodeDom(codeUnit, services);
            }
            if (GenerateConstructorsSansLogicalName)
            {
                new EntityConstructorsGenerator().CustomizeCodeDom(codeUnit, services);
            }
            if (GenerateAttributeNameConsts)
            {
                new AttributeConstGenerator().CustomizeCodeDom(codeUnit, services);
            }
            if (GenerateAnonymousTypeConstructor)
            {
                new AnonymousTypeConstructorGenerator().CustomizeCodeDom(codeUnit, services);
            }
            if (!GenerateEntityTypeCode)
            {
                new RemoveEntityTypeCodeService().CustomizeCodeDom(codeUnit, services);
            }

            var multiSelectCreated = false;

            if (GenerateEnumProperties)
            {
                var generator = new EnumPropertyGenerator(CreateBaseClasses);
                generator.CustomizeCodeDom(codeUnit, services);
                multiSelectCreated = generator.MultiSelectEnumCreated;
            }
            if (CreateBaseClasses)
            {
                new EntityBaseClassGenerator(multiSelectCreated).CustomizeCodeDom(codeUnit, services);
            }
            if (AddDebuggerNonUserCode)
            {
                new MemberAttributes().CustomizeCodeDom(codeUnit, services);
            }
        }
        public static CodeTypeDeclaration GetEarlyBoundEntityClassDeclaration(CodeTypeDeclaration type)
        {
            var entityClass = new CodeTypeDeclaration(BaseEntityName)
            {
                IsClass        = true,
                TypeAttributes = TypeAttributes.Public | TypeAttributes.Abstract,
                BaseTypes      =
                {
                    new CodeTypeReference(typeof(Microsoft.Xrm.Sdk.Entity)),
                    new CodeTypeReference(typeof(System.ComponentModel.INotifyPropertyChanging)),
                    new CodeTypeReference(typeof(System.ComponentModel.INotifyPropertyChanged))
                }
            };

            AddEntityConstructors(entityClass);

            entityClass.Members.AddRange(type.Members.Cast <CodeTypeMember>().Where(p => BaseEntityMembers.Contains(p.Name)).Select(GetCodeTypeMember).ToArray());

            if (CustomizeCodeDomService.GenerateEnumProperties)
            {
                entityClass.Members.Add(EnumPropertyGenerator.CreateGetEnumMethod());
            }
            return(entityClass);
        }