本文整理汇总了C#中System.String.Skip方法的典型用法代码示例。如果您正苦于以下问题:C# String.Skip方法的具体用法?C# String.Skip怎么用?C# String.Skip使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类System.String
的用法示例。
在下文中一共展示了String.Skip方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。
示例1: FindDuplicates
public static void FindDuplicates(String[] args)
{
bool subDirectoriesRecursion = false;
if (args.Length < 1)
{
GiveHelp();
return;
}
int rootDirectoryIndex = 0;
if (args.Length > 1)
{
if (args[0] == "/recurse")
{
if (args.Length < 2)
{
GiveHelp();
return;
}
subDirectoriesRecursion = true;
rootDirectoryIndex = 1;
}
}
var dirsToSearch = args.Skip(rootDirectoryIndex);
List<FileInfosGroup> fileGroups = IterateFolders(subDirectoriesRecursion, dirsToSearch);
Console.ReadKey();
}
示例2: FontGenerationParameters
/// <summary>
/// Initializes a new instance of the <see cref="FontGenerationParameters"/> class.
/// </summary>
/// <param name="args">The application's command line arguments.</param>
public FontGenerationParameters(String[] args)
{
if (args == null || !args.Any())
throw new InvalidCommandLineException();
var parser = new CommandLineParser(args.Skip(1));
if (parser.IsParameter(args.First()))
{
throw new InvalidCommandLineException();
}
NoBold = parser.HasArgument("nobold");
NoItalic = parser.HasArgument("noitalic");
FontName = args.First();
FontSize = parser.GetArgumentOrDefault<Single>("fontsize", 16f);
Overhang = parser.GetArgumentOrDefault<Int32>("overhang", 0);
PadLeft = parser.GetArgumentOrDefault<Int32>("pad-left", 0);
PadRight = parser.GetArgumentOrDefault<Int32>("pad-right", 0);
SuperSamplingFactor = parser.GetArgumentOrDefault<Int32>("supersample", 2);
if (SuperSamplingFactor < 1)
SuperSamplingFactor = 1;
SourceText = parser.GetArgumentOrDefault<String>("sourcetext");
SourceFile = parser.GetArgumentOrDefault<String>("sourcefile");
SourceCulture = parser.GetArgumentOrDefault<String>("sourceculture");
if (SourceText != null && SourceFile != null)
throw new InvalidCommandLineException("Both a source text and a source file were specified. Pick one!");
SubstitutionCharacter = parser.GetArgumentOrDefault<Char>("sub", '?');
}
示例3: Run
public void Run(String[] arguments) {
if (arguments.Length == 0) {
return;
}
String taskArgument = arguments[0];
String[] eventArguments = new String[] { String.Empty };
char[] trimChars = new char[] { '-', '/' };
if (arguments.Length > 1) {
eventArguments = arguments.Skip(1).ToArray();
}
taskArgument = taskArgument.TrimStart(trimChars);
foreach (var kvp in RemotingTaskMethods.Methods.Where(k => k.Key.TrimStart(trimChars) == taskArgument)) {
String argument = kvp.Key.TrimStart(trimChars);
RemoteTaskMethod handler = kvp.Value;
if (Program.Form != null && Program.Form.InvokeRequired) {
Program.Form.Invoke(handler, new object[] { eventArguments });
}
else {
handler(eventArguments);
}
}
}
示例4: RunDllUpdate
public void RunDllUpdate(String[] args)
{
if (args.Length < 2)
{
Console.Error.WriteLine("rdfWebDeploy: Error: 2 Arguments are required in order to use the -dllupdate mode");
return;
}
if (args.Length > 2)
{
if (!this.SetOptions(args.Skip(2).ToArray()))
{
Console.Error.WriteLine("rdfWebDeploy: DLL Update aborted since one/more options were not valid");
return;
}
}
String appFolder;
if (!this._noLocalIIS)
{
//Open the Configuration File
System.Configuration.Configuration config = WebConfigurationManager.OpenWebConfiguration(args[1], this._site);
Console.Out.WriteLine("rdfWebDeploy: Opened the Web.config file for the specified Web Application");
appFolder = Path.GetDirectoryName(config.FilePath);
}
else
{
appFolder = Path.GetDirectoryName(args[1]);
}
//Detect Folders
String binFolder = Path.Combine(appFolder, "bin\\");
if (!Directory.Exists(binFolder))
{
Directory.CreateDirectory(binFolder);
Console.WriteLine("rdfWebDeploy: Created a bin\\ directory for the web application");
}
//Copy all required DLLs are in the bin directory of the application
String sourceFolder = RdfWebDeployHelper.ExecutablePath;
foreach (String dll in RdfWebDeployHelper.RequiredDLLs)
{
if (File.Exists(Path.Combine(sourceFolder, dll)))
{
File.Copy(Path.Combine(sourceFolder, dll), Path.Combine(binFolder, dll), true);
Console.WriteLine("rdfWebDeploy: Updated " + dll + " in the web applications bin directory");
}
else
{
Console.Error.WriteLine("rdfWebDeploy: Error: Required DLL " + dll + " which needs deploying to the web applications bin directory could not be found");
return;
}
}
Console.WriteLine("rdfWebDeploy: OK - All required DLLs are now up to date");
}
示例5: StartDirect
private static void StartDirect(String[] args)
{
try
{
Common.Initialize();
switch (args.First())
{
case "-game": Common.StartGame(args.Skip(1).ToArray()); break;
case "-editor": Common.StartEditor(args.Skip(1).ToArray()); break;
default: throw new ArgumentException(@"Invalid start argument: """ + args[0] + @""", valid arguments are ""-game"" or ""-editor""");
}
}
catch (Exception e)
{
MessageBox.Show(e.ToString(), e.GetType().Name);
}
}
示例6: Verify
public void Verify(String[] args)
{
if (args.Length < 2)
{
Console.Error.WriteLine("rdfWebDeploy: Error: 2 Arguments are required in order to use the -dllverify mode");
return;
}
if (args.Length > 2)
{
if (!this.SetOptions(args.Skip(2).ToArray()))
{
Console.Error.WriteLine("rdfWebDeploy: DLL Verify aborted since one/more options were not valid");
return;
}
}
String appFolder;
if (!this._noLocalIIS)
{
//Open the Configuration File
System.Configuration.Configuration config = WebConfigurationManager.OpenWebConfiguration(args[1], this._site);
Console.Out.WriteLine("rdfWebDeploy: Opened the Web.Config file for the specified Web Application");
appFolder = Path.GetDirectoryName(config.FilePath);
}
else
{
appFolder = Path.GetDirectoryName(args[1]);
}
//Detect Folders
String binFolder = Path.Combine(appFolder, "bin\\");
if (!Directory.Exists(binFolder))
{
Directory.CreateDirectory(binFolder);
Console.WriteLine("rdfWebDeploy: Created a bin\\ directory for the web application");
}
//Verify all required DLLs are in the bin directory of the application
IEnumerable<String> dlls = RdfWebDeployHelper.RequiredDLLs;
if (this._sql) dlls = dlls.Concat(RdfWebDeployHelper.RequiredSqlDLLs);
if (this._virtuoso) dlls = dlls.Concat(RdfWebDeployHelper.RequiredVirtuosoDLLs);
if (this._fulltext) dlls = dlls.Concat(RdfWebDeployHelper.RequiredFullTextDLLs);
foreach (String dll in dlls)
{
if (!File.Exists(Path.Combine(binFolder, dll)))
{
Console.Error.WriteLine("rdfWebDeploy: Error: Required DLL " + dll + " which needs deploying to the web applications bin directory is not present, suggest you use the -dllupdate mode to rectify this");
return;
}
}
Console.WriteLine("rdfWebDeploy: OK - All required DLLs are present");
}
示例7: Execute
public void Execute(String[] args)
{
if (ShowHelpFor(args))
{
ShowHelp();
ShowAvailableModules();
}
else
{
String moduleName = args[0];
String[] moduleArgs = args.Skip(1).ToArray();
GennyModuleDescriptor[] descriptors = Locator.Find(moduleName).ToArray();
switch (descriptors.Length)
{
case 0:
Logger.Write($"Could not find a genny module named: {moduleName}");
ShowAvailableModules();
break;
case 1:
GennyModuleLoaderResult result = Loader.Load(descriptors[0], moduleArgs);
if (result.Errors.Any())
{
foreach (String error in result.Errors)
Logger.Write(error);
result.Module.ShowHelp(Logger);
}
else
{
result.Module.Run();
}
break;
default:
Logger.Write($"Found more than one genny module named: {moduleName}, try using longer identifiers");
foreach (GennyModuleDescriptor descriptor in descriptors)
Logger.Write($" {descriptor.FullName} - {descriptor.Description ?? "{No description}"}");
break;
}
}
}
示例8: ProcessListParameters
/// <summary>
/// Processes user-specified parameters for the list command.
/// </summary>
/// <param name="args">The application's command line arguments.</param>
/// <param name="parser">The command line argument parser.</param>
private void ProcessListParameters(String[] args, CommandLineParser parser)
{
ListInput = args.Skip(1).Take(1).Single();
}
示例9: ProcessPackParameters
/// <summary>
/// Processes user-specified parameters for the pack command.
/// </summary>
/// <param name="args">The application's command line arguments.</param>
/// <param name="parser">The command line argument parser.</param>
private void ProcessPackParameters(String[] args, CommandLineParser parser)
{
PackOutput = args.Skip(1).Take(1).Single();
PackDirectories = args.Skip(2).ToList();
}
示例10: RunDeploy
public void RunDeploy(String[] args)
{
if (args.Length < 3)
{
Console.Error.WriteLine("rdfWebDeploy: Error: 3 Arguments are required in order to use the -deploy mode, type rdfWebDeploy -help to see usage summary");
return;
}
if (args.Length > 3)
{
if (!this.SetOptions(args.Skip(3).ToArray()))
{
Console.Error.WriteLine("rdfWebDeploy: Deployment aborted since one/more options were not valid");
return;
}
}
if (this._noLocalIIS)
{
Console.WriteLine("rdfWebDeploy: No Local IIS Server available so switching to -xmldeploy mode");
XmlDeploy xdeploy = new XmlDeploy();
xdeploy.RunXmlDeploy(args);
return;
}
//Define the Server Manager object
Admin.ServerManager manager = null;
try
{
//Connect to the Server Manager
if (!this._noIntegratedRegistration) manager = new Admin.ServerManager();
//Open the Configuration File
System.Configuration.Configuration config = WebConfigurationManager.OpenWebConfiguration(args[1], this._site);
Console.Out.WriteLine("rdfWebDeploy: Opened the Web.config file for the specified Web Application");
//Detect Folders
String appFolder = Path.GetDirectoryName(config.FilePath);
String binFolder = Path.Combine(appFolder, "bin\\");
String appDataFolder = Path.Combine(appFolder, "App_Data\\");
if (!Directory.Exists(binFolder))
{
Directory.CreateDirectory(binFolder);
Console.WriteLine("rdfWebDeploy: Created a bin\\ directory for the web application");
}
if (!Directory.Exists(appDataFolder))
{
Directory.CreateDirectory(appDataFolder);
Console.WriteLine("rdfWebDeploy: Created an App_Data\\ directory for the web application");
}
//Deploy dotNetRDF and required DLLs to the bin directory of the application
String sourceFolder = RdfWebDeployHelper.ExecutablePath;
foreach (String dll in RdfWebDeployHelper.RequiredDLLs)
{
if (File.Exists(Path.Combine(sourceFolder, dll)))
{
File.Copy(Path.Combine(sourceFolder, dll), Path.Combine(binFolder, dll), true);
Console.WriteLine("rdfWebDeploy: Deployed " + dll + " to the web applications bin directory");
}
else
{
Console.Error.WriteLine("rdfWebDeploy: Error: Required DLL " + dll + " which needs deploying to the web applications bin directory could not be found");
return;
}
}
//Deploy the configuration file to the App_Data directory
if (File.Exists(args[2]))
{
File.Copy(args[2], Path.Combine(appDataFolder, args[2]), true);
Console.WriteLine("rdfWebDeploy: Deployed the configuration file to the web applications App_Data directory");
}
else if (!File.Exists(Path.Combine(appDataFolder, args[2])))
{
Console.Error.WriteLine("rdfWebDeploy: Error: Unable to continue deployment as the configuration file " + args[2] + " could not be found either locally for deployment to the App_Data folder or already present in the App_Data folder");
return;
}
//Set the AppSetting for the configuration file
config.AppSettings.Settings.Remove("dotNetRDFConfig");
config.AppSettings.Settings.Add("dotNetRDFConfig", "~/App_Data/" + Path.GetFileName(args[2]));
Console.WriteLine("rdfWebDeploy: Set the \"dotNetRDFConfig\" appSetting to \"~/App_Data/" + Path.GetFileName(args[2]) + "\"");
//Now load the Configuration Graph from the App_Data folder
Graph g = new Graph();
FileLoader.Load(g, Path.Combine(appDataFolder, args[2]));
Console.WriteLine("rdfWebDeploy: Successfully deployed required DLLs and appSettings");
Console.WriteLine();
//Get the sections of the Configuration File we want to edit
HttpHandlersSection handlersSection = config.GetSection("system.web/httpHandlers") as HttpHandlersSection;
if (handlersSection == null)
{
Console.Error.WriteLine("rdfWebDeploy: Error: Unable to access the Handlers section of the web applications Web.Config file");
return;
}
//Detect Handlers from the Configution Graph and deploy
//.........这里部分代码省略.........
示例11: StartEditor
public static void StartEditor(String[] args)
{
if (!Common.IsInitialized)
Common.Initialize();
if (!File.Exists(Common.EditorPath))
throw new FileNotFoundException("Could not find worldedit.exe!" + Environment.NewLine + "You may need to verify your registry settings are correct.", "worldedit.exe");
if (!File.Exists(Path.Combine(Environment.CurrentDirectory, "SharpCraft.dll")))
throw new FileNotFoundException("Could not find SharpCraft.dll!" + Environment.NewLine + "You may need to redownload SharpCraft.", "SharpCraft.dll");
Boolean kill = false;
Boolean debug = false;
Boolean valid = true;
while (valid && args.Length > 0)
{
switch (args[0])
{
case "-kill":
kill = true;
args = args.Skip(1).ToArray();
break;
case "-debug":
debug = true;
args = args.Skip(1).ToArray();
break;
default:
valid = false;
break;
}
}
var worldedits = Process.GetProcessesByName("worldedit");
if (worldedits.Count() > 0)
{
if (kill)
{
foreach (var worldedit in worldedits)
worldedit.Kill();
}
else throw new InvalidOperationException("World Editor is already running!" + Environment.NewLine + "You may need to check Task Manager for \"worldedit.exe\", and kill it.");
}
Console.Write("Creating and injecting into World Editor . . . ");
var cmd = '"' + Common.EditorPath + '"';
if (args.Length > 0)
cmd += ' ' + args.Aggregate((a, b) => a + ' ' + b);
Int32 processId;
RemoteHooking.CreateAndInject(Common.EditorPath, cmd, 0, "SharpCraft.dll", "SharpCraft.dll", out processId, PluginContext.Editor, debug, Environment.CurrentDirectory, Common.InstallPath);
Console.WriteLine("Done!");
}
示例12: RunXmlDeploy
public void RunXmlDeploy(String[] args)
{
if (args.Length < 3)
{
Console.Error.WriteLine("rdfWebDeploy: Error: 3 Arguments are required in order to use the -xmldeploy mode, type rdfWebDeploy -help to see usage summary");
return;
}
if (args.Length > 3)
{
if (!this.SetOptions(args.Skip(3).ToArray()))
{
Console.Error.WriteLine("rdfWebDeploy: Deployment aborted since one/more options were not valid");
return;
}
}
try
{
//Determine the path to the Web.config file if possible
if (args[1].Equals("."))
{
args[1] = Path.Combine(".", "Web.config");
}
else if (Path.GetFileName(args[1]).Equals(String.Empty))
{
//If we were given a Folder Path then add Web.config to the end
args[1] = Path.Combine(args[1], "Web.config");
}
else if (!Path.GetFileName(args[1]).Equals("Web.config", StringComparison.OrdinalIgnoreCase))
{
//If out path was to a file and it wasn't a Web.config file we error
Console.Error.WriteLine("rdfWebDeploy: Error: You must specify a Web.config file for the web application you wish to deploy to");
return;
}
//Open the Configuration File
XmlDocument config = new XmlDocument();
if (File.Exists(args[1]))
{
//If the File exists open it
config.Load(args[1]);
//Verify this does appear to be a Web.config file
if (!config.DocumentElement.Name.Equals("configuration"))
{
Console.Error.WriteLine("rdfWebDeploy: Error: The Web.Config file for the Web Application does not appear to be a valid Web.Config file");
return;
}
}
else
{
//If the Web.Config file doesn't exist then create one
XmlDeclaration decl = config.CreateXmlDeclaration("1.0", "utf-8", null);
config.AppendChild(decl);
XmlElement docEl = config.CreateElement("configuration");
config.AppendChild(docEl);
config.Save(args[1]);
}
Console.Out.WriteLine("rdfWebDeploy: Opened the Web.Config file for the specified Web Application");
XmlNode reg = null;
//Detect Folders
String appFolder = Path.GetDirectoryName(args[1]);
String binFolder = Path.Combine(appFolder, "bin\\");
String appDataFolder = Path.Combine(appFolder, "App_Data\\");
if (!Directory.Exists(binFolder))
{
Directory.CreateDirectory(binFolder);
Console.WriteLine("rdfWebDeploy: Created a bin\\ directory for the web application");
}
if (!Directory.Exists(appDataFolder))
{
Directory.CreateDirectory(appDataFolder);
Console.WriteLine("rdfWebDeploy: Created an App_Data\\ directory for the web application");
}
//Deploy dotNetRDF and required DLLs to the bin directory of the application
String sourceFolder = RdfWebDeployHelper.ExecutablePath;
IEnumerable<String> dlls = RdfWebDeployHelper.RequiredDLLs;
if (this._sql) dlls = dlls.Concat(RdfWebDeployHelper.RequiredSqlDLLs);
if (this._virtuoso) dlls = dlls.Concat(RdfWebDeployHelper.RequiredVirtuosoDLLs);
if (this._fulltext) dlls = dlls.Concat(RdfWebDeployHelper.RequiredFullTextDLLs);
foreach (String dll in dlls)
{
if (File.Exists(Path.Combine(sourceFolder, dll)))
{
File.Copy(Path.Combine(sourceFolder, dll), Path.Combine(binFolder, dll), true);
Console.WriteLine("rdfWebDeploy: Deployed " + dll + " to the web applications bin directory");
}
else
{
Console.Error.WriteLine("rdfWebDeploy: Error: Required DLL " + dll + " which needs deploying to the web applications bin directory could not be found");
return;
}
}
//Deploy the configuration file to the App_Data directory
if (File.Exists(args[2]))
{
//.........这里部分代码省略.........
示例13: FormatGuid
protected String FormatGuid(String guid) {
return String.Format("{0}..{1}", new String(guid.Take(5).ToArray()), new String(guid.Skip(Math.Max(0, guid.Count() - 3)).Take(3).ToArray()));
}
示例14: TryExtractingDateAndTime
/// <summary>
///
/// </summary>
/// <param name="timestamp"></param>
/// <param name="date"></param>
/// <param name="time"></param>
/// <returns></returns>
private static String TryExtractingDateAndTime(String[] timestamp, ref DateTime date, ref DateTime time)
{
if (timestamp == null)
return null;
if (DateTime.TryParse(timestamp[1], out time))
{
// Rabo format
DateTime dummy;
if (!DateTime.TryParse(timestamp[0], out dummy))
{
date = date.AddTicks(time.Ticks);
return String.Join(" ", timestamp[0], timestamp.Skip(2));
}
}
// ING format
if (timestamp != null && (DateTime.TryParse(timestamp[0], out date) ||
DateTime.TryParseExact(timestamp[0], "yyyyMMdd", CultureInfo.CurrentCulture, DateTimeStyles.None, out date)))
{
date = date.AddTicks(time.Ticks);
return String.Join(" ", timestamp.Skip(2));
}
return null;
}
示例15: Main
static void Main(String[] args)
{
if (args != null && args.Length == 1 && args[0].Length > 1
&& (args[0][0] == '-' || args[0][0] == '/'))
{
switch (args[0].Substring(1).ToLower())
{
default:
Console.WriteLine("Huh?!");
break;
case "uninstall":
case "u":
{
ServiceController[] scServices = ServiceController.GetServices();
foreach (ServiceController sc in scServices)
if (sc.ServiceName == name)
if (sc.Status != ServiceControllerStatus.Stopped && sc.Status != ServiceControllerStatus.StopPending)
sc.Stop();
ManagedInstallerClass.InstallHelper(new string[] { "/u", Assembly.GetExecutingAssembly().Location });
break;
}
case "console":
case "c":
{
TelnetPerfmonServer program = new TelnetPerfmonServer();
program.Run(args.Skip(1).ToArray());
break;
}
/* case "p":
{
TelnetPerfmonServer program = new TelnetPerfmonServer();
Thread t =new Thread(() => program.Run(new String[]{}));
t.Start();
Thread.Sleep(5000);
program.Stop();
break;
}*/
}
}
else
{
bool found = false;
foreach (ServiceController sc in ServiceController.GetServices())
if (sc.ServiceName == name)
found = true;
if (!found)
install();
else
ServiceBase.Run(new ServiceBase[] { new TelnetPerfmonService() });
}
}