Пример #1
0
        public IActionResult EmailLayout()
        {
            var themes = EnumX.AllValues <Theme>();

            var languages = PlainText.AcceptedLanguages();

            var fakeUsers =
                from language in languages
                from theme in themes
                select fakeUser(language, theme);

            var result =
                from fakeUser in fakeUsers
                select getLayout(Format.MoveNotification(fakeUser))
                + getLayout(Format.SecurityAction(fakeUser, SecurityAction.PasswordReset))
                + getLayout(Format.SecurityAction(fakeUser, SecurityAction.UserVerification))
                + getLayout(Format.UserRemoval(fakeUser, RemovalReason.NoInteraction))
                + getLayout(Format.UserRemoval(fakeUser, RemovalReason.NotSignedContract))
                + getLayout(Format.WipeNotice(fakeUser, RemovalReason.NoInteraction))
                + getLayout(Format.WipeNotice(fakeUser, RemovalReason.NotSignedContract))
                + getLayout(Format.WipeNotice(fakeUser, RemovalReason.PersonAsked))
            ;

            return(View(result));
        }
Пример #2
0
 private void fill <T>(ParagraphType type)
 {
     foreach (var style in EnumX.All <T>())
     {
         var name    = style.ToString().ToLower();
         var charMap = new CharMap(type, name);
         Add(style, charMap);
     }
 }
Пример #3
0
        internal PairX(EnumX owner, bool autoExpand = false)
        {
            Owner = owner;
            if (autoExpand)
            {
                AutoExpandRight = true;
            }

            owner.Add(this);
        }
Пример #4
0
        public void GetValues_WhenCalled_ReturnEnumValues()
        {
            //Arrange
            var values = new[] { DummyEnum.Option1, DummyEnum.Option2, DummyEnum.Option3 };

            //Act
            var result = EnumX.GetValues <DummyEnum>();

            //Assert
            result.Should().Equal(values);
        }
Пример #5
0
 public IActionResult GetAds(string sort)
 {
     if (EnumX.TryParse <OrderAdBy>(sort ?? "", out var order))
     {
         var ads = _adService.Get(order);
         return(Ok(ads));
     }
     else
     {
         return(BadRequest());
     }
 }
Пример #6
0
        public void GetDictionary_WhenCalled_ReturnEnumTextValueDictionary()
        {
            //Arrange
            var dictionary = new Dictionary <string, DummyEnum>
            {
                { $"{DummyEnum.Option1}", DummyEnum.Option1 },
                { $"{DummyEnum.Option2}", DummyEnum.Option2 },
                { $"{DummyEnum.Option3}", DummyEnum.Option3 }
            };

            //Act
            var result = EnumX.GetDictionary <DummyEnum>();

            //Assert
            result.Should().Equal(dictionary);
        }
Пример #7
0
 public void LoadFromSaveData(InputActionContainer <TEnum> that)
 {
     saveData = that.saveData;
     foreach (var data in saveData)
     {
         TEnum enumVal;
         if (EnumX <TEnum> .GenericTryParse(data.action, out enumVal))
         {
             actionConfigCleanLookup[enumVal].LoadFrom(data);
             // Add more maps as needed
         }
         else
         {
             Debug.LogError("Unable to parse " + data.action + " as an input action");
         }
     }
 }
Пример #8
0
            public void UpdateSaveData(bool saveRebindable = false)
            {
                saveData.Clear();
                for (int i = 0; i < actionConfigCleanLookup.Count; ++i)
                {
                    TEnum enumVal = EnumX <TEnum> .FromInt(i);

                    if (!actionConfigCleanLookup[enumVal].properties.rebindable && !saveRebindable)
                    {
                        continue;
                    }

                    var newItem = new InputAction.SaveData();
                    actionConfigCleanLookup[enumVal].SaveTo(enumVal.ToString(), newItem);

                    saveData.Add(newItem);
                }
            }
Пример #9
0
        public Service(String task)
        {
            this.task = EnumX.Parse <Task>(task);

            TZ.Init(false);

            service = new ServiceAccess(getTicket, getSite);

            if (this.task != Task.Check)
            {
                service.Current.Set(Cfg.RobotEmail, Cfg.RobotPassword, false);
            }

            if (this.task == Task.Wipe)
            {
                s3 = new S3();
            }
        }
Пример #10
0
        private static IDictionary <String, EmailType> chargeTypes()
        {
            var types = new Dictionary <String, EmailType>
            {
                { EmailType.MoveNotification.ToString(), EmailType.MoveNotification },
            };

            EnumX.AllExcept(SecurityAction.UnsubscribeMoveMail)
            .ForEach(
                sa => types.Add(sa.ToString(), EmailType.SecurityAction)
                );

            EnumX.AllValues <RemovalReason>()
            .ForEach(
                rr => types.Add(rr.ToString(), EmailType.RemovalReason)
                );

            types.Add(
                EmailType.WipeNotice.ToString(),
                EmailType.WipeNotice
                );

            var langs = PlainText.AcceptedLanguages();
            var keys  = types.Keys.ToList();

            foreach (var key in keys)
            {
                var value = types[key];
                types.Remove(key);

                foreach (var lang in langs)
                {
                    var newKey = PlainText.Email[key, lang, "Subject"];
                    types.Add(newKey, value);
                }
            }

            return(types);
        }
        public string GetDescription(T code)
        {
            EnumX <T> e = codes.Where(c => c.Code.Equals(code)).FirstOrDefault();

            return(e is null ? "Undefined" : e.Description);
        }
Пример #12
0
 public void GivenIHaveTheseThemes()
 {
     themes = EnumX.AllValues <Theme>();
 }
Пример #13
0
 public void GivenIHaveTheseEmailTypes()
 {
     emailTypes = EnumX.AllValues <EmailType>();
 }
Пример #14
0
 public ConfigsThemeModel()
 {
     NewTheme       = Theme;
     BrightnessList = EnumX.AllExcept(ThemeBrightness.None);
     ColorList      = EnumX.AllExcept(ThemeColor.None);
 }
Пример #15
0
        public NativeConstructor(Type type, IGlobal global, JsObject PrototypePrototype, JsObject prototype) :
            base(global, prototype)
        {
            if (type == null)
            {
                throw new ArgumentNullException("type");
            }

            if (type.IsGenericType && type.ContainsGenericParameters)
            {
                throw new InvalidOperationException("A native constructor can't be built against an open generic");
            }

            m_marshaller = global.Marshaller;

            reflectedType = type;
            Name          = type.FullName;

            if (!type.IsAbstract)
            {
                m_constructors = type.GetConstructors();
            }

            DefineOwnProperty(PROTOTYPE, PrototypePrototype == null ? Global.ObjectClass.New(this) : Global.ObjectClass.New(this, PrototypePrototype), PropertyAttributes.DontEnum | PropertyAttributes.DontDelete | PropertyAttributes.ReadOnly);

            m_overloads = new NativeOverloadImpl <ConstructorInfo, ConstructorImpl>(
                m_marshaller,
                new NativeOverloadImpl <ConstructorInfo, ConstructorImpl> .GetMembersDelegate(this.GetMembers),
                new NativeOverloadImpl <ConstructorInfo, ConstructorImpl> .WrapMmemberDelegate(this.WrapMember)
                );

            // if this is a value type, define a default constructor
            if (type.IsValueType)
            {
                m_overloads.DefineCustomOverload(
                    new Type[0],
                    new Type[0],
                    (ConstructorImpl)Delegate.CreateDelegate(
                        typeof(ConstructorImpl),
                        typeof(NativeConstructor).GetMethod("CreateStruct", BindingFlags.NonPublic | BindingFlags.Static).MakeGenericMethod(type)
                        )
                    );
            }

            // now we should find all static members and add them as a properties

            // members are grouped by their names
            Dictionary <string, LinkedList <MethodInfo> > members = new Dictionary <string, LinkedList <MethodInfo> >();

            foreach (var info in type.GetMethods(System.Reflection.BindingFlags.Static | System.Reflection.BindingFlags.Public))
            {
                if (info.ReturnType.IsByRef)
                {
                    continue;
                }
                if (!members.ContainsKey(info.Name))
                {
                    members[info.Name] = new LinkedList <MethodInfo>();
                }

                members[info.Name].AddLast(info);
            }

            // add the members to the object
            foreach (var pair in members)
            {
                DefineOwnProperty(pair.Key, ReflectOverload(pair.Value));
            }

            // find and add all static properties and fields
            foreach (var info in type.GetProperties(BindingFlags.Static | BindingFlags.Public))
            {
                DefineOwnProperty(Global.Marshaller.MarshalPropertyInfo(info, this));
            }

            foreach (var info in type.GetFields(BindingFlags.Static | BindingFlags.Public))
            {
                DefineOwnProperty(Global.Marshaller.MarshalFieldInfo(info, this));
            }

            if (type.IsEnum)
            {
                string[] names  = EnumX.GetNames(type);
                object[] values = new object[names.Length];
                EnumX.GetValues(type).CopyTo(values, 0);

                for (int i = 0; i < names.Length; i++)
                {
                    DefineOwnProperty(names[i], Global.ObjectClass.New(values[i], PrototypeProperty));
                }
            }

            // find all nested types
            foreach (var info in type.GetNestedTypes(BindingFlags.Public))
            {
                DefineOwnProperty(info.Name, Global.Marshaller.MarshalClrValue(info), PropertyAttributes.DontEnum);
            }

            // find all instance properties and fields
            LinkedList <MethodInfo> getMethods = new LinkedList <MethodInfo>();
            LinkedList <MethodInfo> setMethods = new LinkedList <MethodInfo>();

            foreach (var info in type.GetProperties(System.Reflection.BindingFlags.Instance | System.Reflection.BindingFlags.Public))
            {
                ParameterInfo[] indexerParams = info.GetIndexParameters();
                if (indexerParams == null || indexerParams.Length == 0)
                {
                    m_properties.AddLast(global.Marshaller.MarshalPropertyInfo(info, this));
                }
                else if (info.Name == "Item" && indexerParams.Length == 1)
                {
                    if (info.CanRead)
                    {
                        getMethods.AddLast(info.GetGetMethod());
                    }
                    if (info.CanWrite)
                    {
                        setMethods.AddLast(info.GetSetMethod());
                    }
                }
            }

            if (getMethods.Count > 0 || setMethods.Count > 0)
            {
                MethodInfo[] getters = new MethodInfo[getMethods.Count];
                getMethods.CopyTo(getters, 0);
                MethodInfo[] setters = new MethodInfo[setMethods.Count];
                setMethods.CopyTo(setters, 0);

                m_indexer = new NativeIndexer(m_marshaller, getters, setters);
            }

            if (reflectedType.IsArray)
            {
                m_indexer = (INativeIndexer)typeof(NativeArrayIndexer <>)
                            .MakeGenericType(reflectedType.GetElementType())
                            .GetConstructor(new Type[] { typeof(Marshaller) })
                            .Invoke(new object[] { m_marshaller });
            }

            foreach (var info in type.GetFields(System.Reflection.BindingFlags.Instance | System.Reflection.BindingFlags.Public))
            {
                m_properties.AddLast(global.Marshaller.MarshalFieldInfo(info, this));
            }
        }