Exemple #1
0
        public SmoScriptableObject Create(SmoScriptingContext context)
        {
            ObjectFactory <SmoScriptableObject> factory = null;
            SmoObjectType type = context.Metadata.Type;

            if (!_factories.TryGetValue(type, out factory))
            {
                throw new InvalidOperationException("Unknown type of object");
            }

            SmoScriptableObject obj = factory(context);

            return(obj);
        }
Exemple #2
0
        private string Script(IDbConnection connection, string schema, string name)
        {
            var metadata = new SmoObjectMetadata(schema, name);

            metadata.Initialize(connection);

            var context = new SmoScriptingContext(connection, metadata);

            SmoScriptableObject obj     = _objectFactory.Create(context);
            StringCollection    batches = obj.Script(context);

            var builder = new StringBuilder();

            foreach (string batch in batches)
            {
                builder.Append(batch);
            }

            string result = builder.ToString();

            return(result);
        }