示例#1
0
        internal static CodeTypeDeclaration AddBindingClass(this CodeNamespace @namespace, Type type)
        {
            if (@namespace == null)
            {
                throw new ArgumentNullException("namespace");
            }
            if (type == null)
            {
                throw new ArgumentNullException("type");
            }
            if (!typeof(BTXService).IsAssignableFrom(type))
            {
                throw new ArgumentException(string.Format("{0} is not an orchestration type.", type.FullName), "type");
            }

            var @class = new CodeTypeDeclaration(type.Name + CodeTypeDeclarationExtensions.ORCHESTRATION_BINDING_TYPE_NAME_SUFFIX)
            {
                TypeAttributes = TypeAttributes.NotPublic,
                IsPartial      = true,
                IsClass        = true
            };

            @class.BaseTypes.Add(new CodeTypeReference(typeof(OrchestrationBindingBase <>).Name, new CodeTypeReference(type.Name)));
            @class.AddGeneratedCodeAttribute();
            @namespace.Types.Add(@class);
            return(@class);
        }