public override void Parse(string arg) { if (arg.StartsWith("--find:case", StringComparison.InvariantCultureIgnoreCase)) { this.findOptions = Wildcard.WildcardOptions.None; } else if (arg.StartsWith("--find:nocase", StringComparison.InvariantCultureIgnoreCase)) { this.findOptions = Wildcard.WildcardOptions.IgnoreCase; } else if (arg.StartsWith("--find:container=", StringComparison.InvariantCultureIgnoreCase)) { string argValue = arg.Substring("--find:container=".Length); if (argValue.IsEmpty()) { FatalError(String.Format("Invalid name ({0}); use 'APPDATA {1} --help' for usage", arg, GetCommandName())); } this.findContainerName = argValue; } else if (arg.StartsWith("--find:value=", StringComparison.InvariantCultureIgnoreCase)) { string argValue = arg.Substring("--find:value=".Length); if (argValue.IsEmpty()) { FatalError(String.Format("Invalid key ({0}); use 'APPDATA {1} --help' for usage", arg, GetCommandName())); } this.findValueKey = argValue; } else if (arg.Equals("-r", StringComparison.InvariantCultureIgnoreCase) || arg.Equals("--recurse", StringComparison.InvariantCultureIgnoreCase)) { this.recurse = true; } else if (arg.StartsWith("--type=", StringComparison.InvariantCultureIgnoreCase)) { string argValue = arg.Substring("--type=".Length); try { this.matchType = AppDataType.ToAppDataType(argValue); } catch (NotSupportedException) { FatalError(String.Format("Unknown type ({0}); use 'APPDATA {1} --help' for usage", arg, GetCommandName())); } } else if (arg.StartsWith("--value=", StringComparison.InvariantCultureIgnoreCase)) { string argValue = arg.Substring("--value=".Length); if (argValue.IsEmpty()) { FatalError(String.Format("Invalid key ({0}); use 'APPDATA {1} --help' for usage", arg, GetCommandName())); } this.matchValueKey = argValue; } else { base.Parse(arg); } }
public static AppDataType.Type ToAppDataType(string s, AppDataType.Type[] allowedTypes) { AppDataType.Type appdataType = ToAppDataType(s); if (Array.Exists(allowedTypes, t => t == appdataType)) { return(appdataType); } throw new NotSupportedException(String.Format("Unknown type ({0})", s)); }
private void DumpValue(string key, object value, AppDataType.Type type) { if (type == AppDataType.Type.ApplicationDataCompositeValue) { DumpComposite(key, (ApplicationDataCompositeValue)value); } else { PrintLineFormat(" {0} {1} {2}", key.ToString(), type.ToString(), value.ToString()); } }
public override void Parse(string arg) { if (arg.StartsWith("--data=", StringComparison.InvariantCultureIgnoreCase)) { this.dataAsString = arg.Substring("--data=".Length); } else if (arg.Equals("--overwrite:no", StringComparison.InvariantCultureIgnoreCase)) { this.overwrite = Overwrite.No; } else if (arg.Equals("--overwrite:prompt", StringComparison.InvariantCultureIgnoreCase)) { this.overwrite = Overwrite.Prompt; } else if (arg.Equals("--overwrite:yes", StringComparison.InvariantCultureIgnoreCase)) { this.overwrite = Overwrite.Yes; } else if (arg.StartsWith("--type=", StringComparison.InvariantCultureIgnoreCase)) { string argValue = arg.Substring("--type=".Length); try { this.dataType = AppDataType.ToAppDataType(argValue, supportedAppDataTypes); } catch (NotSupportedException) { FatalError(String.Format("Unknown type ({0}); use 'APPDATA {1} --help' for usage", arg, GetCommandName())); } } else if (arg.StartsWith("--value=", StringComparison.InvariantCultureIgnoreCase)) { string argValue = arg.Substring("--value=".Length); if (argValue.IsEmpty()) { FatalError(String.Format("Invalid key ({0}); use 'APPDATA {1} --help' for usage", arg, GetCommandName())); } this.valueKey = argValue; } else { base.Parse(arg); } }
public static object Parse(AppDataType.Type type, string s) { object obj = null; switch (type) { case AppDataType.Type.Empty: obj = PropertyValue.CreateEmpty();; break; case AppDataType.Type.UInt8: obj = PropertyValue.CreateUInt8(s.IsEmpty() ? (byte)0 : Byte.Parse(s)); break; case AppDataType.Type.Int16: obj = PropertyValue.CreateInt16(s.IsEmpty() ? (short)0 : Int16.Parse(s)); break; case AppDataType.Type.UInt16: obj = PropertyValue.CreateUInt16(s.IsEmpty() ? (ushort)0 : UInt16.Parse(s)); break; case AppDataType.Type.Int32: obj = PropertyValue.CreateInt32(s.IsEmpty() ? 0 : Int32.Parse(s)); break; case AppDataType.Type.UInt32: obj = PropertyValue.CreateUInt32(s.IsEmpty() ? 0 : UInt32.Parse(s)); break; case AppDataType.Type.Int64: obj = PropertyValue.CreateInt64(s.IsEmpty() ? 0 : Int64.Parse(s)); break; case AppDataType.Type.UInt64: obj = PropertyValue.CreateUInt64(s.IsEmpty() ? 0 : UInt64.Parse(s)); break; case AppDataType.Type.Single: obj = PropertyValue.CreateSingle(s.IsEmpty() ? 0 : Single.Parse(s)); break; case AppDataType.Type.Double: obj = PropertyValue.CreateDouble(s.IsEmpty() ? 0 : Double.Parse(s)); break; case AppDataType.Type.Char16: obj = PropertyValue.CreateChar16(Char.Parse(s)); break; case AppDataType.Type.Boolean: obj = PropertyValue.CreateBoolean(s.IsEmpty() ? false : Boolean.Parse(s)); break; case AppDataType.Type.String: obj = s; break; default: break; } return(obj); }
public TypeXref(System.Type objectType, AppDataType.Type appdataType) { this.objectType = objectType; this.appdataType = appdataType; this.appdataTypeString = AppDataType.ToString(appdataType); }