/** * * * @returns the class declaration containing all added records */ /// <summary> /// Generate a class containing a RECORD definitions /// </summary> /// <param name="recordType">The record type definition to be processed.</param> /// <returns>A roslyn intermediate structure of the record definition</returns> /// <remarks> /// There's a feature in Oberon0 that allows records to be anonymous. Please look at the following code example: /// <example> /// MODULE test; /// VAR foo: RECORD /// field: INTEGER; /// another: REAL /// END; /// END test. /// </example> /// <para> /// This code will create a variable a with a record as the data type. In this case the record does not have a name /// as it is (legally) created as part of the variable declaration. /// </para> /// <para> /// To create a structure that is valid for the intermediate code, those fields get a unique name <code>__internal__{id}</code> /// where id is a increasing counter. /// </para> /// </remarks> private ClassDeclarationSyntax GenerateRecordType(RecordTypeDefinition recordType) { if (string.IsNullOrEmpty(recordType.Name)) { recordType.Name = $"__internal__{++_internalCount}"; } var record = SyntaxFactory.ClassDeclaration(recordType.Name) .AddModifiers(SyntaxFactory.Token(SyntaxKind.PublicKeyword)); foreach (var declaration in recordType.Elements) { record = record.AddMembers(GenerateFieldDeclaration(declaration, true)); } return(record); }
public bool WriteWellKnown(RecordTypeDefinition type, string content, object tag) { if (!(tag is Tag)) { return(false); } if (string.IsNullOrEmpty(content)) { return(false); } WriteResult writeResult = WriteResult.FAILED; NdefMessage ndefMessage = null; try { switch (type) { case RecordTypeDefinition.RTD_TEXT: break; case RecordTypeDefinition.RTD_URI: NdefRecord rtdUriRecord = NdefRecord.CreateUri("http://www.raulrodriguezpacho.com"); ndefMessage = new NdefMessage(new NdefRecord[] { rtdUriRecord }); break; } if (ndefMessage == null) { return(false); } writeResult = WriteTag(ndefMessage, (Tag)tag); } catch { } return(writeResult == WriteResult.OK); }
public bool WriteWellKnown(RecordTypeDefinition type, string content, object tag) { throw new NotImplementedException(); }