Example #1
0
        // TODO: (core) Do we still need DataSettings.ProviderInvariantName and ProviderFriendlyName?
        //public string ProviderInvariantName
        //{
        //    get
        //    {
        //        if (this.DataProvider.HasValue() && this.DataProvider.IsCaseInsensitiveEqual("sqlserver"))
        //            return "System.Data.SqlClient";

        //        // SqlCe should always be the default provider
        //        return "System.Data.SqlServerCe.4.0";
        //    }
        //}

        //public string ProviderFriendlyName
        //{
        //    get
        //    {
        //        if (this.DataProvider.HasValue() && this.DataProvider.IsCaseInsensitiveEqual("sqlserver"))
        //            return "SQL Server";

        //        // SqlCe should always be the default provider
        //        return "SQL Server Compact (SQL CE)";
        //    }
        //}

        protected virtual bool Load()
        {
            using (_rwLock.GetWriteLock())
            {
                Reset();

                (TenantName, TenantRoot) = ResolveTenant();

                if (TenantRoot.FileExists(SETTINGS_FILENAME) && !_testMode)
                {
                    string text     = TenantRoot.ReadAllText(SETTINGS_FILENAME);
                    var    settings = ParseSettings(text);
                    if (settings.Any())
                    {
                        RawDataSettings.AddRange(settings);

                        (DataProviderType, DataProviderClrType) = ConvertDataProvider(settings.Get("DataProvider"));
                        ConnectionString = settings.Get("DataConnectionString");

                        if (settings.ContainsKey("AppVersion"))
                        {
                            AppVersion = new Version(settings["AppVersion"]);
                        }

                        return(IsValid());
                    }
                }

                return(false);
            }
        }
Example #2
0
        public virtual bool Save()
        {
            if (!IsValid())
            {
                return(false);
            }

            using (_rwLock.GetWriteLock())
            {
                TenantRoot.WriteAllText(SETTINGS_FILENAME, SerializeSettings());
                return(true);
            }
        }
 /// <summary>
 /// Gets the hash code
 /// </summary>
 /// <returns>Hash code</returns>
 public override int GetHashCode()
 {
     unchecked // Overflow is fine, just wrap
     {
         var hashCode = 41;
         // Suitable nullity checks etc, of course :)
         if (TenantRoot != null)
         {
             hashCode = hashCode * 59 + TenantRoot.GetHashCode();
         }
         if (TenantPathMatcher != null)
         {
             hashCode = hashCode * 59 + TenantPathMatcher.GetHashCode();
         }
         return(hashCode);
     }
 }
        /// <summary>
        /// Returns true if OrgApacheSlingTenantInternalTenantProviderImplProperties instances are equal
        /// </summary>
        /// <param name="other">Instance of OrgApacheSlingTenantInternalTenantProviderImplProperties to be compared</param>
        /// <returns>Boolean</returns>
        public bool Equals(OrgApacheSlingTenantInternalTenantProviderImplProperties other)
        {
            if (other is null)
            {
                return(false);
            }
            if (ReferenceEquals(this, other))
            {
                return(true);
            }

            return
                ((
                     TenantRoot == other.TenantRoot ||
                     TenantRoot != null &&
                     TenantRoot.Equals(other.TenantRoot)
                     ) &&
                 (
                     TenantPathMatcher == other.TenantPathMatcher ||
                     TenantPathMatcher != null &&
                     TenantPathMatcher.Equals(other.TenantPathMatcher)
                 ));
        }