Sample.Processor.Processor C# (CSharp) Method

Processor() public method

public Processor ( ) : System
return System
        public Processor()
        {
            restClient = new RestServiceClient();
            restClient.Proxy.Credentials = CredentialCache.DefaultCredentials;

            //!!! Please provide your application id and password in Config.txt
            // To create an application and obtain a password,
            // register at http://cloud.ocrsdk.com/Account/Register
            // More info on getting your application id and password at
            // http://ocrsdk.com/documentation/faq/#faq3

            // Name of application you created
            restClient.ApplicationId = "";
            // Password should be sent to your e-mail after application was created
            restClient.Password = "";
            string configFileName = "..\\..\\Config.txt";
            if( File.Exists(configFileName) ) {
                string[] lines = System.IO.File.ReadAllLines(configFileName);
                foreach (string line in lines)
                {
                    if( line.Contains("ApplicationId") ) {
                        restClient.ApplicationId = getValueByKey(line, "ApplicationId");
                    } else if( line.Contains("Password") ) {
                        restClient.Password = getValueByKey(line, "Password");
                    }
                }
            }

            // Display hint to provide credentials
            if (String.IsNullOrEmpty(restClient.ApplicationId) ||
                String.IsNullOrEmpty(restClient.Password))
            {
                throw new Exception("Please provide access credentials to Cloud OCR SDK service in Config.txt!");
            }

            Console.WriteLine(String.Format("Application id: {0}\n", restClient.ApplicationId));
        }