System.Attribute.GetCustomAttributes(System.Reflection.MemberInfo)

Here are the examples of the csharp api System.Attribute.GetCustomAttributes(System.Reflection.MemberInfo) taken from open source projects. By voting up you can indicate which examples are most useful and appropriate.

64 Examples 7

19 Source : EntityDescriptor.cs
with MIT License
from 17MKH

private void SetColumns()
    {
        //加载属性列表
        var properties = new List<PropertyInfo>();
        foreach (var p in EnreplacedyType.GetProperties())
        {
            var type = p.PropertyType;
            if (type == typeof(TimeSpan) || (!type.IsGenericType || type.IsNullable()) && (type.IsGuid() || type.IsNullable() || Type.GetTypeCode(type) != TypeCode.Object)
                && Attribute.GetCustomAttributes(p).All(attr => attr.GetType() != typeof(NotMappingColumnAttribute)))
            {
                properties.Add(p);
            }
        }

        foreach (var p in properties)
        {
            var column = new ColumnDescriptor(p, DbContext.Adapter);

            if (column.IsPrimaryKey)
            {
                PrimaryKey = new PrimaryKeyDescriptor(p);
                Columns.Insert(0, column);
            }
            else
            {
                Columns.Add(column);
            }
        }

        //如果主键为null,则需要指定为没有主键
        if (PrimaryKey == null)
        {
            PrimaryKey = new PrimaryKeyDescriptor();
        }
    }

19 Source : GraphContextMenu.cs
with MIT License
from alexismorin

public bool RefreshNodes( ParentGraph currentGraph )
		{
			if( m_items != null )
			{
				m_items.Clear();
				m_items = null;
			}

			if( m_itemFunctions != null )
			{
				m_itemFunctions.Clear();
				m_itemFunctions = null;
			}

			m_items = new List<ContextMenuItem>();
			m_itemFunctions = new List<ContextMenuItem>();

			if( m_itemsDict != null )
				m_itemsDict.Clear();

			m_itemsDict = new Dictionary<System.Type, NodeAttributes>();

			if( m_deprecatedItemsDict != null )
				m_deprecatedItemsDict.Clear();

			m_deprecatedItemsDict = new Dictionary<System.Type, NodeAttributes>();

			if( m_castTypes != null )
				m_castTypes.Clear();

			m_castTypes = new Dictionary<System.Type, System.Type>();

			if( m_shortcutTypes != null )
				m_shortcutTypes.Clear();

			m_shortcutTypes = new Dictionary<KeyCode, ShortcutKeyData>();

			m_lastKeyPressed = KeyCode.None;

			// Fetch all available nodes by their attributes
			try
			{
				//IEnumerable<System.Type> availableTypes = AppDomain.CurrentDomain.Getreplacedemblies().ToList().SelectMany( type => type.GetTypes() );
				Type[] availableTypes = GetTypesInNamespace( replacedembly.GetExecutingreplacedembly(), "AmplifyShaderEditor" );
				foreach( System.Type type in availableTypes )
				{
					foreach( NodeAttributes attribute in Attribute.GetCustomAttributes( type ).OfType<NodeAttributes>() )
					{
						if( attribute.Available && !attribute.Deprecated )
						{
							//if ( !UIUtils.CurrentWindow.IsShaderFunctionWindow && attribute.AvailableInFunctionsOnly )
							//	continue;

							if( !UIUtils.HasColorCategory( attribute.Category ) )
							{
								if( !String.IsNullOrEmpty( attribute.CustomCategoryColor ) )
								{
									try
									{
										Color color = new Color();
										ColorUtility.TryParseHtmlString( attribute.CustomCategoryColor, out color );
										UIUtils.AddColorCategory( attribute.Category, color );
									}
									catch( Exception e )
									{
										Debug.LogException( e );
										UIUtils.AddColorCategory( attribute.Category, Constants.DefaultCategoryColor );
									}
								}
								//else
								//{
								//	UIUtils.AddColorCategory( attribute.Category, Constants.DefaultCategoryColor );
								//}
							}

							if( attribute.CastType != null && attribute.CastType.Length > 0 && type != null )
							{
								for( int i = 0; i < attribute.CastType.Length; i++ )
								{
									m_castTypes.Add( attribute.CastType[ i ], type );
								}
							}

							if( attribute.ShortcutKey != KeyCode.None && type != null )
								m_shortcutTypes.Add( attribute.ShortcutKey, new ShortcutKeyData( type, attribute.Name ) );

							ContextMenuItem newItem = new ContextMenuItem( attribute, type, attribute.Name, attribute.Category, attribute.Description, null, attribute.ShortcutKey );
							if( UIUtils.GetNodeAvailabilityInBitArray( attribute.NodeAvailabilityFlags, NodeAvailability.SurfaceShader ) )
								m_items.Add( newItem );
							else if( UIUtils.GetNodeAvailabilityInBitArray( attribute.NodeAvailabilityFlags, currentGraph.ParentWindow.CurrentNodeAvailability ) )
								m_items.Add( newItem );
							else if( UIUtils.GetNodeAvailabilityInBitArray( attribute.NodeAvailabilityFlags, currentGraph.CurrentCanvasMode ) )
								m_items.Add( newItem );

							m_itemsDict.Add( type, attribute );
							m_itemFunctions.Add( newItem );
						}
						else
						{
							m_deprecatedItemsDict.Add( type, attribute );
						}
					}
				}
			}
			catch( ReflectionTypeLoadException exception )
			{
				Debug.LogException( exception );
				return false;
			}

			string[] guids = replacedetDatabase.Findreplacedets( "t:AmplifyShaderFunction" );
			List<AmplifyShaderFunction> allFunctions = new List<AmplifyShaderFunction>();

			for( int i = 0; i < guids.Length; i++ )
			{
				allFunctions.Add( replacedetDatabase.LoadreplacedetAtPath<AmplifyShaderFunction>( replacedetDatabase.GUIDToreplacedetPath( guids[ i ] ) ) );
			}

			int functionCount = allFunctions.Count;
			if( functionCount > 0 )
			{
				m_castTypes.Add( typeof( AmplifyShaderFunction ), typeof( FunctionNode ) );
			}

			for( int i = 0; i < functionCount; i++ )
			{
				if( !allFunctions[ i ].Hidden )
				{
					NodeAttributes attribute = new NodeAttributes( allFunctions[ i ].FunctionName, allFunctions[ i ].CustomNodeCategory, allFunctions[ i ].Description, KeyCode.None, true, 0, int.MaxValue, typeof( AmplifyShaderFunction ) );
					System.Type type = typeof( FunctionNode );

					ContextMenuItem newItem = new ContextMenuItem( attribute, type, attribute.Name, attribute.Category, attribute.Description, allFunctions[ i ], attribute.ShortcutKey );
					m_items.Add( newItem );
					m_itemFunctions.Add( newItem );
				}
			}

			//Sort out the final list by name
			m_items.Sort( ( x, y ) => x.Category.CompareTo( y.Category ) );
			m_itemFunctions.Sort( ( x, y ) => x.Category.CompareTo( y.Category ) );
			return true;
		}

19 Source : GraphContextMenu.cs
with GNU General Public License v3.0
from alexismorin

public bool RefreshNodes( ParentGraph currentGraph )
		{
			if( m_items != null )
			{
				m_items.Clear();
				m_items = null;
			}

			if( m_itemFunctions != null )
			{
				m_itemFunctions.Clear();
				m_itemFunctions = null;
			}

			m_items = new List<ContextMenuItem>();
			m_itemFunctions = new List<ContextMenuItem>();

			if( m_itemsDict != null )
				m_itemsDict.Clear();

			m_itemsDict = new Dictionary<System.Type, NodeAttributes>();

			if( m_deprecatedItemsDict != null )
				m_deprecatedItemsDict.Clear();

			m_deprecatedItemsDict = new Dictionary<System.Type, NodeAttributes>();

			if( m_castTypes != null )
				m_castTypes.Clear();

			m_castTypes = new Dictionary<System.Type, System.Type>();

			if( m_shortcutTypes != null )
				m_shortcutTypes.Clear();

			m_shortcutTypes = new Dictionary<KeyCode, ShortcutKeyData>();

			m_lastKeyPressed = KeyCode.None;

			// Fetch all available nodes by their attributes
			try
			{
				//IEnumerable<System.Type> availableTypes = AppDomain.CurrentDomain.Getreplacedemblies().ToList().SelectMany( type => type.GetTypes() );
				Type[] availableTypes = GetTypesInNamespace( replacedembly.GetExecutingreplacedembly(), "AmplifyShaderEditor" );
				foreach( System.Type type in availableTypes )
				{
					foreach( NodeAttributes attribute in Attribute.GetCustomAttributes( type ).OfType<NodeAttributes>() )
					{
						if( attribute.Available && !attribute.Deprecated )
						{
							//if ( !UIUtils.CurrentWindow.IsShaderFunctionWindow && attribute.AvailableInFunctionsOnly )
							//	continue;

							if( !UIUtils.HasColorCategory( attribute.Category ) )
							{
								if( !String.IsNullOrEmpty( attribute.CustomCategoryColor ) )
								{
									try
									{
										Color color = new Color();
										ColorUtility.TryParseHtmlString( attribute.CustomCategoryColor, out color );
										UIUtils.AddColorCategory( attribute.Category, color );
									}
									catch( Exception e )
									{
										Debug.LogException( e );
										UIUtils.AddColorCategory( attribute.Category, Constants.DefaultCategoryColor );
									}
								}
								//else
								//{
								//	UIUtils.AddColorCategory( attribute.Category, Constants.DefaultCategoryColor );
								//}
							}

							if( attribute.CastType != null && attribute.CastType.Length > 0 && type != null )
							{
								for( int i = 0; i < attribute.CastType.Length; i++ )
								{
									m_castTypes.Add( attribute.CastType[ i ], type );
								}
							}

							if( attribute.ShortcutKey != KeyCode.None && type != null )
								m_shortcutTypes.Add( attribute.ShortcutKey, new ShortcutKeyData( type, attribute.Name ) );

							ContextMenuItem newItem = new ContextMenuItem( attribute, type, attribute.Name, attribute.Category, attribute.Description, null, attribute.ShortcutKey );
							if( UIUtils.GetNodeAvailabilityInBitArray( attribute.NodeAvailabilityFlags, NodeAvailability.SurfaceShader ) )
								m_items.Add( newItem );
							else if( UIUtils.GetNodeAvailabilityInBitArray( attribute.NodeAvailabilityFlags, currentGraph.ParentWindow.CurrentNodeAvailability ) )
								m_items.Add( newItem );
							else if( UIUtils.GetNodeAvailabilityInBitArray( attribute.NodeAvailabilityFlags, currentGraph.CurrentCanvasMode ) )
								m_items.Add( newItem );

							m_itemsDict.Add( type, attribute );
							m_itemFunctions.Add( newItem );
						}
						else
						{
							m_deprecatedItemsDict.Add( type, attribute );
						}
					}
				}
			}
			catch( ReflectionTypeLoadException exception )
			{
				Debug.LogException( exception );
				return false;
			}

			string[] guids = replacedetDatabase.Findreplacedets( "t:AmplifyShaderFunction" );
			List<AmplifyShaderFunction> allFunctions = new List<AmplifyShaderFunction>();

			for( int i = 0; i < guids.Length; i++ )
			{
				allFunctions.Add( replacedetDatabase.LoadreplacedetAtPath<AmplifyShaderFunction>( replacedetDatabase.GUIDToreplacedetPath( guids[ i ] ) ) );
			}

			int functionCount = allFunctions.Count;
			if( functionCount > 0 )
			{
				m_castTypes.Add( typeof( AmplifyShaderFunction ), typeof( FunctionNode ) );
			}

			for( int i = 0; i < functionCount; i++ )
			{
				NodeAttributes attribute = new NodeAttributes( allFunctions[ i ].FunctionName, allFunctions[ i ].CustomNodeCategory, allFunctions[ i ].Description, KeyCode.None, true, 0, int.MaxValue, typeof( AmplifyShaderFunction ) );
				System.Type type = typeof( FunctionNode );

				ContextMenuItem newItem = new ContextMenuItem( attribute, type, attribute.Name, attribute.Category, attribute.Description, allFunctions[ i ], attribute.ShortcutKey );
				m_items.Add( newItem );
				m_itemFunctions.Add( newItem );
			}

			//Sort out the final list by name
			m_items.Sort( ( x, y ) => x.Category.CompareTo( y.Category ) );
			m_itemFunctions.Sort( ( x, y ) => x.Category.CompareTo( y.Category ) );
			return true;
		}

19 Source : RequiresSystem.cs
with MIT License
from allenwp

public static bool HasECSSystemForType(Type componentType, List<ECSSystem> systems, out Type firstMissingSystem)
        {
            Attribute[] attrs = Attribute.GetCustomAttributes(componentType);

            firstMissingSystem = null;

            foreach (Attribute attr in attrs)
            {
                if (attr is RequiresSystem)
                {
                    Type requiredSystem = ((RequiresSystem)attr).ECSSystem;
                    if (systems.Where(system => system.GetType() == requiredSystem).Count() == 0)
                    {
                        firstMissingSystem = requiredSystem;
                        return false;
                    }
                }
            }

            return true;
        }

19 Source : ModelDeserializer.cs
with BSD 3-Clause "New" or "Revised" License
from Altinn

private static string GetRootElementName(Type modelType)
        {
            Attribute[] attributes = Attribute.GetCustomAttributes(modelType);

            foreach (var attribute in attributes)
            {
                var xmlRootAttribute = attribute as XmlRootAttribute;
                if (xmlRootAttribute != null)
                {
                    return xmlRootAttribute.ElementName;
                }
            }

            return modelType.Name;
        }

19 Source : Program.cs
with GNU Affero General Public License v3.0
from arklumpus

static async Task Main(string[] args)
        {
            ConsoleColor defaultBackground = Console.BackgroundColor;
            ConsoleColor defaultForeground = Console.ForegroundColor;

            Console.WriteLine();
            Console.WriteLine("MuPDFCore test suite");
            Console.WriteLine();
            Console.WriteLine("Loading tests...");

            replacedembly testreplacedembly = replacedembly.Getreplacedembly(typeof(MuPDFWrapperTests));

            Type[] types = testreplacedembly.GetTypes();

            List<(string, Func<Task>)> tests = new List<(string, Func<Task>)>();
            HashSet<string> filesToDeploy = new HashSet<string>();

            for (int i = 0; i < types.Length; i++)
            {
                bool found = false;

                Attribute[] typeAttributes = Attribute.GetCustomAttributes(types[i]);

                foreach (Attribute attr in typeAttributes)
                {
                    if (attr is TestClreplacedAttribute)
                    {
                        found = true;
                        break;
                    }
                }

                if (found)
                {
                    MethodInfo[] methods = types[i].GetMethods(BindingFlags.Public | BindingFlags.Instance);

                    foreach (MethodInfo method in methods)
                    {
                        bool foundMethod = false;

                        foreach (Attribute attr in method.GetCustomAttributes())
                        {
                            if (attr is TestMethodAttribute)
                            {
                                foundMethod = true;
                            }

                            if (attr is DeploymenreplacedemAttribute dia)
                            {
                                filesToDeploy.Add(dia.Path);
                            }
                        }

                        if (foundMethod)
                        {
                            Type type = types[i];

                            tests.Add((types[i].Name + "." + method.Name, async () =>
                            {
                                object obj = Activator.CreateInstance(type);
                                object returnValue = method.Invoke(obj, null);

                                if (returnValue is Task task)
                                {
                                    await task;
                                }
                            }
                            ));
                        }
                    }
                }
            }

            int longestTestNameLength = (from el in tests select el.Item1.Length).Max();

            Console.WriteLine();
            Console.BackgroundColor = ConsoleColor.Blue;
            Console.Write("  Found {0} tests.  ", tests.Count.ToString());
            Console.BackgroundColor = defaultBackground;
            Console.WriteLine();
            Console.WriteLine();

            Console.WriteLine("{0} files will be deployed:", filesToDeploy.Count.ToString());

            foreach (string sr in filesToDeploy)
            {
                Console.WriteLine("    " + sr);
            }

            Console.WriteLine();

            string deploymentPath = Path.GetTempFileName();
            File.Delete(deploymentPath);
            Directory.CreateDirectory(deploymentPath);

            foreach (string sr in filesToDeploy)
            {
                File.Copy(sr, Path.Combine(deploymentPath, Path.GetFileName(sr)));
            }

            string originalCurrentDirectory = Directory.GetCurrentDirectory();
            Directory.SetCurrentDirectory(deploymentPath);

            Console.WriteLine("Deployment completed.");
            Console.WriteLine();
            Console.WriteLine("Running tests...");
            Console.WriteLine();

            List<(string, Func<Task>)> failedTests = new List<(string, Func<Task>)>();

            for (int i = 0; i < tests.Count; i++)
            {
                Console.Write(tests[i].Item1 + new string(' ', longestTestNameLength - tests[i].Item1.Length + 1));

                bool failed = false;

                Stopwatch sw = Stopwatch.StartNew();

                try
                {
                    await tests[i].Item2();
                    sw.Stop();
                }
                catch (Exception ex)
                {
                    sw.Stop();
                    failed = true;
                    failedTests.Add(tests[i]);

                    Console.BackgroundColor = ConsoleColor.Red;
                    Console.Write("   Failed    ");
                    Console.BackgroundColor = defaultBackground;

                    Console.Write("    {0}ms", sw.ElapsedMilliseconds.ToString());

                    Console.WriteLine();

                    while (ex.InnerException != null)
                    {
                        Console.WriteLine(ex.Message);
                        ex = ex.InnerException;
                    }

                    Console.WriteLine(ex.Message);
                }

                if (!failed)
                {
                    Console.BackgroundColor = ConsoleColor.Green;
                    Console.Write("  Succeeded  ");
                    Console.BackgroundColor = defaultBackground;
                    Console.Write("    {0}ms", sw.ElapsedMilliseconds.ToString());
                }

                Console.WriteLine();
            }

            Console.WriteLine();

            if (failedTests.Count < tests.Count)
            {
                Console.BackgroundColor = ConsoleColor.Green;
                Console.Write("  {0} tests succeeded  ", tests.Count - failedTests.Count);
                Console.BackgroundColor = defaultBackground;
                Console.WriteLine();
            }

            if (failedTests.Count > 0)
            {
                Console.BackgroundColor = ConsoleColor.Red;
                Console.Write("  {0} tests failed  ", failedTests.Count);
                Console.BackgroundColor = defaultBackground;
                Console.WriteLine();

                Console.WriteLine();
                Console.WriteLine("Failed tests:");
                Console.ForegroundColor = ConsoleColor.Red;

                for (int i= 0; i < failedTests.Count; i++)
                {
                    Console.WriteLine("    {0}", failedTests[i].Item1);
                }

                Console.WriteLine();
                Console.ForegroundColor = defaultForeground;

                Console.WriteLine();
                Console.WriteLine("The failed tests will now be repeated one by one.");

                for (int i = 0; i < failedTests.Count; i++)
                {
                    Console.WriteLine();
                    Console.WriteLine("Press any key to continue...");
                    Console.WriteLine();
                    Console.ReadKey();
                    Console.Write(failedTests[i].Item1 + new string(' ', longestTestNameLength - failedTests[i].Item1.Length + 1));

                    bool failed = false;

                    try
                    {
                        await failedTests[i].Item2();
                    }
                    catch (Exception ex)
                    {
                        failed = true;

                        Console.BackgroundColor = ConsoleColor.Red;
                        Console.Write("   Failed    ");
                        Console.BackgroundColor = defaultBackground;

                        Console.WriteLine();

                        while (ex.InnerException != null)
                        {
                            Console.WriteLine(ex.Message);
                            ex = ex.InnerException;
                        }

                        Console.WriteLine(ex.Message);
                    }

                    if (!failed)
                    {
                        Console.BackgroundColor = ConsoleColor.Green;
                        Console.Write("  Succeeded  ");
                        Console.BackgroundColor = defaultBackground;
                    }

                    Console.WriteLine();
                }
            }

            Directory.SetCurrentDirectory(originalCurrentDirectory);
            Directory.Delete(deploymentPath, true);
        }

19 Source : ExpressionFactory.cs
with MIT License
from brunohbrito

internal static WhereClause GetCriteria(ICustomQueryable model, PropertyInfo propertyInfo)
        {
            bool isCollection = propertyInfo.IsPropertyACollection();
            if (!isCollection && propertyInfo.IsPropertyObject(model))
                return null;

            var criteria = new WhereClause();

            var attr = Attribute.GetCustomAttributes(propertyInfo);
            // Check for the AnimalType attribute.
            if (attr.Any(a => a.GetType() == typeof(QueryOperatorAttribute)))
            {
                var data = (QueryOperatorAttribute)attr.First(a => a.GetType() == typeof(QueryOperatorAttribute));
                criteria.UpdateAttributeData(data);
                if (data.Operator != WhereOperator.Contains && isCollection)
                    throw new ArgumentException($"{propertyInfo.Name} - For array the only Operator available is Contains");
            }

            if (isCollection)
                criteria.Operator = WhereOperator.Contains;

            var customValue = propertyInfo.GetValue(model, null);
            if (customValue == null)
                return null;

            criteria.UpdateValues(propertyInfo);
            return criteria;
        }

19 Source : DPAutoGenSettings.cs
with GNU General Public License v3.0
from CircuitLord

public void Generate() {
			
			
			FieldInfo[] objectFields = typeof(DPConfigJson).GetFields(BindingFlags.Instance | BindingFlags.Public);

			int i = 0;
			foreach (FieldInfo info in objectFields) {

				Attribute[] attributes = Attribute.GetCustomAttributes(objectFields[i]);



				foreach (Attribute attribute in attributes) {

					switch (attribute.GetType().ToString()) {
						
						case "CConfigFloat":

							break;
						
						
					}
					
					
				}
				
				
				
				i++;

			}
			
			
			/*PropertyInfo[] props = typeof(DPConfigJson).GetProperties();

			foreach (PropertyInfo prop in props) {
				
			}*/

			
		}

19 Source : ComponentDef.cs
with MIT License
from CragonGame

public Dictionary<string, string> getMapProp4SaveDb(byte current_nodetype)
        {
            if (mMapProp.Count == 0) return null;

            Dictionary<string, string> map_ret = new Dictionary<string, string>();

            FieldInfo[] list_fieldinfo = GetType().GetFields(BindingFlags.Public | BindingFlags.Instance);
            foreach (var fi in list_fieldinfo)
            {
                if (!fi.FieldType.BaseType.Equals(typeof(IProp))) continue;

                Attribute[] attrs = System.Attribute.GetCustomAttributes(fi);
                foreach (Attribute attr in attrs)
                {
                    if (!(attr is PropAttrDistribution)) continue;

                    PropAttrDistribution a = (PropAttrDistribution)attr;
                    if (a.NodePrimary == current_nodetype && a.Save2Db)
                    {
                        IProp p = (IProp)fi.GetValue(this);
                        map_ret[p.getKey()] = EbTool.jsonSerialize(p.getValue());
                    }
                    break;
                }
            }

            return map_ret;
        }

19 Source : ComponentDef.cs
with MIT License
from CragonGame

public Dictionary<string, string> getMapProp4NetSync(byte current_nodetype, byte to_nodetype)
        {
            if (mMapProp.Count == 0) return null;

            Dictionary<string, string> map_ret = new Dictionary<string, string>();

            FieldInfo[] list_fieldinfo = GetType().GetFields(BindingFlags.Public | BindingFlags.Instance);
            foreach (var fi in list_fieldinfo)
            {
                if (!fi.FieldType.BaseType.Equals(typeof(IProp))) continue;

                Attribute[] attrs = System.Attribute.GetCustomAttributes(fi);
                foreach (Attribute attr in attrs)
                {
                    if (!(attr is PropAttrDistribution)) continue;

                    PropAttrDistribution a = (PropAttrDistribution)attr;
                    if (a.NodePrimary == current_nodetype && a.NodeDistribution != null)
                    {
                        foreach (var i in a.NodeDistribution)
                        {
                            if (i == to_nodetype)
                            {
                                IProp p = (IProp)fi.GetValue(this);
                                map_ret[p.getKey()] = EbTool.jsonSerialize(p.getValue());
                                break;
                            }
                        }
                    }
                    break;
                }
            }

            return map_ret;
        }

19 Source : Scenario.cs
with MIT License
from daltskin

public static string GetName(Type t) => ((ScenarioMetadata)System.Attribute.GetCustomAttributes(t)[0]).Name;

19 Source : Scenario.cs
with MIT License
from daltskin

public static string GetDescription(Type t) => ((ScenarioMetadata)System.Attribute.GetCustomAttributes(t)[0]).Description;

19 Source : Scenario.cs
with MIT License
from daltskin

public static string GetName(Type t) => ((ScenarioCategory)System.Attribute.GetCustomAttributes(t)[0]).Name;

19 Source : Scenario.cs
with MIT License
from daltskin

public static List<string> GetCategories(Type t) => System.Attribute.GetCustomAttributes(t)
                .ToList()
                .Where(a => a is ScenarioCategory)
                .Select(a => ((ScenarioCategory)a).Name)
                .ToList();

19 Source : Scenario.cs
with MIT License
from daltskin

internal static List<string> GetAllCategories()
        {
            List<string> categories = new List<string>() { "All" };
            foreach (Type type in typeof(Scenario).replacedembly.GetTypes()
             .Where(myType => myType.IsClreplaced && !myType.IsAbstract && myType.IsSubclreplacedOf(typeof(Scenario))))
            {
                List<System.Attribute> attrs = System.Attribute.GetCustomAttributes(type).ToList();
                categories = categories.Union(attrs.Where(a => a is ScenarioCategory).Select(a => ((ScenarioCategory)a).Name)).ToList();
            }
            return categories;
        }

19 Source : EndpointRoutingConventionShould.cs
with MIT License
from dasiths

[Fact]
        public void MapConventions()
        {
            //Arrange
            var clreplacedAttributes = Attribute.GetCustomAttributes(typeof(TestEndpoint));
            var conventions = new EndpointRoutingConvention(new List<IEndpointMetadataEnricher>()
            {
                new RouteEndpointMetadataEnricher(Options.Create(new SimpleEndpointsConfiguration()),
                    NullLogger<RouteEndpointMetadataEnricher>.Instance),
                new HttpMethodEndpointMetadataEnricher(Options.Create(new SimpleEndpointsConfiguration()),
                    NullLogger<HttpMethodEndpointMetadataEnricher>.Instance)
            }, NullLogger<EndpointRoutingConvention>.Instance);

            var controller = new ControllerModel(typeof(TestEndpoint).GetTypeInfo(), clreplacedAttributes)
            {
                Selectors =
                {
                    new SelectorModel
                    {
                        AttributeRouteModel = new AttributeRouteModel {Template = "route"},
                        EndpointMetadata = { }
                    }
                },
                ControllerName = nameof(TestEndpoint)
            };

            //Act
            conventions.Apply(new ApplicationModel { Controllers = { controller } });

            controller.Selectors[0].AttributeRouteModel.Template.ShouldBe("route");

            //replacedert
            controller.Selectors[0].EndpointMetadata.Count.ShouldBe(1);
            controller.Selectors[0].EndpointMetadata.First().ShouldBeOfType<HttpMethodMetadata>();
            controller.Selectors[0].EndpointMetadata.OfType<HttpMethodMetadata>().First().HttpMethods
                .ShouldBe(new[] { "GET" });
        }

19 Source : HttpMethodMetadataEnricherShould.cs
with MIT License
from dasiths

private static ControllerModel CreateController(Type typeEndpoint)
        {
            var clreplacedAttributes = Attribute.GetCustomAttributes(typeEndpoint);
            return new ControllerModel(typeEndpoint.GetTypeInfo(), clreplacedAttributes)
            {
                Selectors = {new SelectorModel {EndpointMetadata = { }}}
            };
        }

19 Source : RouteMetadataEnricherShould.cs
with MIT License
from dasiths

[Fact]
        public void MapRoute_ReplacingPlaceholderWithEndpointName()
        {
            //Arrange
            var enricher = new RouteEndpointMetadataEnricher(Options.Create(new SimpleEndpointsConfiguration().WithRoutePrefix("api")),
                NullLogger<RouteEndpointMetadataEnricher>.Instance);
            var clreplacedAttributes = Attribute.GetCustomAttributes(typeof(TestEndpoint));
            var controller = CreateControllerModel(clreplacedAttributes.OfType<RouteAttribute>().First().Template);

            //Act
            enricher.Enrich(controller, c => { });

            //replacedert
            controller.Selectors[0].AttributeRouteModel.Template.ShouldBe("api/Test");
        }

19 Source : RouteMetadataEnricherShould.cs
with MIT License
from dasiths

private static ControllerModel CreateControllerModel(string routeTemplate)
        {
            var clreplacedAttributes = Attribute.GetCustomAttributes(typeof(TestEndpoint));

            var controller = new ControllerModel(typeof(TestEndpoint).GetTypeInfo(), clreplacedAttributes)
            {
                Selectors =
                {
                    new SelectorModel
                    {
                        AttributeRouteModel = new AttributeRouteModel {Template = routeTemplate},
                        EndpointMetadata = { }
                    }
                },
                ControllerName = nameof(TestEndpoint)
            };
            return controller;
        }

19 Source : MemberNotNullTest.cs
with MIT License
from DevExpress

[Test]
        public void CheckAttribute() {
            var noAttributePropertySetter = typeof(WithoutMemberNotNullAttribute).GetProperty("NoAttribute").SetMethod;
            var attributes = Attribute.GetCustomAttributes(noAttributePropertySetter);
            var expectedAttributes = new Attribute[] { };
            replacedert.AreEqual(expectedAttributes, attributes);
        }

19 Source : MemberNotNullTest.cs
with MIT License
from DevExpress

[Test]
        public void CheckAttribute() {
            var withAttributePropertySetter = typeof(WithMemberNotNullAttribute).GetProperty("WithAttribute").SetMethod;
            var attributes = Attribute.GetCustomAttributes(withAttributePropertySetter);
            var expectedAttributes = new Attribute[] { new MemberNotNullAttribute("withAttribute") };
            replacedert.AreEqual(expectedAttributes, attributes);
        }

19 Source : AttributeTransferTests.cs
with MIT License
from DevExpress

[Test]
        public void AttributeTransfer() {
            var noAttributeProperty = typeof(AttributeTransfer).GetProperty("NoAttribute");
            var attributes = Attribute.GetCustomAttributes(noAttributeProperty);
            var expectedAttributes = new Attribute[] { };
            replacedert.AreEqual(expectedAttributes, attributes);

            var withMultipleAttributesProperty = typeof(AttributeTransfer).GetProperty("WithMultipleAttributes");
            attributes = Attribute.GetCustomAttributes(withMultipleAttributesProperty);
            expectedAttributes = new Attribute[] {
                new System.ComponentModel.DataAnnotations.RangeAttribute(0, 1),
                new RequiredAttribute(),
                new MyCustomAttribute(1, "Some string", true, TestEnum.Num)
            };
            replacedert.AreEqual(expectedAttributes, attributes);
        }

19 Source : ContextsComponentDataProvider.cs
with GNU General Public License v3.0
from FNGgames

public static string[] GetContextNames(Type type) {
            return Attribute
                .GetCustomAttributes(type)
                .OfType<ContextAttribute>()
                .Select(attr => attr.contextName)
                .ToArray();
        }

19 Source : IsUniqueComponentDataProvider.cs
with GNU General Public License v3.0
from FNGgames

public void Provide(Type type, ComponentData data) {
            var isUnique = Attribute
                .GetCustomAttributes(type)
                .OfType<UniqueAttribute>()
                .Any();

            data.IsUnique(isUnique);
        }

19 Source : ShouldGenerateComponentIndexComponentDataProvider.cs
with GNU General Public License v3.0
from FNGgames

bool getGenerateIndex(Type type) {
            var attr = Attribute
                .GetCustomAttributes(type)
                .OfType<DontGenerateAttribute>()
                .SingleOrDefault();

            return attr == null || attr.generateIndex;
        }

19 Source : ShouldGenerateMethodsComponentDataProvider.cs
with GNU General Public License v3.0
from FNGgames

public void Provide(Type type, ComponentData data) {
            var generate = !Attribute
                .GetCustomAttributes(type)
                .OfType<DontGenerateAttribute>()
                .Any();

            data.ShouldGenerateMethods(generate);
        }

19 Source : UniquePrefixComponentDataProvider.cs
with GNU General Public License v3.0
from FNGgames

string getUniqueComponentPrefix(Type type) {
            var attr = Attribute.GetCustomAttributes(type)
                                .OfType<CustomPrefixAttribute>()
                                .SingleOrDefault();

            return attr == null ? "is" : attr.prefix;
        }

19 Source : AbstractComponentDataProvider.cs
with GNU General Public License v3.0
from FNGgames

string[] getComponentNames(Type type) {
            var attr = Attribute
                .GetCustomAttributes(type)
                .OfType<CustomComponentNameAttribute>()
                .SingleOrDefault();

            if(attr == null) {
                return new[] { type.ToCompilableString().ShortTypeName().AddComponentSuffix() };
            }

            return attr.componentNames;
        }

19 Source : JsonKnownTypeConverter.cs
with MIT License
from FuzzySlipper

public override bool CanConvert( Type objectType ) {
            return System.Attribute.GetCustomAttributes( objectType ).Any( v => v is KnownTypeAttribute );
        }

19 Source : JsonKnownTypeConverter.cs
with MIT License
from FuzzySlipper

public override object ReadJson( JsonReader reader, Type objectType, object existingValue, JsonSerializer serializer ) {
            // Load JObject from stream
            JObject jObject = JObject.Load( reader );

            // Create target object based on JObject
            System.Attribute[ ] attrs = System.Attribute.GetCustomAttributes( objectType );  // Reflection. 

            // check known types for a match. 
            foreach( var attr in attrs.OfType<KnownTypeAttribute>( ) ) {
                object target = Activator.CreateInstance( attr.Type );

                JObject jTest;
                using( var writer = new StringWriter( ) ) {
                    using( var jsonWriter = new JsonTextWriter( writer ) ) {
                        serializer.Serialize( jsonWriter, target );
                        string json = writer.ToString( );
                        jTest = JObject.Parse( json );
                    }
                }

                var jO = this.GetKeys( jObject ).Select( k => k.Key ).ToList( );
                var jT = this.GetKeys( jTest ).Select( k => k.Key ).ToList( );

                if( jO.Count == jT.Count && jO.Intersect( jT ).Count( ) == jO.Count ) {
                    serializer.Populate( jObject.CreateReader( ), target );
                    return target;
                }
            }

            throw new SerializationException( string.Format( "Could not convert base clreplaced {0}", objectType ) );
        }

19 Source : MandatoryPropertyChecker.cs
with GNU General Public License v3.0
from HicServices

public void Check(ICheckNotifier notifier)
        {
            //get all possible properties that we could set
            foreach (var propertyInfo in _clreplacedInstanceToCheck.GetType().GetProperties())
            {
                //see if any demand initialization
                DemandsInitializationAttribute demand = System.Attribute.GetCustomAttributes(propertyInfo).OfType<DemandsInitializationAttribute>().FirstOrDefault();

                //this one does
                if (demand != null)
                {
                    if(demand.Mandatory)
                    {
                        var value = propertyInfo.GetValue(_clreplacedInstanceToCheck);
                        if (value == null || string.IsNullOrEmpty(value.ToString()))
                            notifier.OnCheckPerformed(new CheckEventArgs( "DemandsInitialization Property '" + propertyInfo.Name + "' is marked Mandatory but does not have a value", CheckResult.Fail));

                    }
                }
            }
        }

19 Source : RuntimeTask.cs
with GNU General Public License v3.0
from HicServices

public void SetPropertiesForClreplaced(RuntimeArgumentCollection args, object toSetPropertiesOf)
        {
            if (toSetPropertiesOf == null)
                throw new NullReferenceException(ProcessTask.Path + " instance has not been created yet! Call SetProperties after the factory has created the instance.");
            
            if (UsefulStuff.IsreplacedignableToGenericType(toSetPropertiesOf.GetType(),typeof (IPipelineRequirement<>)))
                throw new Exception("ProcessTask '" + ProcessTask.Name + "' was was an instance of Clreplaced '" + ProcessTask.Path + "' which declared an IPipelineRequirement<>.  RuntimeTask clreplacedes are not the same as IDataFlowComponents, IDataFlowComponents can make IPipelineRequirement requests but RuntimeTasks cannot");

            //get all possible properties that we could set
            foreach (var propertyInfo in toSetPropertiesOf.GetType().GetProperties())
            {
                //see if any demand initialization
                DemandsInitializationAttribute initialization = (DemandsInitializationAttribute)System.Attribute.GetCustomAttributes(propertyInfo).FirstOrDefault(a => a is DemandsInitializationAttribute) ;

                //this one does
                if (initialization != null)
                {
                    try
                    {
                        //get the approrpriate value from arguments
                        var value = args.GetCustomArgumentValue(propertyInfo.Name);

                        //use reflection to set the value
                        propertyInfo.SetValue(toSetPropertiesOf, value, null);
                    }
                    catch (NotSupportedException e)
                    {
                        throw new Exception("Clreplaced " + toSetPropertiesOf.GetType().Name + " has a property " + propertyInfo.Name +
                                            " but is of unexpected type " + propertyInfo.GetType(), e);
                    }
                    catch (KeyNotFoundException e)
                    {
                        if(initialization.Mandatory)
                            throw new ArgumentException(
                              "Clreplaced " + toSetPropertiesOf.GetType().Name + " has a Mandatory property '" + propertyInfo.Name +
                              "' marked with DemandsInitialization but no corresponding argument was provided in ArgumentCollection", e);
                    }
                }
            }
        }

19 Source : DataFlowPipelineEngineFactory.cs
with GNU General Public License v3.0
from HicServices

private object CreateComponent(IPipelineComponent toBuild)
        {
            var type = toBuild.GetClreplacedreplacedystemType();
            
            if(type == null)
                throw new Exception("Could not find Type '" + toBuild.Clreplaced  +"'");

            object toReturn = _constructor.Construct(type);

            //all the IArguments we need to initialize the clreplaced
            var allArguments = toBuild.GetAllArguments().ToArray();

            //get all possible properties that we could set on the underlying clreplaced
            foreach (var propertyInfo in toReturn.GetType().GetProperties())
            {
                SetPropertyIfDemanded(toBuild,toReturn,propertyInfo,allArguments);

                //see if any demand nested initialization
                Attribute nestedInit =
                    System.Attribute.GetCustomAttributes(propertyInfo)
                        .FirstOrDefault(a => a is DemandsNestedInitializationAttribute);

                //this one does
                if (nestedInit != null)
                {
                    // initialise the container before nesting-setting all properties
                    var container = Activator.CreateInstance(propertyInfo.PropertyType);

                    foreach (var nestedProp in propertyInfo.PropertyType.GetProperties())
                        SetPropertyIfDemanded(toBuild, container, nestedProp, allArguments, propertyInfo);

                    //use reflection to set the container
                    propertyInfo.SetValue(toReturn, container, null);
                }
            }

            return toReturn;
        }

19 Source : DataFlowPipelineEngineFactory.cs
with GNU General Public License v3.0
from HicServices

private void SetPropertyIfDemanded(IPipelineComponent toBuild,object toReturn, PropertyInfo propertyInfo, IArgument[] arguments, PropertyInfo nestedProperty = null)
        {
            //see if any demand initialization
            var initialization =
                (DemandsInitializationAttribute)
                    System.Attribute.GetCustomAttributes(propertyInfo)
                        .FirstOrDefault(a => a is DemandsInitializationAttribute);

            //this one does
            if (initialization != null)
            {
                try
                {
                    //look for 'DeleteUsers' if not nested
                    //look for 'Settings.DeleteUsers' if nested in a property called Settings on clreplaced
                    string expectedArgumentName = nestedProperty != null ?nestedProperty.Name + "." + propertyInfo.Name : propertyInfo.Name;

                    //get the appropriate value from arguments
                    var argument = arguments.SingleOrDefault(n => n.Name.Equals(expectedArgumentName));

                    //if there is no matching argument and no default value
                    if (argument == null)
                        if (initialization.DefaultValue == null && initialization.Mandatory)
                        {
                            string msg = string.Format("Clreplaced {0} has a property {1} marked with DemandsInitialization but no corresponding argument was found in the arguments (PipelineComponentArgument) of the PipelineComponent called {2}", 
                                toReturn.GetType().Name ,
                                propertyInfo.Name ,
                                toBuild.Name);

                            throw new PropertyDemandNotMetException(msg, toBuild,propertyInfo);
                        }
                        else
                        {
                            //use reflection to set the value
                            propertyInfo.SetValue(toReturn, initialization.DefaultValue, null);
                        }
                    else
                    {
                        //use reflection to set the value
                        propertyInfo.SetValue(toReturn, argument.GetValuereplacedystemType(), null);
                    }


                }
                catch (NotSupportedException e)
                {
                    throw new Exception("Clreplaced " + toReturn.GetType().Name + " has a property " + propertyInfo.Name +
                                        " but is of unexpected/unsupported type " + propertyInfo.GetType(), e);
                }
            }
        }

19 Source : DataFlowPipelineEngineFactory.cs
with GNU General Public License v3.0
from HicServices

private object CreateComponent(IPipelineComponent toBuild)
        {
            object toReturn = _constructor.Construct(toBuild.GetClreplacedreplacedystemType());

            //all the IArguments we need to initialize the clreplaced
            var allArguments = toBuild.GetAllArguments().ToArray();

            //get all possible properties that we could set on the underlying clreplaced
            foreach (var propertyInfo in toReturn.GetType().GetProperties())
            {
                SetPropertyIfDemanded(toBuild,toReturn,propertyInfo,allArguments);

                //see if any demand nested initialization
                Attribute nestedInit =
                    System.Attribute.GetCustomAttributes(propertyInfo)
                        .FirstOrDefault(a => a is DemandsNestedInitializationAttribute);

                //this one does
                if (nestedInit != null)
                {
                    // initialise the container before nesting-setting all properties
                    var container = Activator.CreateInstance(propertyInfo.PropertyType);

                    foreach (var nestedProp in propertyInfo.PropertyType.GetProperties())
                        SetPropertyIfDemanded(toBuild, container, nestedProp, allArguments, propertyInfo);

                    //use reflection to set the container
                    propertyInfo.SetValue(toReturn, container, null);
                }
            }

            return toReturn;
        }

19 Source : RuntimeTask.cs
with GNU General Public License v3.0
from HicServices

public void SetPropertiesForClreplaced(RuntimeArgumentCollection args, object toSetPropertiesOf)
        {
            if (toSetPropertiesOf == null)
                throw new NullReferenceException(ProcessTask.Path + " instance has not been created yet! Call SetProperties after the factory has created the instance.");
            
            if (UsefulStuff.IsreplacedignableToGenericType(toSetPropertiesOf.GetType(),typeof (IPipelineRequirement<>)))
                throw new Exception("ProcessTask '" + ProcessTask.Name + "' was was an instance of Clreplaced '" + ProcessTask.Path + "' which declared an IPipelineRequirement<>.  RuntimeTask clreplacedes are not the same as IDataFlowComponents, IDataFlowComponents can make IPipelineRequirement requests but RuntimeTasks cannot");

            //get all possible properties that we could set
            foreach (var propertyInfo in toSetPropertiesOf.GetType().GetProperties())
            {
                //see if any demand initialization
                Attribute initialization = System.Attribute.GetCustomAttributes(propertyInfo).FirstOrDefault(a => a is DemandsInitializationAttribute);

                //this one does
                if (initialization != null)
                {
                    try
                    {
                        //get the approrpriate value from arguments
                        var value = args.GetCustomArgumentValue(propertyInfo.Name, propertyInfo.PropertyType);

                        //use reflection to set the value
                        propertyInfo.SetValue(toSetPropertiesOf, value, null);
                    }
                    catch (NotSupportedException e)
                    {
                        throw new Exception("Clreplaced " + toSetPropertiesOf.GetType().Name + " has a property " + propertyInfo.Name +
                                            " but is of unexpected type " + propertyInfo.GetType(), e);
                    }
                    catch (KeyNotFoundException e)
                    {
                        throw new ArgumentException(
                          "Clreplaced " + toSetPropertiesOf.GetType().Name + " has a property " + propertyInfo.Name +
                          "marked with DemandsInitialization but no corresponding argument was provided in ArgumentCollection", e);
                    }
                }
            }
        }

19 Source : EntityDescriptor.cs
with MIT License
from iamoldli

private void SetColumns()
        {
            Columns = new ColumnDescriptorCollection();

            //加载属性列表
            var properties = new List<PropertyInfo>();
            foreach (var p in EnreplacedyType.GetProperties())
            {
                var type = p.PropertyType;
                if (type == typeof(TimeSpan) || (!type.IsGenericType || type.IsNullable()) && (type.IsGuid() || type.IsNullable() || Type.GetTypeCode(type) != TypeCode.Object)
                    && Attribute.GetCustomAttributes(p).All(attr => attr.GetType() != typeof(IgnoreAttribute)))
                {
                    properties.Add(p);
                }
            }

            foreach (var p in properties)
            {
                var column = new ColumnDescriptor(p, SqlAdapter);
                if (column.IsPrimaryKey)
                {
                    PrimaryKey = new PrimaryKeyDescriptor(p);
                    Columns.Insert(0, column);
                }
                else
                {
                    Columns.Add(column);
                }
            }
        }

19 Source : EntitasStats.cs
with MIT License
from jeffcampbellmakesgames

private static string[] GetContextNames(Type type)
		{
			return Attribute
				.GetCustomAttributes(type)
				.OfType<ContextAttribute>()
				.Select(attr => attr.contextName)
				.ToArray();
		}

19 Source : EntitasStats.cs
with MIT License
from jeffvella

static string[] getContextNames(Type type) {
            return Attribute
                .GetCustomAttributes(type)
                .OfType<ContextAttribute>()
                .Select(attr => attr.contextName)
                .ToArray();
        }

19 Source : SoftAssert.cs
with MIT License
from Magenic

public void CaptureTestMethodAttributes(MethodInfo testMethod)
        {
            foreach (var attr in Attribute.GetCustomAttributes(testMethod).Where(a => a is SoftreplacedertExpectedreplacedertsAttribute))
            {
                var expectedreplacedertAttribute = attr as SoftreplacedertExpectedreplacedertsAttribute;
                AddExpectedreplacederts(expectedreplacedertAttribute.ExpectedreplacedertKeys);
            }
        }

19 Source : RfcClient.cs
with MIT License
from metalsimyaci

private string GetRfcTableName<TEnreplacedy>()
        {
            Attribute[] attributes = Attribute.GetCustomAttributes(typeof(TEnreplacedy));
            RfcEnreplacedyAttribute attribute = (RfcEnreplacedyAttribute)attributes.FirstOrDefault(p => p is RfcEnreplacedyAttribute);

            return attribute?.Name ?? nameof(TEnreplacedy).ToUpperInvariant();
        }

19 Source : Scenario.cs
with MIT License
from migueldeicaza

public static string GetName (Type t) => ((ScenarioMetadata)System.Attribute.GetCustomAttributes (t) [0]).Name;

19 Source : Scenario.cs
with MIT License
from migueldeicaza

public static string GetDescription (Type t) => ((ScenarioMetadata)System.Attribute.GetCustomAttributes (t) [0]).Description;

19 Source : Scenario.cs
with MIT License
from migueldeicaza

public static string GetName (Type t) => ((ScenarioCategory)System.Attribute.GetCustomAttributes (t) [0]).Name;

19 Source : Scenario.cs
with MIT License
from migueldeicaza

public static List<string> GetCategories (Type t) => System.Attribute.GetCustomAttributes (t)
				.ToList ()
				.Where (a => a is ScenarioCategory)
				.Select (a => ((ScenarioCategory)a).Name)
				.ToList ();

19 Source : Scenario.cs
with MIT License
from migueldeicaza

internal static List<string> GetAllCategories ()
		{
			List<string> categories = new List<string> () { "All" };
			foreach (Type type in typeof (Scenario).replacedembly.GetTypes ()
			 .Where (myType => myType.IsClreplaced && !myType.IsAbstract && myType.IsSubclreplacedOf (typeof (Scenario)))) {
				List<System.Attribute> attrs = System.Attribute.GetCustomAttributes (type).ToList ();
				categories = categories.Union (attrs.Where (a => a is ScenarioCategory).Select (a => ((ScenarioCategory)a).Name)).ToList ();
			}
			return categories;
		}

19 Source : ReflectionMixIn.cs
with GNU General Public License v3.0
from Mutagen-Modding

public static bool TryGetCustomAttributeByName(this MemberInfo info, string name, [MaybeNullWhen(false)] out Attribute attr)
        {
            attr = Attribute.GetCustomAttributes(info).FirstOrDefault(a => IsNamed(a, name));
            return attr != null;
        }

19 Source : ReflectionMixIn.cs
with GNU General Public License v3.0
from Mutagen-Modding

public static IEnumerable<Attribute> GetCustomAttributesByName(this MemberInfo info, string name)
        {
            return Attribute.GetCustomAttributes(info).Where(a => IsNamed(a, name));
        }

19 Source : TypeMapInfoHelper.cs
with MIT License
from Mutuduxf

internal static TypeMapInfo GetTypeMapInfo(Type type)
        {
            return TypePropertyCache.GetOrAdd(type, _ =>
            {
                lock (type)
                {
                    var typeMapInfo = new TypeMapInfo
                    {
                        TableName =
                            Attribute.GetCustomAttributes(type).OfType<TableAttribute>().FirstOrDefault()?.Name ?? type.Name
                    };

                    var typeProperties = type.GetProperties().Where(p =>
                        !Attribute.GetCustomAttributes(p).OfType<NotMappedAttribute>().Any()).ToList();

                    typeMapInfo.IdPropertyInfo = typeProperties.FirstOrDefault(property =>
                        Attribute.GetCustomAttributes(property).OfType<KeyAttribute>().Any() ||
                        property.Name is "Id" or "ID" or "id" or "_id" ||
                        property.Name == $"{typeMapInfo.TableName}Id");

                    if (typeMapInfo.IdPropertyInfo is null)
                        throw new ArgumentException($"Can not find the id property in {nameof(type)}.");

                    typeMapInfo.IdColumnName = Attribute.GetCustomAttributes(typeMapInfo.IdPropertyInfo)
                                                   .OfType<ColumnAttribute>().FirstOrDefault()?.Name
                                               ?? typeMapInfo.IdPropertyInfo.Name;

                    typeMapInfo.PropertyColumnDict = typeProperties
                        .Where(property => property != typeMapInfo.IdPropertyInfo)
                        .ToDictionary(k => Attribute.GetCustomAttributes(k)
                                               .OfType<ColumnAttribute>().FirstOrDefault()?.Name
                                           ?? k.Name, v => v);

                    return typeMapInfo;
                }
            });
        }

19 Source : IwsdSpikeWindow2.cs
with MIT License
from naqtn

static void ExamCustomAttributes(MemberInfo info, System.Text.StringBuilder buf)
    {
        Attribute[] attributes = Attribute.GetCustomAttributes(info);
        foreach (Attribute att in attributes)
        {
            buf.Append("[");
            buf.Append(att.GetType().FullName);
            buf.Append("]");
        }
    }

See More Examples