void AddInheritedInterfaces(InterfaceGen iface, CodeGenerationOptions opt) { foreach (var isym in iface.Interfaces) { var igen = (isym is GenericSymbol ? (isym as GenericSymbol).Gen : isym) as InterfaceGen; // igen *should not* be null here because we *should* only be inheriting interfaces, but // in the case of constants on that interface we create a C# *class* that is registered for the // Java *interface*. Thus when we do type resolution, we are actually pointed to the // Foo abstract class instead of the IFoo interface. if (igen is null || igen.IsConstSugar(opt) || igen.RawVisibility != "public") { continue; } Implements.Add(opt.GetOutputName(isym.FullName)); } if (Implements.Count == 0 && !iface.IsConstSugar(opt)) { if (opt.CodeGenerationTarget != CodeGenerationTarget.JavaInterop1) { Implements.Add("IJavaObject"); } Implements.Add("IJavaPeerable"); } }
public InterfaceInvokerClass(InterfaceGen iface, CodeGenerationOptions opt, CodeGeneratorContext context) { Name = $"{iface.Name}Invoker"; IsInternal = true; IsPartial = true; UsePriorityOrder = true; Inherits = "global::Java.Lang.Object"; Implements.Add(iface.Name); Attributes.Add(new RegisterAttr(iface.RawJniName, noAcw: true, additionalProperties: iface.AdditionalAttributeString()) { UseGlobal = true }); Fields.Add(new PeerMembersField(opt, iface.RawJniName, $"{iface.Name}Invoker", false)); Properties.Add(new InterfaceHandleGetter()); Properties.Add(new JniPeerMembersGetter()); Properties.Add(new InterfaceThresholdClassGetter()); Properties.Add(new ThresholdTypeGetter()); Fields.Add(new FieldWriter { Name = "class_ref", Type = TypeReferenceWriter.IntPtr, IsShadow = opt.BuildingCoreAssembly }); Methods.Add(new GetObjectMethod(iface, opt)); Methods.Add(new ValidateMethod(iface)); Methods.Add(new DisposeMethod()); Constructors.Add(new InterfaceInvokerConstructor(iface, context)); AddMemberInvokers(iface, new HashSet <string> (), opt, context); }
public InterfaceEventHandlerImplClass(InterfaceGen iface, CodeGenerationOptions opt, CodeGeneratorContext context) { var jni_class = "mono/" + iface.RawJniName.Replace('$', '_') + "Implementor"; Name = iface.Name + "Implementor"; Inherits = "global::Java.Lang.Object"; Implements.Add(iface.Name); IsInternal = true; IsSealed = true; IsPartial = true; Attributes.Add(new RegisterAttr(jni_class, additionalProperties: iface.AdditionalAttributeString()) { UseGlobal = true }); if (iface.NeedsSender) { Fields.Add(new FieldWriter { Name = "sender", Type = TypeReferenceWriter.Object }); } AddConstructor(iface, jni_class, opt); AddMethods(iface, opt); }
public void AddImplementor(string implementor) { if (implementor != typeof(object).FullName && !Implements.Contains(implementor)) { Implements.Add(implementor); Commit(); } }
/// <summary> /// Consultas y mutación en Azure search. /// </summary> /// <param name="SearchServiceName">Nombre del servicio</param> /// <param name="SearchServiceKey">Clave del servicio</param> /// <param name="corsOptions">Opciones de cors</param> /// /// <param name="implements">Implement de search, para la generación de entitySearch</param> /// <param name="entityId">Índice del search</param>} /// <param name="hashOper">Convertidor de hasg</param> public AgroSearch(string SearchServiceName, string SearchServiceKey, Implements <GeoPointType> implements, IHashSearchHelper hashOper, string entityId = "entities-agro") : this( (IBaseEntitySearch <GeoPointType>) new MainSearch(SearchServiceName, SearchServiceKey, entityId), new SearchQueries(), implements, hashOper ) { }
public override int GetHashCode() { unchecked { var hashCode = Implements.GetSetHashCode(); hashCode = (hashCode * 397) ^ (Extends != null ? Extends.GetHashCode() : 0); hashCode = (hashCode * 397) ^ (Element.GetHashCode()); return(hashCode); } }
void AddImplementedInterfaces(ClassGen klass) { foreach (var isym in klass.Interfaces) { if ((!(isym is GenericSymbol gs) ? isym : gs.Gen) is InterfaceGen gen && (gen.IsConstSugar || gen.RawVisibility != "public")) { continue; } Implements.Add(opt.GetOutputName(isym.FullName)); } }
public override void Commit() { string impStr = string.Join(";", Implements.Select(x => x)); if (_XML.Attribute(nameof(Implements))?.Value != impStr) { _XML.SetAttributeValue(nameof(Implements), string.IsNullOrWhiteSpace(impStr) ? null : impStr); } _XML.SetAttributeValue(nameof(Base), Base == null ? null : Base); _XML.SetAttributeValue(nameof(ClassType), string.IsNullOrWhiteSpace(ClassType ?? "") ? null : ClassType); }
public void Expand(Dictionary <string, ApiReferenceBuildOutput> references, string[] supportedLanguages) { if (_needExpand) { _needExpand = false; Inheritance = Inheritance?.Select(i => ApiBuildOutputUtility.GetReferenceViewModel(i.Uid, references, supportedLanguages)).ToList(); Implements = Implements?.Select(i => ApiBuildOutputUtility.GetApiNames(i.Uid, references, supportedLanguages)).ToList(); Syntax?.Expand(references, supportedLanguages); Overridden = ApiBuildOutputUtility.GetApiNames(Overridden?.Uid, references, supportedLanguages); SeeAlsos?.ForEach(e => e.Expand(references, supportedLanguages)); Sees?.ForEach(e => e.Expand(references, supportedLanguages)); Exceptions?.ForEach(e => e.Expand(references, supportedLanguages)); } }
/// <summary> /// entrega un nuevo entitySearch sin considerar las referencias locales y sin asignarle un id. /// </summary> /// <typeparam name="T">Tipo de dato de la propiedad geo de una entidad </typeparam> /// <param name="implements">objeto que mantiene todos los tipos a los que cada propiedad debe ser convertido</param> /// <param name="typeToCast">tipo a convertir el entity, no debe implementar IEntitySearch pero cada propiedad debe tener el tipo de IEntitySearch<T></param> /// <param name="mdl">diccionario con la metadata y los datos de cada propiedad.</param> /// <returns>nueva entidad desde ub objeto</returns> public static IEntitySearch <T> FillProps <T>(Implements <T> implements, Dictionary <BaseIndexAttribute, object> mdl, Type typeToCast) { var objSearch = Collections.CreateEntityInstance(typeToCast); var entitySearch = GetEntityBaseSearch <T>(objSearch); entitySearch.num32 = (INum32Property[])InvokeDynamicGeneric("GetNumProps", implements.num32, new object[] { mdl }); entitySearch.dbl = (IDblProperty[])InvokeDynamicGeneric("GetDblProps", implements.dbl, new object[] { mdl }); entitySearch.dt = (IDtProperty[])InvokeDynamicGeneric("GetDtProps", implements.dt, new object[] { mdl }); entitySearch.enm = (IEnumProperty[])InvokeDynamicGeneric("GetEnumProps", implements.enm, new object[] { mdl }); entitySearch.bl = (IBoolProperty[])InvokeDynamicGeneric("GetBoolProps", implements.bl, new object[] { mdl }); entitySearch.geo = (IProperty <T>[])InvokeDynamicGeneric("GetGeoProps", implements.geo, new object[] { mdl, implements.GeoObjetoToGeoSearch }, typeof(T)); entitySearch.num64 = (INum64Property[])InvokeDynamicGeneric("GetNum64Props", implements.num64, new object[] { mdl }); entitySearch.str = (IStrProperty[])InvokeDynamicGeneric("GetStrProps", implements.str, new object[] { mdl }); entitySearch.sug = (IStrProperty[])InvokeDynamicGeneric("GetSugProps", implements.sug, new object[] { mdl }); entitySearch.rel = GetReferences(mdl, implements.rel); return(entitySearch); }
void AddInheritedInterfaces(InterfaceGen iface, CodeGenerationOptions opt) { foreach (var isym in iface.Interfaces) { var igen = (isym is GenericSymbol ? (isym as GenericSymbol).Gen : isym) as InterfaceGen; if (igen.IsConstSugar(opt) || igen.RawVisibility != "public") { continue; } Implements.Add(opt.GetOutputName(isym.FullName)); } if (Implements.Count == 0 && !iface.IsConstSugar(opt)) { Implements.AddRange(new [] { "IJavaObject", "IJavaPeerable" }); } }
public ClassInvokerClass(ClassGen klass, CodeGenerationOptions opt) { Name = $"{klass.Name}Invoker"; IsInternal = true; IsPartial = true; UsePriorityOrder = true; Inherits = klass.Name; foreach (var igen in klass.GetAllDerivedInterfaces().Where(i => i.IsGeneric)) { Implements.Add(opt.GetOutputName(igen.FullName)); } Attributes.Add(new RegisterAttr(klass.RawJniName, noAcw: true, additionalProperties: klass.AdditionalAttributeString()) { UseGlobal = true }); var ctor = new ConstructorWriter { Name = Name, IsPublic = true, BaseCall = "base (handle, transfer)" }; ctor.Parameters.Add(new MethodParameterWriter("handle", TypeReferenceWriter.IntPtr)); ctor.Parameters.Add(new MethodParameterWriter("transfer", new TypeReferenceWriter("JniHandleOwnership"))); Constructors.Add(ctor); // ClassInvokerHandle Fields.Add(new PeerMembersField(opt, klass.RawJniName, $"{klass.Name}Invoker", false)); Properties.Add(new JniPeerMembersGetter()); Properties.Add(new ThresholdTypeGetter()); AddMemberInvokers(klass, opt, new HashSet <string> ()); }
/// <summary> /// obtiene una nueva entidad con sus propiedaes, sin asignar el id y sin referencias locales. /// </summary> /// <typeparam name="T">Tipo de dato de la propiedad geo de una entidad</typeparam> /// <see cref="Implements{T}"/> /// <param name="implements">objeto que mantiene todos los tipos a los que cada propiedad debe ser convertido</param> /// <param name="obj">objeto desde el que se obtendrán los atributos</param> /// <param name="index">índice de la entidad a crear, el índice se encuentra en el atributo mdm de la clase</param> /// <returns>retorna un nuevo entitySearch desde un objeto, instancia de una clase.</returns> public static IEntitySearch <T> GetSimpleEntity <T>(Implements <T> implements, object obj, int index, IHashSearchHelper hash) { // obtiene la metadata y los datos del objeto var mdl = Attributes.GetPropertiesByAttributeWithValue(obj).Where(s => Mdm.Reflection.IsPrimitiveAndCollection(s.Value.GetType()) || s.Value.GetType().IsEnum).ToDictionary(s => s.Key, s => s.Value); // asigna las propiedades. var entitySearch = Props.FillProps(implements, mdl, implements.GetEntitySearchImplementedType); // hash de cabecera entitySearch.hm = hash.HashModel(obj); // hash de modelo entitySearch.hh = hash.HashHeader(obj.GetType()); // toma el índice de la metadata del atributo entitySearch.index = index; // asigna una fecha de creación. chequear si es necesario entitySearch.created = DateTime.Now; // retorna un entitySearch. return(entitySearch); }
/// <summary> /// 修饰方法行为的特性 /// </summary> /// <param name="implement">实现者</param> /// <param name="cmd">命令值</param> public ServiceAttribute(Implements implement, int cmd) { this.Implement = implement; this.Command = cmd; }
/// <summary> /// Obtiene una colección de EntitySearch desde un objeto /// </summary> /// <typeparam name="T">Tipo del dato geo que tiene la entidad</typeparam> /// <param name="implements">retorna los tipos de datos para los elementos de un entity</param> /// <param name="obj">objeto a convertir</param> /// <param name="hash">clase que permite convertir un objeto en un hash y también convertir la cabecera de un entitySearch</param> /// <param name="collection">usado como recursivo, para obtener los entitySearch internos </param> /// <param name="parent">EntitySearch padre, usado para la recursividad</param> /// <returns>Colección de entitySearch que representan un model</returns> public static IEntitySearch <T>[] GetEntitySearch <T>(Implements <T> implements, object obj, IHashSearchHelper hash, List <IEntitySearch <T> > collection = null, IEntitySearch <T> parent = null) { // lista con las entidades var list = collection ?? new List <IEntitySearch <T> >(); // busca la metadata para obtener el índice. var entityAttr = Attributes.GetAttributes <EntityIndexAttribute>(obj.GetType()); // si el objeto no tiene el atributo que lo vincula con una entidad, retornará una colección vacia. if (entityAttr == null || !entityAttr.Any()) { return(list.ToArray()); } // busca si existen propieades con metadata. var values = Attributes.GetPropertiesByAttributeWithValue(obj); // obtiene todas las propiedades sin metadata. // filtra por aquellas propiedades que sean de tipo clase. // las propiedades sin metadata se usan para comprobar si son una entidad local, es decir tienen el atributo mdm que lo identifica como entidad. var valuesWithoutProperty = Attributes.GetPropertiesWithoutAttributeWithValues(obj).Where(s => !Mdm.Reflection.IsPrimitiveAndCollection(s.GetType()) && !s.GetType().IsEnum); // obtiene las propiedades del objeto, sin incorporar las entidades referenciales locales. var entitySearch = GetSimpleEntity(implements, obj, entityAttr.First().Index, hash); // identifica si el elemento tiene la propiedad id y si la tiene, si tiene un valor. var definedId = obj.GetType().GetProperty("Id")?.GetValue(obj)?.ToString(); // si el elemento no tiene id, se asigna uno. entitySearch.id = !string.IsNullOrWhiteSpace(definedId) ? definedId : Guid.NewGuid().ToString("N"); // si la colección no es nula, significa que pasó por el primer nivel de recursión. // si ese es el caso, asignamos la relación con el padre que es asignada como parámetro de entrada. if (parent != null) { var entity = Props.GetEntityProperty(parent.index, parent.id, implements.rel); if (entity.Any()) { var arr = entitySearch.rel.ToList(); arr.AddRange(entity); entitySearch.rel = arr.ToArray(); } } // toma todos los valores de propiedad que sean de tipo local reference o no tengan atributos de metadata y que los valores deben ser clases y no valores primitivos, para poder identificar entidades locales. // el método recorrerá el objeto y verificará que tenga el atributo que lo identifique como entidad, sino lo tiene no será reconocido como entidad, no importa si la propiedad tiene el atributo de entidad local. // el atributo de la clase es el que vale (EntityIndexAttribute). var posibleLocals = valuesWithoutProperty.Union(values.Where(s => !Mdm.Reflection.IsPrimitiveAndCollection(s.Value.GetType()) && !s.Value.GetType().IsEnum).Select(s => s.Value)).ToList(); // si existen propiedades de tipo clase se comprobará si tienen la etiqueta que los identifica como entidades locales, realizando un método recursivo. foreach (var item in posibleLocals) { // hará una busqueda recursiva de entidades locales con las propiedades que se especifiquen que sean entidades locales o aquellas que no especifiquen pero sea de tipo clase o colleción de clases. var locals = posibleLocals.SelectMany(s => { // si es enumerable deberá generar una entidad por cada registro if (IsEnumerable(s)) { // por cada elemento verifica si existen entidades locales, si el objeto no es identificado como referencia local, no retornará nada. return(((IEnumerable <object>)s).SelectMany(a => GetEntitySearch <T>(implements, a, hash, new List <IEntitySearch <T> >(), entitySearch))); } // si no es una colección retornará una lista de entidades para esta propiedad, si tiene el atributo que lo identifica como identidad local. return(GetEntitySearch <T>(implements, item, hash, new List <IEntitySearch <T> >(), entitySearch)); } ).ToList(); // dentro de las entidades encontradas chequea si alguna tiene su identificador (del entitySearch actual), para asignarlo en sus relaciones. var localsRelated = locals.Where(s => s.rel.Any(a => a.index == entitySearch.index && a.id.Equals(entitySearch.id))).ToList(); // si encuentra las asociará a la lista de entidades relacionadas. if (localsRelated.Any()) { // recorre las en entidades para asignarla como propiedad de relación de entidades. foreach (var entity in localsRelated) { var arr = entitySearch.rel.ToList(); arr.AddRange(Props.GetEntityProperty(entity.index, entity.id, implements.rel)); entitySearch.rel = arr.ToArray(); } } list.AddRange(locals); } // añade el mismo entitySearch a la lista list.Add(entitySearch); return(list.ToArray()); }
public bool Matches(string name, string versionRange) => Implements.Contains(name) && new SemVer.Range(versionRange).IsSatisfied(Version);
public TheClass(CsEntity pCsEntity, FactoryExpressionCreator pCreator) { IsEntity = true; List <string> name = new List <string>(); CsEntity parent = pCsEntity.parent; while (parent != null && parent is CsEntityNamespace) { if (!string.IsNullOrEmpty(parent.name)) { name.Add(parent.name); } parent = parent.parent; } name.Reverse(); NameSpace = string.Join(".", name.ToArray()); //RealName = pCsEntity.name; //Name = Helpers.GetRealName(pCsEntity, RealName); Name = pCsEntity.name; FullName = NameSpace + "." + Name; //FullRealName = NameSpace + "." + RealName; CsEntityClass klass = pCsEntity as CsEntityClass; if (klass != null) { _baseEntityTyperef = klass.base_type; if (klass.base_type.type != cs_entity_type.et_object) { Extends.Add(Helpers.GetType(klass.base_type)); } if (klass.interfaces != null) { foreach (CsEntityTypeRef @interface in klass.interfaces) { Implements.Add(Helpers.GetType(@interface)); } } Dictionary <string, int> methodNames = new Dictionary <string, int>(); //bool constructorsDone = false; bool methodsDone = false; if (klass.method_implementations == null) { return; } foreach (CsEntityMethodImplementation methodImplementation in klass.method_implementations) { CsEntityMethod m = methodImplementation.implementation_method; TheMethod tm = new TheMethod(m, this, pCreator); if (methodNames.ContainsKey(tm.Name)) { methodNames[tm.Name]++; int index = tm._index = methodNames[tm.Name]; if (!methodsDone) { methodsDone = true; foreach (KeyValuePair <CsMethod, TheMethod> method in _methods) { method.Value._isUnique = false; method.Value._index = --index; } } tm._isUnique = false; } else { methodNames[tm.Name] = tm._index = 1; } _entityMethods.Add(m, tm); } return; } CsEntityInterface entityInterface = pCsEntity as CsEntityInterface; if (entityInterface != null) { _baseEntityTyperef = entityInterface.base_type; if (entityInterface.base_type.type != cs_entity_type.et_object) { Extends.Add(Helpers.GetType(entityInterface.base_type)); } if (entityInterface.interfaces != null) { foreach (CsEntityTypeRef @interface in entityInterface.interfaces) { Implements.Add(Helpers.GetType(@interface)); } } Dictionary <string, int> methodNames = new Dictionary <string, int>(); bool methodsDone = false; if (entityInterface.method_implementations == null) { return; } foreach (CsEntityMethodImplementation methodImplementation in entityInterface.method_implementations) { CsEntityMethod m = methodImplementation.implementation_method; TheMethod tm = new TheMethod(m, this, pCreator); if (methodNames.ContainsKey(tm.Name)) { methodNames[tm.Name]++; int index = tm._index = methodNames[tm.Name]; if (!methodsDone) { methodsDone = true; foreach (KeyValuePair <CsMethod, TheMethod> method in _methods) { method.Value._isUnique = false; method.Value._index = --index; } } tm._isUnique = false; } else { methodNames[tm.Name] = tm._index = 1; } _entityMethods.Add(m, tm); } return; } CsEntityStruct entityStruct = pCsEntity as CsEntityStruct; if (entityStruct != null) { _baseEntityTyperef = entityStruct.base_type; if (entityStruct.base_type.type != cs_entity_type.et_object) { Extends.Add(Helpers.GetType(entityStruct.base_type)); } if (entityStruct.interfaces != null) { foreach (CsEntityTypeRef @interface in entityStruct.interfaces) { Implements.Add(Helpers.GetType(@interface)); } } Dictionary <string, int> methodNames = new Dictionary <string, int>(); bool methodsDone = false; if (entityStruct.method_implementations == null) { return; } foreach (CsEntityMethodImplementation methodImplementation in entityStruct.method_implementations) { CsEntityMethod m = methodImplementation.implementation_method; TheMethod tm = new TheMethod(m, this, pCreator); if (methodNames.ContainsKey(tm.Name)) { methodNames[tm.Name]++; int index = tm._index = methodNames[tm.Name]; if (!methodsDone) { methodsDone = true; foreach (KeyValuePair <CsMethod, TheMethod> method in _methods) { method.Value._isUnique = false; method.Value._index = --index; } } tm._isUnique = false; } else { methodNames[tm.Name] = tm._index = 1; } _entityMethods.Add(m, tm); } return; } throw new NotImplementedException(); }
public TheClass(CsInterface pCsInterface, FactoryExpressionCreator pCreator) { IsInterface = true; List <string> name = new List <string>(); CsNamespace parent = pCsInterface.parent as CsNamespace; if (parent != null) { name.AddRange(parent.qualified_identifier.Select(pArt => pArt.identifier.identifier)); } NameSpace = string.Join(".", name.ToArray()); Name = pCsInterface.identifier.identifier; FullName = NameSpace + "." + Name; if (pCsInterface.type_base != null && pCsInterface.type_base.base_list.Count != 0) { foreach (CsTypeRef typeRef in pCsInterface.type_base.base_list) { object u = typeRef.entity_typeref.u; if (u == null) { continue; } if (u is CsEntityClass) { Extends.Add(Helpers.GetType(typeRef.type_name)); _baseTyperef = typeRef; } else if (u is CsEntityInterface) { Implements.Add(Helpers.GetType(typeRef.type_name)); } else if (u is CsEntityInstanceSpecifier) { Implements.Add(Helpers.GetType(typeRef.type_name)); } else { throw new NotSupportedException(); } } } Dictionary <string, int> methodNames = new Dictionary <string, int>(); bool methodsDone = false; if (pCsInterface.member_declarations != null) { foreach (CsNode memberDeclaration in pCsInterface.member_declarations) { CsMethod m = memberDeclaration as CsMethod; if (m != null) { if (m.interface_type != null) { continue; } TheMethod tm = new TheMethod(m, this, pCreator); if (methodNames.ContainsKey(tm.Name)) { methodNames[tm.Name]++; int index = tm._index = methodNames[tm.Name]; if (!methodsDone) { methodsDone = true; foreach (KeyValuePair <CsMethod, TheMethod> method in _methods) { method.Value._isUnique = false; method.Value._index = --index; } } tm._isUnique = false; } else { methodNames[tm.Name] = tm._index = 1; } _methods.Add(m, tm); continue; } CsIndexer i = memberDeclaration as CsIndexer; if (i != null) { _indexers.Add(i, new TheIndexer(i, this, pCreator)); continue; } CsVariableDeclaration v = memberDeclaration as CsVariableDeclaration; if (v != null) { _variables.Add(v, new TheVariable(v, this, pCreator)); continue; } CsProperty p = memberDeclaration as CsProperty; if (p != null) { if (p.interface_type == null) { _properties.Add(p, new TheProperty(p, this, pCreator)); } continue; } throw new NotImplementedException("Unknown type not implemented"); } } Modifiers.AddRange(Helpers.GetModifiers(pCsInterface.modifiers)); }
public TheClass(CsClassStruct pCsClass, FactoryExpressionCreator pCreator) { CsNamespace csNamespace; _creator = pCreator; List <string> name = new List <string>(); if (pCsClass.parent is CsClass) { IsPrivate = true; csNamespace = (CsNamespace)pCsClass.parent.parent; } else { csNamespace = (CsNamespace)pCsClass.parent; } CsQualifiedIdentifier list = csNamespace.qualified_identifier; name.AddRange(list.Select(pIdentifier => pIdentifier.identifier.identifier)); if (IsPrivate) { name.Add(((CsClass)pCsClass.parent).identifier.identifier); } NameSpace = string.Join(".", name.ToArray()); //RealName = pCsClass.identifier.identifier; //Name = Helpers.GetRealName(pCsClass, RealName); Name = pCsClass.identifier.identifier; FullName = NameSpace + "." + Name; //FullRealName = NameSpace + "." + RealName; if (pCsClass.type_base != null && pCsClass.type_base.base_list.Count != 0) { foreach (CsTypeRef typeRef in pCsClass.type_base.base_list) { object u = typeRef.entity_typeref.u; if (u == null) { continue; } if (u is CsEntityClass) { Extends.Add(Helpers.GetType(typeRef.type_name)); _baseTyperef = typeRef; } else if (u is CsEntityInterface) { Implements.Add(Helpers.GetType(typeRef.type_name)); } else if (u is CsEntityInstanceSpecifier) { Implements.Add(Helpers.GetType(typeRef.type_name)); //CsEntityInstanceSpecifier specifier = (CsEntityInstanceSpecifier)typeRef.entity_typeref.u; } else { throw new NotSupportedException(); } } } Dictionary <string, int> methodNames = new Dictionary <string, int>(); bool constructorsDone = false; bool methodsDone = false; if (pCsClass.member_declarations != null) { foreach (CsNode memberDeclaration in pCsClass.member_declarations) { CsConstructor c = memberDeclaration as CsConstructor; if (c != null) { TheConstructor tm = new TheConstructor(c, this, pCreator); if (methodNames.ContainsKey(tm.Name)) { methodNames[tm.Name]++; int index = tm._index = methodNames[tm.Name]; if (!constructorsDone) { constructorsDone = true; foreach (KeyValuePair <CsConstructor, TheConstructor> constructor in _constructors) { constructor.Value._isUnique = false; constructor.Value._index = --index; } } tm._isUnique = false; } else { methodNames[tm.Name] = tm._index = 1; } _constructors.Add(c, tm); continue; } CsMethod m = memberDeclaration as CsMethod; if (m != null) { if (m.interface_type != null) { continue; } TheMethod tm = new TheMethod(m, this, pCreator); if (methodNames.ContainsKey(tm.Name)) { methodNames[tm.Name]++; int index = tm._index = methodNames[tm.Name]; if (!methodsDone) { methodsDone = true; foreach (KeyValuePair <CsMethod, TheMethod> method in _methods) { method.Value._isUnique = false; method.Value._index = --index; } } tm._isUnique = false; } else { methodNames[tm.Name] = tm._index = 1; } _methods.Add(m, tm); continue; } CsIndexer i = memberDeclaration as CsIndexer; if (i != null) { _indexers.Add(i, new TheIndexer(i, this, pCreator)); continue; } CsVariableDeclaration v = memberDeclaration as CsVariableDeclaration; if (v != null) { _variables.Add(v, new TheVariable(v, this, pCreator)); continue; } CsConstantDeclaration k = memberDeclaration as CsConstantDeclaration; if (k != null) { _constants.Add(k, new TheConstant(k, this, pCreator)); continue; } CsProperty p = memberDeclaration as CsProperty; if (p != null) { if (p.interface_type == null) { _properties.Add(p, new TheProperty(p, this, pCreator)); } continue; } CsDelegate d = memberDeclaration as CsDelegate; if (d != null) { _delegates.Add(d, new TheDelegate(d, this, pCreator)); continue; } CsEvent e = memberDeclaration as CsEvent; if (e != null) { TheEvent theEvent = new TheEvent(e, this, pCreator); _events.Add(theEvent.Name, theEvent); continue; } CsClass csClass = memberDeclaration as CsClass; if (csClass != null) { continue; } throw new NotImplementedException("Unknown type not implemented"); } } Modifiers.AddRange(Helpers.GetModifiers(pCsClass.modifiers)); }
protected void CreateClassModels( IModelGeneratorContext context, FieldNode fieldSelection, IFragmentNode returnType, IInterfaceDescriptor interfaceDescriptor, IReadOnlyCollection <SelectionInfo> selections, List <ResultParserTypeDescriptor> resultParserTypes, Path path) { foreach (SelectionInfo selection in selections) { IFragmentNode modelType = ResolveReturnType( context, selection.Type, fieldSelection, selection); var interfaces = new List <IInterfaceDescriptor>(); foreach (IFragmentNode fragment in ShedNonMatchingFragments(selection.Type, modelType)) { interfaces.Add(CreateInterfaceModel(context, fragment, path)); } interfaces.Insert(0, interfaceDescriptor); NameString typeName = HoistName(selection.Type, modelType); if (typeName.IsEmpty) { typeName = selection.Type.Name; } bool update = false; var fieldNames = new HashSet <string>( selection.Fields.Select(t => GetPropertyName(t.ResponseName))); string className = context.GetOrCreateName( modelType.Fragment.SelectionSet, GetClassName(typeName), fieldNames); if (context.TryGetDescriptor(className, out ClassDescriptor? modelClass)) { var interfaceNames = new HashSet <string>(interfaces.Select(t => t.Name)); foreach (IInterfaceDescriptor item in modelClass !.Implements.Reverse()) { if (!interfaceNames.Contains(item.Name)) { interfaces.Insert(0, item); } } update = true; } modelClass = new ClassDescriptor( className, context.Namespace, selection.Type, interfaces); context.Register(modelClass, update); resultParserTypes.Add(new ResultParserTypeDescriptor(modelClass)); } }
public AgroSearch(IBaseEntitySearch <GeoPointType> mainSearch, ISearchQueries queries, Implements <GeoPointType> implements, IHashSearchHelper hashOper) { this.hashOper = hashOper; this.baseMainSearch = mainSearch; this.ServiceKey = mainSearch.ServiceKey; this.UriService = mainSearch.UriService; Index = mainSearch.Index; this.implements = implements; _queries = queries; }
public ClassInvokerClass(ClassGen klass, CodeGenerationOptions opt) { Name = $"{klass.Name}Invoker"; IsInternal = true; IsPartial = true; UsePriorityOrder = true; Inherits = klass.Name; foreach (var igen in klass.GetAllDerivedInterfaces().Where(i => i.IsGeneric)) { Implements.Add(opt.GetOutputName(igen.FullName)); } if (opt.CodeGenerationTarget == CodeGenerationTarget.JavaInterop1) { Attributes.Add(new JniTypeSignatureAttr(klass.RawJniName, false)); } else { Attributes.Add(new RegisterAttr(klass.RawJniName, noAcw: true, additionalProperties: klass.AdditionalAttributeString()) { UseGlobal = true }); } SourceWriterExtensions.AddSupportedOSPlatform(Attributes, klass, opt); ConstructorWriter ctor = opt.CodeGenerationTarget == CodeGenerationTarget.JavaInterop1 ? new ConstructorWriter { Name = Name, IsPublic = true, BaseCall = "base (ref reference, options)", Parameters = { new MethodParameterWriter("reference", new TypeReferenceWriter("ref JniObjectReference")), new MethodParameterWriter("options", new TypeReferenceWriter("JniObjectReferenceOptions")), }, } : new ConstructorWriter { Name = Name, IsPublic = true, BaseCall = "base (handle, transfer)", Parameters = { new MethodParameterWriter("handle", TypeReferenceWriter.IntPtr), new MethodParameterWriter("transfer", new TypeReferenceWriter("JniHandleOwnership")), }, } ; Constructors.Add(ctor); // ClassInvokerHandle Fields.Add(new PeerMembersField(opt, klass.RawJniName, $"{klass.Name}Invoker", false)); Properties.Add(new JniPeerMembersGetter()); if (opt.CodeGenerationTarget != CodeGenerationTarget.JavaInterop1) { Properties.Add(new ThresholdTypeGetter()); } AddMemberInvokers(klass, opt, new HashSet <string> ()); }