예제 #1
0
		public static ObjectWrapper CreateFromObject (TypeRegistry registry, ClassWrapper clazz, object obj)
		{
			Type type = obj.GetType ();
			ObjectWrapper wrapper = new ObjectWrapper (clazz, obj);
			foreach (MemberInfo info in type.GetMembers (BindingFlags.Instance | BindingFlags.Public)) {
				switch (info.MemberType) {
				case MemberTypes.Method:
					if (!wrapper.HasAttribute (info.Name)) {
						wrapper.SetAttribute (info.Name, CreateMultiMethod (registry, type, obj,
							info.Name));
					}
					break;
				case MemberTypes.Field:
					wrapper.SetAttribute (info.Name, FieldWrapper.Create (registry, (FieldInfo)info,
						obj));
					break;
				case MemberTypes.Property:
					wrapper.SetAttribute (info.Name, PropertyWrapper.Create (registry, (PropertyInfo)info,
						obj));
					break;
				}
			}
			return wrapper;
		}