public override int GetHashCode()
        {
            int hash = 1;

            if (ClientIp.Length != 0)
            {
                hash ^= ClientIp.GetHashCode();
            }
            if (ClientPort != 0)
            {
                hash ^= ClientPort.GetHashCode();
            }
            if (Type.Length != 0)
            {
                hash ^= Type.GetHashCode();
            }
            if (ConnectionId.Length != 0)
            {
                hash ^= ConnectionId.GetHashCode();
            }
            if (ClientVersion.Length != 0)
            {
                hash ^= ClientVersion.GetHashCode();
            }
            hash ^= Labels.GetHashCode();
            hash ^= Headers.GetHashCode();
            if (_unknownFields != null)
            {
                hash ^= _unknownFields.GetHashCode();
            }
            return(hash);
        }
Example #2
0
        /// <summary>
        /// This changes/pins the java script variable name <see cref="ElementReference"/> which is used to
        /// execute commands on FireFox.
        /// </summary>
        public void Pin()
        {
            var elementVariableName = ClientPort.CreateVariableName();

            ClientPort.Write("{0}={1};", elementVariableName, ElementReference);

            ElementReference = elementVariableName;
        }
Example #3
0
        /// <summary>
        /// Executes the event.
        /// </summary>
        /// <param name="eventName">Name of the event to fire.</param>
        /// <param name="eventProperties"></param>
        /// <param name="WaitForEventToComplete"></param>
        private void ExecuteEvent(string eventName, NameValueCollection eventProperties, bool WaitForEventToComplete)
        {
            var creator = new JSEventCreator(ElementReference, ClientPort);
            var command = creator.CreateEvent(eventName, eventProperties, WaitForEventToComplete);

            ClientPort.WriteAndReadAsBool(command);
            Thread.Sleep(30);
        }
Example #4
0
        public CustomClient(string name)
        {
            ClientName = name;

            ClientIP = ClientHost + "." + ClientPort.ToString();

            ipEndPoint = new IPEndPoint(IPAddress.Any, 0);
            UdpClient  = new UdpClient(ipEndPoint);
            UdpClient.Client.SetSocketOption(SocketOptionLevel.Socket, SocketOptionName.ReuseAddress, true);
        }
Example #5
0
        /// <summary>
        /// Sets the property.
        /// </summary>
        /// <param name="propertyName">Name of the property.</param>
        /// <param name="value">The value.</param>
        public void SetProperty(string propertyName, string value)
        {
            if (SetPropertyTransformations.ContainsKey(propertyName))
            {
                value = SetPropertyTransformations[propertyName].Invoke(value);
            }

            var command = string.Format("{0}.{1} = {2};", ElementReference, propertyName, value);

            ClientPort.Write(command);
        }
        private bool Navigate(string action)
        {
            var ticks = Guid.NewGuid().ToString();

            ClientPort.Write("{0}.WatiNGoBackCheck='{1}';", ClientPort.DocumentVariableName, ticks);
            ClientPort.Write("{0}.{1}();", BrowserVariableName, action);

            ClientPort.InitializeDocument();

            return(ClientPort.WriteAndReadAsBool("{0}.WatiNGoBackCheck!='{1}';", ClientPort.DocumentVariableName, ticks));
        }
Example #7
0
 public void RunScript(string scriptCode, string language)
 {
     try
     {
         ClientPort.Write(scriptCode);
     }
     catch (FireFoxException e)
     {
         throw new RunScriptException(e);
     }
 }
Example #8
0
        public string GetPropertyValue(string propertyName)
        {
            var command = string.Format("{0}.{1};", DocumentReference, propertyName);

            if (propertyName == Document.ERROR_PROPERTY_NAME)
            {
                return(ClientPort.WriteAndReadIgnoreError(command));
            }

            return(ClientPort.WriteAndRead(command));
        }
        public override int GetHashCode()
        {
            int hash = 1;

            if (ClientType != global::AcFunDanmu.DeviceInfo.Types.PlatformType.KInvalid)
            {
                hash ^= ClientType.GetHashCode();
            }
            if (DeviceId.Length != 0)
            {
                hash ^= DeviceId.GetHashCode();
            }
            if (ClientIp.Length != 0)
            {
                hash ^= ClientIp.GetHashCode();
            }
            if (AppVersion.Length != 0)
            {
                hash ^= AppVersion.GetHashCode();
            }
            if (Channel.Length != 0)
            {
                hash ^= Channel.GetHashCode();
            }
            if (appInfo_ != null)
            {
                hash ^= AppInfo.GetHashCode();
            }
            if (deviceInfo_ != null)
            {
                hash ^= DeviceInfo.GetHashCode();
            }
            if (envInfo_ != null)
            {
                hash ^= EnvInfo.GetHashCode();
            }
            if (ClientPort != 0)
            {
                hash ^= ClientPort.GetHashCode();
            }
            if (Location.Length != 0)
            {
                hash ^= Location.GetHashCode();
            }
            if (Kpf.Length != 0)
            {
                hash ^= Kpf.GetHashCode();
            }
            if (_unknownFields != null)
            {
                hash ^= _unknownFields.GetHashCode();
            }
            return(hash);
        }
        /// <summary>
        /// Load a URL into the document. see: http://developer.mozilla.org/en/docs/XUL:browser#m-loadURI
        /// </summary>
        /// <param name="url">The URL to laod.</param>
        /// <param name="waitForComplete">If false, makes to execution of LoadUri asynchronous.</param>
        protected override void LoadUri(Uri url, bool waitForComplete)
        {
            var command = string.Format("{0}.loadURI(\"{1}\");", BrowserVariableName, url.AbsoluteUri);

            if (!waitForComplete)
            {
                command = JSUtils.WrapCommandInTimer(command);
            }

            ClientPort.Write(command);
        }
Example #11
0
        /// <summary>
        /// Load a URL into the document. see: http://developer.mozilla.org/en/docs/XUL:browser#m-loadURI
        /// </summary>
        /// <param name="url">The URL to laod.</param>
        /// <param name="waitForComplete">If false, makes to execution of LoadUri asynchronous.</param>
        protected override void LoadUri(Uri url, bool waitForComplete)
        {
            var command = string.Format("{0}.loadURI(\"{1}\");", ClientPort.PromptName, url.AbsoluteUri);

            //var command = string.Format("w0.content.location.href = \"{0}\"; }}",url.AbsoluteUri);
            if (!waitForComplete)
            {
                command = JSUtils.WrapCommandInTimer(command);
            }

            ClientPort.Write(command);
        }
Example #12
0
        /// <summary>
        /// Gets the element by property.
        /// </summary>
        /// <param name="propertyName">Name of the property.</param>
        /// <returns>Returns the element that is returned by the specified property</returns>
        public JSElement GetElementByProperty(string propertyName)
        {
            if (string.IsNullOrEmpty(propertyName))
            {
                throw new ArgumentNullException("propertyName");
            }

            var elementvar = ClientPort.CreateVariableName();
            var command    = string.Format("{0}={1}.{2}; {0}!=null;", elementvar, ElementReference, propertyName);
            var exists     = ClientPort.WriteAndReadAsBool(command);

            return(exists ? new JSElement(ClientPort, elementvar) : null);
        }
Example #13
0
        public bool IsElementReferenceStillValid()
        {
            if (UtilityClass.IsNullOrEmpty(ElementReference))
            {
                return(false);
            }

            // Note: We exclude elements that might appear as root elements from this check since we cannot verify them.
            const string excludedTags = "! HTML HEAD BODY TITLE LINK META SCRIPT STYLE BASE";
            var          command      = string.Format("({0} != undefined && {0} != null) && ({0}.offsetParent != null || '{1}'.indexOf({0}.tagName.toUpperCase())> -1); ", ElementReference, excludedTags);

            return(ClientPort.WriteAndReadAsBool(command));
        }
Example #14
0
 private void Window_Closed(object sender, EventArgs e)
 {
     if (DialogResult == true)
     {
         ServerHost.GetBindingExpression(TextBox.TextProperty).UpdateSource();
         QrServerAeTitle.GetBindingExpression(TextBox.TextProperty).UpdateSource();
         QrServerPort.GetBindingExpression(IntegerUpDown.ValueProperty).UpdateSource();
         StoreServerAeTitle.GetBindingExpression(TextBox.TextProperty).UpdateSource();
         StoreServerPort.GetBindingExpression(IntegerUpDown.ValueProperty).UpdateSource();
         ClientAeTitle.GetBindingExpression(TextBox.TextProperty).UpdateSource();
         ClientPort.GetBindingExpression(IntegerUpDown.ValueProperty).UpdateSource();
     }
 }
        private void ThrowSecurityException(string msg)
        {
            msg += " ip=" + ClientIp + " port=" + ClientPort;

            Error(msg);
            throw (new ExceptionSecurityThreat(msg)
            {
                ClientIp = ClientIp,
                ClientPort = ClientPort.ToString()
            }

                   );
        }
Example #16
0
 public static void SaveSetting()
 {
     reader.SetNodeText("PingTimeout", PingTimeout.ToString());
     reader.SetNodeText("RequestTimeout", RequestTimeout.ToString());
     reader.SetNodeText("TcpPort", TcpPort.ToString());
     reader.SetNodeText("UdpPort", UdpPort.ToString());
     reader.SetNodeText("ClientPort", ClientPort.ToString());
     reader.SetNodeText("Adapter", Adapter);
     reader.SetNodeText("PlayerID", PlayerID);
     reader.SetNodeText("DataMode", dataMode);
     reader.SetNodeText("SyncMode", syncMode);
     reader.Save("setting.xml");
 }
Example #17
0
        public bool ContainsText(string text)
        {
            try
            {
                var script = string.Format("{0}.body.innerHTML.indexOf('{1}')>-1;", JavaScriptVariableName, text);

                return(ClientPort.WriteAndReadAsBool(script));
            }
            catch (JavaScriptException e)
            {
                Logger.LogDebug("ContainsText: " + e);
                return(false);
            }
        }
Example #18
0
        /// <summary>
        /// Returns the hash code for this instance.
        /// </summary>
        /// <returns>The hash code for this instance.</returns>
        public override int GetHashCode()
        {
            if (_cachedHashCode < 1)
            {
                unchecked
                {
                    _cachedHashCode = (ClientIPAddress != null ? ClientIPAddress.GetHashCode() : 0);
                    _cachedHashCode = (_cachedHashCode * 397) ^ ClientPort.GetHashCode();
                    _cachedHashCode = (_cachedHashCode * 397) ^ (ServerIPAddress != null ? ServerIPAddress.GetHashCode() : 0);
                    _cachedHashCode = (_cachedHashCode * 397) ^ ServerPort.GetHashCode();
                }
            }

            return(_cachedHashCode);
        }
 /// <summary>
 /// Format the data section of a FTP termination record.
 /// </summary>
 /// <returns>String representation of a FTP termination record.</returns>
 public override string ToString()
 {
     return(StartTime.ToString().PadRight(22, ' ')
            + "  " + EndTime.ToString().PadRight(22, ' ')
            + "  " + VseTaskId.ToString().PadRight(2 + 5, ' ')
            + "  " + FtpNodeName.PadRight(16, ' ')
            + "  " + FtpUserId.PadRight(8, ' ')
            + "  " + VseIp.PadRight(15, ' ')
            + "  " + VsePort.ToString().PadRight(8, ' ')
            + "  " + ClientPort.ToString().PadRight(11, ' ')
            + "  " + ClientIp.PadRight(15, ' ')
            + "  " + ForeignDataIp.PadRight(15, ' ')
            + "  " + FilesSent.ToString().PadRight(10, ' ')
            + "  " + FilesReceived.ToString().PadRight(10, ' ')
            + "  " + BytesSentAcked.ToString().PadRight(20, ' ')
            + "  " + BytesReceived.ToString().PadRight(20, ' ')
            + "  " + GeneralFlagFormatter(GeneralFlag).PadRight(8, ' ')
            + "  " + SslFlagFormatter(SslFlag).ToString().PadRight(5, ' '));
 }
 /// <summary>  
 /// 接收消息  
 /// </summary>  
 /// <param name="clientSocket"></param>  
 private static void ReceiveMessage(object clientSocket)
 {
     Socket myClientSocket = (Socket)clientSocket;
     ErlConnect erlConnect = ConnectManager.manager ().beginConnect (myClientSocket) as ErlConnect;
     ClientPort clientPort = new ClientPort (erlConnect);
     while (true) {
         try {
             //通过clientSocket接收数据
             if (myClientSocket.Available > 0) {
                 //connect.readLength();
                 clientPort.receive ();
             }
             //int receiveNumber = myClientSocket.Receive(result);
             //Console.WriteLine("接收客户端{0}消息{1}", myClientSocket.RemoteEndPoint.ToString(), Encoding.ASCII.GetString(result, 0, receiveNumber));
         } catch (Exception ex) {
             Console.WriteLine (ex.Message);
             myClientSocket.Shutdown (SocketShutdown.Both);
             myClientSocket.Close ();
             break;
         }
     }
 }
        public bool IsLoading()
        {
            bool loading;

            switch (ClientPort.JavaScriptEngine)
            {
            case JavaScriptEngineType.WebKit:
                loading = ClientPort.WriteAndReadAsBool("{0}.readyState != 'complete';", ClientPort.DocumentVariableName);
                ClientPort.WriteAndRead("{0}.readyState;", ClientPort.DocumentVariableName);
                ClientPort.WriteAndRead("window.location.href");
                break;

            case JavaScriptEngineType.Mozilla:
                loading = ClientPort.WriteAndReadAsBool("{0}.webProgress.busyFlags!=0;", BrowserVariableName);
                break;

            default:
                throw new NotImplementedException();
            }

            return(loading);
        }
Example #22
0
        public string GetStyleAttributeValue(string attributeName)
        {
            if (string.IsNullOrEmpty(attributeName))
            {
                throw new ArgumentNullException("attributeName");
            }

            attributeName = UtilityClass.TurnStyleAttributeIntoProperty(attributeName);

            string attributeValue;

            if (attributeName == "cssText")
            {
                attributeValue = GetProperty("style." + attributeName);
            }
            else
            {
                attributeValue = ClientPort.WriteAndRead("{2}.defaultView.getComputedStyle({0},null).{1};", ElementReference, attributeName, ClientPort.DocumentVariableName);
            }

            return(string.IsNullOrEmpty(attributeValue) ? null : attributeValue);
        }
Example #23
0
 private void Connect()
 {
     try
     {
         Console.WriteLine("Connecting to {0}:{1}", ClientIp, ClientPort.ToString());
         server = new TcpListener(IPAddress.Parse(ClientIp), ClientPort);
         TerminateConnection = false;
         server.Start();
         ConnectionHandler();
     }
     catch (SocketException e)
     {
         Console.WriteLine("Socket Exception: {0}", e);
     }
     catch (Exception e)
     {
         Console.WriteLine("Unknown Exception: {0}", e);
     }
     finally
     {
         server.Stop();
     }
 }
Example #24
0
        private void OptionsDialog_Load(object sender, EventArgs e)
        {
            _initializing                            = true;
            _textBoxClientAE.Text                    = ClientAE;
            _textBoxClientPort.Text                  = ClientPort.ToString();
            _textBoxClientCertificate.Text           = ClientCertificate;
            _textBoxPrivateKey.Text                  = PrivateKey;
            _textBoxKeyPassword.Text                 = PrivateKeyPassword;
            _checkBoxLogLowLevel.Checked             = LogLowLevel;
            _checkBoxGroupLengthDataElements.Checked = GroupLengthDataElements;
            _radioButtonWaitForResults.Checked       = StorageCommitResultsOnSameAssociation;
            _radioButtonNoWaitForResults.Checked     = !StorageCommitResultsOnSameAssociation;
            switch (_compression)
            {
            case Leadtools.Dicom.Scu.Common.Compression.Native:
                _radioButtonCompressionNative.Checked = true;
                break;

            case Leadtools.Dicom.Scu.Common.Compression.Lossy:
                _radioButtonCompressionLossy.Checked = true;
                break;

            case Leadtools.Dicom.Scu.Common.Compression.Lossless:
                _radioButtonCompressionLossless.Checked = true;
                break;
            }
#if !LEADTOOLS_V19_OR_LATER
            _groupBoxStorageCommit.Visible   = false;
            this._groupMiscellaneous.Visible = false;
#endif

            _listViewCipherSuites.InitializeCipherListView(CipherSuites, imageListCiphers);
            _checkBoxTlsOld.Checked = CipherSuites.ContainsOldCipherSuites();

            _initializing = false;
            EnableDialogItems();
        }
Example #25
0
        public void Save(string fileName)
        {
            using (XmlTextWriter xml = new XmlTextWriter(fileName, Encoding.UTF8))
            {
                xml.Formatting = System.Xml.Formatting.Indented;
                xml.WriteStartDocument(true);
                xml.WriteStartElement("configuration");
                xml.WriteStartElement("settings");

                xml.WriteStartElement("server");
                xml.WriteAttributeString("ip", ServerIP.ToString());
                xml.WriteAttributeString("port", ServerPort.ToString());
                xml.WriteAttributeString("password", Password);
                xml.WriteEndElement();

                xml.WriteStartElement("client");
                xml.WriteAttributeString("port", ClientPort.ToString());
                xml.WriteEndElement();

                xml.WriteEndElement();
                xml.WriteEndElement();
                xml.WriteEndDocument();
            }
        }
Example #26
0
        public bool IsLoading()
        {
            bool loading;

            switch (ClientPort.JavaScriptEngine)
            {
            case JavaScriptEngineType.WebKit:
                loading = ClientPort.WriteAndReadAsBool("{0}.readyState != 'complete';", ClientPort.DocumentVariableName);
                ClientPort.WriteAndRead("{0}.readyState;", ClientPort.DocumentVariableName);
                ClientPort.WriteAndRead("window.location.href");
                break;

            case JavaScriptEngineType.Mozilla:
                ClientPort.WriteAndRead(string.Format("{0}.home();true;", PromptName));
                loading = ClientPort.WriteAndReadAsBool("{0}.webProgress.busyFlags!=0;", BrowserVariableName);
                ClientPort.WriteAndRead(string.Format("if(typeof(w0)!=='undefined'){0}.enter(w0.content);true;", PromptName));
                break;

            default:
                throw new NotImplementedException();
            }

            return(loading);
        }
Example #27
0
        /// <summary>
        /// Returns a <see cref="System.String"/> that represents this instance.
        /// </summary>
        /// <returns>
        /// A <see cref="System.String"/> that represents this instance.
        /// </returns>
        public override string ToString()
        {
            StringBuilder transportString = new StringBuilder();

            transportString.Append(Transport.ToString());
            transportString.Append('/');
            transportString.Append(Profile.ToString());
            transportString.Append('/');
            transportString.Append(LowerTransport.ToString());
            if (LowerTransport == LowerTransportType.TCP)
            {
                transportString.Append(";unicast");
            }
            if (LowerTransport == LowerTransportType.UDP)
            {
                transportString.Append(';');
                transportString.Append(IsMulticast ? "multicast" : "unicast");
            }
            if (Destination != null)
            {
                transportString.Append(";destination=");
                transportString.Append(Destination);
            }
            if (Source != null)
            {
                transportString.Append(";source=");
                transportString.Append(Source);
            }
            if (Interleaved != null)
            {
                transportString.Append(";interleaved=");
                transportString.Append(Interleaved.ToString());
            }
            if (IsAppend)
            {
                transportString.Append(";append");
            }
            if (TTL > 0)
            {
                transportString.Append(";ttl=");
                transportString.Append(TTL);
            }
            if (Layers > 0)
            {
                transportString.Append(";layers=");
                transportString.Append(Layers);
            }
            if (Port != null)
            {
                transportString.Append(";port=");
                transportString.Append(Port.ToString());
            }
            if (ClientPort != null)
            {
                transportString.Append(";client_port=");
                transportString.Append(ClientPort.ToString());
            }
            if (ServerPort != null)
            {
                transportString.Append(";server_port=");
                transportString.Append(ServerPort.ToString());
            }
            if (SSrc != null)
            {
                transportString.Append(";ssrc=");
                transportString.Append(SSrc);
            }
            if (Mode != null && Mode != "PLAY")
            {
                transportString.Append(";mode=");
                transportString.Append(Mode);
            }
            return(transportString.ToString());
        }
Example #28
0
 private bool IsReferenceEqual(string left, string right)
 {
     return(ClientPort.WriteAndReadAsBool("{0}=={1};", left, right));
 }
 /// <summary>
 /// Reloads this instance.
 /// </summary>
 /// <param name="forceGet">When it is <c>true</c>, causes the page to always be reloaded from the server.
 /// If it is <c>false</c>, the browser may reload the page from its cache.</param>
 private void Reload(bool forceGet)
 {
     ClientPort.Write("{0}.location.reload({1});", FireFoxClientPort.WindowVariableName, forceGet.ToString().ToLower());
 }
 protected void Reopen(Uri url)
 {
     ClientPort.Dispose();
     ClientPort.Connect(url == null ? string.Empty : url.ToString());
 }
 /// <summary>
 /// Closes the browser.
 /// </summary>
 public void Close()
 {
     ClientPort.Write("{0}.close()", FireFoxClientPort.WindowVariableName);
 }