Пример #1
0
		/// <summary>
		/// Serializes an instance of <see cref="DcilSchema"/>
		/// </summary>
		/// <param name="schema">The <see cref="DcilSchema"/> to Serialize</param>
		/// <param name="stream">The <see cref="System.IO.MemoryStream"/> to write to</param>
		public static void Serialize(DcilSchema schema, System.IO.MemoryStream stream)
		{
			schema.Namespaces = new XmlSerializerNamespaces();
			schema.Namespaces.Add("dcl", "http://schemas.orm.net/DIL/DCIL");
			schema.Namespaces.Add("dil", "http://schemas.orm.net/DIL/DIL");
			schema.Namespaces.Add("ddt", "http://schemas.orm.net/DIL/DILDT");
			schema.Namespaces.Add("dep", "http://schemas.orm.net/DIL/DILEP");
			schema.Namespaces.Add("dml", "http://schemas.orm.net/DIL/DMIL");
			schema.Namespaces.Add("ddl", "http://schemas.orm.net/DIL/DDIL");
			XmlSerializer s = new XmlSerializer(typeof(DcilSchema));
			using (XmlWriter writer = XmlWriter.Create(stream, new XmlWriterSettings()))
			{
				writer.WriteProcessingInstruction("new", "");
				s.Serialize(writer, schema);
			}
		}
Пример #2
0
        /// <summary>
        /// Serializes an instance of <see cref="DcilSchema"/>
        /// </summary>
        /// <param name="schema">The <see cref="DcilSchema"/> to Serialize</param>
        /// <param name="stream">The <see cref="System.IO.MemoryStream"/> to write to</param>
        public static void Serialize(DcilSchema schema, System.IO.MemoryStream stream)
        {
            schema.Namespaces = new XmlSerializerNamespaces();
            schema.Namespaces.Add("dcl", "http://schemas.orm.net/DIL/DCIL");
            schema.Namespaces.Add("dil", "http://schemas.orm.net/DIL/DIL");
            schema.Namespaces.Add("ddt", "http://schemas.orm.net/DIL/DILDT");
            schema.Namespaces.Add("dep", "http://schemas.orm.net/DIL/DILEP");
            schema.Namespaces.Add("dml", "http://schemas.orm.net/DIL/DMIL");
            schema.Namespaces.Add("ddl", "http://schemas.orm.net/DIL/DDIL");
            XmlSerializer s = new XmlSerializer(typeof(DcilSchema));

            using (XmlWriter writer = XmlWriter.Create(stream, new XmlWriterSettings()))
            {
                writer.WriteProcessingInstruction("new", "");
                s.Serialize(writer, schema);
            }
        }
Пример #3
0
        /// <summary>
        /// Implements <see cref="IWizard.RunStarted"/>
        /// </summary>
        protected void RunStarted(object automationObject, Dictionary <string, string> replacementsDictionary, WizardRunKind runKind, object[] customParams)
        {
            IOleServiceProvider oleServiceProvider = automationObject as IOleServiceProvider;
            ServiceProvider     serviceProvider    = (oleServiceProvider != null) ? new ServiceProvider(oleServiceProvider) : null;

            DataConnectionDialogFactory dialogFactory = GetService <DataConnectionDialogFactory>(serviceProvider);

            Debug.Assert(dialogFactory != null, "Can't get DataConnectionDialogFactory!");

            System.Data.IDbConnection dbConn;
            DataConnectionDialog      dialog = dialogFactory.CreateConnectionDialog();

            dialog.AddAllSources();
            DataConnection dataConn = dialog.ShowDialog(false);

            if (dataConn != null)
            {
                if ((dbConn = dataConn.ConnectionSupport.ProviderObject as System.Data.IDbConnection) == null)
                {
                    // show error
                    return;
                }

                DataProviderManager manager = GetService <DataProviderManager>(serviceProvider);
                if (manager != null)
                {
                    DataProvider provider      = manager.GetDataProvider(dataConn.Provider);
                    string       invariantName = provider.GetProperty("InvariantName") as string;

                    IList <string> schemaList     = DcilSchema.GetAvailableSchemaNames(dbConn, invariantName);
                    string         selectedSchema = null;
                    switch (schemaList.Count)
                    {
                    case 1:
                        selectedSchema = schemaList[0];
                        break;

                    default:
                        // Allow this for an empty list
                        selectedSchema = SchemaSelector.SelectSchema(serviceProvider, schemaList);
                        break;
                    }

                    if (!string.IsNullOrEmpty(selectedSchema))
                    {
                        DcilSchema schema = DcilSchema.FromSchemaName(selectedSchema, dbConn, invariantName);

                        StringBuilder stringBuilder     = new StringBuilder();
                        string        replacementString = null;
                        using (MemoryStream ms = new MemoryStream())
                        {
                            DcilSchema.Serialize(schema, ms);
                            ms.Seek(0, SeekOrigin.Begin);
                            StreamReader sr = new StreamReader(ms);
                            replacementString = sr.ReadToEnd();
                        }


                        replacementsDictionary.Add("$DcilFile$", replacementString);
                        myAddToProject = true;
                    }
                }
            }
        }