コード例 #1
0
 /// <summary>
 /// Merge PropertyFilter
 /// </summary>
 /// <param name="mergeFilter">PropertyFilter to merge</param>
 public void Merge(PropertyFilter mergeFilter)
 {
     EqualTo             = EqualTo.Concat(mergeFilter.EqualTo.Where(s => !EqualTo.Contains(s))).ToList();
     StartWith           = StartWith.Concat(mergeFilter.StartWith.Where(s => !StartWith.Contains(s))).ToList();
     Contain             = Contain.Concat(mergeFilter.Contain.Where(s => !Contain.Contains(s))).ToList();
     PropertySetsEqualTo = PropertySetsEqualTo.Concat(mergeFilter.PropertySetsEqualTo.Where(s => !PropertySetsEqualTo.Contains(s))).ToList();
 }
コード例 #2
0
 /// <summary>
 /// Test for string exists in EqTo, Contains, or StartWith string lists
 /// </summary>
 /// <param name="testStr">String to test</param>
 /// <returns>bool</returns>
 public bool NameFilter(string testStr)
 {
     testStr = testStr.ToUpper();
     return(EqualTo.Any(a => testStr.Equals(a)) ||
            StartWith.Any(a => testStr.StartsWith(a)) ||
            (Contain.Count(a => testStr.Contains(a)) > 0));
 }
コード例 #3
0
 /// <summary>
 /// Clear PropertyFilter
 /// </summary>
 public void Clear()
 {
     EqualTo.Clear();
     StartWith.Clear();
     Contain.Clear();
     PropertySetsEqualTo.Clear();
 }
コード例 #4
0
 /// <summary>
 /// Test for string exists in EqTo, Contains, or StartWith string lists
 /// </summary>
 /// <param name="testStr">String to test</param>
 /// <returns>bool</returns>
 public bool NameFilter(string testStr)
 {
     testStr = testStr.ToUpper();
     return((EqualTo.Where(a => testStr.Equals(a)).Count() > 0) ||
            (StartWith.Where(a => testStr.StartsWith(a)).Count() > 0) ||
            (Contain.Where(a => testStr.Contains(a)).Count() > 0)
            );
 }
コード例 #5
0
 /// <summary>
 /// Copy values from passed PropertyFilter
 /// </summary>
 /// <param name="copyFilter">PropertyFilter to copy</param>
 public void Copy(PropertyFilter copyFilter)
 {
     EqualTo.Clear();
     EqualTo = EqualTo.Concat(copyFilter.EqualTo).ToList();
     StartWith.Clear();
     StartWith = StartWith.Concat(copyFilter.StartWith).ToList();
     Contain.Clear();
     Contain = Contain.Concat(copyFilter.Contain).ToList();
     PropertySetsEqualTo.Clear();
     PropertySetsEqualTo = PropertySetsEqualTo.Concat(copyFilter.PropertySetsEqualTo).ToList();
 }
コード例 #6
0
 public StringFilter ToUpper()
 {
     Equal        = Equal?.ToUpper();
     NotEqual     = NotEqual?.ToUpper();
     Contain      = Contain?.ToUpper();
     NotContain   = NotContain?.ToUpper();
     StartWith    = StartWith?.ToUpper();
     NotStartWith = NotStartWith?.ToUpper();
     EndWith      = EndWith?.ToUpper();
     NotEndWith   = NotEndWith?.ToUpper();
     return(this);
 }
コード例 #7
0
        public void contain_unknown()
        {
            Contain obj = new Contain
            {
                Unknown = (IFooBar) new FooBar {
                    Test = "test"
                }
            };

            var serialized = _serializer.Serialize(obj);

            var deserialized = _serializer.Deserialize <Contain>(serialized);

            Assert.AreEqual(deserialized.Unknown.Test, obj.Unknown.Test);
        }
コード例 #8
0
ファイル: Commands.cs プロジェクト: virajs/Aggregates.NET
        public void contain_command()
        {
            Contain obj = new Contain
            {
                Command = (Simple) new Simple {
                    Test = "test"
                }
            };

            var serialized = _serializer.Serialize(obj);

            var deserialized = _serializer.Deserialize <Contain>(serialized);

            Assert.IsTrue(deserialized.Command is Simple);
            Assert.AreEqual((deserialized.Command as Simple).Test, (obj.Command as Simple).Test);
        }
コード例 #9
0
        /// <summary>
        /// Set Property Filters constructor via ConfigurationSection from configuration file
        /// </summary>
        /// <param name="section">ConfigurationSection from configuration file</param>
        public PropertyFilter(ConfigurationSection section) : this()
        {
            //initialize fields
            if (section == null)
            {
                return;
            }

            foreach (KeyValueConfigurationElement keyVal in ((AppSettingsSection)section).Settings)
            {
                if (string.IsNullOrEmpty(keyVal.Value))
                {
                    continue;
                }

                switch (keyVal.Key.ToUpper())
                {
                case "EQUALTO":
                    EqualTo.AddRange(keyVal.Value.Split(new[] { ';' }, StringSplitOptions.RemoveEmptyEntries).ToList().ConvertAll(s => s.ToUpper()));
                    break;

                case "STARTWITH":
                    StartWith.AddRange(keyVal.Value.Split(new[] { ';' }, StringSplitOptions.RemoveEmptyEntries).ToList().ConvertAll(s => s.ToUpper()));
                    break;

                case "CONTAIN":
                    Contain.AddRange(keyVal.Value.Split(new[] { ';' }, StringSplitOptions.RemoveEmptyEntries).ToList().ConvertAll(s => s.ToUpper()));
                    break;

                case "PROPERTYSETSEQUALTO":
                    PropertySetsEqualTo.AddRange(keyVal.Value.Split(new[] { ';' }, StringSplitOptions.RemoveEmptyEntries).ToList().ConvertAll(s => s.ToUpper()));
                    break;

                default:
#if DEBUG
                    Debug.WriteLine(string.Format("Invalid Key - {0}", keyVal.Key.ToUpper()));
#endif
                    break;
                }
            }
        }
コード例 #10
0
 /// <summary>
 /// Creates a MysteryBlock with a specific item.
 /// s determines the item can be "Coin", "Flower", or "Mushroom" otherwise the block will stay empty.
 /// i determines the amount of that item inside.
 /// </summary>
 /// <param name="s"></param>
 /// <param name="i"></param>
 public MysteryBlock(string s, int i) : base()
 {
     ItemsLeft = i;
     if (s.Equals(Contain.Coin.ToString()))
     {
         Contains = Contain.Coin;
     }
     else if (s.Equals(Contain.Flower.ToString()))
     {
         Contains = Contain.Flower;
     }
     else if (s.Equals(Contain.Mushroom.ToString()))
     {
         Contains = Contain.Mushroom;
     }
     else
     {
         Contains  = Contain.Empty;
         ItemsLeft = 0;
     }
 }
コード例 #11
0
        public async Task <ActionResult <Contain> > PostContain(Contain contain)
        {
            _context.Contain.Add(contain);
            try
            {
                await _context.SaveChangesAsync();
            }
            catch (DbUpdateException)
            {
                if (ContainExists(contain.TopicId))
                {
                    return(Conflict());
                }
                else
                {
                    throw;
                }
            }

            return(CreatedAtAction("GetContain", new { id = contain.TopicId }, contain));
        }
コード例 #12
0
        private void CreateConsumer(string mqName, string mqServer, string projectKey, int index, EventHandler <BasicDeliverEventArgs> handler)
        {
            if (HttpContext.Application["TaskList"] == null)
            {
                HttpContext.Application["TaskList"] = new List <Contain>();
            }


            Dictionary <string, string> args = new Dictionary <string, string>();

            args["projectKey"] = projectKey;
            args["mqName"]     = mqName;
            args["index"]      = index.ToString();
            args["type"]       = "1";

            ConsumerInfo info = new ConsumerInfo()
            {
                Handler     = handler,
                HostName    = mqServer,
                QueueName   = mqName,
                ConsumerTag = mqName + "_" + (index + 1),
                Args        = args,
                Notice      = new Func <Dictionary <string, string>, string>(SendHeartData)
            };


            ConsumerTask cTask = RabbitMQHelper.CreateConsumer(info);

            Contain c = new Contain {
                task = cTask.Task, tokenSource = cTask.TokenSource, taskKey = mqName, projectKey = projectKey
            };

            List <Contain> tasklist = HttpContext.Application["TaskList"] as List <Contain>;

            tasklist.Add(c);

            Dictionary <string, List <HeartData> > heart = HttpContext.Application[projectKey] as Dictionary <string, List <HeartData> >;

            heart[mqName + "_" + (index + 1)] = new List <HeartData>();
        }
コード例 #13
0
        /// <summary>
        /// Set Property Filters constructor
        /// </summary>
        /// <param name="equalTo">';' delimited string for property names to equal</param>
        /// <param name="startWith">';' delimited string for property names to start with</param>
        /// <param name="contain">';' delimited string for property names containing</param>
        /// <param name="pSetEqualTo">';' delimited string for Property Set names to equal</param>
        public PropertyFilter(string equalTo, string startWith, string contain, string pSetEqualTo) : this()
        {
            //Property names to exclude
            if (!string.IsNullOrEmpty(equalTo))
            {
                EqualTo.AddRange(equalTo.Split(new[] { ';' }, StringSplitOptions.RemoveEmptyEntries).ToList().ConvertAll(s => s.ToUpper()));
            }
            if (!string.IsNullOrEmpty(startWith))
            {
                StartWith.AddRange(startWith.Split(new[] { ';' }, StringSplitOptions.RemoveEmptyEntries).ToList().ConvertAll(s => s.ToUpper()));
            }
            if (!string.IsNullOrEmpty(contain))
            {
                Contain.AddRange(contain.Split(new[] { ';' }, StringSplitOptions.RemoveEmptyEntries).ToList().ConvertAll(s => s.ToUpper()));
            }

            //PropertySet names to exclude
            if (!string.IsNullOrEmpty(pSetEqualTo))
            {
                PropertySetsEqualTo.AddRange(pSetEqualTo.Split(new[] { ';' }, StringSplitOptions.RemoveEmptyEntries).ToList().ConvertAll(s => s.ToUpper()));
            }
        }
コード例 #14
0
        public static void CreateFilter(object sender, object selectedItem)
        {
            if (selectedItem is FilterCollectionViewModel filterCollectionViewModel)
            {
                CreateFilter(sender, filterCollectionViewModel.Parent);
                return;
            }

            var button = (Button)sender;

            var type = (string)button.CommandParameter;

            FilterBase entity;

            switch (type)
            {
            case nameof(ActiveOn):
                entity = ActiveOn.New("0001-01-01");
                break;

            case nameof(ActiveWithin):
                entity = ActiveWithin.New("0001-01-01,0001-01-01");
                break;

            case nameof(OfType):
                entity = OfType.New("TypeName");
                break;

            case nameof(NotOfType):
                entity = NotOfType.New("TypeName");
                break;

            case nameof(Contain):
                entity = Contain.New("Property", "Value");
                break;

            case nameof(NotContain):
                entity = NotContain.New("Property", "Value");
                break;

            case nameof(EqualTo):
                entity = EqualTo.New("Property", "Value");
                break;

            case nameof(NotEqualTo):
                entity = NotEqualTo.New("Property", "Value");
                break;

            case nameof(GreaterThan):
                entity = GreaterThan.New("Property", "Value");
                break;

            case nameof(LessThan):
                entity = LessThan.New("Property", "Value");
                break;

            case nameof(GreaterThanEqualTo):
                entity = GreaterThanEqualTo.New("Property", "Value");
                break;

            case nameof(LessThanEqualTo):
                entity = LessThanEqualTo.New("Property", "Value");
                break;

            case nameof(Between):
                entity = Between.New("Property", "0001-01-01", "0001-01-01");
                break;

            case nameof(WithinArray):
                entity = WithinArray.New("Property", "ValueA,ValueB,ValueC");
                break;

            case nameof(NotWithinArray):
                entity = NotWithinArray.New("Property", "ValueA,ValueB,ValueC");
                break;

            case nameof(IsNull):
                entity = IsNull.New("Property");
                break;

            case nameof(IsNotNull):
                entity = IsNotNull.New("Property");
                break;

            case nameof(IsNullOrGreaterThan):
                entity = IsNullOrGreaterThan.New("Property", "Value");
                break;

            case nameof(IsNullOrGreaterThanEqualTo):
                entity = IsNullOrGreaterThanEqualTo.New("Property", "Value");
                break;

            case nameof(IsNullOrLessThan):
                entity = IsNullOrLessThan.New("Property", "Value");
                break;

            case nameof(IsNullOrLessThanEqualTo):
                entity = IsNullOrLessThanEqualTo.New("Property", "Value");
                break;

            case nameof(StartsWith):
                entity = StartsWith.New("Property", "Value");
                break;

            case nameof(EndsWith):
                entity = EndsWith.New("Property", "Value");
                break;

            case nameof(TakeFirst):
                entity = TakeFirst.New(1);
                break;

            case nameof(OfDerivedType):
                entity = OfDerivedType.New("TypeName");
                break;

            case nameof(NotOfDerivedType):
                entity = NotOfDerivedType.New("TypeName");
                break;

            default:
                throw new ArgumentOutOfRangeException();
            }

            FilterViewModel           viewModel;
            FilterCollectionViewModel viewModelCollection;

            if (selectedItem is GroupViewModel entityGroupViewModel)
            {
                entityGroupViewModel.IsExpanded = true;

                entityGroupViewModel.Element.Filters.Add(entity);
                viewModelCollection = entityGroupViewModel.Children.OfType <FilterCollectionViewModel>().First();

                viewModel = new FilterViewModel(entity, viewModelCollection);
                viewModelCollection.Children.Add(viewModel);
            }
            else if (selectedItem is OutputViewModel outputViewModel)
            {
                if (!(outputViewModel.Element is AggregateOutputBase elementAsAggregate))
                {
                    return;
                }

                outputViewModel.IsExpanded = true;

                elementAsAggregate.Filters.Add(entity);
                viewModelCollection = outputViewModel.Children.OfType <FilterCollectionViewModel>().First();

                viewModel = new FilterViewModel(entity, viewModelCollection);
                viewModelCollection.Children.Add(viewModel);
            }
            else
            {
                return;
            }

            viewModelCollection.IsExpanded = true;
            viewModel.IsSelected           = true;
            viewModel.IsExpanded           = true;
        }
コード例 #15
0
 public void Should_Have_Length()
 {
     new string[] { "hi", "there" }.Should(Have.Member("hi"));
     new string[] { "hi", "there" }.Should(Contain.Item("hi"));
 }
コード例 #16
0
        public async Task <RelationshipInstance <Contraindicate> > UpdateContraindicateAsync(string sourceSubstanceId, string targetSubstanceId, Contain data = null)
        {
            try
            {
                var contains = await _client.Cypher
                               .Match("(s:Substance)-[r:Contraindicate]->(t:Substance)")
                               .Where((Substance s) => s.SubstanceId == sourceSubstanceId)
                               .AndWhere((Substance t) => t.SubstanceId == targetSubstanceId)
                               .Set("r = {data}")
                               .WithParam("data", data)
                               .Return <RelationshipInstance <Contraindicate> >("r")
                               .ResultsAsync;

                return(contains.Single());
            }
            catch (Exception ex)
            {
                _logger.LogError("Error executing graph query: {0}", ex.Message);
                throw new InvalidOperationException(ex.Message);
            }
        }
コード例 #17
0
        public async Task <RelationshipInstance <Contain> > CreateContainAsync(string productId, string substanceId, Contain data = null)
        {
            try
            {
                var contains = await _client.Cypher
                               .Match("(s:Product)", "(t:Substance)")
                               .Where((Product s) => s.ProductId == productId)
                               .AndWhere((Substance t) => t.SubstanceId == substanceId)
                               .CreateUnique("(s)-[r:Contain {data}]->(t)")
                               .WithParam("data", data)
                               .Return <RelationshipInstance <Contain> >("r")
                               .ResultsAsync;

                return(contains.Single());
            }
            catch (Exception ex)
            {
                _logger.LogError("Error executing graph query: {0}", ex.Message);
                throw new InvalidOperationException(ex.Message);
            }
        }
コード例 #18
0
    public IEnumerator deleteMapBeforeQuit(string otherPlayerID)
    {
        WWWForm formQuit = new WWWForm();

        formQuit.AddField("otherClientIDPost", otherPlayerID);
        WWW itemsDataQuit = new WWW(UpdateMapWhenAClientQuitURL, formQuit);

        yield return(itemsDataQuit);

        string itemsDataString = itemsDataQuit.text;

        //try catch trong trường hợp chỉ có duy nhất 1 map mà disconnect
        try{
            itemsDataString = itemsDataString.Substring(0, itemsDataString.Length - 1);
            string[] list_items;
            list_items = itemsDataString.Split('/');
            //Debug.Log (itemsDataString);
            //Debug.Log (otherPlayerID);
            //Debug.Log (list_items [0]);
            foreach (string itemString in list_items)
            {
                string[] items = itemString.Split(';');
                this.GetComponent <NetworkView> ().RPC("TellClientToReCreateWall", RPCMode.Others, new object[] { items[1], items[2] });

                //--//
                GameObject[] list_createdWalls = GameObject.FindGameObjectsWithTag("To" + items[2]);
                foreach (GameObject go in list_createdWalls)
                {
                    if (go.transform.IsChildOf(GameObject.Find("ClientMap" + items [1]).transform))
                    {
                        Destroy(go);
                    }
                }

                if (items [2] == "Right")
                {
                    if (GameObject.Find("ClientMap" + items [1]) != null)
                    {
                        GameObject go = GameObject.Find("ClientMap" + items [1]).transform.GetChild(1).GetChild(4).gameObject;
                        go.SetActive(true);

                        Contain l = (Contain)go.GetComponent(typeof(Contain));
                        l.isRightDownCreated = false;
                        l.isRightUpCreated   = false;
                        //l.listPoints.Clear ();
                        //Debug.Log ("GOOO: " + go.name);
                    }
                }
                if (items [2] == "Left")
                {
                    if (GameObject.Find("ClientMap" + items [1]) != null)
                    {
                        GameObject go = GameObject.Find("ClientMap" + items [1]).transform.GetChild(1).GetChild(2).gameObject;
                        go.SetActive(true);

                        Contain l = (Contain)go.GetComponent(typeof(Contain));
                        l.isLeftUpCreated   = false;
                        l.isLeftDownCreated = false;
                        //l.listPoints.Clear ();
                        //Debug.Log ("GOOO: " + go.name);
                    }
                }
                if (items [2] == "Front")
                {
                    if (GameObject.Find("ClientMap" + items [1]) != null)
                    {
                        GameObject go = GameObject.Find("ClientMap" + items [1]).transform.GetChild(1).GetChild(5).gameObject;
                        go.SetActive(true);

                        Contain l = (Contain)go.GetComponent(typeof(Contain));
                        l.isLeftUpCreated  = true;
                        l.isRightUpCreated = true;
                        //l.listPoints.Clear ();
                        //Debug.Log ("GOOO: " + go.name);
                    }
                }
            }
        }catch (Exception e) {
            Debug.Log(e, this);
        }

        GameObject clientMap = GameObject.Find("ClientMap" + otherPlayerID);

        Destroy(clientMap);

        GameObject clientMinimap = GameObject.Find("Minimap" + otherPlayerID);

        Destroy(clientMinimap);
        this.GetComponent <NetworkView> ().RPC("TellOtherClientsToDeleteMinimap", RPCMode.Others, otherPlayerID);


        GameObject chooseMap = GameObject.Find("ChooseMap" + otherPlayerID);

        Destroy(chooseMap);

        for (int i = 0; i < grid_ListClientManager.transform.childCount; i++)
        {
            if (grid_ListClientManager.transform.GetChild(i).gameObject.name.Contains(otherPlayerID))
            {
                Destroy(grid_ListClientManager.transform.GetChild(i).gameObject);
            }
        }
        //-----//
        WWWForm formPrint = new WWWForm();

        formPrint.AddField("otherClientIDPost", otherPlayerID);
        WWW itemsDataPrint = new WWW(DeleteMapStateURL, formPrint);
    }
コード例 #19
0
 /// <summary>
 /// Creates an empty MysteryBlock
 /// </summary>
 public MysteryBlock() : base()
 {
     Contains  = Contain.Empty;
     ItemsLeft = 0;
 }