//================================================================================ Construction protected SchemaRoot() { _propertyTypes = new TypeCollection<PropertyType>(this); _nodeTypes = new TypeCollection<NodeType>(this); _contentListTypes = new TypeCollection<ContentListType>(this); _permissionTypes = new TypeCollection<PermissionType>(this); }
public void AssemblyCanBeLoaded() { var typeCollection = TypeCollection.Create(typeof(TypeCollectionTests).Assembly); Assert.NotEqual(0, typeCollection.TypeCount); Assert.True(typeCollection.Any()); }
/// <summary> /// Loads a TypeCollection with the plugins defined in the assembly /// </summary> /// <param name="assembly">The assembly to check for plugin definitions</param> /// <returns></returns> private TypeCollection LoadPluginTypesFromAssembly(Assembly assembly) { TypeCollection types = null; try { object[] value = assembly.GetCustomAttributes(typeof(PluginDefinitionAttribute), false); if (value != null) { PluginDefinitionAttribute[] attributes = (PluginDefinitionAttribute[])value; foreach (PluginDefinitionAttribute attribute in attributes) { if (types == null) { types = new TypeCollection(); } types.Add(attribute.Type); } } } catch (Exception ex) { Log.WriteLine(ex); } return(types); }
public TypeCollection ReflectOnAssembly(Assembly assembly, IncludeKind includeKind) { TypeCollection typeCollection = new TypeCollection(); Type[] types = assembly.GetTypes(); foreach (Type type in types) { // Skip any classes they don't want us to include. IncludeKind currentIncludeKind = type.IsPublic ? IncludeKind.Public : IncludeKind.Internal; if ((currentIncludeKind & includeKind) == 0) { continue; } // Skip compiler-generated classes, which are invisible to both // consumers of the assembly and to the assembly's creator. if (type.Name.StartsWith("<")) { continue; } TypeDoc typeDoc = ConvertTypeToDocForm(type, includeKind); typeCollection = typeCollection.AddType(typeDoc.Name, typeDoc); } return(typeCollection); }
private void initializeType() { int chickenCount = context.orders.Where(e => e.type.Equals("Chicken")).Count(); int porkCount = context.orders.Where(e => e.type.Equals("Pork")).Count(); int mixedCount = context.orders.Where(e => e.type.Equals("Mixed")).Count(); TypeCollection.Clear(); TypeCollection.Add(new PieSeries { Title = Application.Current.FindResource("Pork") as string, Values = new ChartValues <ObservableValue> { new ObservableValue(porkCount) }, DataLabels = true }); TypeCollection.Add(new PieSeries { Title = Application.Current.FindResource("Chicken") as string, Values = new ChartValues <ObservableValue> { new ObservableValue(chickenCount) }, DataLabels = true }); TypeCollection.Add( new PieSeries { Title = Application.Current.FindResource("Mixed") as string, Values = new ChartValues <ObservableValue> { new ObservableValue(mixedCount) }, DataLabels = true }); }
public void TypeCollection_Constructor_WithAllAllowedTypes() { SchemaEditor ed = new SchemaEditor(); TypeCollection <NodeType> tc1 = TypeCollectionAccessor <NodeType> .Create(ed).Target; TypeCollection <PropertyType> tc5 = TypeCollectionAccessor <PropertyType> .Create(ed).Target; }
public void AutoDiscovery() { var typeCollection = new TypeCollection() .AddTypesFromAllReferencedAssemblies(filterLoadingType: x => x.HasAttribute <ShouldBeTakenAttribute>()); Assert.Equal(2, typeCollection.Count); }
internal void AssignInitialValueAsync(List <BarcodeModel> _alerts) { try { ConstantManager.VerifiedBarcodes = _alerts; LoadOwnderAsync(); LoadAssetSizeAsync(); LoadAssetTypeAsync(); var RealmDb = Realm.GetInstance(RealmDbManager.GetRealmDbConfig()); foreach (var item in _alerts) { AssetTypeModel selectedType = null; AssetSizeModel selectedSize = null; OwnerModel selectedOwner = OwnerCollection.Where(x => x.FullName == item?.Kegs?.Partners?.FirstOrDefault()?.FullName).FirstOrDefault(); if (selectedOwner != null) { RealmDb.Write(() => { selectedOwner.HasInitial = true; }); } if (item.Tags.Count > 2) { selectedType = TypeCollection.Where(x => x.AssetType == item.Tags?[2]?.Value).FirstOrDefault(); RealmDb.Write(() => { selectedType.HasInitial = true; }); } if (item.Tags.Count > 3) { selectedSize = SizeCollection.Where(x => x.AssetSize == item.Tags?[3]?.Value).FirstOrDefault(); RealmDb.Write(() => { selectedSize.HasInitial = true; }); } MaintenaceCollection.Add( new MoveMaintenanceAlertModel { UOwnerCollection = OwnerCollection.ToList(), USizeCollection = SizeCollection.ToList(), UTypeCollection = TypeCollection.ToList(), BarcodeId = item.Barcode, SelectedUOwner = selectedOwner ?? selectedOwner, SelectedUSize = selectedSize ?? selectedSize, SelectedUType = selectedType ?? selectedType }); } } catch (Exception ex) { Crashes.TrackError(ex); } }
public DocumentationGenerator( IMarkdownWriter writer, TypeCollection typeCollection, Type firstType = null) { Reader = new DocXmlReader(); Writer = writer; TypeCollection = typeCollection; TypesToDocument = typeCollection.ReferencedTypes.Values .OrderBy(t => t.Type.Namespace) .ThenBy(t => t.Type.Name).ToList(); if (firstType != null) { var typeDesc = TypesToDocument.FirstOrDefault(t => t.Type == firstType); if (typeDesc != null) { TypesToDocument.Remove(typeDesc); TypesToDocument.Insert(0, typeDesc); } } TypesToDocumentSet = new HashSet <Type>(TypesToDocument.Select(t => t.Type)); typeLinkConverter = (type, _) => TypesToDocumentSet.Contains(type) ? Writer.HeadingLink(TypeTitle(type), type.ToNameString()) : null; }
/// <summary> /// Loads a TypeCollection with the plugins defined in the assembly /// </summary> /// <param name="assembly">The assembly to check for plugin definitions</param> /// <returns></returns> private TypeCollection LoadPluginTypesFromAssembly(Assembly assembly) { TypeCollection types = null; try { object[] value = assembly.GetCustomAttributes(typeof(PluginDefinitionAttribute), false); if (value.Length > 0) { var attributes = (PluginDefinitionAttribute[])value; foreach (PluginDefinitionAttribute attribute in attributes) { if (types == null) { types = new TypeCollection(); } types.Add(attribute.Type); } } } catch (Exception ex) { CairoLogger.Instance.Debug(ex.Message, ex); } return(types); }
public void TreeIsMappedAccordingToSchemeRules() { var typeCollection = TypeCollection.Create(typeof(TreeMapperTests).Assembly); var context = Context.Create(typeCollection, FieldSource.Properties); var tree = context.MapTree($"{typeof(TreeMapperTests).FullName}+IRootInterface"); var expectedTree = TreeDefinitionBuilder.Create($"{typeof(TreeMapperTests).FullName}+IRootInterface", b => { var rootAlias = b.PushAlias( $"{typeof(TreeMapperTests).FullName}+IRootInterface", $"{typeof(TreeMapperTests).FullName}+TestNodeB"); var innerAlias = b.PushAlias( $"{typeof(TreeMapperTests).FullName}+IInnerInterface", $"{typeof(TreeMapperTests).FullName}+TestNodeA", $"{typeof(TreeMapperTests).FullName}+TestNodeB"); b.PushNode($"{typeof(TreeMapperTests).FullName}+TestNodeB", nb => { nb.PushNumberField("Field1"); nb.PushAliasField("Field2", innerAlias); }); b.PushNode($"{typeof(TreeMapperTests).FullName}+TestNodeA", nb => { nb.PushStringField("Field1"); nb.PushNumberField("Field2"); nb.PushBooleanField("Field3"); nb.PushAliasField("Field4", innerAlias, isArray: true); nb.PushAliasField("Field5", innerAlias); }); }); Assert.Equal(expectedTree, tree); }
/// <summary> /// Generate treescheme json for a given type. /// </summary> /// <param name="rootAliasTypeName">Fullname of the type to use as the root of the tree</param> /// <param name="fieldSource">Enum to indicator how to find fields on types</param> /// <param name="typeIgnorePattern">Optional regex pattern to ignore types</param> /// <param name="nodeCommentProvider">Optional provider of node-comments</param> /// <param name="logger">Optional logger for diagnostic output</param> /// <returns>Json string representing the scheme</returns> public static string GenerateScheme( string rootAliasTypeName, FieldSource fieldSource, Regex typeIgnorePattern = null, INodeCommentProvider nodeCommentProvider = null, Core.ILogger logger = null) { try { // Gather all the types. var typeCollection = TypeCollection.Create(AppDomain.CurrentDomain.GetAssemblies(), logger); // Create mapping context. var context = Context.Create( typeCollection, fieldSource, typeIgnorePattern, nodeCommentProvider, logger); // Map the tree. var tree = TreeMapper.MapTree(context, rootAliasTypeName); // Serialize the scheme. return(JsonSerializer.ToJson(tree, JsonSerializer.Mode.Pretty)); } catch (Exception e) { logger?.LogCritical($"Failed to generate scheme: {e.Message.ToDistinctLines()}"); return(null); } }
private void OnEnable() { _binding = target as PropertyBinding; _sourceTypeCollection = new TypeCollection <INotifyPropertyChanged>(); _sourceProperties = new MemberCollection <PropertyInfo>(_binding.SourceType, MemberFilters.SourceProperties); _targetProperties = new MemberCollection <PropertyInfo>(_binding.TargetType, MemberFilters.TargetProperties); }
public TypeWriterBase(TypeDefinition typeDefinition, int indentCount, TypeCollection typeCollection, ConfigBase config) { this.TypeDefinition = typeDefinition; this.IndentCount = indentCount; this.TypeCollection = typeCollection; this.Config = config; }
public void GetReferenceTypes_DefaultSettings() { var tc = new TypeCollection(); tc.GetReferencedTypes(typeof(TCTestClass)); Assert.IsTrue(tc.ReferencedTypes.Count > 3); }
public void Save(FileInfo file) { lock (typeof(EasyProperties)) { file.Directory.Create(); CultureInfo savedCulture = Thread.CurrentThread.CurrentCulture; Thread.CurrentThread.CurrentCulture = new CultureInfo("en-US"); try { using (XmlTextWriter writer = new XmlTextWriter(file.FullName, Encoding.UTF8)) { writer.Formatting = Formatting.Indented; writer.WriteStartElement(PXmlRootName); writer.WriteAttributeString("version", PXmlVersion); TypeCollection types = new TypeCollection(); this.FillTypeCollection(this, types); writer.WriteStartElement("Types"); for (int i = 0; i < types.Count; i++) { Type type = types[i]; writer.WriteStartElement(EasyPropertiesNode.XN_ELEMENT); writer.WriteAttributeString(EasyPropertiesNode.XN_INDEX, i.ToString()); string typeName = string.Format("{0}, {1}", type.FullName, type.Assembly); writer.WriteAttributeString(EasyPropertiesNode.XN_AT_TYPE, typeName); writer.WriteEndElement(); } writer.WriteEndElement(); base.Write(writer, types); writer.WriteEndElement(); // PXmlRootName } } finally { Thread.CurrentThread.CurrentCulture = savedCulture; } } }
internal XzaarAssembly() : this(null, null) { Types = new TypeCollection(); GlobalVariables = new GlobalVariableCollection(); GlobalInstructions = new GlobalInstructionCollection(); GlobalMethods = new MethodCollection(); }
public void Test() { TypeCollection collection = new TypeCollection(); // This gets compile time warning: collection.Add(typeof(int)); }
public ToolTipListBox() { _collection = new TypeCollection <ListBoxEntry>(this); this.MouseHover += new EventHandler(ToolTipListBox_MouseHover); this.MouseLeave += new EventHandler(ToolTipListBox_MouseLeave); }
/// <summary> /// Searches for plugins in the application's startup path /// </summary> /// <returns>null if no plugins were found</returns> private TypeCollection InternalSearchForPluginTypes() { TypeCollection types = null; // starting in the startup path // var directoryInfo = new DirectoryInfo(Application.StartupPath); var directoryInfo = new DirectoryInfo(_CairoShell.StartupPath); // look for all the dlls FileInfo[] files = directoryInfo.GetFiles("*.dll"); // see if we can find any plugins defined in each assembly foreach (FileInfo file in files.Where(f => f.IsManagedAssembly())) { // try and load the assembly Assembly assembly = LoadAssembly(file.FullName); if (assembly != null) { // see if the assembly has any plugins defined in it TypeCollection typesInAssembly = LoadPluginTypesFromAssembly(assembly); if (typesInAssembly != null) { if (types == null) { types = new TypeCollection(); } // add the types defined as plugins to the master list types.AddRange(typesInAssembly); } } } return(types); }
/// <summary> /// Converts comma-separated list of exception type names into the appropriate TypeCollection ready to set into the filter. /// </summary> /// <param name="configString"></param> /// <returns></returns> public static TypeCollection ParseTriggerExceptions(string configString) { if (configString == null || configString.Length == 0) { return(null); } TypeCollection outCollection = new TypeCollection(); string[] tokens = configString.Split(SEPS); for (int i = 0; i < tokens.Length; i++) { string typename = tokens[i]; Type t = null; // Normally you must fully-qualify the name, e.g. eBay.Service.Core.Sdk.ApiException. // We allow shorthand for the 3 obvious ones. if (tokens[i].ToLower(System.Globalization.CultureInfo.InvariantCulture).Equals("apiexception")) { t = typeof(ApiException); } else if (tokens[i].ToLower(System.Globalization.CultureInfo.InvariantCulture).Equals("httpexception")) { t = typeof(HttpException); } else if (tokens[i].ToLower(System.Globalization.CultureInfo.InvariantCulture).Equals("sdkexception")) { t = typeof(SdkException); } else { t = Type.GetType(tokens[i]); } outCollection.Add(t); } return(outCollection); }
public bool Load(FileInfo file) { if (file == null) { throw (new ArgumentNullException("file")); } if (!file.Exists) { return(false); } CultureInfo savedCulture = Thread.CurrentThread.CurrentCulture; Thread.CurrentThread.CurrentCulture = new CultureInfo("en-US"); try { lock (typeof(EasyProperties)) { using (XmlTextReader reader = new XmlTextReader(file.FullName)) { TypeCollection types = new TypeCollection(); bool inTree = false; bool fBreak = false; while (reader.Read() && !fBreak) { switch (reader.NodeType) { case XmlNodeType.EndElement: if (reader.LocalName == "Types") { fBreak = true; } break; case XmlNodeType.Element: string propertyName = reader.LocalName; if (propertyName == "Types") { inTree = true; } if (inTree && propertyName == EasyPropertiesNode.XN_ELEMENT) { string typeName = reader.GetAttribute(EasyPropertiesNode.XN_AT_TYPE); types.Add(Type.GetType(typeName, true)); } break; } } base.Read(reader, types); } } return(true); } catch (Exception ex) { throw (new Exception("Error loading properties: " + ex.Message + "\nSettings have been restored to default values.", ex)); } finally { Thread.CurrentThread.CurrentCulture = savedCulture; } }
public void AbstractClassesAreNotReturned() { var typeCollection = TypeCollection.Create(typeof(ImplementationFinderTests).Assembly); var implementations = typeCollection.GetImplementations(typeof(TestSingleAbstractClass)); Assert.Empty(implementations); }
private void OnEnable() { _binding = target as EventBinding; _sourceTypeCollection = new TypeCollection <INotifyPropertyChanged>(); _sourceCallbacks = new MemberCollection <MethodInfo>(_binding.SourceType, MemberFilters.EventCallbacks); _targetEvents = new MemberCollection <PropertyInfo>(_binding.TargetType, MemberFilters.TargetEvents); }
public void SingleTypeImplementionIsFound() { var typeCollection = TypeCollection.Create(typeof(ImplementationFinderTests).Assembly); var implementations = typeCollection.GetImplementations(typeof(TestStruct)); Assert.Equal(new[] { typeof(TestStruct) }, implementations); }
public void DirectDiscovery() { var typeCollection = new TypeCollection() .AddTypesFromTypeAssembly <MainClass>( x => x.HasAttribute <ShouldBeTakenAttribute>()); Assert.Equal(2, typeCollection.Count); }
public static void StartData() { using (var s = new StreamWriter("data.csv")) using (var c = new CsvWriter(s, new(CultureInfo.InvariantCulture))) { var tc = new TypeCollection(main); c.WriteRecords(tc.Get <ItemType>()); } }
public void TypeCanBeFound() { var typeCollection = TypeCollection.Create(typeof(TypeCollectionTests).Assembly); Assert.True(typeCollection.HasType(typeof(TypeCollectionTests))); Assert.True(typeCollection.HasType(typeof(TypeCollectionTests).FullName)); Assert.True(typeCollection.TryGetType(typeof(TypeCollectionTests).FullName, out _)); }
public GunDesc(TypeCollection collection, XElement e) { //Don't modify the original source when we inherit e = new XElement(e); inherit = e.TryAtt(nameof(inherit), null); if (inherit != null) { var source = collection.sources[inherit].Element(Tag); e.InheritAttributes(source); } Dictionary <string, int> difficultyMap = new Dictionary <string, int> { { "none", 0 }, { "easy", 20 }, { "medium", 40 }, { "hard", 60 }, { "expert", 80 }, { "master", 100 }, }; if (Enum.TryParse <WeaponDifficulty>(e.TryAtt(nameof(difficulty)), out var r)) { difficulty = (int)r; } else { throw new Exception("Difficulty expected"); } recoil = e.TryAttInt(nameof(recoil), 0); noiseRange = e.TryAttInt(nameof(noiseRange), 0); projectileCount = e.TryAttInt(nameof(projectileCount), 1); knockback = e.TryAttInt(nameof(knockback), 0); spread = e.TryAttInt(nameof(spread), 0); fireTime = e.TryAttInt(nameof(fireTime), 0); reloadTime = e.TryAttInt(nameof(reloadTime), 0); critOnLastShot = e.TryAttBool(nameof(critOnLastShot), false); clipSize = e.TryAttInt(nameof(clipSize), 0); maxAmmo = e.TryAttInt(nameof(maxAmmo), 0); initialClip = e.TryAttInt(nameof(initialClip), clipSize); initialAmmo = e.TryAttInt(nameof(initialAmmo), maxAmmo); if (e.HasElement("Bullet", out var bulletXml)) { projectile = new BulletDesc(bulletXml); } else if (e.HasElement("Flame", out var flameXml)) { projectile = new FlameDesc(flameXml); } else if (e.HasElement("Grenade", out var grenadeXml)) { projectile = new GrenadeDesc(grenadeXml); } }
public ProjectionSchema([NotNull] Type projectionType, string category, params Type[] partitioners) { Type = projectionType; ProjectionHash = projectionType.FullName.ToGuid(); Category = category; Events = new TypeCollection(); _tags = new Lazy <HashSet <string> >(() => new HashSet <string>(Type.FullName.Split('.'))); Partitioners = new TypeCollection(partitioners); }
internal XzaarAssembly(string name, string filename) { this.name = name; this.filename = filename; Types = new TypeCollection(); GlobalVariables = new GlobalVariableCollection(); GlobalInstructions = new GlobalInstructionCollection(); GlobalMethods = new MethodCollection(); }
public Function(string name) { if (name == null) { throw Error.SchemaRequirementViolation("Function", "Name"); } this.name = name; parameters = new ParameterCollection(); types = new TypeCollection(); }
public Type(string name) { if (name == null) { throw Error.SchemaRequirementViolation("Type", "Name"); } this.name = name; columns = new ColumnCollection(); associations = new AssociationCollection(); subTypes = new TypeCollection(); }
//================================================================================ Construction internal NodeType(int id, string name, ISchemaRoot schemaRoot, string className, NodeType parent) : base(id, name, schemaRoot) { _declaredPropertyTypes = new TypeCollection<PropertyType>(this.SchemaRoot); _parent = parent; _children = new TypeCollection<NodeType>(this.SchemaRoot); _className = className; _nodeTypePath = name; if (parent != null) { parent._children.Add(this); //-- Inherit PropertyTypes foreach (PropertyType propType in parent.PropertyTypes) this.PropertyTypes.Add(propType); _nodeTypePath = String.Concat(parent._nodeTypePath, "/", _nodeTypePath); } }
public MemberDeclResolver(CompilationErrorManager errorManager, TypeCollection types) { m_errorManager = errorManager; m_types = types; }
public static TypeCollection<PropertyType> GetDynamicSignature(int nodeTypeId, int contentListTypeId) { System.Diagnostics.Debug.Assert(nodeTypeId > 0); var nodePropertyTypes = NodeTypeManager.Current.NodeTypes.GetItemById(nodeTypeId).PropertyTypes; var allPropertyTypes = new TypeCollection<PropertyType>(nodePropertyTypes); if (contentListTypeId > 0) allPropertyTypes.AddRange(NodeTypeManager.Current.ContentListTypes.GetItemById(contentListTypeId).PropertyTypes); return allPropertyTypes; }
public TypeCollection<NodeType> GetChildren() { TypeCollection<NodeType> children = new TypeCollection<NodeType>(this.SchemaRoot); foreach (NodeType nt in _children) children.Add(nt); return children; }
public TypeCollection<NodeType> GetAllTypes() { TypeCollection<NodeType> types = new TypeCollection<NodeType>(this.SchemaRoot); this.GetAllTypes(types); return types; }
private void GetAllTypes(TypeCollection<NodeType> types) { types.Add(this); foreach (NodeType subType in this.GetChildren()) subType.GetAllTypes(types); }
public static bool Compare(this TypeCollection source, TypeCollection n, Func<Type, Type, bool> checkitem) { return Compare<Type>(source,n,checkitem); }
public static bool Compare(this TypeCollection source, TypeCollection n) { return Compare<Type>(source,n); }
public static bool Compare(this TypeCollection source, TypeCollection n, Func<Type, Type, Action<string, string>, bool> checkitem, Action<string, string> errAct) { return Compare<Type>(source,n,checkitem,errAct); }
public MethodBodyResolver(CompilationErrorManager errorManager, TypeCollection types) { m_errorManager = errorManager; m_types = types; }
internal TypeCollection method_8(IGenericParameterProvider igenericParameterProvider_0) { TypeCollection typeCollection = new TypeCollection(); foreach (GenericParameter genericParameter in igenericParameterProvider_0.GenericParameters) { typeCollection.method_1(this.method_7(genericParameter)); typeCollection.method_2(this.method_8(genericParameter)); } return typeCollection; }
//================================================================================ Construction internal PropertySet(int id, string name, ISchemaRoot schemaRoot) : base(schemaRoot, name, id) { _propertyTypes = new TypeCollection<PropertyType>(schemaRoot); }
public ToolTipListBox() { _collection = new TypeCollection<ListBoxEntry>( this ); this.MouseHover += new EventHandler( ToolTipListBox_MouseHover ); this.MouseLeave += new EventHandler( ToolTipListBox_MouseLeave ); }
public TypeDeclResolver(CompilationErrorManager errorManager) { m_errorManager = errorManager; m_types = new TypeCollection(); }
public virtual ITypeCollection TransformTypeCollection(ITypeCollection types) { IType[] array = new IType[types.Count]; for (int i = 0; i < types.Count; i++) { array[i] = this.TransformType(types[i]); } ITypeCollection target = new TypeCollection(); target.AddRange(array); return target; }