public static bool CanIndexContent(IContent content) { if (content == null) { return(false); } if (IndexAllTypes) { return(true); } return(IncludedTypes.Any(c => c.Value.ContentType.IsAssignableFrom(content.GetOriginalType()))); }
private List <ITypescriptObject> CollectTypes() { var types = new Dictionary <Type, ITypescriptObject>(); var typeQueue = new Queue <Type>(IncludedTypes.Distinct().Except(ExcludedTypes)); var classConverter = CreateTypescriptClassToInterfaceConverter(); var enumConverter = new TypescriptEnumConverter(EnumSettings, NamespaceSettings); while (typeQueue.Count > 0) { var type = typeQueue.Dequeue(); if (type.IsEnum) { var typescriptEnum = enumConverter.Convert(type); types.Add(type, typescriptEnum); } else { var typescriptInterface = classConverter.Convert(type); types.Add(type, typescriptInterface); foreach (var dependency in typescriptInterface.DirectDependencies) { if (types.ContainsKey(dependency)) { continue; } if (typeQueue.Contains(dependency)) { continue; } if (ExcludedTypes.Contains(dependency)) { continue; } typeQueue.Enqueue(dependency); } } } return(types.Values.ToList()); }
private string GenerateFieldStruct(Type t) { StringBuilder rVal = new StringBuilder("struct {\n"); //Add base type instance rVal.Append("struct " + GetTypeFieldName(t.BaseType) + " super" + lineTerm); //Add implemented interfaces var interfaces = t.GetInterfaces(); for (int i = 0; i < interfaces.Length; i++) { IncludedTypes.Add(interfaces [i]); rVal.Append("struct " + GetTypeFieldName(interfaces [i]) + " " + GetTypeInstanceName(interfaces[i]) + lineTerm); } //Add vtable rVal.Append("struct " + GetTypeVtableName(t) + " *vptr" + lineTerm); //Add generics table if needed if (t.IsGenericType) { rVal.Append("struct " + GetTypeGenericName(t) + " *generic" + lineTerm); } //Add fields var fields = t.GetFields(BindingFlags.DeclaredOnly | BindingFlags.Instance | BindingFlags.NonPublic | BindingFlags.Public); for (int i = 0; i < fields.Length; i++) { //Generate field definitions rVal.Append(BuildFieldSignature(fields[i]) + lineTerm); } rVal.Append("}" + GetTypeFieldName(t) + lineTerm); return(rVal.ToString()); }
public override void Init(XElement xmlTask) { base.Init(xmlTask); PathFrom = xmlTask.Attribute("PathFrom").Value; PathTo = xmlTask.Attribute("PathTo").Value; if (!String.IsNullOrWhiteSpace(xmlTask.Attribute("IncludedTypes").Value.Trim())) { IncludedTypes.AddRange(xmlTask.Attribute("IncludedTypes").Value.Trim().Replace(",", "").Split(',')); } if (!String.IsNullOrWhiteSpace(xmlTask.Attribute("ExcludedTypes").Value.Trim())) { ExcludedTypes.AddRange(xmlTask.Attribute("ExcludedTypes").Value.Trim().Replace(",", "").Split(',')); } IncludedRegex = xmlTask.Attribute("IncludedRegex").Value; ExcludedRegex = xmlTask.Attribute("ExcludedRegex").Value; if (!String.IsNullOrWhiteSpace(xmlTask.Attribute("ReplaceIfExists").Value)) { ReplaceIfExists = bool.Parse(xmlTask.Attribute("ReplaceIfExists").Value); } if (!String.IsNullOrWhiteSpace(xmlTask.Attribute("Recursive").Value)) { Recursive = bool.Parse(xmlTask.Attribute("Recursive").Value); } }
} // TODO: TypeKind? // Returns own fields and the fields of all included types. public IEnumerable <GraphQLField> GetQueryFields() { return(OwnFields.Concat(IncludedTypes.SelectMany(t => t.GetQueryFields()).Where(f => f.Name != "__typename"))); }
void ResolveExtensions(XmlNode root) { foreach (XmlNode extension in root.ChildNodes) { if (extension is XmlComment) { continue; } string eName = extension.Attributes["name"].Value; foreach (XmlNode r in extension.ChildNodes) { foreach (XmlNode node in r.ChildNodes) { if (r.Name == "require") { if (node.Name == "command") { if (ExtensionRequested(eName)) { IncludedCommands.Add(node.Attributes["name"].Value); ExtensionCommands.Add(node.Attributes["name"].Value); } } else if (node.Name == "type") { string tName = node.Attributes["name"].Value; if (ExtensionRequested(eName)) { IncludedTypes.Add(tName); } ExtensionTypes.Add(tName); } else if (node.Name == "enum") { if (ExtensionRequested(eName)) { var extends = node.Attributes["extends"]; var offsetNode = node.Attributes["offset"]; var extensionNumber = node.Attributes["extnumber"]; if (node.Attributes["alias"] != null) { continue; } if (extends != null && offsetNode != null) { var name = extends.Value; int exNumber; if (extensionNumber != null) { exNumber = int.Parse(extensionNumber.Value); } else { exNumber = 2; } var offset = int.Parse(offsetNode.Value); var sign = 1; if (node.Attributes["dir"] != null) { sign = -1; } EnumMap[name].Extend(node.Attributes["name"].Value, exNumber, offset, sign); } IncludedTypes.Add(node.Attributes["name"].Value); } } } } } } }