Exemplo n.º 1
0
        protected override void InternalLoad(System.Collections.Generic.Dictionary <string, object> databaseProperties)
        {
            dao.Properties        daoProperties = (dao.Properties)((dao.Database)DaoObject).Properties;
            PropertyCollectionDao properties    = new PropertyCollectionDao(DaoObject, (dao.Properties)((dao.Database)DaoObject).Properties);

            foreach (KeyValuePair <string, object> item in databaseProperties)
            {
                //initialize default values
                int    dataType      = (int)dao.DataTypeEnum.dbText;
                string propertyValue = String.Empty;

                //Split property "value" in dataType,propertyValue. NOTE: In version 1.0, property value only contained the value itself, not the data type
                //the first group matches one or more digits followed by colon
                //    ?: is used for non capture group (if data type do not exists)
                //inside the first group is the dataType group
                //the second group matches any character after the colon
                Match match = Regex.Match(item.Value.ToString(), @"^(?:(?<dataType>[0-9]+),)*(?<value>.*)$");
                if (match.Success)
                {
                    if (match.Groups["dataType"].Success)
                    {
                        dataType = int.Parse(match.Groups["dataType"].Value);
                    }
                    if (match.Groups["value"].Success)
                    {
                        propertyValue = match.Groups["value"].Value;
                    }

                    if (propertyValue != String.Empty)
                    {
                        properties.AddProperty(item.Key, propertyValue, (dao.DataTypeEnum)dataType);
                    }
                }
            }
        }
Exemplo n.º 2
0
 /// <summary>
 /// Ctor. Create a PropertyCollection object to manage the properties of a dao object
 /// </summary>
 /// <param name="daoObject">dao object like a field, table or database</param>
 /// <param name="properties">The Properties property of <paramref name="daoObject"/> object</param>
 public PropertyCollectionDao(object daoObject, dao.Properties properties)
 {
     if (daoObject == null)
     {
         throw new ArgumentNullException("daoObject");
     }
     if (properties == null)
     {
         throw new ArgumentNullException("properties");
     }
     DaoObject  = daoObject;
     Properties = properties;
 }
Exemplo n.º 3
0
 internal void ListProperties(string objectName, dao.Properties properties)
 {
     System.Diagnostics.Debug.WriteLine(objectName);
     for (int i = 1; i < properties.Count; i++)
     {
         dao.Property property = properties[i];
         object       value    = null;
         try {
             value = property.Value;
         } catch {
             value = "#Error";
         }
         System.Diagnostics.Debug.WriteLine(String.Format("\t{0}:\t{1}", property.Name, value));
     }
 }
Exemplo n.º 4
0
        protected override void ClearProperties()
        {
            dao.Properties properties = App.Application.CurrentDb().Properties;

            //If we delete AccessVersion property the database will be Access 2000 format
            string[] readOnlyProperties = new string[] { "AccessVersion", "Name", "Connect",
                                                         "Transactions", "Updatable", "CollatingOrder",
                                                         "QueryTimeout", "Version", "RecordsAffected",
                                                         "ReplicaID", "DesignMasterID", "Connection" };

            foreach (dao.Property property in properties)
            {
                try {
                    if (!Array.Exists <string>(readOnlyProperties, p => p.Equals(property.Name)))
                    {
                        properties.Delete(property.Name);
                    }
                } catch (System.Runtime.InteropServices.COMException ex) {
                    System.Diagnostics.Debug.Print(String.Format("Property: {0}, Error {1}{2}", property.Name, ex.ErrorCode, ex.Message));
                }
            }
        }