Esempio n. 1
0
        static void Main(string[] args)
        {
            OBPClient Dispatch = new OBPClient ();

            //try {
                if (args.Length == 0) {
                    throw new ParserException ("No command specified");
                    }

                if (IsFlag(args[0][0])) {

                    switch (args[0].Substring(1).ToLower()) {
                        case "resolve" : {
                            Handle_Resolve (Dispatch, args, 1);
                            break;
                            }
                        case "bind" : {
                            Handle_Bind (Dispatch, args, 1);
                            break;
                            }
                        case "unbind" : {
                            Handle_Unbind (Dispatch, args, 1);
                            break;
                            }
                        default: {
                            throw new ParserException("Unknown Command: " + args[0]);
                            }
                        }
                    }
                else {
                    Handle_Resolve (Dispatch, args, 0);
                    }
            //    }

            //catch (System.Exception Exception) {
            //    if (Exception.GetType() == typeof (ParserException)) {
            //        Usage ();
            //        }
            //    else {
            //       Console.WriteLine("Application: {0}", Exception.Message);
            //        }
            //    }
        }
Esempio n. 2
0
        private static void Handle_Resolve(
					OBPClient Dispatch, string[] args, int index)
        {
            Resolve		Options = new Resolve ();

            Registry Registry = new Registry ();

            Options.Domain.Register ("domain", Registry, (int) TagType_Resolve.Domain);
            Options.Service.Register ("service", Registry, (int) TagType_Resolve.Service);
            Options.Verbose.Register ("verbose", Registry, (int) TagType_Resolve.Verbose);

            // looking for parameter Param.Name}
            if (index < args.Length && !IsFlag (args [index][0] )) {
                // Have got the parameter, call the parameter value method
                Options.Domain.Parameter (args [index]);
                index++;
                }
            // looking for parameter Param.Name}
            if (index < args.Length && !IsFlag (args [index][0] )) {
                // Have got the parameter, call the parameter value method
                Options.Service.Parameter (args [index]);
                index++;
                }

            #pragma warning disable 162
            for (int i = index; i< args.Length; i++) {
                if 	(!IsFlag (args [i][0] )) {
                    throw new Exception ("Unexpected parameter: " + args[i]);}
                string Rest = args [i].Substring (1);

                TagType_Resolve TagType = (TagType_Resolve) Registry.Find (Rest);

                // here have the cases for what to do with it.

                switch (TagType) {
                    case TagType_Resolve.Verbose : {
                        int OptionParams = Options.Verbose.Tag (Rest);

                        if (OptionParams>0 && ((i+1) < args.Length)) {
                            if 	(!IsFlag (args [i+1][0] )) {
                                i++;
                                Options.Verbose.Parameter (args[i]);
                                }
                            }
                        break;
                        }
                    default : throw new Exception ("Internal error");
                    }
                }

            #pragma warning restore 162
            Dispatch.Resolve (Options);
        }
Esempio n. 3
0
        private static void Handle_Unbind(
					OBPClient Dispatch, string[] args, int index)
        {
            Unbind		Options = new Unbind ();

            Registry Registry = new Registry ();

            #pragma warning disable 162
            for (int i = index; i< args.Length; i++) {
                if 	(!IsFlag (args [i][0] )) {
                    throw new Exception ("Unexpected parameter: " + args[i]);}
                string Rest = args [i].Substring (1);

                TagType_Unbind TagType = (TagType_Unbind) Registry.Find (Rest);

                // here have the cases for what to do with it.

                switch (TagType) {
                    default : throw new Exception ("Internal error");
                    }
                }

            #pragma warning restore 162
            Dispatch.Unbind (Options);
        }
Esempio n. 4
0
        private static void Handle_Bind(
					OBPClient Dispatch, string[] args, int index)
        {
            Bind		Options = new Bind ();

            Registry Registry = new Registry ();

            Options.Account.Register ("account", Registry, (int) TagType_Bind.Account);
            Options.PIN.Register ("pin", Registry, (int) TagType_Bind.PIN);
            Options.Server.Register ("server", Registry, (int) TagType_Bind.Server);
            Options.Port.Register ("port", Registry, (int) TagType_Bind.Port);

            // looking for parameter Param.Name}
            if (index < args.Length && !IsFlag (args [index][0] )) {
                // Have got the parameter, call the parameter value method
                Options.Account.Parameter (args [index]);
                index++;
                }
            // looking for parameter Param.Name}
            if (index < args.Length && !IsFlag (args [index][0] )) {
                // Have got the parameter, call the parameter value method
                Options.PIN.Parameter (args [index]);
                index++;
                }

            #pragma warning disable 162
            for (int i = index; i< args.Length; i++) {
                if 	(!IsFlag (args [i][0] )) {
                    throw new Exception ("Unexpected parameter: " + args[i]);}
                string Rest = args [i].Substring (1);

                TagType_Bind TagType = (TagType_Bind) Registry.Find (Rest);

                // here have the cases for what to do with it.

                switch (TagType) {
                    case TagType_Bind.Server : {
                        int OptionParams = Options.Server.Tag (Rest);

                        if (OptionParams>0 && ((i+1) < args.Length)) {
                            if 	(!IsFlag (args [i+1][0] )) {
                                i++;
                                Options.Server.Parameter (args[i]);
                                }
                            }
                        break;
                        }
                    case TagType_Bind.Port : {
                        int OptionParams = Options.Port.Tag (Rest);

                        if (OptionParams>0 && ((i+1) < args.Length)) {
                            if 	(!IsFlag (args [i+1][0] )) {
                                i++;
                                Options.Port.Parameter (args[i]);
                                }
                            }
                        break;
                        }
                    default : throw new Exception ("Internal error");
                    }
                }

            #pragma warning restore 162
            Dispatch.Bind (Options);
        }