Пример #1
0
        public static ITweakable MakeTweakable(TweakableAttribute attribute, Type type, MemberInfo memberInfo, IBoundInstance instance, MemberInfo containerMemberInfo = null)
        {
            Type                  type2       = typeof(TweakableInfo <>).MakeGenericType(type);
            uint                  num         = instance?.UniqueId ?? 0;
            MemberInfo            memberInfo2 = ((containerMemberInfo != null) ? containerMemberInfo : memberInfo);
            TweakerRangeAttribute attribute2  = memberInfo2.GetCustomAttributes(typeof(TweakerRangeAttribute), inherit: false).FirstOrDefault() as TweakerRangeAttribute;
            StepSizeAttribute     attribute3  = memberInfo2.GetCustomAttributes(typeof(StepSizeAttribute), inherit: false).FirstOrDefault() as StepSizeAttribute;

            NamedToggleValueAttribute[] source = memberInfo2.GetCustomAttributes(typeof(NamedToggleValueAttribute), inherit: false) as NamedToggleValueAttribute[];
            ICustomTweakerAttribute[]   array  = memberInfo2.GetCustomAttributes(typeof(ICustomTweakerAttribute), inherit: true) as ICustomTweakerAttribute[];
            source = source.OrderBy((NamedToggleValueAttribute toggle) => toggle.Order).ToArray();
            object        obj           = MakeTweakableRange(type, attribute2);
            object        obj2          = MakeTweakableStepSize(type, attribute3, attribute.Name);
            Array         array2        = MakeTweakableToggleValues(type, source);
            WeakReference weakReference = null;

            if (instance != null)
            {
                weakReference = new WeakReference(instance.Instance);
            }
            string finalName = GetFinalName(attribute.Name, instance);
            object obj3      = Activator.CreateInstance(type2, finalName, obj, obj2, array2, num, array, attribute.Description);
            Type   type3     = typeof(BaseTweakable <>).MakeGenericType(type);

            return(Activator.CreateInstance(type3, obj3, memberInfo, weakReference) as ITweakable);
        }
Пример #2
0
 public static ITweakable MakeTweakable(TweakableAttribute attribute, FieldInfo fieldInfo, IBoundInstance instance, MemberInfo containerMemberInfo = null)
 {
     return(MakeTweakable(attribute, fieldInfo.FieldType, fieldInfo, instance, containerMemberInfo));
 }
Пример #3
0
 public static ITweakable MakeTweakable(TweakableAttribute attribute, PropertyInfo propertyInfo, IBoundInstance instance, MemberInfo containerMemberInfo = null)
 {
     return(MakeTweakable(attribute, propertyInfo.PropertyType, propertyInfo, instance, containerMemberInfo));
 }