VuzitCL.ArgvParser.GetArg C# (CSharp) 메소드

GetArg() 공개 메소드

Returns the data for an argument.
public GetArg ( string argument1, string argument2 ) : string
argument1 string
argument2 string
리턴 string
        public string GetArg(string argument1, string argument2)
        {
            string result = null;

            if (this[argument1] != null)
            {
                result = this[argument1];
            }

            if (result == null && this[argument2] != null)
            {
                result = this[argument2];
            }

            return result;
        }
        #endregion

Usage Example

예제 #1
0
파일: Program.cs 프로젝트: vuzit/vuzit.net
        /// <summary>
        /// Executes the event sub-command.  
        /// </summary>
        static void EventCommand(string[] args)
        {
            string id = OptionLast(args);
            string[] options = OptionTrim(args);
            ArgvParser parser = new ArgvParser(options);

            if (!GlobalParametersLoad(parser))
            {
                return;
            }

            Vuzit.OptionList list = new Vuzit.OptionList();
            if (parser.GetArg("e", "event") != null)
            {
                list.Add("event", parser.GetArg("e", "event"));
            }
            if (parser.GetArg("c", "custom") != null)
            {
                list.Add("custom", parser.GetArg("c", "custom"));
            }
            if (parser.GetArg("l", "limit") != null)
            {
                list.Add("limit", parser.GetArg("l", "limit"));
            }
            if (parser.GetArg("o", "offset") != null)
            {
                list.Add("offset", parser.GetArg("o", "offset"));
            }

            Vuzit.Event[] events = null;
            try
            {
                 events = Vuzit.Event.FindAll(id, list);
            }
            catch(Exception ex)
            {
                Console.WriteLine("Load failed: " + ex.Message);
                return;
            }

            int i = 1;
            Console.WriteLine("{0} events found", events.Length);
            Console.WriteLine("");

            string format = "{0:yyyy-MM-dd HH:mm:ss}";

            foreach (Vuzit.Event e in events)
            {
                Console.Write("[" + String.Format(format, e.RequestedAt) + "] ");

                if (e.EventType == "page_view")
                {
                    Console.Write(e.Duration + "s -");
                }
                Console.Write(e.EventType);

                if (e.Page != -1)
                {
                    Console.Write(", p" + e.Page);
                }
                if (e.Custom != null)
                {
                    Console.Write(" (" + e.Custom + ")");
                }
                if (e.Referer != null)
                {
                    Console.Write(" - " + e.Referer.Substring(7, 8));
                }
                Console.Write(" - " + e.RemoteHost);
                Console.Write(" - " + e.UserAgent.Substring(0, 8));
                Console.WriteLine("");
                i++;
            }
        }
All Usage Examples Of VuzitCL.ArgvParser::GetArg