private static bool toIsFriendly(Relations rel) { if (rel.HasFlagFast(Relations.Enemy)) return false; return rel.HasFlagFast(Relations.Owner) || rel.HasFlagFast(Relations.Faction); }
public static RelationsCollection GetAll() { resourceSchema.Dal.Relations dbo = null; try { dbo = new resourceSchema.Dal.Relations(); System.Data.DataSet ds = dbo.Relations_Select_All(); RelationsCollection collection = new RelationsCollection(); if (GlobalTools.IsSafeDataSet(ds)) { for (int i = 0; (i < ds.Tables[0].Rows.Count); i = (i + 1)) { Relations obj = new Relations(); obj.Fill(ds.Tables[0].Rows[i]); if ((obj != null)) { collection.Add(obj); } } } return collection; } catch (System.Exception ) { throw; } finally { if ((dbo != null)) { dbo.Dispose(); } } }
public void SetRelations(Relations relations) { relations.Named("self").Uses<TracksController>().Get(_id); relations.Named("AddToBasketPost").At("http://sharprestfulie.local/Baskets/{BasketId}/Add"); relations.Named("list").Uses<TracksController>().Index(); }
public void SetRelations(Relations relations) { relations.Named("self").At(Rotas.Mensagem(Contato.Id, Identificador)); relations.Named("origin").At(Rotas.Mensagens(Contato.Id)); relations.Named("post").At(Rotas.Mensagens(Contato.Id)); }
public override object ReadJson(JsonReader reader, Type objectType, object existingValue, JsonSerializer serializer) { var relations = new Relations(); var jToken = JToken.ReadFrom(reader); foreach (JProperty jProperty in jToken.Where(_ => _.GetType() == typeof(JProperty)).Cast<JProperty>()) { if (jProperty.Value.GetType() == typeof (JArray)) { var links = serializer.Deserialize<Link[]>(jProperty.Value.CreateReader()); foreach (var link in links) { relations.Add(link); link.Rel = jProperty.Name; } } else { var link = serializer.Deserialize<Link>(jProperty.Value.CreateReader()); link.Rel = jProperty.Name; relations.Add(link); } } return relations; }
private void ReplaceEntryUrl(XmlNode node, Relations relations) { var self = relations.GetAll().SingleOrDefault(r => r.Name.ToLower().Equals("self")); if (self != null) { var id = FindNode(node, "id"); id.InnerText = self.Url; } }
public void SetRelations(Relations relations) { relations.Named("self").Uses<ContatosController>().Get(Id); relations.Named("origin").At(Rotas.Contatos()); relations.Named("delete").At(Rotas.Contato(Id)); relations.Named("put").At(Rotas.Contato(Id)); relations.Named("post").At(Rotas.Contatos()); relations.Named("mensagens").At(Rotas.Mensagens(Id)); }
private static bool toIsHostile(Relations rel) { if (rel.HasFlagFast(Relations.Enemy)) return true; if (rel == Relations.None) return true; return false; }
/// <summary> /// Clears this instance. /// </summary> public void Clear() { if (PrimaryKey != null) { PrimaryKey.Keys.Clear(); PrimaryKey = null; } Properties.Clear(); Relations.Clear(); AllProperties.Clear(); }
public IProcessDefinition GetProcessDefinition(Int64 processDefinitionId, Relations relations, DbSession dbSession) { ProcessDefinitionImpl processDefinition = null; processDefinition = (ProcessDefinitionImpl)dbSession.Load(typeof(ProcessDefinitionImpl), processDefinitionId); if (relations != null) { relations.Resolve(processDefinition); } return(processDefinition); }
public IProcessDefinition GetProcessDefinition(String processDefinitionName, Relations relations, DbSession dbSession) { ProcessDefinitionImpl processDefinition = null; processDefinition = (ProcessDefinitionImpl)dbSession.FindOne(queryFindProcessDefinitionByName, processDefinitionName, DbType.STRING); if (relations != null) { relations.Resolve(processDefinition); } return(processDefinition); }
public IList GetProcessDefinitions(Relations relations, DbSession dbSession) { IList processDefinitions = null; processDefinitions = dbSession.Find(queryFindProcessDefinitions); if (relations != null) { relations.Resolve(processDefinitions); } return(processDefinitions); }
protected override void ImportRelations() { Relation <UserGroup, User> relation_User = new Relation <UserGroup, User>("User_UserGroup"); relation_User.Add(new RelationDetail <UserGroup, User>() { PrimaryField = x => x.IDUserGroup, ForeignField = x => x.IDUserGroup }); Relations.Add("User", relation_User); }
public Relations Invert() { Relations temp = this; temp.church *= -1; temp.army *= -1; temp.people *= -1; temp.economics *= -1; return(temp); }
protected override void OnUpdate(SQLiteConnection conn) { Base.Update(conn); NatStats.Update(conn); ClassChoices.Update(conn); Skills.Update(conn); StateRates.Update(conn); ElementRates.Update(conn); Relations.Update(conn); SQLUpdate(conn, "Companionship=@Companionship, SavePartnerRate=@SavePartnerRate, CounterattackRate=@CounterattackRate, AssistDamageRate=@AssistDamageRate"); }
public void ShouldWorkWhenUsingTheAPIFluentlyInARow() { var relations = new Relations(new Mock<IUrlGenerator>().Object); relations.Named("pay").Uses<SomeController>().SomeSimpleAction(); relations.Named("cancel").Uses<SomeController>().SomeSimpleAction(); var all = relations.GetAll(); Assert.AreEqual(2, all.Count); Assert.IsNotNull(all.Where(t => t.Name == "pay").Single()); Assert.IsNotNull(all.Where(t => t.Name == "cancel").Single()); }
public void ShouldCreateALinkToaNonAction() { var relations = new Relations(new Mock<IUrlGenerator>().Object); relations.Named("to_another_website").At("some/url"); var all = relations.GetAll(); Assert.AreEqual(1, all.Count); Assert.AreEqual("to_another_website" , all.First().Name); Assert.AreEqual("some/url", all.First().Url); }
public bool IsBroken() { if (RelationType != RelationType.Spouse) { return(false); } var spouseRelations = Relations.Where(r => r.RelationType == RelationType.Spouse); var spouseOfFirstPerson = spouseRelations.FirstOrDefault(r => r.From == Person1); var spouseOfSecondPerson = spouseRelations.FirstOrDefault(r => r.From == Person2); return(spouseOfFirstPerson is not null || spouseOfSecondPerson is not null); }
public IList GetAllProcessDefinitions(Relations relations, DbSession dbSession) { IList processDefinitions = null; log.Debug("getting all process definitions..."); processDefinitions = dbSession.Find(queryFindAllProcessDefinitions); if (relations != null) { relations.Resolve(processDefinitions); } return(processDefinitions); }
public TestViewModel() { From = Products; AllowRead = false; Relations.Add(Categories, Categories.CategoryID.IsEqualTo(Products.CategoryID)); AllowUpdate = true; MapColumn(Products.ProductID, Products.ProductName, Products.CategoryID, Categories.CategoryName); DenyUpdate(Products.CategoryID); }
private void SetRelations(ArrayList relationList) { Debug.Assert(relationList != null); var tables = base.Tables; foreach (ArrayList list in relationList) { Debug.Assert(list.Count == 5); var relationName = (string)list[0]; var parentInfo = (int[])list[1]; var childInfo = (int[])list[2]; var isNested = (bool)list[3]; var extendedProperties = (Hashtable)list[4]; //ParentKey Columns. Debug.Assert(parentInfo.Length >= 1); var parentkeyColumns = new DataColumn[parentInfo.Length - 1]; for (int i = 0; i < parentkeyColumns.Length; i++) { Debug.Assert(tables.Count > parentInfo[0]); Debug.Assert(tables[parentInfo[0]].Columns.Count > parentInfo[i + 1]); parentkeyColumns[i] = tables[parentInfo[0]].Columns[parentInfo[i + 1]]; } //ChildKey Columns. Debug.Assert(childInfo.Length >= 1); var childkeyColumns = new DataColumn[childInfo.Length - 1]; for (int i = 0; i < childkeyColumns.Length; i++) { Debug.Assert(tables.Count > childInfo[0]); Debug.Assert(tables[childInfo[0]].Columns.Count > childInfo[i + 1]); childkeyColumns[i] = tables[childInfo[0]].Columns[childInfo[i + 1]]; } //Create the Relation, without any constraints[Assumption: The constraints are added earlier than the relations] var rel = new DataRelation(relationName, parentkeyColumns, childkeyColumns, false); rel.Nested = isNested; //Extended Properties. Debug.Assert(extendedProperties != null); if (extendedProperties.Keys.Count > 0) { foreach (object propertyKey in extendedProperties.Keys) { rel.ExtendedProperties.Add(propertyKey, extendedProperties[propertyKey]); } } //Add the relations to the dataset. Relations.Add(rel); } }
public virtual void Reset() { try { this.Clear(); Relations.Clear(); Tables.Clear(); } finally { } }
protected override void OnCreate(SQLiteConnection conn) { Base.Create(conn); NatStats.Create(conn); ElementRates.Create(conn); SQLCreate(conn, "BaseObjectID, NaturalStats, ElementRates, Companionship, SavePartnerRate, CounterattackRate, AssistDamageRate", "@BaseObjectID, @NaturalStats, @ElementRates, @Companionship, @SavePartnerRate, @CounterattackRate, @AssistDamageRate"); ClassChoices.Create(conn); Skills.Create(conn); StateRates.Create(conn); Relations.Create(conn); }
public void CheckAndModify(EmployeeRelation relation, IEmployeeRelationService service) { if (CheckIfOutside(relation)) { //relation.EndTime = relation.BeginTime.AddDays(-1); service.Delete(relation); return; } if (Include(relation)) { Relations.Add(relation); return; } else if (DateTimeHelper.IsIntersectExc(relation.BeginTime, relation.EndTime, BeginDate, EndDate)) { if (DateTimeHelper.Between(relation.BeginTime, BeginDate, EndDate)) { EmployeeRelation newrelation = relation.GetCopy(); newrelation.ID = 0; newrelation.BeginTime = NextDay; relation.EndTime = EndDate; Debug.Assert(relation.IsValidRelation()); Relations.Add(relation); service.SaveOrUpdate(relation); relation = newrelation; } else if (DateTimeHelper.Between(relation.EndTime, BeginDate, EndDate)) { EmployeeRelation newrelation = relation.GetCopy(); newrelation.ID = 0; newrelation.EndTime = PrevDay; relation.BeginTime = BeginDate; Debug.Assert(relation.IsValidRelation()); Relations.Add(relation); service.SaveOrUpdate(relation); relation = newrelation; } if (NextContract != null) { NextContract.CheckAndModify(relation, service); } } else if (NextContract != null) { NextContract.CheckAndModify(relation, service); } return; }
public JointConstraint( KinectWrapper.Joints joint_a, KinectWrapper.Joints joint_b, Relations relation, Operators operation, Vector3 val ) { this.joint_a = joint_a; this.joint_b = joint_b; this.relation = relation; this.operation = operation; this.val = val; }
public void ShouldCreateALinkToaNonAction() { var relations = new Relations(new Mock <IUrlGenerator>().Object); relations.Named("to_another_website").At("some/url"); var all = relations.GetAll(); Assert.AreEqual(1, all.Count); Assert.AreEqual("to_another_website", all.First().Name); Assert.AreEqual("some/url", all.First().Url); }
public void ShouldTransitToAControllerAction() { var urlGenerator = new Mock<IUrlGenerator>(); urlGenerator.Setup(ug => ug.For("Some", "SomeSimpleAction", It.IsAny<IDictionary<string, object>>())).Returns("http://Some/SomeSimpleAction"); var relations = new Relations(urlGenerator.Object); relations.Named("pay").Uses<SomeController>().SomeSimpleAction(); var all = relations.GetAll(); Assert.AreEqual("pay", all.First().Name); Assert.AreEqual("http://Some/SomeSimpleAction", all.First().Url); }
public bool Add(Relations relation) { try { ListOfRelations.Add(relation); return(true); } catch (IOException e) { Logger.Logger.CreateLog(e); return(false); } }
public Reference(string fieldName, string fieldDataType, Relations relation, bool notNull, bool addToRequest, bool addToResponse , bool hasGetMethod, bool isUnique, string referenceClassName) { FieldName = fieldName; FieldDataType = fieldDataType; Relation = relation; NotNull = notNull; AddToRequest = addToRequest; AddToResponse = addToResponse; HasGetMethod = hasGetMethod; IsUnique = isUnique; ReferenceClassName = referenceClassName; }
public static void ContainsTest() { var r = Relations.Make <string, int>((s, i) => s.Length == i); Assert.True(r.Contains("", 0)); Assert.True(r.Contains("x", 1)); Assert.True(r.Contains("xyz", 3)); Assert.False(r.Contains("", 1)); Assert.False(r.Contains("x", 0)); Assert.False(r.Contains("x", -1)); Assert.False(r.Contains("xyz", 88)); }
public void ShouldWorkWhenUsingTheAPIFluentlyInARow() { var relations = new Relations(new Mock <IUrlGenerator>().Object); relations.Named("pay").Uses <SomeController>().SomeSimpleAction(); relations.Named("cancel").Uses <SomeController>().SomeSimpleAction(); var all = relations.GetAll(); Assert.AreEqual(2, all.Count); Assert.IsNotNull(all.Where(t => t.Name == "pay").Single()); Assert.IsNotNull(all.Where(t => t.Name == "cancel").Single()); }
/// <summary> /// Remove a table fromt the dataset, and all constraints and references refering to it /// </summary> /// <param name="ATableName">table to remove</param> public void RemoveTable(String ATableName) { DataTable TableToDelete; // remove all constraints referencing the table that should be deleted foreach (TTypedConstraint constr in FConstraints) { if ((constr.FTable1 == ATableName) || (constr.FTable2 == ATableName)) { TableToDelete = Tables[constr.FTable2]; if (TableToDelete != null) { if (TableToDelete.Constraints.IndexOf(constr.FName) != -1) { TableToDelete.Constraints.Remove(constr.FName); } } } } // remove all relations referencing the table that should be deleted foreach (TTypedRelation relation in FRelations) { if ((relation.FTable1 == ATableName) || (relation.FTable2 == ATableName)) { TableToDelete = Tables[relation.FTable2]; if (TableToDelete != null) { if (Relations.IndexOf(relation.FName) != -1) { Relations.Remove(relation.FName); } if (TableToDelete.Constraints.IndexOf(relation.FName) != -1) { TableToDelete.Constraints.Remove(relation.FName); } } } } TableToDelete = Tables[ATableName]; if (TableToDelete != null) { // remove the table itself Tables.Remove(TableToDelete); } }
public static bool toIsHostile(Relations rel, bool ownerlessHostile = true) { if (rel.HasAnyFlag(Relations.Enemy)) { return(true); } if (rel == Relations.NoOwner) { return(ownerlessHostile); } return(false); }
public RelationRatingsData Initialize(Relations relations) { if (relations.Count > Capacity) { Capacity = relations.Count; } for (var i = 0; i < relations.Count; i++) { Add(new Dictionary <RelationDataPair, float>(MARSMemoryOptions.instance.RatingDictionaryCapacity * 4)); } return(this); }
private void RemoveDataTables() { Relations.Clear(); foreach (DataTable dt in Tables) { ClearConstraintsOnTable(dt); } EnforceConstraints = false; while (Tables.Count > 0) { Tables.RemoveAt(0); } EnforceConstraints = true; }
protected override void OnRead(SQLiteDataReader reader) { Base.Read(reader); NatStats.Read(reader); ClassChoices.Read(); Skills.Read(); StateRates.Read(); ElementRates.Read(); Relations.Read(); CompanionshipInput.Text = reader["Companionship"].ToString(); SavePartnerRateInput.Text = reader["SavePartnerRate"].ToString(); CounterattackRateInput.Text = reader["CounterattackRate"].ToString(); AssistDamageRateInput.Text = reader["AssistDamageRate"].ToString(); }
public override IParsedPhrase ConceptToPhrase(Context context, Concept concept, POSTagger tagger, GrammarParser parser) { Verbs.Person person = Verbs.Person.ThirdSingle; object start = context.LookupDefaulted <object>("$check", null); if (start != null && start is Datum) { Datum noundat = KnowledgeUtilities.GetClosestDatum(memory, (Datum)start, Relations.Relation.Subject); person = nouns.GetPerson(noundat.Right.Name); } return(Relations.ConjugateToPhrase(memory, conjugate, person, concept)); }
private static bool toIsHostile(Relations rel) { if (rel.HasFlagFast(Relations.Enemy)) { return(true); } if (rel == Relations.None) { return(true); } return(false); }
public JointConstraint( KinectSkeleton ks, KinectSkeleton.Joints joint_a, KinectSkeleton.Joints joint_b, Relations relation, Operators operation, Vector3 val ) { this.ks = ks; this.joint_a = joint_a; this.joint_b = joint_b; this.relation = relation; this.operation = operation; this.val = val; }
public static Relations GetRelations(GameObject gameObject) { var objectToArgs = new Dictionary <IMRObject, SetChildArgs>(); foreach (var proxy in gameObject.GetComponentsInChildren <Proxy>()) { var memberArgs = DefaultSetChildArgs(proxy); objectToArgs.Add(proxy, memberArgs); } var relations = new Relations(gameObject, objectToArgs); return(relations); }
public string Inject(string content, Relations relations, IRequestInfoFinder requestInfo) { var xmlDocument = new XmlDocument(); xmlDocument.LoadXml(content); foreach (var state in relations.GetAll()) { var transition = GetTransition(xmlDocument, state); xmlDocument.DocumentElement.AppendChild(transition); } return xmlDocument.InnerXml; }
public async Task DeleteBeatmapFromCollection(Beatmap beatmap, Collection collection) { if (beatmap.IsTemporary) { Logger.Warn("需确认加入自定义目录后才可继续"); return; } var relation = await Relations .FirstOrDefaultAsync(k => k.CollectionId == collection.Id && k.BeatmapId == beatmap.Id); Relations.Remove(relation); await SaveChangesAsync(); }
public void Script_0_0_0() { FunctionalIds.Default = FunctionalIds.New("Shared", "0", IdFormat.Numeric, 0); Entities.New("BaseEntity") .AddProperty("Uid", typeof(string), false, IndexType.Unique) .Abstract(true) .Virtual(true) .SetKey("Uid", true) .AddProperty("LastModifiedOn", typeof(DateTime)) .SetRowVersionField("LastModifiedOn"); Entities.New("Person", Entities["BaseEntity"]) .AddProperty("Name", typeof(string)) .AddProperty("MandatoryProperty", typeof(int), false); Entities.New("Movie", Entities["BaseEntity"]) .AddProperty("Title", typeof(string), IndexType.Unique) .AddProperty("ReleaseDate", typeof(DateTime)); Relations.New(Entities["Person"], Entities["Movie"], "DIRECTED_BY", "DIRECTED_BY") .SetInProperty("DirectedMovies", PropertyType.Collection) .SetOutProperty("Director", PropertyType.Lookup); Relations.New(Entities["Person"], Entities["Movie"], "ACTED_IN", "ACTORS") .SetInProperty("ActedInMovies", PropertyType.Collection) .SetOutProperty("Actors", PropertyType.Collection); Entities.New("Genre", Entities["BaseEntity"]) .AddProperty("Name", typeof(string), IndexType.Unique) .HasStaticData(true) .SetFullTextProperty("Name"); Relations.New(Entities["Movie"], Entities["Genre"], "MOVIE_HAS", "MOVIE_HAS") .SetInProperty("MovieGenre", PropertyType.Lookup) .SetOutProperty("Movies", PropertyType.Collection); Relations.New(Entities["Person"], Entities["Genre"], "LIKES", "LIKES") .SetInProperty("MovieGenre", PropertyType.Lookup) .SetOutProperty("Person", PropertyType.Collection); Entities["Genre"].Refactor.CreateNode(new { Uid = "7", Name = "Action" }); Entities["Genre"].Refactor.CreateNode(new { Uid = "8", Name = "Adventure" }); Entities["Genre"].Refactor.CreateNode(new { Uid = "9", Name = "Comedy" }); Entities["Genre"].Refactor.CreateNode(new { Uid = "10", Name = "Drama" }); Entities["Genre"].Refactor.CreateNode(new { Uid = "11", Name = "Horror" }); Entities["Genre"].Refactor.CreateNode(new { Uid = "12", Name = "Musical" }); Entities["Genre"].Refactor.CreateNode(new { Uid = "13", Name = "Science Fiction" }); }
public void SetRelations(Relations relations) { relations.Named("self").Uses<BasketsController>().Get(_id); //TODO: Comment current Business Process relations.Named("SubmitPaymentPost").At("http://sharprestfulie.local/Payments"); //TODO: Uncomment new Business Process //var basketPrice = Tracks.Sum(x => x.Price); //if (basketPrice >= 3) //{ // relations.Named("submit payment").Uses<PaymentsController>().Create(this); //} }
public List <string> GetSubProductsLackingPrice() { List <string> productsLackingFixedPrice = Relations .Where(r => r.Product.FixedPrice <= 0) .Select(p => p.Product.Id) .OrderByDescending(c => c) .ToList(); List <string> subproductslack = this.GetSubSubProductsLackingPrice(); return(productsLackingFixedPrice .Concat(subproductslack) .Distinct() .OrderBy(x => x) .ToList()); }
public void VerifyRoundtrip() { // Arrange var relations = new Relations(); relations.Add(Link.CreateSelfLink("http://localhost/users")); relations.Add(Link.CreateLink("dt:admins", "http://locahost/users/admins")); relations.Add(Link.CreateLink("admin", "http://locahost/users/admins/1")); relations.Add(Link.CreateLink("admin", "http://locahost/users/admins/2")); relations.Add(Link.CreateCuriesLink("http://locahost/doc/{rel}", "dt")); // Act var serializedRelations = JsonConvert.SerializeObject(relations, new RelationsConverter()); var deserializedRelations = JsonConvert.DeserializeObject<Relations>(serializedRelations, new RelationsConverter()); var t = JsonConvert.SerializeObject(deserializedRelations, new RelationsConverter()); // Assert Assert.Equal(relations, deserializedRelations); }
public void SetRelations(Relations relations) { relations.Named("pay").Uses<SomeController>().SomeSimpleAction(); }
public static Relations getRelationsTo(this IMyCubeBlock block, IMyCubeGrid target, Relations breakOn = Relations.None) { VRage.Exceptions.ThrowIf<ArgumentNullException>(block == null, "block"); VRage.Exceptions.ThrowIf<ArgumentNullException>(target == null, "target"); if (target.BigOwners.Count == 0 && target.SmallOwners.Count == 0) // grid has no owner return Relations.Enemy; Relations relationsToGrid = Relations.None; foreach (long gridOwner in target.BigOwners) { relationsToGrid |= block.getRelationsTo(gridOwner); if (breakOn != Relations.None && relationsToGrid.HasFlagFast(breakOn)) return relationsToGrid; } foreach (long gridOwner in target.SmallOwners) { relationsToGrid |= block.getRelationsTo(gridOwner); if (breakOn != Relations.None && relationsToGrid.HasFlagFast(breakOn)) return relationsToGrid; } return relationsToGrid; }
public static Relations getRelationsTo(this IMyCubeBlock block, object target, Relations breakOn = Relations.None) { IMyCubeBlock asBlock = target as IMyCubeBlock; if (asBlock != null) return block.getRelationsTo(asBlock); IMyCubeGrid asGrid = target as IMyCubeGrid; if (asGrid != null) return block.getRelationsTo(asGrid, breakOn); IMyCharacter asChar = target as IMyCharacter; if (asChar != null) { IMyPlayer player = asChar.GetPlayer_Safe(); if (player != null) return block.getRelationsTo(player.IdentityId); } IMyPlayer asPlayer = target as IMyPlayer; if (asPlayer != null) return block.getRelationsTo(asPlayer.IdentityId); throw new InvalidOperationException("Cannot handle: " + target); }
public FilterItem(uint value, uint mask, Relations rel) { Value = value; Mask = mask; Relation = rel; }
public static Relations getRelationsTo(this IMyPlayer player, IMyCubeGrid target, Relations breakOn = Relations.None) { if (player == null) throw new ArgumentNullException("player"); if (target == null) throw new ArgumentNullException("grid"); if (target.BigOwners.Count == 0 && target.SmallOwners.Count == 0) // grid has no owner return Relations.Enemy; Relations relationsToGrid = Relations.None; foreach (long gridOwner in target.BigOwners) { relationsToGrid |= player.getRelationsTo(gridOwner); if (breakOn != Relations.None && relationsToGrid.HasFlagFast(breakOn)) return relationsToGrid; } foreach (long gridOwner in target.SmallOwners) { relationsToGrid |= player.getRelationsTo(gridOwner); if (breakOn != Relations.None && relationsToGrid.HasFlagFast(breakOn)) return relationsToGrid; } return relationsToGrid; }
public static bool toIsFriendly(Relations rel) { if (rel.HasAnyFlag(Relations.Enemy)) return false; return rel.HasAnyFlag(Relations.Owner) || rel.HasAnyFlag(Relations.Faction); }
public void ShouldDetectWrongUseOfFluentAPI() { var relations = new Relations(new Mock<IUrlGenerator>().Object); Assert.Throws<ArgumentException>(() => relations.Uses<SomeController>().SomeSimpleAction()); }
public string Inject(string content, Relations relations, IRequestInfoFinder requestInfo) { return InjectJsonTransitions(content, relations); }
public static bool HasFlagFast(this Relations rel, Relations flag) { return (rel & flag) == flag; }
public static Relations getRelationsTo(this IMyCubeBlock block, IMyCubeGrid target, Relations breakOn = Relations.None) { if (target.BigOwners.Count == 0 && target.SmallOwners.Count == 0) // grid has no owner return Relations.Enemy; Relations relationsToGrid = Relations.None; foreach (long gridOwner in target.BigOwners) { relationsToGrid |= block.getRelationsTo(gridOwner); if (breakOn != Relations.None && relationsToGrid.HasFlagFast(breakOn)) return relationsToGrid; } foreach (long gridOwner in target.SmallOwners) { relationsToGrid |= block.getRelationsTo(gridOwner); if (breakOn != Relations.None && relationsToGrid.HasFlagFast(breakOn)) return relationsToGrid; } return relationsToGrid; }
public static bool toIsHostile(Relations rel) { if (rel.HasAnyFlag(Relations.Enemy)) return true; if (rel == Relations.None) return true; return false; }
public void SetRelations(Relations relations) { relations.Named("self") .Uses<MusicaController>() .Exibe(Id); }
private string InjectJsonTransitions(string content, Relations relations) { var jsonTransitions = relations.GetAll().Select(GetTransitionOnJsonFormat); var jsonTransitionsConcatenated = string.Join(",", jsonTransitions.ToArray()); var jsonWithTransitions = content.Insert(content.Length - 1, ",\"links\":[" + jsonTransitionsConcatenated + "]"); return jsonWithTransitions; }
public static Relations Load(System.Nullable<int> Id) { resourceSchema.Dal.Relations dbo = null; try { dbo = new resourceSchema.Dal.Relations(); System.Data.DataSet ds = dbo.Relations_Select_One(Id); Relations obj = null; if (GlobalTools.IsSafeDataSet(ds)) { if ((ds.Tables[0].Rows.Count > 0)) { obj = new Relations(); obj.Fill(ds.Tables[0].Rows[0]); } } return obj; } catch (System.Exception ) { throw; } finally { if ((dbo != null)) { dbo.Dispose(); } } }