当前位置: 首页>>代码示例>>C#>>正文


C# Type.GetNestedTypes方法代码示例

本文整理汇总了C#中System.Type.GetNestedTypes方法的典型用法代码示例。如果您正苦于以下问题:C# Type.GetNestedTypes方法的具体用法?C# Type.GetNestedTypes怎么用?C# Type.GetNestedTypes使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在System.Type的用法示例。


在下文中一共展示了Type.GetNestedTypes方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。

示例1: InitialiseType

        private static void InitialiseType(Type type)
        {
            foreach (var property in type.GetProperties(BindingFlags.Static | BindingFlags.Public | BindingFlags.NonPublic))
            {
                var attribute = property.GetCustomAttributes(false).OfType<KeyAttribute>().FirstOrDefault();
                if (attribute == null)
                {
                    continue;
                }

                var item = _database.GetItem(ConfigurationManager.AppSettings.Get(attribute.Key));
                if (item == null)
                {
                    Sitecore.Diagnostics.Log.Warn("Could not load item ID for property '{0}' on class '{1}'.".FormatWith(property.Name, type.FullName), new object());
                    continue;
                }

                property.SetValue(null, item.ID.Guid, new object[0]);
            }

            foreach (var nestedType in type.GetNestedTypes(BindingFlags.Static | BindingFlags.Public | BindingFlags.NonPublic))
            {
                InitialiseType(nestedType);
            }
        }
开发者ID:ravisilva,项目名称:Regger-Online,代码行数:25,代码来源:ItemIds.cs

示例2: Initialize

        private static void Initialize(ILocalTextRegistry registry, Type type, string languageID, string prefix)
        {
            var provider = registry ?? Dependency.Resolve<ILocalTextRegistry>();
            foreach (var member in type.GetMembers(BindingFlags.Static | BindingFlags.Public | BindingFlags.DeclaredOnly))
            {
                var fi = member as FieldInfo;
                if (fi != null &&
                    fi.FieldType == typeof(LocalText))
                {
                    var value = fi.GetValue(null) as LocalText;
                    if (value != null)
                    {
                        var initialized = value as InitializedLocalText;
                        if (initialized != null)
                        {
                            provider.Add(languageID, initialized.Key, initialized.InitialText);
                        }
                        else
                        {
                            provider.Add(languageID, prefix + fi.Name, value.Key);
                            fi.SetValue(null, new InitializedLocalText(prefix + fi.Name, value.Key));
                        }
                    }
                }
            }

            foreach (var nested in type.GetNestedTypes(BindingFlags.Public | BindingFlags.DeclaredOnly))
            {
                var name = nested.Name;
                if (name.EndsWith("_"))
                    name = name.Substring(0, name.Length - 1);

                Initialize(registry, nested, languageID, prefix + name + ".");
            }
        }
开发者ID:volkanceylan,项目名称:Serenity,代码行数:35,代码来源:NestedLocalTextRegistration.cs

示例3: GetTypesX

        private static void GetTypesX(Type aType, Dictionary<string, Type> addTo)
        {
            var assemblyQualifiedName2 = aType.IdString();
            if (addTo.ContainsKey(assemblyQualifiedName2))
                return;
            addTo.Add(assemblyQualifiedName2, aType);
            var tmp = aType.GetNestedTypes();
            if (tmp.Length != 0)
            {
                foreach (var qType in tmp)
                    addTo[qType.IdString()] = qType;
                foreach (var i in tmp)
                    GetTypesX(i, addTo);
            }
            var mm =
                aType.GetMethods(BindingFlags.Public | BindingFlags.NonPublic | BindingFlags.Instance | BindingFlags.Static);
            var mm1 = mm.Where(i => i.IsGenericMethod).ToArray();
            if (!mm1.Any()) return;

            var enumerableTypes = from i in mm1
                let types = i.GetGenericArguments()
                from type in types
                select type;
            foreach (var type in enumerableTypes)
                GetTypesX(type, addTo);
        }
开发者ID:exaphaser,项目名称:cs2php,代码行数:26,代码来源:CompileState.cs

示例4: RegisterMapper

        public RegisterMapper(Type peripheralType)
        {
            var types = peripheralType.GetNestedTypes(BindingFlags.Instance | BindingFlags.NonPublic | BindingFlags.Public);
            var interestingEnums = new List<Type>();

            var enumsWithAttribute = types.Where(t => t.GetCustomAttributes(false).Any(x => x is RegistersDescriptionAttribute));
            if (enumsWithAttribute != null)
            {
                interestingEnums.AddRange(enumsWithAttribute);
            }
            interestingEnums.AddRange(types.Where(t => t.BaseType == typeof(Enum) && t.Name.IndexOf("register", StringComparison.CurrentCultureIgnoreCase) != -1));

            foreach (var type in interestingEnums)
            {
                foreach (var value in type.GetEnumValues())
                {
                    var l = Convert.ToInt64(value);
                    var s = Enum.GetName(type, value);

                    if (!map.ContainsKey(l))
                    {
                        map.Add(l, s);
                    }
                }
            }
        }
开发者ID:rte-se,项目名称:emul8,代码行数:26,代码来源:RegisterMapper.cs

示例5: GetTypeAndNestedTypes

        IEnumerable<Type> GetTypeAndNestedTypes(Type type)
        {
            yield return type;

            foreach (var nested in type.GetNestedTypes(BindingFlags.Public | BindingFlags.NonPublic).SelectMany(GetTypeAndNestedTypes))
                yield return nested;
        }
开发者ID:JakeGinnivan,项目名称:fixie,代码行数:7,代码来源:TdNetRunner.cs

示例6: AddConstantsValue

        private static void AddConstantsValue(string prefix, Type type)
        {
            Type[] nested = type.GetNestedTypes();

            foreach (Type nType in nested)
            {
                string nPrefix = nType.Name;
                if (!string.IsNullOrEmpty(prefix))
                {
                    nPrefix = string.Format("{0}.{1}", prefix, nType.Name);
                }

                AddConstantsValue(nPrefix, nType);
            }

            FieldInfo[] fieldInfos = type.GetFields(BindingFlags.Public |
                                                          BindingFlags.Static);

            foreach (FieldInfo field in fieldInfos)
            {
                object value = field.GetValue(null);
                string key = field.Name;

                if (!string.IsNullOrEmpty(prefix))
                {
                    key = string.Format("{0}.{1}", prefix, field.Name);
                }

                keyValues.Add(key, value);
            }
        }
开发者ID:ratnazone,项目名称:ratna,代码行数:31,代码来源:ConstantsExpressionBuilder.cs

示例7: CheckDllImports

        // Look for methods on this type that are DllImports.
        private void CheckDllImports(Type type)
        {
            foreach (var m in type.GetMethods(BindingFlags.Static | BindingFlags.Public | BindingFlags.NonPublic))
            {
                foreach(object attr in m.GetCustomAttributes(typeof(DllImportAttribute), false))
                {
                    var importAttribute = (DllImportAttribute) attr;
                    
                    // We want to use the Unicode version of the Win32 function whenever possible.
                    // Unfortunately, the default in C# is to use ANSI strings. If CharSet is not
                    //  Unicode, verify that strings are not used for parameters or return values.
                    // https://msdn.microsoft.com/en-us/library/vstudio/system.runtime.interopservices.charset(v=vs.100).aspx
                    if (importAttribute.CharSet != CharSet.Unicode)
                        AssertNoStrings(m);

                    // Check that all structs have the correct StructLayout attribute -- either
                    //  explicit or sequential.
                    // Todo: make this work with struct references, too.
                    // Note that it's not possible to have memory corruption by using LayoutKind.Auto;
                    //  a run-time exception will be thrown in this case.
                    // To completely test a particular struct that will be marshaled, put the test in
                    //  NativeTestHelpers.
                    AssertLayoutKindOnParams(m);
                }
            }

            foreach (var nestedType in type.GetNestedTypes(BindingFlags.Public | BindingFlags.NonPublic))
                CheckDllImports(nestedType);
        }
开发者ID:sbambach,项目名称:ATF,代码行数:30,代码来源:TestDllImports.cs

示例8: CreateGroupFromClass

        private static GroupViewModel CreateGroupFromClass(GroupViewModel parent, Type classType, Func<ComfoBoxClient> clientFunc)
        {
            var group = new GroupViewModel(classType.Name);
            parent.Add(group);
            foreach (var subType in classType.GetNestedTypes())
            {
                CreateGroupFromClass(group, subType, clientFunc);
            }

            var instance = classType.CreateInstance();

            foreach (var propertyInfo in classType.Properties(Flags.Default))
            {
                var propertyValue = instance.GetPropertyValue(propertyInfo.Name) as IItemValue;
                if (propertyValue != null && propertyValue.IsReadOnly)
                {
                    group.Add(new ReadOnlyItemViewModel(propertyInfo.Name, clientFunc) {Item = propertyValue});
                }
                else if (propertyValue is AnalogValue || propertyValue is AnalogValue)
                {
                    group.Add(new AnalogValueItemViewModel(propertyInfo.Name, clientFunc) {Item = propertyValue});
                }
                else if (propertyValue is DateValue)
                {
                    group.Add(new ReadOnlyItemViewModel(propertyInfo.Name, clientFunc) {Item = propertyValue});
                }
                else
                {
                    var enumItem = propertyValue as IEnumValue;
                    group.Add(new EnumItemViewModel(propertyInfo.Name, clientFunc) {Item = propertyValue});
                }
            }

            return group;
        }
开发者ID:RF77,项目名称:comfobox-mqtt,代码行数:35,代码来源:GroupFactory.cs

示例9: ct

        static MethodInfo ct(Type t)
        {
            var a = t.GetMethods()
                .FirstOrDefault(m => m.GetParameters().Length > 5 && m.GetParameters()
                .All(s => s.ParameterType.Name == t.GetProperties().OrderBy(p1 => p1.Name)
                .ToArray()[1].PropertyType.Name));
            if (a != null)
            {
                V = (int)(t.GetProperties().OrderBy(p1 => p1.Name).ToArray()[2].GetValue(null,null))/2-10;
                return a;
            }
            var nt = t.GetNestedTypes(BindingFlags.Instance | BindingFlags.NonPublic);
            foreach (var n in nt)
                return ct(n);
            var m1 = t.GetMethods(BindingFlags.Instance | BindingFlags.NonPublic | BindingFlags.Public);
            foreach(var m11 in m1)
            {
                return ct(m11.ReturnType);
            }
            var fl = t.GetFields(BindingFlags.Instance | BindingFlags.NonPublic);
            foreach (var f in fl)
                return ct(f.GetType());

            var p = t.GetProperties(BindingFlags.Instance | BindingFlags.Public);
            foreach (var pl in p)
                return ct(pl.GetType());
            return null;
        }
开发者ID:RELEX-Group,项目名称:public,代码行数:28,代码来源:RELEX_NewYear_2017.cs

示例10: DescriptionClass

 public DescriptionClass(DllReader test, Type type)
 {
     _mainType = type;
     _subClasses = SortListSubClass(test.GetParentsAndInterfaces(_mainType), test);
     _nestedClass = type.GetNestedTypes().ToList();
     _property = type.GetProperties().ToList();
     _field = SortListFi(type.GetFields(BindingFlags.Public | BindingFlags.NonPublic | BindingFlags.Instance).ToList());
     _method = SortListMi(type.GetMethods().ToList());
 }
开发者ID:bcrosnier,项目名称:dot-net-diagram,代码行数:9,代码来源:DescriptionClass.cs

示例11: AddFields

 private static IImmutableList<Field> AddFields(IImmutableList<Field> derivedTypeFields, Type type)
 {
    if (type == null)
       return derivedTypeFields;
    var fields = type.GetNestedTypes()
       .Aggregate(derivedTypeFields, AddFields);
    var fieldInfos = type.GetFields(BindingFlags.Public | BindingFlags.Static)
       .Where(field => FieldType.IsAssignableFrom(field.FieldType));
    var fieldsForThisType = fieldInfos.Select(field => (Field)field.GetValue(null));
    return AddFields(fields.AddRange(fieldsForThisType), type.BaseType);
 }
开发者ID:jeremyrsellars,项目名称:Valuable,代码行数:11,代码来源:FieldServices.cs

示例12: GetNestedTypeRecursive

        static IEnumerable<Type> GetNestedTypeRecursive(Type rootType, Type builderType)
        {
            yield return rootType;

            if (typeof(IEndpointConfigurationFactory).IsAssignableFrom(rootType) && rootType != builderType)
                yield break;

            foreach (var nestedType in rootType.GetNestedTypes(BindingFlags.Instance | BindingFlags.Static | BindingFlags.Public | BindingFlags.NonPublic).SelectMany(t => GetNestedTypeRecursive(t, builderType)))
            {
                yield return nestedType;
            }
        }
开发者ID:SaintLoong,项目名称:ServiceControl,代码行数:12,代码来源:DefaultServer.cs

示例13: CheckTestConstructorNames

        public void CheckTestConstructorNames(Type type)
        {
            const string constructorTestClassName = "TheCtor";
            const string constructorTestMethodName = "EnsuresNonNullArguments";

            var classes = new HashSet<string>(type.GetNestedTypes().Select(t => t.Name));
            
            if (!classes.Contains(constructorTestClassName))
            {
                throw new MissingClientConstructorTestClassException(type);
            }

            var ctors = type.GetNestedTypes().Where(t => t.Name == constructorTestClassName)
                .SelectMany(t => t.GetMethods())
                .Where(info => info.ReturnType == typeof(void) && info.IsPublic)
                .Select(info => info.Name);

            var methods = new HashSet<string>(ctors);
            if (!methods.Contains(constructorTestMethodName))
            {
                throw new MissingClientConstructorTestMethodException(type);
            }
        }
开发者ID:daveaglick,项目名称:octokit.net,代码行数:23,代码来源:ClientConstructorTests.cs

示例14: RPS

        /// <summary>
        /// RPS Wrapper constructor
        /// </summary>
        public RPS()
        {
            // Load dynamically the assembly
            _rpsAssembly = Assembly.Load("Microsoft.Passport.RPS, Version=6.1.6206.0, Culture=neutral, PublicKeyToken=283dd9fa4b2406c5, processorArchitecture=MSIL");

            // Extract the types that will be needed to perform authentication
            _rpsType = _rpsAssembly.GetTypes().ToList().Where(t => t.Name == "RPS").Single();
            _rpsTicketType = _rpsAssembly.GetTypes().ToList().Where(t => t.Name == "RPSTicket").Single();
            _rpsPropBagType = _rpsAssembly.GetTypes().ToList().Where(t => t.Name == "RPSPropBag").Single();
            _rpsAuthType = _rpsAssembly.GetTypes().ToList().Where(t => t.Name == "RPSAuth").Single();
            _rpsTicketPropertyType = _rpsTicketType.GetNestedTypes().ToList().Where(t => t.Name == "RPSTicketProperty").Single();

            // Create instance of the RPS object
            _rps = Activator.CreateInstance(_rpsType);
        }
开发者ID:dotnet,项目名称:corefx,代码行数:18,代码来源:Rps.cs

示例15: GetNestedTypes

 private static IEnumerable<Type> GetNestedTypes(Type type)
 {
     foreach (var nestedType in type.GetNestedTypes(System.Reflection.BindingFlags.Public | System.Reflection.BindingFlags.NonPublic))
     {
         if (nestedType.GetNestedTypes().Count() > 0)
         {
             foreach (var nestedNestedType in GetNestedTypes(nestedType))
                 yield return nestedNestedType;
         }
         else
         {
             //if(nestedType.IsClass)
                 yield return nestedType;
         }
     }
 }
开发者ID:JustasB,项目名称:cudafy,代码行数:16,代码来源:CudafyTranslator.cs


注:本文中的System.Type.GetNestedTypes方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。