Beispiel #1
0
 public IEnumerable <String> BinaryTranslator_ClientCommand(ClientCommandDef c, String NamespaceName)
 {
     foreach (var _Line in Combine(Begin(), BinaryTranslator_Record(GetSuffixedTypeName(c.Name, c.Version, "Request", NamespaceName), GetSuffixedTypeString(c.Name, c.Version, "Request", NamespaceName), c.OutParameters, NamespaceName)))
     {
         yield return(_Line);
     }
     foreach (var _Line in Combine(Begin(), BinaryTranslator_TaggedUnion(GetSuffixedTypeName(c.Name, c.Version, "Reply", NamespaceName), GetSuffixedTypeString(c.Name, c.Version, "Reply", NamespaceName), GetSuffixedTypeName(c.Name, c.Version, "ReplyTag", NamespaceName), GetSuffixedTypeString(c.Name, c.Version, "ReplyTag", NamespaceName), c.InParameters, NamespaceName)))
     {
         yield return(_Line);
     }
 }
Beispiel #2
0
        public void FillTranslatorClientCommand(Dictionary <String, TypeDef> VersionedNameToType, ClientCommandDef c, List <String> l, String NamespaceName)
        {
            var Name = c.FullName();
            ClientCommandDef cHead = null;

            if (VersionedNameToType.ContainsKey(Name))
            {
                var tHead = VersionedNameToType[Name];
                if (tHead.OnClientCommand)
                {
                    cHead = tHead.ClientCommand;
                }
            }
            var cHeadTypeRef                 = Nonversioned(c.GetTypeSpec()).TypeRef;
            var SimpleName                   = cHeadTypeRef.SimpleName(NamespaceName);
            var VersionedSimpleName          = c.GetTypeSpec().SimpleName(NamespaceName);
            var RequestTypeString            = GetSuffixedTypeString(c.Name, c.Version, "Request", NamespaceName);
            var ReplyTypeString              = GetSuffixedTypeString(c.Name, c.Version, "Reply", NamespaceName);
            var RequestName                  = GetSuffixedTypeName(c.Name, c.Version, "Request", NamespaceName);
            var ReplyName                    = GetSuffixedTypeName(c.Name, c.Version, "Reply", NamespaceName);
            var UnversionedRequestTypeString = GetSuffixedTypeString(cHeadTypeRef.Name, cHeadTypeRef.Version, "Request", NamespaceName);
            var UnversionedReplyTypeString   = GetSuffixedTypeString(cHeadTypeRef.Name, cHeadTypeRef.Version, "Reply", NamespaceName);

            if (c.Attributes.Any(a => a.Key == "Async"))
            {
                l.AddRange(Translator_ClientCommandAsync(SimpleName, VersionedSimpleName, RequestTypeString, ReplyTypeString, NamespaceName).Select(Line => cHead != null ? Line : "//" + Line));
            }
            else
            {
                l.AddRange(Translator_ClientCommand(SimpleName, VersionedSimpleName, RequestTypeString, ReplyTypeString, NamespaceName).Select(Line => cHead != null ? Line : "//" + Line));
            }
            if (cHead != null)
            {
                FillTranslatorRecordTo(RequestName, UnversionedRequestTypeString, RequestTypeString, c.OutParameters, cHead.OutParameters, l, false, NamespaceName);
                FillTranslatorTaggedUnionFrom(ReplyName, UnversionedReplyTypeString, ReplyTypeString, c.InParameters, cHead.InParameters, l, false, NamespaceName);
            }
            else
            {
                FillTranslatorRecordTo(RequestName, UnversionedRequestTypeString, RequestTypeString, c.OutParameters, new List <VariableDef> {
                }, l, true, NamespaceName);
                FillTranslatorTaggedUnionFrom(ReplyName, UnversionedReplyTypeString, ReplyTypeString, c.InParameters, new List <VariableDef> {
                }, l, true, NamespaceName);
            }
        }
Beispiel #3
0
        public IEnumerable <String> ClientCommand(ClientCommandDef c)
        {
            var RequestRef = GetSuffixedTypeRef(c.Name, c.Version, "Request");
            var ReplyRef   = GetSuffixedTypeRef(c.Name, c.Version, "Reply");
            var Request    = new RecordDef {
                Name = RequestRef.Name, Version = RequestRef.Version, GenericParameters = new List <VariableDef> {
                }, Fields = c.OutParameters, Attributes = c.Attributes, Description = c.Description
            };
            var Reply = new TaggedUnionDef {
                Name = ReplyRef.Name, Version = ReplyRef.Version, GenericParameters = new List <VariableDef> {
                }, Alternatives = c.InParameters, Attributes = c.Attributes, Description = c.Description
            };

            foreach (var _Line in Combine(Begin(), Record(Request)))
            {
                yield return(_Line);
            }
            foreach (var _Line in Combine(Begin(), TaggedUnion(Reply)))
            {
                yield return(_Line);
            }
        }