コード例 #1
0
        static void Main(string[] args)
        {
            try
            {
                MetadataEdit Editor = new MetadataEdit();

                if (args.Length < 3)
                {
                    Editor.Usage();
                    return;
                }

                if (args[1].Equals("show"))
                {
                    if (3 != args.Length)
                    {
                        Editor.Usage( );
                        return;
                    }

                    ushort wStreamNum = Convert.ToUInt16(args[2]);

                    if (!Editor.ShowAttributes(args[0], wStreamNum))
                    {
                        Console.WriteLine("ShowAttributes failed.");
                        return;
                    }
                }
                else if (args[1].Equals("show3"))
                {
                    if (3 != args.Length)
                    {
                        Editor.Usage( );
                        return;
                    }

                    ushort wStreamNum = Convert.ToUInt16(args[2]);

                    if (!Editor.ShowAttributes3(args[0], wStreamNum))
                    {
                        Console.WriteLine("ShowAttributes3 failed.");
                        return;
                    }
                }
                else if (args[1].Equals("delete"))
                {
                    if (4 != args.Length)
                    {
                        Editor.Usage( );
                        return;
                    }

                    ushort wStreamNum   = Convert.ToUInt16(args[2]);
                    ushort wAttribIndex = Convert.ToUInt16(args[3]);

                    if (!Editor.DeleteAttrib(args[0], wStreamNum, wAttribIndex))
                    {
                        Console.WriteLine("DeleteAttrib failed.");
                        return;
                    }

                    if (!Editor.ShowAttributes3(args[0], wStreamNum))
                    {
                        Console.WriteLine("ShowAttributes3 failed.");
                        return;
                    }
                }
                else if (args[1].Equals("set"))
                {
                    if (6 != args.Length)
                    {
                        Editor.Usage();
                        return;
                    }


                    ushort wStreamNum  = Convert.ToUInt16(args[2]);
                    ushort wAttribType = Convert.ToUInt16(args[4]);

                    if (!Editor.SetAttrib(args[0], wStreamNum, args[3], wAttribType, args[5]))
                    {
                        Console.WriteLine("SetAttrib failed.");
                        return;
                    }

                    if (!Editor.ShowAttributes(args[0], wStreamNum))
                    {
                        Console.WriteLine("ShowAttributes failed.");
                        return;
                    }
                }
                else if (args[1].Equals("add"))
                {
                    if (7 != args.Length)
                    {
                        Editor.Usage();
                        return;
                    }

                    ushort wStreamNum  = Convert.ToUInt16(args[2]);
                    ushort wAttribType = Convert.ToUInt16(args[4]);
                    ushort wLangIndex  = Convert.ToUInt16(args[6]);

                    if (!Editor.AddAttrib(args[0], wStreamNum, args[3], wAttribType, args[5], wLangIndex))
                    {
                        Console.WriteLine("AddAttrib failed.");
                        return;
                    }

                    if (!Editor.ShowAttributes3(args[0], wStreamNum))
                    {
                        Console.WriteLine("ShowAttributes3 failed.");
                        return;
                    }
                }
                else if (args[1].Equals("modify"))
                {
                    if (7 != args.Length)
                    {
                        Editor.Usage();
                        return;
                    }

                    ushort wStreamNum   = Convert.ToUInt16(args[2]);
                    ushort wAttribIndex = Convert.ToUInt16(args[3]);
                    ushort wAttribType  = Convert.ToUInt16(args[4]);
                    ushort wLangIndex   = Convert.ToUInt16(args[6]);

                    if (!Editor.ModifyAttrib(args[0], wStreamNum, wAttribIndex, wAttribType, args[5], wLangIndex))
                    {
                        Console.WriteLine("ModifyAttrib failed.");
                        return;
                    }

                    if (!Editor.ShowAttributes3(args[0], wStreamNum))
                    {
                        Console.WriteLine("ShowAttributes3 failed.");
                        return;
                    }
                }
                else
                {
                    Editor.Usage( );
                    return;
                }

                String Footer = new String('*', 70);

                Console.WriteLine(Footer);
            }
            catch (Exception e)
            {
                Console.WriteLine(e.Message);
                Console.WriteLine("Invalid argument was found");
            }
        }
コード例 #2
0
        static void Main( string[] args )
        {
            try
            {
                MetadataEdit Editor = new MetadataEdit();

                if ( args.Length < 3 )
                {
                    Editor.Usage();
                    return;
                }

                if ( args[1].Equals( "show" ) )
                {
                    if ( 3 != args.Length )
                    {
                        Editor.Usage( );
                        return;
                    }

                    ushort wStreamNum = Convert.ToUInt16( args[2] );

                    if ( !Editor.ShowAttributes( args[0], wStreamNum ) )
                    {
                        Console.WriteLine( "ShowAttributes failed." );
                        return;
                    }
                }
                else if ( args[1].Equals( "show3" ) )
                {
                    if ( 3 != args.Length )
                    {
                        Editor.Usage( );
                        return;
                    }

                    ushort wStreamNum = Convert.ToUInt16( args[2] );

                    if ( !Editor.ShowAttributes3( args[0], wStreamNum ) )
                    {
                        Console.WriteLine( "ShowAttributes3 failed." );
                        return;
                    }
                }
                else if ( args[1].Equals( "delete" ) )
                {
                    if ( 4 != args.Length )
                    {
                        Editor.Usage( );
                        return;
                    }

                    ushort wStreamNum = Convert.ToUInt16( args[2] );
                    ushort wAttribIndex = Convert.ToUInt16( args[3] );

                    if ( !Editor.DeleteAttrib( args[0], wStreamNum, wAttribIndex ) )
                    {
                        Console.WriteLine( "DeleteAttrib failed." );
                        return;
                    }

                    if ( !Editor.ShowAttributes3( args[0], wStreamNum ) )
                    {
                        Console.WriteLine( "ShowAttributes3 failed." );
                        return;
                    }
                }
                else if ( args[1].Equals( "set" ) )
                {
                    if ( 6 != args.Length )
                    {
                        Editor.Usage();
                        return;
                    }

                    ushort wStreamNum = Convert.ToUInt16( args[2] );
                    ushort wAttribType = Convert.ToUInt16( args[4] );

                    if ( !Editor.SetAttrib( args[0], wStreamNum, args[3], wAttribType, args[5] ) )
                    {
                        Console.WriteLine( "SetAttrib failed." );
                        return;
                    }

                    if ( !Editor.ShowAttributes( args[0], wStreamNum ) )
                    {
                        Console.WriteLine( "ShowAttributes failed." );
                        return;
                    }
                }
                else if( args[1].Equals( "add" ) )
                {
                    if ( 7 != args.Length )
                    {
                        Editor.Usage();
                        return;
                    }

                    ushort wStreamNum = Convert.ToUInt16( args[2] );
                    ushort wAttribType = Convert.ToUInt16( args[4] );
                    ushort wLangIndex = Convert.ToUInt16( args[6] );

                    if ( !Editor.AddAttrib( args[0], wStreamNum, args[3], wAttribType, args[5], wLangIndex ) )
                    {
                       Console.WriteLine( "AddAttrib failed." );
                       return;
                    }

                    if ( !Editor.ShowAttributes3( args[0], wStreamNum ) )
                    {
                        Console.WriteLine( "ShowAttributes3 failed." );
                        return;
                    }
                }
                else if( args[1].Equals( "modify" ) )
                {
                    if ( 7 != args.Length )
                    {
                        Editor.Usage();
                        return;
                    }

                    ushort wStreamNum = Convert.ToUInt16( args[2] );
                    ushort wAttribIndex = Convert.ToUInt16( args[3] );
                    ushort wAttribType = Convert.ToUInt16( args[4] );
                    ushort wLangIndex = Convert.ToUInt16( args[6] );

                    if ( !Editor.ModifyAttrib( args[0], wStreamNum, wAttribIndex, wAttribType, args[5], wLangIndex ) )
                    {
                        Console.WriteLine( "ModifyAttrib failed." );
                        return;
                    }

                    if ( !Editor.ShowAttributes3( args[0], wStreamNum ) )
                    {
                        Console.WriteLine( "ShowAttributes3 failed." );
                        return;
                    }
                }
                else
                {
                    Editor.Usage( );
                    return;
                }

                String Footer = new String( '*', 70 );

                Console.WriteLine( Footer );
            }
            catch ( Exception e )
            {
                Console.WriteLine( e.Message );
                Console.WriteLine( "Invalid argument was found" );
            }
        }