Пример #1
0
        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("}");
        }
Пример #2
0
        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);
            }
        }
Пример #3
0
        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("}");
        }