Exemplo n.º 1
0
        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);
            }
        }
        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 + ".");
            }
        }
Exemplo n.º 3
0
        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);
        }
Exemplo n.º 4
0
        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);
                    }
                }
            }
        }
Exemplo n.º 5
0
        IEnumerable<Type> GetTypeAndNestedTypes(Type type)
        {
            yield return type;

            foreach (var nested in type.GetNestedTypes(BindingFlags.Public | BindingFlags.NonPublic).SelectMany(GetTypeAndNestedTypes))
                yield return nested;
        }
Exemplo n.º 6
0
        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);
            }
        }
Exemplo n.º 7
0
        // 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);
        }
Exemplo n.º 8
0
        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;
        }
Exemplo n.º 9
0
        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;
        }
Exemplo n.º 10
0
 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());
 }
Exemplo n.º 11
0
 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);
 }
Exemplo n.º 12
0
        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;
            }
        }
        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);
            }
        }
Exemplo n.º 14
0
Arquivo: Rps.cs Projeto: dotnet/corefx
        /// <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);
        }
Exemplo n.º 15
0
 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;
         }
     }
 }
        public static object Convert(this object obj, Type type)
        {
            try
            {
                if (obj is string && !type.GetNestedTypes().Any(t => t == typeof(ValueType)))
                    return new JsonSerializer().Deserialize(new JsonTextReader(new StringReader((string)obj)), type);
            }
            catch(JsonReaderException)
            {
                var serializedResult = new StringBuilder();
                new JsonSerializer().Serialize(new StringWriter(serializedResult), obj);
                return new JsonSerializer().Deserialize(new JsonTextReader(new StringReader(serializedResult.ToString())), type);
            }

            return obj;
        }
Exemplo n.º 17
0
        void LoadSettingsFromClass(ConfigFile configFile, Type settingsClass, string sectionName)
        {
            foreach (FieldInfo fieldInfo in settingsClass.GetFields())
            {
                if (fieldInfo.FieldType == typeof(Dictionary<string, string>))
                {
                    Dictionary<string, string> dict = new Dictionary<string, string>();
                    var section = configFile.GetSection(sectionName);

                    foreach (var property in section.GetProperties())
                    {
                        var value = section.GetValue(property, "");
                        if (dict.ContainsKey(property))
                        {
                            dict.Add(property, value);
                        }
                        else
                        {
                            dict[property] = value;
                        }
                    }

                    fieldInfo.SetValue(null, dict);
                }
                else if (configFile.HasProperty(sectionName, fieldInfo.Name))
                {
                    string stringValue = configFile.GetValue(sectionName, fieldInfo.Name, "");
                    object value = StringConverter.Parse(stringValue, fieldInfo.FieldType);

                    fieldInfo.SetValue(null, value);
                }
            }

            foreach (Type nestedType in settingsClass.GetNestedTypes())
            {
                string newSectionName = sectionName;
                if (newSectionName.Length > 0)
                {
                    newSectionName += ".";
                }
                newSectionName += nestedType.Name;

                LoadSettingsFromClass(configFile, nestedType, newSectionName);
            }
        }
Exemplo n.º 18
0
        public static ArrayList    GetNestedTypes(Type type, bool inherit)
        {
            //GetNestedTypes: 
            //  "This method returns only the nested types of the current type. 
            //   It does not search the hierarchy of inherited types. 
            //   To find types that are nested in inherited types, you must walk the inheritance hierarchy."
            ArrayList types = new ArrayList();
            
            //Recurse
            if(inherit && type.BaseType != null)
                types = GetNestedTypes(type.BaseType, inherit);

            //Nested Types
            foreach(Type t in type.GetNestedTypes())
                types.Add(t);

            return types;
        }
        static IEnumerable<Type> GetNestedTypeRecursive(Type rootType, Type builderType)
        {
            if (rootType == null)
            {
                throw new InvalidOperationException("Make sure you nest the endpoint infrastructure inside the TestFixture as nested classes");
            }

            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;
            }
        }
Exemplo n.º 20
0
        public BlackAction ActivateActionCore(Type controllerType, string actionName)
        {
            if (controllerType == null)
                throw new ArgumentNullException ("controllerType");
            if (actionName == null)
                throw new ArgumentNullException ("actionName");
            var controllerInstance = (Controller)Activator.CreateInstance (controllerType);

            var actionType = (from nt in controllerType.GetNestedTypes ()
                where nt.Name == actionName
                select nt).FirstOrDefault ();
            if (actionType == null)
                throw new BlackException (string.Format ("No type for action '{0}' was found in controller '{1}'", actionName, controllerType.AssemblyQualifiedName), null);

            var actionInstance = (BlackAction)Activator.CreateInstance (actionType);
            controllerInstance.own (actionInstance);
            actionInstance.loadFilters ();
            return actionInstance;
        }
Exemplo n.º 21
0
 static List<Type> GetSubTypes(Type T, BindingFlags flags, bool recurse, bool Protected = false, bool Private = false)
 {
     List<Type> retSet = new List<Type>();
     if (Protected || Private) flags = flags | BindingFlags.NonPublic;
     Type[] tmp = T.GetNestedTypes(flags);
     foreach (Type t in tmp)
     {
         if (t.IsPublic || (Protected && t.IsNotPublic && t.IsNestedFamily) || (Private && t.IsNotPublic && !t.IsNestedAssembly))
             retSet.Add(t);
     }
     if (recurse)
     {
         foreach (Type t in retSet)
         {
             retSet.AddRange(GetSubTypes(t, flags, recurse, Protected, Private));
         }
     }
     return retSet;
 }
		void InitMembers(Type type)
		{
			foreach (Type nestedType in type.GetNestedTypes(flags)) {
				// We cannot use nestedType.IsVisible - that only checks for public types,
				// but we also need to load protected types.
				if (nestedType.IsNestedPublic || nestedType.IsNestedFamily || nestedType.IsNestedFamORAssem) {
					string name = this.FullyQualifiedName + "." + nestedType.Name;
					InnerClasses.Add(new ReflectionClass(CompilationUnit, nestedType, name, this));
				}
			}
			
			foreach (FieldInfo field in type.GetFields(flags)) {
				if (!field.IsPublic && !field.IsFamily && !field.IsFamilyOrAssembly) continue;
				if (!field.IsSpecialName) {
					Fields.Add(new ReflectionField(field, this));
				}
			}
			
			foreach (PropertyInfo propertyInfo in type.GetProperties(flags)) {
				ReflectionProperty prop = new ReflectionProperty(propertyInfo, this);
				if (prop.IsPublic || prop.IsProtected)
					Properties.Add(prop);
			}
			
			foreach (ConstructorInfo constructorInfo in type.GetConstructors(flags)) {
				if (!constructorInfo.IsPublic && !constructorInfo.IsFamily && !constructorInfo.IsFamilyOrAssembly) continue;
				Methods.Add(new ReflectionMethod(constructorInfo, this));
			}
			
			foreach (MethodInfo methodInfo in type.GetMethods(flags)) {
				if (!methodInfo.IsPublic && !methodInfo.IsFamily && !methodInfo.IsFamilyOrAssembly) continue;
				if (!methodInfo.IsSpecialName) {
					Methods.Add(new ReflectionMethod(methodInfo, this));
				}
			}
			this.AddDefaultConstructorIfRequired = (this.ClassType == ClassType.Struct || this.ClassType == ClassType.Enum);
			
			foreach (EventInfo eventInfo in type.GetEvents(flags)) {
				Events.Add(new ReflectionEvent(eventInfo, this));
			}
		}
Exemplo n.º 23
0
        public static void ScanType(Type type)
        {
            foreach(Type nestedType in type.GetNestedTypes())
                ScanType(nestedType);

            LispCustomSerializerAttribute customSerializer =
                (LispCustomSerializerAttribute)
                Attribute.GetCustomAttribute(type, typeof(LispCustomSerializerAttribute));
            if(customSerializer != null) {
                object instance = CreateObject(type);
                typeSerializers.Add(customSerializer.Type, (ILispSerializer) instance);
                return;
            }

            LispRootAttribute rootAttrib = (LispRootAttribute)
                Attribute.GetCustomAttribute(type, typeof(LispRootAttribute));
            if(rootAttrib != null) {
                LispRootSerializer serializer = new LispRootSerializer(type);
                typeSerializers.Add(type, serializer);
                return;
            }
        }
Exemplo n.º 24
0
 private static void CheckType(Type type)
 {
     foreach (MemberInfo member in type.GetMembers(memberFlags))
     {
         MethodBase mb = member as MethodBase;
         if (mb != null && member.DeclaringType == type)
         {
             CheckMethodBase(mb);
         }
     }   
     CheckUsedType(type.BaseType);
     foreach (Type ifc in type.GetInterfaces())
     {
         if (ifc.DeclaringType == type)
         {
             CheckUsedType(ifc);
         }
     }
     foreach (Type nestedType in type.GetNestedTypes(nextedFlags))
     {
         CheckType(nestedType);
     }
 }
Exemplo n.º 25
0
		void InitMembers(Type type)
		{
			foreach (Type nestedType in type.GetNestedTypes(flags)) {
				if (!nestedType.IsVisible) continue;
				string name = nestedType.FullName.Replace('+', '.');
				InnerClasses.Add(new ReflectionClass(CompilationUnit, nestedType, name, this));
			}
			
			foreach (FieldInfo field in type.GetFields(flags)) {
				if (!field.IsPublic && !field.IsFamily) continue;
				if (!field.IsSpecialName) {
					Fields.Add(new ReflectionField(field, this));
				}
			}
			
			foreach (PropertyInfo propertyInfo in type.GetProperties(flags)) {
				ReflectionProperty prop = new ReflectionProperty(propertyInfo, this);
				if (prop.IsPublic || prop.IsProtected)
					Properties.Add(prop);
			}
			
			foreach (ConstructorInfo constructorInfo in type.GetConstructors(flags)) {
				if (!constructorInfo.IsPublic && !constructorInfo.IsFamily) continue;
				Methods.Add(new ReflectionMethod(constructorInfo, this));
			}
			
			foreach (MethodInfo methodInfo in type.GetMethods(flags)) {
				if (!methodInfo.IsPublic && !methodInfo.IsFamily) continue;
				if (!methodInfo.IsSpecialName) {
					Methods.Add(new ReflectionMethod(methodInfo, this));
				}
			}
			
			foreach (EventInfo eventInfo in type.GetEvents(flags)) {
				Events.Add(new ReflectionEvent(eventInfo, this));
			}
		}
Exemplo n.º 26
0
		public ClassDetail(RootDetail parent, Type type)
			: base(parent, type, false)
		{
			BindingFlags flags = BindingFlags.Instance | BindingFlags.Static | BindingFlags.Public | BindingFlags.NonPublic;
			Type[] types = type.GetNestedTypes(flags);

			_category = "class";

			foreach (Type nested in types)
			{
				if (nested.IsEnum)
				{
					_children.Add(new EnumDetail(this, nested));
				}
				else if (nested.IsInterface)
				{
					_children.Add(new InterfaceDetail(this, nested));
				}
				else if (nested.IsClass)
				{
					_children.Add(new ClassDetail(this, nested));
				}
			}
		}
Exemplo n.º 27
0
            protected MemberGroup/*!*/ GetMember(Type/*!*/ type, string/*!*/ name, BindingFlags flags) {
                Assert.NotNull(type, name);

                MemberInfo[] foundMembers = type.GetMember(name, BindingFlags.Public | BindingFlags.Static | BindingFlags.Instance | flags);

                if (!Binder.DomainManager.Configuration.PrivateBinding) {
                    foundMembers = CompilerHelpers.FilterNonVisibleMembers(type, foundMembers);
                }

                MemberGroup members = new MemberGroup(foundMembers);

                // check for generic types w/ arity...
                Type[] types = type.GetNestedTypes(BindingFlags.Public | flags);
                string genName = name + ReflectionUtils.GenericArityDelimiter;
                List<Type> genTypes = null;
                foreach (Type t in types) {
                    if (t.Name.StartsWith(genName)) {
                        if (genTypes == null) genTypes = new List<Type>();
                        genTypes.Add(t);
                    }
                }

                if (genTypes != null) {
                    List<MemberTracker> mt = new List<MemberTracker>(members);
                    foreach (Type t in genTypes) {
                        mt.Add(MemberTracker.FromMemberInfo(t));
                    }

                    return new MemberGroup(mt.ToArray());
                }

                if (members.Count == 0) {
                    if ((flags & BindingFlags.DeclaredOnly) == 0) {
                        members = Binder.GetAllExtensionMembers(type, name);
                    } else {
                        members = Binder.GetExtensionMembers(type, name);
                    }
                }

                return members;
            }
Exemplo n.º 28
0
        private void AddKnownType(Type type)
        {
            Guard.AgainstNull(type, "type");

            if (HasKnownType(type))
            {
                return;
            }

            lock (padlock)
            {
                if (HasKnownType(type))
                {
                    return;
                }

                knownTypes.Add(type);

                foreach (var nested in type.GetNestedTypes(BindingFlags.Public | BindingFlags.NonPublic))
                {
                    if (!HasKnownType(nested))
                    {
                        AddKnownType(nested);
                    }
                }

                ResetSerializers();
            }
        }
Exemplo n.º 29
0
 private static void AddNestedTypesRecursively(List<Type> types, Type type)
 {
   Type[] nestedTypes = type.GetNestedTypes(BindingFlags.Public);
   foreach (Type nestedType in nestedTypes)
   {
     types.Add(nestedType);
     AddNestedTypesRecursively(types, nestedType);
   }
 }
Exemplo n.º 30
0
        private void SearchMusicAndSounds(Type contentType)
        {
            // Search all fields
            FieldInfo[] fields = contentType.GetFields();
            foreach (FieldInfo field in fields)
            {
                if (field.FieldType == typeof(string))
                {
                    string fieldValue = (string)field.GetValue(null);
                    if (!string.IsNullOrEmpty(fieldValue)
                         && (Path.GetExtension(fieldValue) == ".wav" || Path.GetExtension(fieldValue) == ".mp3")
                        )
                    {
                        this.audioPaths.Add(field.Name, fieldValue);
                    }
                }
            }

            // Search child classes
            Type[] types = contentType.GetNestedTypes();
            foreach (Type type in types)
            {
                this.SearchMusicAndSounds(type);
            }
        }