public void Serialize() { // Assign var serializer = new JsonFeatureToggleSerializer(); var condition = Allow.Simple() .Or(Allow.FromDateTime(new DateTime(2019, 05, 16, 15, 0, 0, DateTimeKind.Utc)) .And(Allow.UntilDateTime(new DateTime(2019, 05, 17, 15, 0, 0, DateTimeKind.Utc))) .And(Restrict.DayOfWeek(DayOfWeek.Wednesday)) .And(Restrict.Installation("SAMPLE_INSTALLATION#2")) .And(Restrict.User("USER#2")) .And(Allow.DaysOfWeek(DayOfWeek.Monday, DayOfWeek.Tuesday, DayOfWeek.Thursday, DayOfWeek.Friday, DayOfWeek.Saturday, DayOfWeek.Sunday)) .And(Allow.Installation("SAMPLE_INSTALLATION#1")) .And(Allow.User("USER#1")) .And(Restrict.Simple()) .And(Allow.FromTimeOfDay(new TimeSpan(15, 0, 0))) .And(Allow.UntilTimeOfDay(new TimeSpan(16, 0, 0))) ); var featureToggle = new FeatureToggle(); featureToggle.FeatureName = "MyFeature"; featureToggle.Condition = condition; // Act var serialized = serializer.Serialize(featureToggle); // Assert // Assert correctly. Don't read the expected from the static variable but from a static file }
public IEnumerable <AccessRule> GetAcls(string resource, string verb) { OrderedList <string, AccessRule> acls = new OrderedList <string, AccessRule>(); foreach (KeyValuePair <string, IAclProvider> provider in GetConcernedProviders(resource)) { foreach (AccessRule acl in provider.Value.GetAcls(provider.Key == AclManager.ROOT ? resource : resource.Substring(provider.Key.Length), verb)) { AccessRule computedAcl = null; switch (acl.Type) { case AccessRules.Allow: computedAcl = new Allow(acl.Resource == AclManager.ROOT ? provider.Key : provider.Key + acl.Resource, acl.Verb, acl.Subject); break; case AccessRules.Deny: computedAcl = new Deny(acl.Resource == AclManager.ROOT ? provider.Key : provider.Key + acl.Resource, acl.Verb, acl.Subject); break; } if (computedAcl != null) { acls.Add(computedAcl.Resource, computedAcl); } } } return(acls); }
public DistributorRole ToDistributorRole() { return(new DistributorRole( Allow.Aggregate(Role.None, (aggregate, role) => aggregate | role), Deny.Aggregate(Role.None, (aggregate, role) => aggregate | role), IsAuthorizationRequired, FeedRoles?.ToDictionary(x => x.Key, x => x.Value.ToFeedRole(x.Key)))); }
public void ConstructorShouldThrowExceptionWhenRightOperandIsNull() { // Arrange // Act // Assert Assert.Throws <ArgumentNullException>(() => new OrCondition(Allow.Simple(), null)); }
public void ConstructorShouldThrowExceptionWhenLeftOperandIsNull() { // Arrange // Act // Assert Assert.Throws <ArgumentNullException>(() => new AndCondition(null, Allow.Simple())); }
public InteractorRole ToInteractorRole(string host, string user) { var expandedHost = Environment.ExpandEnvironmentVariables(host); return(new InteractorRole( expandedHost, user, Allow.Aggregate(Role.None, (aggregate, role) => aggregate | role), Deny.Aggregate(Role.None, (aggregate, role) => aggregate | role))); }
/// <summary> /// Inicializa os mecanismos de animação. É executado /// quando a classe for atribuida a propriedade do componente /// </summary> public override void Attach(Control parent) { Visibility.Attach(parent); Allow.Attach(parent); Text.Attach(parent); Visibility.Execute(); Allow.Execute(); Text.Execute(); }
public FeedRole ToFeedRole(string feed) { return(new FeedRole( feed, Allow.Aggregate(Role.None, (aggregate, role) => aggregate | role), Deny.Aggregate(Role.None, (aggregate, role) => aggregate | role), IsAuthorized, IsImpersonationAllowed, IsProxyAllowed, InteractorRoles?.SelectMany(x => x.Value.Select(y => y.Value.ToInteractorRole(x.Key, y.Key)))?.ToList())); }
public void ConditionHoldsShouldReturnFalseWhenRightOperandIsFalse() { // Arrange var condition = Allow.Simple().And(Restrict.Simple()); var context = new Context(null, null, null); // Act var conditionHolds = condition.Holds(context); // Assert Assert.False(conditionHolds); }
public void ConditionHoldsShouldReturnTrueWhenBothOperandsAreTrue() { // Arrange var condition = Allow.Simple().And(Allow.Simple()); var context = new Context(null, null, null); // Act var conditionHolds = condition.Holds(context); // Assert Assert.True(conditionHolds); }
public void ConditionHoldsShouldReturnTrueWhenRightOperandIsTrue() { // Arrange var condition = Restrict.Simple().Or(Allow.Simple()); var context = new Context(null, null, null); // Act var conditionHolds = condition.Holds(context); // Assert Assert.True(conditionHolds); }
/// <summary> /// 验证文件是否为允许的格式 /// </summary> /// <param name="fileName"></param> /// <returns></returns> public virtual bool VerifyFileType(string fileName) { string ext = Regex.Match(fileName, "\\.[^\\.]+$").Value; if (string.IsNullOrEmpty(ext)) { return(false); } ext = ext.Substring(1); string exts = "(" + Allow.Replace(",", ")|(") + ")"; return(exts.IndexOf("(" + ext + ")", StringComparison.OrdinalIgnoreCase) != -1); }
public bool HasRole(Role role, bool decision) { if (Allow.HasFlag(role)) { decision = true; } if (Deny.HasFlag(role)) { decision = false; } return(decision); }
private bool?GetBit(PermissionsBits pos) { if (Allow.GetBit(pos)) { return(true); } else if (Deny.GetBit(pos)) { return(false); } else { return(null); } }
public OverwrittenPermissionState GetPermissionState(DiscordPermission permission) { if (Allow.HasFlag(permission)) { return(OverwrittenPermissionState.Allow); } else if (Deny.HasFlag(permission)) { return(OverwrittenPermissionState.Deny); } else { return(OverwrittenPermissionState.Inherit); } }
public bool HasRole(string host, string user, string feed, Role role, bool decision) { if (Allow.HasFlag(role)) decision = true; if (Deny.HasFlag(role)) decision = false; if (InteractorRoles.TryGetValue(new InteractorRole.Key(host, user), out var interactorRole)) decision = interactorRole.HasRole(role, decision); else if (InteractorRoles.TryGetValue(new InteractorRole.Key("*", user), out interactorRole)) decision = interactorRole.HasRole(role, decision); return decision; }
/// <summary> /// Dispose the robots file /// </summary> protected virtual void Dispose(bool disposable) { foreach (var state in Allow.States.Keys) { state.Dispose(); } foreach (var state in Disallow.States.Keys) { state.Dispose(); } Disallow.Dispose(); Allow.Dispose(); }
protected WebPart () { verbs = new WebPartVerbCollection(); allow = Allow.Close | Allow.Connect | Allow.Edit | Allow.Hide | Allow.Minimize | Allow.ZoneChange; auth_filter = ""; catalog_icon_url = ""; titleIconImageUrl = string.Empty; titleUrl = string.Empty; helpUrl = string.Empty; isStatic = false; hasUserData = false; hasSharedData = false; hidden = false; isClosed = false; }
protected WebPart() { verbs = new WebPartVerbCollection(); allow = Allow.Close | Allow.Connect | Allow.Edit | Allow.Hide | Allow.Minimize | Allow.ZoneChange; auth_filter = ""; catalog_icon_url = ""; titleIconImageUrl = string.Empty; titleUrl = string.Empty; helpUrl = string.Empty; isStatic = false; hasUserData = false; hasSharedData = false; hidden = false; isClosed = false; }
public IEnumerator C_One() { //这个地方可能重复了,否则有时候按超多次的时候,会出现数组越界,出现次数很少,但是有时会有,尚未知道原因。强制去越界。 if (groupIndex >= groupCount) { groupIndex = groupCount; state = General_State.拆完; } switch (state) { case General_State.拆完: chai_One = false; chaiFlag_One = false; yield break; case General_State.装完: groupIndex = 0; break; case General_State.单装到一半: groupIndex += 1; break; case General_State.一键分步拆ing: chai_OneKeyAll = false; chaiFlag_OneKeyAll = false; break; case General_State.一键分步装ing: zhuang_OneKeyAll = false; zhuangFlag_OneKeyAll = false; break; } state = General_State.单拆ing; allow = Allow.只能单拆; C_Group(groupIndex); SetNowTrans_Pre(groupIndex); yield return(new WaitForSeconds(duration * fellowRate)); if (allow == Allow.只能单拆) { if (null != Chai_Group_Complete) { Chai_Group_Complete.Invoke(groupIndex); } allow = Allow.无限制; groupIndex += 1; SetNowTrans_Aft(); } if (groupIndex == groupCount) { state = General_State.拆完; } else { state = General_State.单拆到一半; } chai_One = false; chaiFlag_One = false; //xg OriGroupEffect(groupIndex); }
public bool HasRole(string host, string user, string feed, Role role) { var decision = Allow.HasFlag(role); if (Deny.HasFlag(role)) { decision = false; } if (FeedRoles.TryGetValue(feed, out var feedPermission)) { decision = feedPermission.HasRole(host, user, feed, role, decision); } return(decision); }
public IEnumerator Z_Order() { if (groupIndex <= -1) { groupIndex = -1; state = General_State.装完; } switch (state) { case General_State.拆完: groupIndex = groupCount - 1; break; case General_State.装完: zhuang_OneKeyAll = false; zhuangFlag_OneKeyAll = false; yield break; case General_State.单拆到一半: groupIndex -= 1; break; case General_State.单装ing: groupIndex -= 1; break; } state = General_State.一键分步装ing; allow = Allow.只能一键装; for (int i = groupIndex; i > -1; i--) { if (allow == Allow.只能一键装) { Z_Group(groupIndex); SetNowTrans_Pre(groupIndex); } yield return(new WaitForSeconds(duration * fellowRate)); if (allow == Allow.只能一键装) { if (null != Zhuang_Group_Complete) { Zhuang_Group_Complete.Invoke(groupIndex); } groupIndex -= 1; SetNowTrans_Aft(); } } //被这个无限制弄的不行 if (allow == Allow.只能一键装) { state = General_State.装完; allow = Allow.无限制; zhuang_OneKeyAll = false; zhuangFlag_OneKeyAll = false; } }
public bool HasRole(IPAddress address, string user, string feed, Role role) { var decision = Allow.HasFlag(role); if (Deny.HasFlag(role)) { decision = false; } FeedRole feedPermission; if (FeedRoles.TryGetValue(feed, out feedPermission)) { decision = feedPermission.HasRole(address, user, feed, role, decision); } return(decision); }
private void SetBit(PermissionsBits pos, bool?value) { if (value == true) { Allow.SetBit(pos, true); Deny.SetBit(pos, false); } else if (value == false) { Allow.SetBit(pos, false); Deny.SetBit(pos, true); } else { Allow.SetBit(pos, false); Deny.SetBit(pos, false); } }
public IEnumerator Z_One() { if (groupIndex <= -1) { groupIndex = -1; state = General_State.装完; } switch (state) { case General_State.拆完: groupIndex = groupCount - 1; break; case General_State.装完: zhuang_One = false; zhuangFlag_One = false; yield break; case General_State.单拆到一半: groupIndex -= 1; break; case General_State.一键分步拆ing: chai_OneKeyAll = false; chaiFlag_OneKeyAll = false; break; case General_State.一键分步装ing: zhuang_OneKeyAll = false; zhuangFlag_OneKeyAll = false; break; } state = General_State.单装ing; allow = Allow.只能单装; Z_Group(groupIndex); SetNowTrans_Pre(groupIndex); yield return(new WaitForSeconds(duration * fellowRate)); if (allow == Allow.只能单装) { if (null != Zhuang_Group_Complete) { Zhuang_Group_Complete.Invoke(groupIndex); } allow = Allow.无限制; groupIndex -= 1; SetNowTrans_Aft(); } if (groupIndex == -1) { state = General_State.装完; } else { state = General_State.单装到一半; } zhuang_One = false; zhuangFlag_One = false; }
public IEnumerator C_Order() { if (groupIndex >= groupCount) { groupIndex = groupCount; state = General_State.拆完; } switch (state) { case General_State.拆完: chai_OneKeyAll = false; chaiFlag_OneKeyAll = false; U_List.ClearList(movingTrans); yield break; case General_State.装完: groupIndex = 0; break; case General_State.单装到一半: groupIndex += 1; break; } state = General_State.一键分步拆ing; allow = Allow.只能一键拆; for (int i = groupIndex; i < groupCount; i++) { if (allow == Allow.只能一键拆) { C_Group(groupIndex); SetNowTrans_Pre(groupIndex); } yield return(new WaitForSeconds(duration * fellowRate)); if (allow == Allow.只能一键拆) { if (null != Chai_Group_Complete) { Chai_Group_Complete.Invoke(groupIndex); } groupIndex += 1; SetNowTrans_Aft(); } } if (allow == Allow.只能一键拆) { state = General_State.拆完; allow = Allow.无限制; chai_OneKeyAll = false; chaiFlag_OneKeyAll = false; } }
public bool HasRole(IPAddress address, string user, string feed, Role role, bool decision) { if (Allow.HasFlag(role)) { decision = true; } if (Deny.HasFlag(role)) { decision = false; } InteractorRole interactorRole; if (InteractorRoles.TryGetValue(new InteractorRole.Key(address, user), out interactorRole)) { decision = interactorRole.HasRole(role, decision); } return(decision); }
public IEnumerator Z_All() { state = General_State.一步装ing; allow = Allow.只能一步到位装; foreach (C_AssembleOBJ assemble in assembles_Obj) { assemble.state = W_AssembleState.装ING; assemble.transform.DOLocalMove (assemble.oriPostion, duration) .OnComplete(() => { assemble.state = W_AssembleState.装ED; groupIndex = -1; state = General_State.装完; }); assemble.transform.DOLocalRotate(assemble.oriEuler, duration); } chai_One = false; chaiFlag_One = false; chai_OneKeyAll = false; chaiFlag_OneKeyAll = false; zhuang_One = false; zhuangFlag_One = false; zhuang_OneKeyAll = false; zhuangFlag_OneKeyAll = false; yield return(new WaitForSeconds(duration)); SetNowTrans_Aft(); zhuang_OneStepAll = false; zhuangFlag_OneStepAll = false; allow = Allow.无限制; }
public IEnumerator C_All() { state = General_State.一步拆ing; allow = Allow.只能一步到位拆; foreach (C_AssembleOBJ assemble in assembles_Obj) { assemble.state = W_AssembleState.装ING; assemble.transform.DOLocalMove (assemble.DicGroupTarTrans[assemble.groups[assemble.groups.Count - 1]].localPosition, duration) .OnComplete(() => { assemble.state = W_AssembleState.拆ED; groupIndex = groupCount; state = General_State.拆完; }); assemble.transform.DOLocalRotate (assemble.DicGroupTarTrans[assemble.groups[assemble.groups.Count - 1]].localEulerAngles, duration); } chai_One = false; chaiFlag_One = false; chai_OneKeyAll = false; chaiFlag_OneKeyAll = false; zhuang_One = false; zhuangFlag_One = false; zhuang_OneKeyAll = false; zhuangFlag_OneKeyAll = false; yield return(new WaitForSeconds(duration)); SetNowTrans_Aft(); chai_OneStepAll = false; chaiFlag_OneStepAll = false; allow = Allow.无限制; }
/// <summary> /// Check if teh current user has a given permission /// </summary> /// <param name="permission">The permission to check for</param> protected bool HasPermission(Allow permission) => Request.SessionAs <UserSession>() .Permissions .Contains(permission.ToString("D"));
public void Init() { instance = new Allow(); }
public override int GetHashCode() => unchecked (Allow.GetHashCode() + Deny.GetHashCode() + 1724);