public void CustomizeCodeDom(CodeCompileUnit codeUnit, IServiceProvider services)
        {
            NamingService = new NamingService((INamingService)services.GetService(typeof(INamingService)));
            Services = services;
            InitializeMappings();
            var types = codeUnit.Namespaces[0].Types;
            foreach (CodeTypeDeclaration type in types)
            {
                if (!type.IsClass || type.IsContextType()) { continue; }

                var logicalName = type.GetFieldInitalizedValue("EntityLogicalName");
                var propertiesToAdd = new List<CodeMemberProperty>();
                foreach (var member in type.Members)
                {
                    var property = member as CodeMemberProperty;
                    if (SkipProperty(property, type))
                    {
                        continue;
                    }
                    propertiesToAdd.Add(GetOptionSetEnumType(property, logicalName));
                }

                foreach (var enumProp in propertiesToAdd.Where(p => p != null))
                {
                    type.Members.Add(enumProp);
                }
            }

            AddEntityOptionSetEnumDeclaration(types);
        }
        /// <summary>
        /// Does not mark the OptionSet for generation if it has already been generated.  
        /// This could get called for the same Global Option Set multiple times because it's on multiple Entites
        /// </summary>
        public bool GenerateOptionSet(OptionSetMetadataBase optionSetMetadata, IServiceProvider services)
        {

#if SKIP_STATE_OPTIONSETS
            // Only skip the state optionsets if the user of the extension wishes to.
            if (optionSetMetadata.OptionSetType == OptionSetType.State)
            {
                return false;
            }
#endif
            if (Skip(optionSetMetadata.Name))
            {
                return false;
            }

            bool generate = false;

            if (optionSetMetadata.IsGlobal.GetValueOrDefault())
            {
                if (!GeneratedOptionSets.Contains(optionSetMetadata.Name))
                {
                    GeneratedOptionSets.Add(optionSetMetadata.Name);
                    generate = true;
                }
            }
            else
            {
                generate = true;
            }

            if (generate && optionSetMetadata.Name != null)
            {
                string name = optionSetMetadata.Name;
                if (name.ToLower().EndsWith("set"))
                {
                    optionSetMetadata.Name = name + "Enum";
                }
            }

            // Remove Dups
            var metadataOptionSet = optionSetMetadata as OptionSetMetadata;
            if (generate && metadataOptionSet != null)
            {
                var namingService = new NamingService((INamingService)services.GetService(typeof(INamingService)));
                var names = new HashSet<string>();
                foreach (var option in metadataOptionSet.Options.ToList())
                {
                    var name = namingService.GetNameForOption(optionSetMetadata, option, services);
                    if (names.Contains(name))
                    {
                        metadataOptionSet.Options.Remove(option);
                    }
                    names.Add(name);
                }
            }

            return generate;
        }