Ejemplo n.º 1
0
        internal static void InitializeContext(IConnectionInfo r, object context, bool dallas)
        {
            DataServiceContext context2 = (DataServiceContext)context;

            context2.ResolveType = name => Type.GetType("LINQPad.User." + name.Split(new char[] { '.' }).Last <string>());
            if (dallas)
            {
                string str = (string)r.DriverData.Element("AccountKey");
                if (!string.IsNullOrEmpty(str))
                {
                    str = r.Decrypt(str);
                }
                if (!string.IsNullOrEmpty(str))
                {
                    context2.Credentials = new NetworkCredential("accountkey", str);
                }
            }
            else if (r.DatabaseInfo.UserName.Length > 0)
            {
                context2.Credentials = new NetworkCredential(r.DatabaseInfo.UserName, r.DatabaseInfo.Password);
            }
            else
            {
                context2.Credentials = CredentialCache.DefaultNetworkCredentials;
            }
            context2.SendingRequest += delegate(object sender, SendingRequestEventArgs e) {
                WebProxy webProxy = Util.GetWebProxy();
                if (webProxy != null)
                {
                    e.Request.Proxy = webProxy;
                }
                DataContextBase.SqlLog.WriteLine(e.Request.RequestUri);
            };
        }
Ejemplo n.º 2
0
        string WithDecrypt(string elementName)
        {
            var v = (string)driverData.Element(elementName);

            if (v == null)
            {
                return(null);
            }
            return(cxInfo.Decrypt(v));
        }
        public static RavenConnectionDialogViewModel Load(IConnectionInfo cxInfo)
        {
            var xe = cxInfo.DriverData.Element(RavenConnectionInfoKey);

            if (xe == null)
            {
                return(null);
            }
            var json    = xe.Value;
            var rvnConn = JsonConvert.DeserializeObject <RavenConnectionDialogViewModel>(json);

            rvnConn.CxInfo = cxInfo;

            if (!string.IsNullOrWhiteSpace(rvnConn.Password))
            {
                rvnConn.Password = cxInfo.Decrypt(rvnConn.Password);
            }

            return(rvnConn);
        }
Ejemplo n.º 4
0
 public DallasCxForm(IConnectionInfo cxInfo)
 {
     this._cxInfo = cxInfo;
     this.InitializeComponent();
     this.cboServer.Text      = this._cxInfo.DatabaseInfo.Server ?? "";
     this.txtDisplayName.Text = this._cxInfo.DisplayName;
     this.txtKey.Text         = this._cxInfo.Decrypt((string)this._cxInfo.DriverData.Element("AccountKey"));
     if (this.txtKey.Text.Length == 0)
     {
         Repository repository = Repository.FromDisk().LastOrDefault <Repository>(r => r.DriverLoader.InternalID == "DallasAuto");
         if (repository != null)
         {
             string str = (string)repository.DriverData.Element("AccountKey");
             if (!string.IsNullOrEmpty(str))
             {
                 this._lastKey = cxInfo.Decrypt(str);
             }
         }
     }
     this.llCopyLast.Enabled = !string.IsNullOrEmpty(this._lastKey);
     string[] names = MRU.DallasUriNames.GetNames();
     if (this.cboServer.Text.Length == 0)
     {
         this.cboServer.Text      = (names.Length == 0) ? "https://" : names[0];
         this.chkRemember.Checked = true;
     }
     this.cboServer.Items.AddRange(names);
     this.chkRemember.Checked = this._cxInfo.Persist;
     try
     {
         this.lblWarning.Font = new Font(this.Font, FontStyle.Bold);
     }
     catch
     {
     }
     this.panWarning.Dispose();
     this.EnableControls();
 }
Ejemplo n.º 5
0
 public DallasCxForm(IConnectionInfo cxInfo)
 {
     this._cxInfo = cxInfo;
     this.InitializeComponent();
     this.cboServer.Text = this._cxInfo.DatabaseInfo.Server ?? "";
     this.txtDisplayName.Text = this._cxInfo.DisplayName;
     this.txtKey.Text = this._cxInfo.Decrypt((string) this._cxInfo.DriverData.Element("AccountKey"));
     if (this.txtKey.Text.Length == 0)
     {
         Repository repository = Repository.FromDisk().LastOrDefault<Repository>(r => r.DriverLoader.InternalID == "DallasAuto");
         if (repository != null)
         {
             string str = (string) repository.DriverData.Element("AccountKey");
             if (!string.IsNullOrEmpty(str))
             {
                 this._lastKey = cxInfo.Decrypt(str);
             }
         }
     }
     this.llCopyLast.Enabled = !string.IsNullOrEmpty(this._lastKey);
     string[] names = MRU.DallasUriNames.GetNames();
     if (this.cboServer.Text.Length == 0)
     {
         this.cboServer.Text = (names.Length == 0) ? "https://" : names[0];
         this.chkRemember.Checked = true;
     }
     this.cboServer.Items.AddRange(names);
     this.chkRemember.Checked = this._cxInfo.Persist;
     try
     {
         this.lblWarning.Font = new Font(this.Font, FontStyle.Bold);
     }
     catch
     {
     }
     this.panWarning.Dispose();
     this.EnableControls();
 }
Ejemplo n.º 6
0
 internal static void InitializeContext(IConnectionInfo r, object context, bool dallas)
 {
     DataServiceContext context2 = (DataServiceContext) context;
     context2.ResolveType = name => Type.GetType("LINQPad.User." + name.Split(new char[] { '.' }).Last<string>());
     if (dallas)
     {
         string str = (string) r.DriverData.Element("AccountKey");
         if (!string.IsNullOrEmpty(str))
         {
             str = r.Decrypt(str);
         }
         if (!string.IsNullOrEmpty(str))
         {
             context2.Credentials = new NetworkCredential("accountkey", str);
         }
     }
     else if (r.DatabaseInfo.UserName.Length > 0)
     {
         context2.Credentials = new NetworkCredential(r.DatabaseInfo.UserName, r.DatabaseInfo.Password);
     }
     else
     {
         context2.Credentials = CredentialCache.DefaultNetworkCredentials;
     }
     context2.SendingRequest += delegate (object sender, SendingRequestEventArgs e) {
         WebProxy webProxy = Util.GetWebProxy();
         if (webProxy != null)
         {
             e.Request.Proxy = webProxy;
         }
         DataContextBase.SqlLog.WriteLine(e.Request.RequestUri);
     };
 }
        public static RavenConnectionDialogViewModel Load(IConnectionInfo cxInfo)
        {
            var xe = cxInfo.DriverData.Element(RavenConnectionInfoKey);
            if (xe == null) return null;
            var json = xe.Value;
            var rvnConn = JsonConvert.DeserializeObject<RavenConnectionDialogViewModel>(json);
            rvnConn.CxInfo = cxInfo;

            if (!string.IsNullOrWhiteSpace(rvnConn.Password))
                rvnConn.Password = cxInfo.Decrypt(rvnConn.Password);

            return rvnConn;
        }