protected override async Task <AccessorList> AssignUpsertedReferences(AccessorList record) { record.ListIdentifier = await _strings.UpsertAsync(record.ListIdentifier); record.ListIdentifierId = record.ListIdentifier?.AsciiStringReferenceId ?? record.ListIdentifierId; return(record); }
protected override string InnerTranslate() { var found = TravelUp(f => f is ClassDeclarationTranslation || f is InterfaceDeclarationTranslation); // following TypeScript with interface, we just need set as Field if (found is InterfaceDeclarationTranslation) { //return string.Format("{0}: {1}", syntax.Identifier,type.Translate()); return($"{Helper.GetAttributeList(Syntax.AttributeLists)}{Syntax.Identifier}: {Type.Translate()} ;"); } // hmm, if it's in class, much thing to do if (AccessorList.IsShorten()) { var defaultStr = Helper.GetDefaultValue(Type); if (defaultStr == "null") { defaultStr = string.Empty; } else { defaultStr = " = " + defaultStr; } return($"{Helper.GetAttributeList(Syntax.AttributeLists)} {Modifiers.Translate()} {Syntax.Identifier}: {Type.Translate()}{defaultStr} ;"); } return(AccessorList.Translate()); }
public BasePropertyDeclarationTranslation(BasePropertyDeclarationSyntax syntax, SyntaxTranslation parent) : base(syntax, parent) { Type = syntax.Type.Get <TypeTranslation>(this); AccessorList = syntax.AccessorList.Get <AccessorListTranslation>(this); Modifiers = syntax.Modifiers.Get(this); AccessorList.SetModifier(Modifiers); }
protected override string InnerTranslate() { if (IsInScope <InterfaceDeclarationTranslation>()) { StringBuilder bd = new StringBuilder(); if (AccessorList.Accessors.GetEnumerable().Any(f => f.Syntax.Keyword.ToString() == "get")) { bd.Append($"{TC.IndexerGetName}({ParameterList.Parameters.Translate()}) :{Type.Translate()};"); } if (AccessorList.Accessors.GetEnumerable().Any(f => f.Syntax.Keyword.ToString() == "set")) { bd.Append($"{TC.IndexerSetName}({ParameterList.Parameters.Translate()}, value :{Type.Translate()}):void;"); } return(bd.ToString()); } return(AccessorList.Translate()); //}else //{ // StringBuilder bd = new StringBuilder(); // var getAccessor = AccessorList.Accessors.GetEnumerable().FirstOrDefault(f => f.Syntax.Keyword.ToString() == "get"); // if (getAccessor != null) // { // bd.Append("\{TC.IndexerGetName}(\{ParameterList.Parameters.Translate()}) :\{Type.Translate()}\n \{getAccessor.Translate()}"); // } // var setAccessor = AccessorList.Accessors.GetEnumerable().FirstOrDefault(f => f.Syntax.Keyword.ToString() == "set"); // if (setAccessor!=null) // { // bd.Append("\{TC.IndexerSetName}(\{ParameterList.Parameters.Translate()}, value :\{Type.Translate()}):void \{setAccessor.Translate()}"); // } //} //return Syntax.ToString(); }
protected override Expression <Func <AccessorList, bool> > FindExisting(AccessorList record) => existing => existing.ListIdentifierId == record.ListIdentifierId;
protected override IEnumerable <object> EnumerateReferences(AccessorList record) { yield return(record.AccessorListAssociations); yield return(record.ListIdentifier); }
public void Add(Accessor accessor) { AccessorList.Add(accessor); }