public IEnumerable <String> JsonTranslator_Alias(AliasDef a, String NamespaceName) { var TypeString = GetTypeString(a.GetTypeSpec(), NamespaceName); var Name = a.GetTypeSpec().SimpleName(NamespaceName); var ValueSimpleName = a.Type.SimpleName(NamespaceName); foreach (var _Line in Combine(Combine(Combine(Combine(Begin(), "public static function "), GetEscapedIdentifier(Combine(Combine(Begin(), LowercaseCamelize(Name)), "FromJson"))), "(j : Dynamic) : "), TypeString)) { yield return(_Line); } yield return("{"); foreach (var _Line in Combine(Combine(Combine(Begin(), " return "), GetEscapedIdentifier(Combine(Combine(Begin(), LowercaseCamelize(ValueSimpleName)), "FromJson"))), "(j);")) { yield return(_Line); } yield return("}"); foreach (var _Line in Combine(Combine(Combine(Combine(Combine(Begin(), "public static function "), GetEscapedIdentifier(Combine(Combine(Begin(), LowercaseCamelize(Name)), "ToJson"))), "(o : "), TypeString), ") : Dynamic")) { yield return(_Line); } yield return("{"); foreach (var _Line in Combine(Combine(Combine(Begin(), " return "), GetEscapedIdentifier(Combine(Combine(Begin(), LowercaseCamelize(ValueSimpleName)), "ToJson"))), "(o);")) { yield return(_Line); } yield return("}"); }
public IEnumerable <String> Alias(AliasDef a) { var Name = GetEscapedIdentifier(a.DefinitionName()) + GetGenericParameters(a.GenericParameters); var Type = GetTypeString(a.Type, a.NamespaceName()); foreach (var _Line in Combine(Begin(), GetXmlComment(a.Description))) { yield return(_Line); } foreach (var _Line in Combine(Combine(Combine(Begin(), Name), " = "), Type)) { yield return(_Line); } }
public IEnumerable <String> Alias(AliasDef a) { var Name = GetEscapedIdentifier(a.TypeFriendlyName()) + GetGenericParameters(a.GenericParameters); var Type = GetTypeString(a.Type); foreach (var _Line in Combine(Begin(), GetXmlComment(a.Description))) { yield return(_Line); } yield return("[Alias]"); foreach (var _Line in Combine(Combine(Begin(), "public sealed class "), Name)) { yield return(_Line); } yield return("{"); foreach (var _Line in Combine(Combine(Combine(Begin(), " public "), Type), " Value;")) { yield return(_Line); } yield return(""); foreach (var _Line in Combine(Combine(Combine(Combine(Combine(Begin(), " public static implicit operator "), Name), "("), Type), " o)")) { yield return(_Line); } yield return(" {"); foreach (var _Line in Combine(Combine(Combine(Begin(), " return new "), Name), " {Value = o};")) { yield return(_Line); } yield return(" }"); foreach (var _Line in Combine(Combine(Combine(Combine(Combine(Begin(), " public static implicit operator "), Type), "("), Name), " c)")) { yield return(_Line); } yield return(" {"); yield return(" return c.Value;"); yield return(" }"); yield return("}"); }
public void FillTranslatorAliasTo(Dictionary <String, TypeDef> VersionedNameToType, AliasDef a, List <String> l, String NamespaceName) { var Name = a.FullName(); AliasDef aHead = null; if (VersionedNameToType.ContainsKey(Name)) { var tHead = VersionedNameToType[Name]; if (tHead.OnAlias) { aHead = tHead.Alias; } } var VersionedSimpleName = a.GetTypeSpec().SimpleName(NamespaceName); var TypeString = GetTypeString(Nonversioned(a.GetTypeSpec()), NamespaceName); var VersionedTypeString = GetTypeString(a.GetTypeSpec(), NamespaceName); if (aHead == null) { FillTranslatorRecordTo(VersionedSimpleName, TypeString, VersionedTypeString, new List <VariableDef> { new VariableDef { Name = "Value", Type = a.Type, Attributes = new List <KeyValuePair <String, List <String> > > { }, Description = "" } }, new List <VariableDef> { }, l, true, NamespaceName); } else { FillTranslatorRecordTo(VersionedSimpleName, TypeString, VersionedTypeString, new List <VariableDef> { new VariableDef { Name = "Value", Type = a.Type, Attributes = new List <KeyValuePair <String, List <String> > > { }, Description = "" } }, new List <VariableDef> { new VariableDef { Name = "Value", Type = aHead.Type, Attributes = new List <KeyValuePair <String, List <String> > > { }, Description = "" } }, l, false, NamespaceName); } }
public IEnumerable <String> Alias(AliasDef a) { var Name = GetEscapedIdentifier(a.DefinitionName()) + GetGenericParameters(a.GenericParameters); var Type = GetTypeString(a.Type, a.NamespaceName()); foreach (var _Line in Combine(Begin(), GetXmlComment(a.Description))) { yield return(_Line); } yield return("@Alias"); foreach (var _Line in Combine(Combine(Begin(), "public final class "), Name)) { yield return(_Line); } yield return("{"); foreach (var _Line in Combine(Combine(Combine(Begin(), " public "), Type), " Value;")) { yield return(_Line); } yield return(""); foreach (var _Line in Combine(Combine(Combine(Combine(Combine(Begin(), " public static "), Name), " Create("), Type), " o)")) { yield return(_Line); } yield return(" {"); foreach (var _Line in Combine(Combine(Combine(Combine(Combine(Begin(), " "), Name), " r = new "), Name), "();")) { yield return(_Line); } yield return(" r.Value = o;"); yield return(" return r;"); yield return(" }"); yield return("}"); }
public IEnumerable <String> Alias(AliasDef a) { var Name = GetEscapedIdentifier(a.DefinitionName()) + GetGenericParameters(a.GenericParameters); var Type = GetTypeString(a.Type, a.NamespaceName()); foreach (var _Line in Combine(Begin(), GetXmlComment(a.Description))) { yield return(_Line); } yield return("<[Alias]()>"); foreach (var _Line in Combine(Combine(Begin(), "Public NotInheritable Class "), Name)) { yield return(_Line); } foreach (var _Line in Combine(Combine(Begin(), " Public Value As "), Type)) { yield return(_Line); } yield return(""); foreach (var _Line in Combine(Combine(Combine(Combine(Begin(), " Public Shared Widening Operator CType(ByVal o As "), Type), ") As "), Name)) { yield return(_Line); } foreach (var _Line in Combine(Combine(Combine(Begin(), " Return New "), Name), " With {.Value = o}")) { yield return(_Line); } yield return(" End Operator"); foreach (var _Line in Combine(Combine(Combine(Combine(Begin(), " Public Shared Widening Operator CType(ByVal c As "), Name), ") As "), Type)) { yield return(_Line); } yield return(" Return c.Value"); yield return(" End Operator"); yield return("End Class"); }
public IEnumerable <String> BinaryTranslator_Alias(AliasDef a, String NamespaceName) { var TypeString = GetTypeString(a.GetTypeSpec(), NamespaceName); var Name = a.GetTypeSpec().SimpleName(NamespaceName); var ValueSimpleName = a.Type.SimpleName(NamespaceName); foreach (var _Line in Combine(Combine(Combine(Combine(Combine(Begin(), "public static "), TypeString), " "), GetEscapedIdentifier(Combine(Combine(Begin(), Name), "FromBinary"))), "(IReadableStream s)")) { yield return(_Line); } yield return("{"); foreach (var _Line in Combine(Combine(Combine(Combine(Combine(Begin(), " "), TypeString), " o = new "), TypeString), "();")) { yield return(_Line); } foreach (var _Line in Combine(Combine(Combine(Begin(), " o.Value = "), GetEscapedIdentifier(Combine(Combine(Begin(), ValueSimpleName), "FromBinary"))), "(s);")) { yield return(_Line); } yield return(" return o;"); yield return("}"); foreach (var _Line in Combine(Combine(Combine(Combine(Combine(Begin(), "public static void "), GetEscapedIdentifier(Combine(Combine(Begin(), Name), "ToBinary"))), "(IWritableStream s, "), TypeString), " o)")) { yield return(_Line); } yield return("{"); foreach (var _Line in Combine(Combine(Combine(Begin(), " "), GetEscapedIdentifier(Combine(Combine(Begin(), ValueSimpleName), "ToBinary"))), "(s, o.Value);")) { yield return(_Line); } yield return("}"); }
private static void CmdAlias(CommandLineApplication parent, AliasManager aliasManager) { parent.Command("alias", cmd => { cmd.Description = "Alias commands"; cmd.AddFullNameLogo(); var optCreate = cmd.Option("--create|-c", "Create new", CommandOptionType.NoValue); var optRemove = cmd.Option("--remove|-r", "Delete", CommandOptionType.NoValue); var optVerbose = cmd.VerboseOption(); cmd.OnExecute(() => { /// <summary> /// Get name alias /// </summary> /// <param name="title"></param> /// <param name="create"></param> /// <returns></returns> string GetName(string title, bool create) { Console.Out.WriteLine(title); var name = " "; while (true) { name = ReadLine.Read("Name: ", name.Trim()); if (string.IsNullOrWhiteSpace(name)) { Console.Out.WriteLine($"Abort {title}"); break; } var exists = aliasManager.Exists(name); if ((create && AliasDef.IsValid(name) && !exists) || (!create && exists)) { break; } else { Console.Out.WriteLine($"Alias '{name}' already exists!"); } } return(name); } if (optCreate.HasValue()) { //create var name = GetName("Create alias (using comma to more name)", true); if (string.IsNullOrWhiteSpace(name)) { return; } var description = ReadLine.Read("Description: "); var command = ReadLine.Read("Command: "); if (string.IsNullOrWhiteSpace(command)) { Console.Out.WriteLine("Abort create alias"); return; } aliasManager.Create(name, description, command, false); Console.Out.WriteLine($"Alias '{name}' created!"); } else if (optRemove.HasValue()) { //remove var name = GetName("Remove alias", false); if (string.IsNullOrWhiteSpace(name)) { return; } aliasManager.Remove(name); Console.Out.WriteLine($"Alias '{name}' removed!"); } else { Console.Out.Write(aliasManager.ToTable(optVerbose.HasValue())); } }); }); }
public IEnumerable <String> Alias(AliasDef a) { var Name = GetEscapedIdentifier(a.DefinitionName()) + GetGenericParameters(a.GenericParameters); var Type = GetTypeString(a.Type, a.NamespaceName()); foreach (var _Line in Combine(Begin(), GetXmlComment(a.Description))) { yield return(_Line); } yield return("/* Alias */"); foreach (var _Line in Combine(Begin(), GetGenericParameterLine(a.GenericParameters))) { yield return(_Line); } foreach (var _Line in Combine(Combine(Combine(Begin(), "class "), Name), " final")) { yield return(_Line); } yield return("{"); yield return("public:"); foreach (var _Line in Combine(Combine(Combine(Begin(), " "), Type), " Value;")) { yield return(_Line); } yield return(""); foreach (var _Line in Combine(Combine(Combine(Begin(), " "), Name), "()")) { yield return(_Line); } yield return(" {"); yield return(" }"); foreach (var _Line in Combine(Combine(Combine(Combine(Combine(Begin(), " "), Name), "(const "), Type), " &v)")) { yield return(_Line); } yield return(" : Value(v)"); yield return(" {"); yield return(" }"); yield return(""); foreach (var _Line in Combine(Combine(Combine(Begin(), " operator const "), Type), " &() const")) { yield return(_Line); } yield return(" {"); yield return(" return Value;"); yield return(" }"); yield return("};"); }
public AliasCommand(AliasDef aliasDef) { _aliasDef = aliasDef; Names.AddRange(aliasDef.Names); }