コード例 #1
0
		private static bool toIsFriendly(Relations rel)
		{
			if (rel.HasFlagFast(Relations.Enemy))
				return false;

			return rel.HasFlagFast(Relations.Owner) || rel.HasFlagFast(Relations.Faction);
		}
コード例 #2
0
 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();
         }
     }
 }
コード例 #3
0
        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();
        }
コード例 #4
0
        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));

        }
コード例 #5
0
        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;
        }
コード例 #6
0
 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;
     }
 }
コード例 #7
0
 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));
 }
コード例 #8
0
		private static bool toIsHostile(Relations rel)
		{
			if (rel.HasFlagFast(Relations.Enemy))
				return true;

			if (rel == Relations.None)
				return true;

			return false;
		}
コード例 #9
0
 /// <summary>
 /// Clears this instance.
 /// </summary>
 public void Clear()
 {
     if (PrimaryKey != null)
     {
         PrimaryKey.Keys.Clear();
         PrimaryKey = null;
     }
     Properties.Clear();
     Relations.Clear();
     AllProperties.Clear();
 }
コード例 #10
0
        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);
        }
コード例 #11
0
        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);
        }
コード例 #12
0
        public IList GetProcessDefinitions(Relations relations, DbSession dbSession)
        {
            IList processDefinitions = null;

            processDefinitions = dbSession.Find(queryFindProcessDefinitions);
            if (relations != null)
            {
                relations.Resolve(processDefinitions);
            }
            return(processDefinitions);
        }
コード例 #13
0
ファイル: UserGroup.cs プロジェクト: fercbk9/SQLAgent
        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);
        }
コード例 #14
0
    public Relations Invert()
    {
        Relations temp = this;

        temp.church    *= -1;
        temp.army      *= -1;
        temp.people    *= -1;
        temp.economics *= -1;

        return(temp);
    }
コード例 #15
0
ファイル: Player.xaml.cs プロジェクト: rafapena/SideBattleRPG
 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");
 }
コード例 #16
0
        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());
        }
コード例 #17
0
        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);
        }
コード例 #18
0
        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);
        }
コード例 #19
0
        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);
        }
コード例 #20
0
 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);
 }
コード例 #21
0
        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);
            }
        }
コード例 #22
0
 public virtual void Reset()
 {
     try
     {
         this.Clear();
         Relations.Clear();
         Tables.Clear();
     }
     finally
     {
     }
 }
コード例 #23
0
ファイル: Player.xaml.cs プロジェクト: rafapena/SideBattleRPG
 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);
 }
コード例 #24
0
        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;
        }
コード例 #25
0
    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;
    }
コード例 #26
0
        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);
        }
コード例 #27
0
        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);
        }
コード例 #28
0
 public bool Add(Relations relation)
 {
     try
     {
         ListOfRelations.Add(relation);
         return(true);
     }
     catch (IOException e)
     {
         Logger.Logger.CreateLog(e);
         return(false);
     }
 }
コード例 #29
0
 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;
 }
コード例 #30
0
ファイル: RelationsTests.cs プロジェクト: nordril/functional
        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));
        }
コード例 #31
0
        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());
        }
コード例 #32
0
ファイル: TypedDataSet.cs プロジェクト: jsuen123/openpetragit
        /// <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);
            }
        }
コード例 #33
0
        public static bool toIsHostile(Relations rel, bool ownerlessHostile = true)
        {
            if (rel.HasAnyFlag(Relations.Enemy))
            {
                return(true);
            }

            if (rel == Relations.NoOwner)
            {
                return(ownerlessHostile);
            }

            return(false);
        }
コード例 #34
0
        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);
        }
コード例 #35
0
ファイル: RegexDataset.cs プロジェクト: xuan2261/EasyETL.Net
 private void RemoveDataTables()
 {
     Relations.Clear();
     foreach (DataTable dt in Tables)
     {
         ClearConstraintsOnTable(dt);
     }
     EnforceConstraints = false;
     while (Tables.Count > 0)
     {
         Tables.RemoveAt(0);
     }
     EnforceConstraints = true;
 }
コード例 #36
0
ファイル: Player.xaml.cs プロジェクト: rafapena/SideBattleRPG
 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();
 }
コード例 #37
0
        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));
        }
コード例 #38
0
        private static bool toIsHostile(Relations rel)
        {
            if (rel.HasFlagFast(Relations.Enemy))
            {
                return(true);
            }

            if (rel == Relations.None)
            {
                return(true);
            }

            return(false);
        }
コード例 #39
0
ファイル: JointConstraint.cs プロジェクト: brgmnn/van-dyke
    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;
    }
コード例 #40
0
        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);
        }
コード例 #41
0
        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;
        }
コード例 #42
0
        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();
        }
コード例 #43
0
            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" });
            }
コード例 #44
0
        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);
            //}
        }
コード例 #45
0
        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());
        }
コード例 #46
0
        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);
        }
コード例 #47
0
 public void SetRelations(Relations relations)
 {
     relations.Named("pay").Uses<SomeController>().SomeSimpleAction();
 }
コード例 #48
0
        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;
        }
コード例 #49
0
        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);
        }
コード例 #50
0
ファイル: Filter.cs プロジェクト: gloria1/pviewer5
 public FilterItem(uint value, uint mask, Relations rel)
 {
     Value = value;
     Mask = mask;
     Relation = rel;
 }
コード例 #51
0
        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;
        }
コード例 #52
0
        public static bool toIsFriendly(Relations rel)
        {
            if (rel.HasAnyFlag(Relations.Enemy))
                return false;

            return rel.HasAnyFlag(Relations.Owner) || rel.HasAnyFlag(Relations.Faction);
        }
コード例 #53
0
        public void ShouldDetectWrongUseOfFluentAPI()
        {
            var relations = new Relations(new Mock<IUrlGenerator>().Object);
            Assert.Throws<ArgumentException>(() =>
			relations.Uses<SomeController>().SomeSimpleAction());
        }
コード例 #54
0
 public string Inject(string content, Relations relations, IRequestInfoFinder requestInfo)
 {
     return InjectJsonTransitions(content, relations);
 }
コード例 #55
0
 public static bool HasFlagFast(this Relations rel, Relations flag)
 {
     return (rel & flag) == flag;
 }
コード例 #56
0
		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;
		}
コード例 #57
0
        public static bool toIsHostile(Relations rel)
        {
            if (rel.HasAnyFlag(Relations.Enemy))
                return true;

            if (rel == Relations.None)
                return true;

            return false;
        }
コード例 #58
0
ファイル: Musica.cs プロジェクト: hvitorino/iTunes-Library
 public void SetRelations(Relations relations)
 {
     relations.Named("self")
         .Uses<MusicaController>()
         .Exibe(Id);
 }
コード例 #59
0
        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;
        }
コード例 #60
0
 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();
         }
     }
 }