示例#1
0
        protected virtual void AddNestedTypes(IEnumerable <TypeDefinition> types)
        {
            foreach (TypeDefinition type in types)
            {
                if (type.FullName.Contains("<"))
                {
                    continue;
                }

                string key = BridgeTypes.GetTypeDefinitionKey(type);
                this.Validator.CheckType(type, this);
                if (this.TypeDefinitions.ContainsKey(key))
                {
                    throw new System.Exception(type + " is already exists");
                }

                this.TypeDefinitions.Add(key, type);
                this.BridgeTypes.Add(key, new BridgeType(key)
                {
                    TypeDefinition = type
                });

                if (type.HasNestedTypes)
                {
                    Translator.InheritAttributes(type);
                    this.AddNestedTypes(type.NestedTypes);
                }
            }
        }
示例#2
0
        protected virtual void AddNestedTypes(IEnumerable <TypeDefinition> types)
        {
            bool skip_key;

            foreach (TypeDefinition type in types)
            {
                if (type.FullName.Contains("<"))
                {
                    continue;
                }

                this.Validator.CheckType(type, this);

                string key = BridgeTypes.GetTypeDefinitionKey(type);

                BridgeType duplicateBridgeType = null;

                skip_key = false;
                if (this.BridgeTypes.TryGetValue(key, out duplicateBridgeType))
                {
                    var duplicate = duplicateBridgeType.TypeDefinition;

                    var message = string.Format(
                        Constants.Messages.Exceptions.DUPLICATE_BRIDGE_TYPE,
                        type.Module.Assembly.FullName,
                        type.FullName,
                        duplicate.Module.Assembly.FullName,
                        duplicate.FullName);

                    if (!this.AssemblyInfo.IgnoreDuplicateTypes)
                    {
                        this.Log.Error(message);
                        throw new System.InvalidOperationException(message);
                    }
                    else
                    {
                        this.Log.Warn(message);
                    }
                    skip_key = true;
                }

                if (!skip_key)
                {
                    this.TypeDefinitions.Add(key, type);

                    this.BridgeTypes.Add(key, new BridgeType(key)
                    {
                        TypeDefinition = type
                    });

                    if (type.HasNestedTypes)
                    {
                        Translator.InheritAttributes(type);
                        this.AddNestedTypes(type.NestedTypes);
                    }
                }
            }
        }