Exemplo n.º 1
0
        public void AddField(string name, IGenReference reference)
        {
            var existingField = Fields.Find(p => p.Name == name);

            if (existingField != null)
            {
                return;
            }

            Fields.Add(new GenField
            {
                Name   = name,
                Parent = this,
                Type   = reference
            });
        }
        static string TypeReferenceName(GenContext context, IGenReference reference, bool fullname = false)
        {
            switch (reference)
            {
            case GenSelectionSet set:
            {
                var name = TypeName(set);

                var clrType = GetClrType(set);
                if (clrType != null)
                {
                    return(ClrTypeFullName(clrType));
                }

                if (fullname)
                {
                    name = "global::" + NamespaceDeclarionName(context, set.Namespace) + "." + name;
                }

                return(name);
            }

            case GenList list:
            {
                var element = TypeReferenceName(context, list.Element, fullname);
                return(ClrTypeFullName(typeof(List <>)) + "<" + element + ">");
            }

            case GenNonNull nonNull:
            {
                return(TypeReferenceName(context, nonNull.Element, fullname));
            }

            default:
                throw new NotImplementedException(reference.GetType().FullName);
            }
        }
Exemplo n.º 3
0
 public GenList(IGenReference element)
 {
     Element = element;
 }
Exemplo n.º 4
0
 public void AddVariable(string name, IGenReference reference)
 => Varaibles.Add(new GenVaraible {
     Name = name, Type = reference
 });