Example #1
0
        public IActionResult Send(
            [FromQuery(Name = "api_id")] Guid apiId,
            [FromQuery] String from,
            [FromQuery] Int32 json,
            [FromQuery(Name = "msg")] String encodedMsg,
            [FromQuery] String to
            )
        {
            var msg   = Uri.UnescapeDataString(encodedMsg);
            var phone = new Phone(to);

            this._logger.LogInformation($"Received message to {phone}");
            var account = this.Find(from);
            var cascade = new Cascade(
                this.CreateValidators(
                    account,
                    phone
                    )
                );

            this.TryToSaveMessage(new Sms {
                Message = msg, To = phone.ToString()
            }, cascade.Answer());
            return(new OkObjectResult(
                       new OkFromSmsRu(
                           phone,
                           cascade.Answer(),
                           account
                           )
                       ));
        }
Example #2
0
 public OrderMapping(Cascade productsCascade, Cascade fkProductsCascade)
 {
     Property(o => o.Status, o => o.NotNullable(true));
     Property(o => o.Name, o =>
     {
         o.NotNullable(true);
         o.Length(20);
     });
     Property(o => o.TotalPrice, o => o.NotNullable(true));
     Property(o => o.Active, o => o.NotNullable(true));
     Component(o => o.Address, o =>
     {
         o.Property(c => c.City);
         o.Property(c => c.Country);
         o.Property(c => c.HouseNumber);
         o.Property(c => c.Street);
     });
     Set(o => o.Products, o =>
     {
         o.Key(k => k.Column("OrderId"));
         o.Inverse(true);
         o.Cascade(productsCascade);
         o.Lazy(CollectionLazy.Extra);
     }, o => o.OneToMany());
     Set(o => o.FkProducts, o =>
     {
         o.Key(k => k.Column("OrderId"));
         o.Inverse(true);
         o.Cascade(fkProductsCascade);
         o.Lazy(CollectionLazy.Extra);
     }, o => o.OneToMany());
 }
Example #3
0
        private async Task <Cascade <int> > GetCascadeAsync(SiteSummary summary, Func <SiteSummary, Task <object> > func = null)
        {
            object extra = null;

            if (func != null)
            {
                extra = await func(summary);
            }
            var cascade = new Cascade <int>
            {
                Value    = summary.Id,
                Label    = summary.SiteName,
                Children = await GetCascadeChildrenAsync(summary.Id, func)
            };

            if (extra == null)
            {
                return(cascade);
            }

            var dict = TranslateUtils.ToDictionary(extra);

            foreach (var o in dict)
            {
                cascade[o.Key] = o.Value;
            }

            return(cascade);
        }
        public void SimplePropertyAccess_GetCustomMember_FixedAttributeProxy()
        {
            const string scriptFunctionSourceCode = @"
import clr
def PropertyPathAccess(cascade) :
  return cascade.GetName()
";

            const int numberChildren = 10;
            var       cascade        = new Cascade(numberChildren);

            var attributeNameProxy = _scriptContext.GetAttributeProxy(cascade, "GetName");
            var cascadeGetCustomMemberReturnsFixedAttributeProxy = new CascadeGetCustomMemberReturnsFixedAttributeProxy(numberChildren, attributeNameProxy);

            var privateScriptEnvironment = ScriptEnvironment.Create();

            privateScriptEnvironment.Import(typeof(Cascade).Assembly.GetName().Name, typeof(Cascade).Namespace, typeof(Cascade).Name);

            var propertyPathAccessScript = new ScriptFunction <Cascade, string> (
                _scriptContext,
                ScriptLanguageType.Python,
                scriptFunctionSourceCode,
                privateScriptEnvironment,
                "PropertyPathAccess"
                );

            //var nrLoopsArray = new[] { 1, 1, 10, 100, 1000, 10000, 100000, 1000000 };
            var nrLoopsArray = new[] { 1, 1, 10, 100, 1000, 10000, 100000 };

            ScriptingHelper.ExecuteAndTime("script function", nrLoopsArray, () => propertyPathAccessScript.Execute(cascade));
            ScriptingHelper.ExecuteAndTime("script function (FixedAttributeProxy)", nrLoopsArray, () => propertyPathAccessScript.Execute(cascadeGetCustomMemberReturnsFixedAttributeProxy));
        }
        public void SimplePropertyAccess_GetCustomMember2()
        {
            const string scriptFunctionSourceCode = @"
import clr
def PropertyPathAccess(cascade) :
  return cascade.Child.Child.Child.Child.Child.Child.Child.Child.Child.Name
";

            const int numberChildren                = 10;
            var       cascade                       = new Cascade(numberChildren);
            var       cascadeStableBinding          = new CascadeStableBinding(numberChildren);
            var       cascadeStableBindingFromMixin = ObjectFactory.Create <CascadeStableBindingFromMixin> (ParamList.Create(numberChildren));

            var privateScriptEnvironment = ScriptEnvironment.Create();

            privateScriptEnvironment.Import(typeof(TestDomain.Cascade).Assembly.GetName().Name, typeof(TestDomain.Cascade).Namespace, typeof(TestDomain.Cascade).Name);

            var propertyPathAccessScript = new ScriptFunction <Cascade, string> (
                _scriptContext, ScriptLanguageType.Python,
                scriptFunctionSourceCode, privateScriptEnvironment, "PropertyPathAccess"
                );

            var nrLoopsArray = new[] { 1, 1, 100000 };

            ScriptingHelper.ExecuteAndTime("SimplePropertyAccess_GetCustomMember2 (No StableBinding)", nrLoopsArray, () => propertyPathAccessScript.Execute(cascade));
            ScriptingHelper.ExecuteAndTime("SimplePropertyAccess_GetCustomMember2 (StableBinding from Mixin)", nrLoopsArray, () => propertyPathAccessScript.Execute(cascadeStableBindingFromMixin));
            ScriptingHelper.ExecuteAndTime("SimplePropertyAccess_GetCustomMember2 (StableBinding)", nrLoopsArray, () => propertyPathAccessScript.Execute(cascadeStableBinding));
        }
        public void BoardTest()
        {
            foreach (FreeSpace space in board.FreeSpaces)
            {
                Assert.AreEqual(0, space.CardList.Count);
            }
            int totalCards = 0;

            for (int i = 0; i < 4; i++)
            {
                Cascade casc = board.Cascades[i];
                totalCards = totalCards + casc.CardList.Count;
                Assert.AreEqual(7, casc.CardList.Count);
            }
            for (int i = 4; i < 8; i++)
            {
                Cascade casc = board.Cascades[i];
                totalCards = totalCards + casc.CardList.Count;
                Assert.AreEqual(6, casc.CardList.Count);
            }
            Assert.AreEqual(52, totalCards);

            Assert.AreEqual(false, board.Foundations[Suit.Spades] == null);
            Assert.AreEqual(0, board.Foundations[Suit.Spades].CardList.Count);
            Assert.AreEqual(false, board.Foundations[Suit.Hearts] == null);
            Assert.AreEqual(0, board.Foundations[Suit.Hearts].CardList.Count);
            Assert.AreEqual(false, board.Foundations[Suit.Diamonds] == null);
            Assert.AreEqual(0, board.Foundations[Suit.Diamonds].CardList.Count);
            Assert.AreEqual(false, board.Foundations[Suit.Clubs] == null);
            Assert.AreEqual(0, board.Foundations[Suit.Clubs].CardList.Count);
        }
        private async Task GetDirectoriesAndFilesAsync(List <Cascade <string> > directories, List <KeyValuePair <string, string> > files, Site site, string virtualPath, string extName)
        {
            extName = "." + extName;
            var directoryPath = await _pathManager.GetSitePathAsync(site, virtualPath);

            DirectoryUtils.CreateDirectoryIfNotExists(directoryPath);
            var fileNames = DirectoryUtils.GetFileNames(directoryPath);

            foreach (var fileName in fileNames)
            {
                if (StringUtils.EqualsIgnoreCase(PathUtils.GetExtension(fileName), extName))
                {
                    files.Add(new KeyValuePair <string, string>(virtualPath, fileName));
                }
            }

            var dir = new Cascade <string>
            {
                Label = PathUtils.GetDirectoryName(directoryPath, false),
                Value = virtualPath
            };

            var children = DirectoryUtils.GetDirectoryNames(directoryPath);

            dir.Children = new List <Cascade <string> >();
            foreach (var directoryName in children)
            {
                await GetDirectoriesAndFilesAsync(dir.Children, files, site, PageUtils.Combine(virtualPath, directoryName), extName);
            }

            directories.Add(dir);
        }
        public void SimplePropertyAccess_GetCustomMember()
        {
            const string scriptFunctionSourceCode = @"
import clr
def PropertyPathAccess(cascade) :
  return cascade.Child.Child.Child.Child.Child.Child.Child.Child.Child.Name
";

            const int numberChildren = 10;
            var       cascadeWithoutStableBinding = new Cascade(numberChildren);
            var       cascadeStableBinding        = new CascadeStableBinding(numberChildren);

            var privateScriptEnvironment = ScriptEnvironment.Create();

            privateScriptEnvironment.Import(typeof(TestDomain.Cascade).Assembly.GetName().Name, typeof(TestDomain.Cascade).Namespace, typeof(TestDomain.Cascade).Name);

            var propertyPathAccessScript = new ScriptFunction <Cascade, string> (
                _scriptContext, ScriptLanguageType.Python,
                scriptFunctionSourceCode, privateScriptEnvironment, "PropertyPathAccess"
                );

            //var nrLoopsArray = new[] { 1, 1, 10000 };
            var nrLoopsArray = new[] { 1, 1, 100000 };

            // Warm up
            ScriptingHelper.ExecuteAndTime(nrLoopsArray, () => propertyPathAccessScript.Execute(cascadeStableBinding)).Last();

            double timingStableBinding        = ScriptingHelper.ExecuteAndTime(nrLoopsArray, () => propertyPathAccessScript.Execute(cascadeStableBinding)).Last();
            double timingWithoutStableBinding = ScriptingHelper.ExecuteAndTime(nrLoopsArray, () => propertyPathAccessScript.Execute(cascadeWithoutStableBinding)).Last();

            //To.ConsoleLine.e (() => timingStableBinding).e (() => timingWithoutStableBinding);
            //To.ConsoleLine.e ("timingStableBinding / timingWithoutStableBinding = ", timingStableBinding / timingWithoutStableBinding);

            Assert.That(timingStableBinding / timingWithoutStableBinding, Is.LessThan(7.0));
        }
Example #9
0
 // Use this for initialization
 void Start()
 {
     manager = this;
     for (int i = 0; i < 7; i++)
     {
         var         obj         = Instantiate(placeholderPrefab) as GameObject;
         BoxCollider boxCollider = obj.GetComponent <BoxCollider>();
         Cascade     cascade     = obj.GetComponent <Cascade>();
         cascades.Add(cascade);
         cascade.transform.parent          = cascadesTransform;
         cascade.cardsRootTransform.parent = cascadeCardsTransform;
         float width = boxCollider.bounds.size.x;
         cascade.transform.localPosition          = new Vector3(i * (width + spacing), 0, 0);
         cascade.cardsRootTransform.localPosition = new Vector3(i * (width + spacing), 0, 0);
         cascade.transform.rotation          = obj.transform.parent.rotation;
         cascade.cardsRootTransform.rotation = cascadeCardsTransform.rotation;
         obj.transform.localRotation        *= Quaternion.AngleAxis(-90, new Vector3(1, 0, 0));
         allPlaceholders.Add(cascade);
     }
     //acePiles.AddRange(new List<AcePile>{wands,cups,swords,coins});
     allPlaceholders.AddRange(from p in acePiles select(Placeholder) p);
     allPlaceholders.AddRange(from p in cascades select(Placeholder) p);
     allPlaceholders.Add(deck);
     allPlaceholders.Add(hand);
     allPlaceholders.Add(discard);
     hand.deck    = deck;
     hand.discard = discard;
     deck.hand    = hand;
     deck.discard = discard;
 }
        public ActionResult Index(Cascade cas)
        {
            tblstud stud = new tblstud();

            if (ModelState.IsValid)
            {
                try
                {
                    stud.name    = cas.getstu.name;
                    stud.address = cas.getstu.address;
                    stud.gender  = cas.getstu.gender;
                    stud.stateid = cas.StateId;
                    stud.cityid  = cas.CityId;
                    cas.getstu   = stud;
                    sd.tblstuds.Add(stud);
                    sd.SaveChanges();
                    State_Bind();
                }
                catch
                {
                    State_Bind();
                    return(View(cas));
                }
            }

            return(View(cas));
        }
Example #11
0
 private static IEnumerable <string> CascadeDefinitions(this Cascade source)
 {
     if (source.Has(Cascade.All))
     {
         yield return("all");
     }
     if (source.Has(Cascade.Persist))
     {
         yield return("save-update, persist");
     }
     if (source.Has(Cascade.Refresh))
     {
         yield return("refresh");
     }
     if (source.Has(Cascade.Merge))
     {
         yield return("merge");
     }
     if (source.Has(Cascade.Remove))
     {
         yield return("delete");
     }
     if (source.Has(Cascade.Detach))
     {
         yield return("evict");
     }
     if (source.Has(Cascade.ReAttach))
     {
         yield return("lock");
     }
     if (source.Has(Cascade.DeleteOrphans))
     {
         yield return("delete-orphan");
     }
 }
        public void LongPropertyPathAccess_StableBinding()
        {
            const string scriptFunctionSourceCode =
                @"
import clr
def PropertyPathAccess(cascade) :
  if cascade.GetChild().GetChild().GetChild().GetChild().GetChild().GetChild().GetChild().GetChild().GetChild().GetName() == 'C0' :
    return cascade.GetChild().GetChild().GetChild().GetChild().GetChild().GetChild().GetChild().GetName()
  return 'FAILED'
";

            const int numberChildren       = 10;
            var       cascade              = new Cascade(numberChildren);
            var       cascadeStableBinding = new CascadeStableBinding(numberChildren);
            //var cascadeStableBinding = ObjectFactory.Create<CascadeStableBinding> (ParamList.Create (numberChildren));

            var privateScriptEnvironment = ScriptEnvironment.Create();

            privateScriptEnvironment.Import(typeof(Cascade).Assembly.GetName().Name, typeof(Cascade).Namespace, typeof(Cascade).Name);

            var propertyPathAccessScript = new ScriptFunction <Cascade, string> (
                _scriptContext,
                ScriptLanguageType.Python,
                scriptFunctionSourceCode,
                privateScriptEnvironment,
                "PropertyPathAccess"
                );

            //var nrLoopsArray = new[] { 1, 1, 10, 100, 1000, 10000, 100000, 1000000 };
            var nrLoopsArray = new[] { 1, 1, 10, 100, 1000, 10000 };

            ScriptingHelper.ExecuteAndTime("script function", nrLoopsArray, () => propertyPathAccessScript.Execute(cascade));
            ScriptingHelper.ExecuteAndTime("script function (stable binding)", nrLoopsArray, () => propertyPathAccessScript.Execute(cascadeStableBinding));
        }
Example #13
0
 public static Cascade Exclude(this Cascade source, Cascade value)
 {
     if (source.Has(Cascade.All) && !value.Has(Cascade.All))
     {
         return(Cleanup(((source & ~Cascade.All) | AnyButOrphans) & ~value));
     }
     return(Cleanup(source & ~value));
 }
Example #14
0
        public void CascadeTest()
        {
            Cascade cascade = new Cascade();

            double actual = cascade.ComputeLength(testArray);

            Assert.AreEqual(result, actual);
        }
		public static Cascade Exclude(this Cascade source, Cascade value)
		{
			if (source.Has(Cascade.All) && !value.Has(Cascade.All))
			{
				return Cleanup(((source & ~Cascade.All) | AnyButOrphans) & ~value);
			}
			return Cleanup(source & ~value);
		}
        /// <summary>
        /// Constructs a new Midi Processor.
        /// </summary>
        /// <param name="plugin">Must not be null.</param>
        public MidiProcessor(Plugin plugin)
        {
            _plugin = plugin;
            Cascade = new Cascade(plugin);

            // for most hosts, midi output is expected during the audio processing cycle.
            SyncWithAudioProcessor = true;
        }
Example #17
0
        /// <summary>
        /// Gets the child entities which would be affected by the specified cascade.
        /// </summary>
        /// <param name="entity">The entity.</param>
        /// <param name="cascade">The cascade.</param>
        /// <returns>Returns a list of entities.</returns>
        public List <Entity> GetChildEntities(Entity entity, Cascade cascade)
        {
            var entities = new List <Entity>();

            GetChildEntities(entity, cascade, entities);

            return(entities);
        }
 public ManyToManyAttribute( Type childType, Mapping.Loading loading, Cascade cascade )
     : base()
 {
     this.ChildReturnType = childType;
     this.Linked = true;
     this.Loading = loading;
     this.Cascade = cascade;
 }
Example #19
0
 protected override Message ReceiveAuthenticatedMessage(AuthenticatedMessage message)
 {
     if (message is BlocksParityRequest)
     {
         var blockParityRequestMessage = message as BlocksParityRequest;
         var blocksPayload             = message.Payload as Blocks;
         for (int i = 0; i < blocksPayload.BlocksArray.Length; i++)
         {
             var block  = blocksPayload.BlocksArray[i];
             var parity = Cascade.Parity(DestilationBuffer.GetBits(block.Index, block.Length));
             blocksPayload.BlocksArray[i].Parity = parity;
         }
         var mac = MessageAuthenticator.GetMAC(blocksPayload.GetBytes());
         return(new BlocksParityResponse(mac, blocksPayload));
     }
     if (message is CheckParity)
     {
         var checkParityMessage  = message as CheckParity;
         var blockIdentification = checkParityMessage.Payload as BlockIdentifiaction;
         var parity  = Cascade.Parity(DestilationBuffer.GetBits(blockIdentification.Index, blockIdentification.Length));
         var payload = new ParityPayload(blockIdentification.Index, blockIdentification.Length, parity);
         var mac     = MessageAuthenticator.GetMAC(payload.GetBytes());
         return(new Parity(mac, payload));
     }
     if (message is RequestBits)
     {
         var requestBitsMessage  = message as RequestBits;
         var blockIdentification = requestBitsMessage.Payload as BlockIdentifiaction;
         var bytes   = DestilationBuffer.GetBytes(blockIdentification.Index, blockIdentification.Length);
         var payload = new BitsAsBytes(blockIdentification.Index, blockIdentification.Length, bytes);
         var mac     = MessageAuthenticator.GetMAC(payload.GetBytes());
         return(new Bytes(mac, payload, requestBitsMessage.Demand));
     }
     if (message is AddKey)
     {
         var addKeyMessage = message as AddKey;
         var messagPayload = (addKeyMessage.Payload as BlockIdAndKeyAllocation);
         if (messagPayload.BlockId == _currentKeyChunk + 1)
         {
             var key = LocalKeyStore.GetKey();
             CommonKeyStore.AddNewKey(key, messagPayload.KeyAllocation);
             _currentKeyChunk += 1;
             return(PrepareAckForCommonKeyProposition(_currentKeyChunk));
         }
         else
         {
             if (messagPayload.BlockId == _currentKeyChunk)
             {
                 return(PrepareAckForCommonKeyProposition(_currentKeyChunk));
             }
             else
             {
                 return(new NOP());
             }
         }
     }
     return(new NOP());
 }
 public Cascade(int nrChildren)
 {
     --nrChildren;
     _name = "C" + nrChildren;
     if (nrChildren > 0)
     {
         Child = new Cascade(nrChildren);
     }
 }
 /// <summary>
 /// Instantiates a new instance of the <see cref="T:ManyToManyAttribute"/> defining a many to many relationship.
 /// </summary>
 /// <param name="childTable">The table name of the child.</param>
 /// <param name="linkingTable">The table name of the linking table between the parent and child.</param>
 /// <param name="childType">The <see cref="T:Type"/> of child.</param>
 /// <param name="loading">The <see cref="T:Loading"/> behavior to use for this member.</param>
 /// <param name="cascade"><see cref="T:Cascade"/> behavior of this relationship.</param>
 public ManyToManyAttribute( string childTable, string linkingTable, Type childType, Mapping.Loading loading, Cascade cascade )
     : base()
 {
     this.ChildReturnType = childType;
     this.Name = childTable;
     this.Linked = true;
     this.LinkName = linkingTable;
     this.Loading = loading;
     this.Cascade = cascade;
 }
        private Rect[] GetFacesInImage(Mat image)
        {
            Rect[] faces;
            lock (cascadeLock)
            {
                faces = Cascade.DetectMultiScale(image);
            }

            return(faces);
        }
Example #23
0
        /// <summary>
        /// Checks to see if it is possible to move the specified <see cref="Card"/> to the specified <see cref="Cascade"/>.
        /// </summary>
        /// <param name="card">The <see cref="Card"/> to check if its possible to move to the specified <see cref="Cascade"/></param>
        /// <param name="cascade">The <see cref="Cascade"/> that will be holding the specified <see cref="Card"/></param>
        /// <returns><c>true</c> if the specified <see cref="Card"/> can be moved to the specified <see cref="Stack"/>; otherwise <c>false</c></returns>
        public virtual bool CanMoveToCascade(Card card, Cascade cascade)
        {
            if (!EnforceRules)
                return true;

            if (cascade.Count == 0)
                return true;
            if (DoCardsLinkInCascade(card, cascade.Last()))
                return true;
            return false;
        }
Example #24
0
        public void Run()
        {
            Console.WriteLine(@"Creating face image...");
            SettingData.TotalFrameNum   = 0;
            SettingData.CurrentFrameNum = 0;

            foreach (var videoName in SettingData.VideoFileNames)
            {
                using (var video = new VideoCapture(videoName)) {
                    SettingData.TotalFrameNum += video.FrameCount;
                }
            }

            Cv2.NamedWindow("image", WindowMode.FreeRatio);

            foreach (var videoName in SettingData.VideoFileNames)
            {
                using (var video = VideoCapture.FromFile(videoName)) {
                    var frameNum = 0;
                    while (true)
                    {
                        using (var frame = video.RetrieveMat()) {
                            if (frame.Empty() || IsExitStatus)
                            {
                                if (IsExitStatus)
                                {
                                    Console.WriteLine(@"Cancel");
                                    IsExitStatus = false;
                                    goto CANCEL;
                                }
                                break;
                            }

                            frameNum++;
                            SettingData.CurrentFrameNum++;

                            //Detecting every 10 frames because the number of images
                            //increases too much when cutting out all frames
                            if (frameNum % SettingData.FrameRateNum == 0)
                            {
                                DetectAndSaveImg(frame);
                            }
                        }
                    }
                    Console.WriteLine(@"End of video");
                }
            }
CANCEL:

            Cv2.DestroyAllWindows();
            Cascade.Dispose();
        }
Example #25
0
 public Bag(CodeFileBuilder builder)
 {
     _builder      = builder;
     _where        = new Where(builder);
     _orderBy      = new OrderBy(builder);
     _cascade      = new Cascade(builder);
     _fetch        = new Fetch(builder);
     _inverse      = new Inverse(builder);
     _table        = new Table(builder);
     _keyColumn    = new KeyColumn(builder);
     _lazyLoad     = new LazyLoad(builder);
     _cacheBuilder = new CacheBuilder(builder);
 }
		private static Cascade Cleanup(Cascade cascade)
		{
			bool hasAll = cascade.Has(Cascade.All) || cascade.Has(AnyButOrphans);
			if (hasAll && cascade.Has(Cascade.DeleteOrphans))
			{
				return Cascade.All | Cascade.DeleteOrphans;
			}
			if (hasAll)
			{
				return Cascade.All;
			}
			return cascade;
		}
        public void LongPropertyPathAccess_StableBindingSimple()
        {
            const string scriptFunctionSourceCode = @"
import clr
def PropertyPathAccess(cascade) :
  return cascade.GetChild().GetChild().GetName()
";

            const int numberChildren       = 10;
            var       cascade              = new Cascade(numberChildren);
            var       cascadeStableBinding = new CascadeStableBinding(numberChildren);
            //var cascadeStableBinding = ObjectFactory.Create<CascadeStableBinding> (ParamList.Create (numberChildren));
            var cascadeLocalStableBinding = new CascadeLocalStableBinding(numberChildren);

            var cascadeGetCustomMemberReturnsAttributeProxyFromMap = new CascadeGetCustomMemberReturnsAttributeProxyFromMap(numberChildren);

            cascadeGetCustomMemberReturnsAttributeProxyFromMap.AddAttributeProxy("GetChild", cascade, _scriptContext);
            cascadeGetCustomMemberReturnsAttributeProxyFromMap.AddAttributeProxy("GetName", cascade, _scriptContext);


            var privateScriptEnvironment = ScriptEnvironment.Create();

            privateScriptEnvironment.Import(typeof(Cascade).Assembly.GetName().Name, typeof(Cascade).Namespace, typeof(Cascade).Name);

            var propertyPathAccessScript = new ScriptFunction <Cascade, string> (
                _scriptContext,
                ScriptLanguageType.Python,
                scriptFunctionSourceCode,
                privateScriptEnvironment,
                "PropertyPathAccess"
                );


            privateScriptEnvironment.ImportIifHelperFunctions();
            privateScriptEnvironment.SetVariable("GLOBAL_cascade", cascade);
            var expression = new ExpressionScript <Object> (
                _scriptContext,
                ScriptLanguageType.Python,
                "GLOBAL_cascade.GetChild().GetChild().GetName()",
                privateScriptEnvironment
                );


            //var nrLoopsArray = new[] { 1, 1, 10, 100, 1000, 10000, 100000, 1000000 };
            var nrLoopsArray = new[] { 1, 1, 10, 100, 1000, 10000 };

            ScriptingHelper.ExecuteAndTime("script function", nrLoopsArray, () => propertyPathAccessScript.Execute(cascade));
            ScriptingHelper.ExecuteAndTime("script function (stable binding)", nrLoopsArray, () => propertyPathAccessScript.Execute(cascadeStableBinding));
            ScriptingHelper.ExecuteAndTime("script function (local stable binding)", nrLoopsArray, () => propertyPathAccessScript.Execute(cascadeLocalStableBinding));
            ScriptingHelper.ExecuteAndTime("script function (from map)", nrLoopsArray, () => propertyPathAccessScript.Execute(cascadeGetCustomMemberReturnsAttributeProxyFromMap));
        }
Example #28
0
        /// <summary>
        /// Gets the child entities which would be affected by the specified cascade.
        /// </summary>
        /// <param name="entity">The entity.</param>
        /// <param name="cascade">The cascade,</param>
        /// <param name="entities">The entitylist.</param>
        private void GetChildEntities(Entity entity, Cascade cascade, List <Entity> entities)
        {
            if (entities.Contains(entity))
            {
                return;
            }

            entities.Add(entity);

            var entityType = entity.GetType();
            var metadata   = EntityMetadataResolver.GetEntityMetadata(entityType);

            foreach (var field in metadata.Fields.Where(x => x.IsComplexFieldType && x.Cascade >= cascade))
            {
                try
                {
                    var result = ReflectionHelper.GetProperty(entityType, field.ForeignKey).GetValue(entity);
                    if (result != null)
                    {
                        var subEntity = (Entity)result;
                        GetChildEntities(subEntity, cascade, entities);
                    }
                }
                catch (TargetInvocationException)
                {
                }
            }

            foreach (var listField in metadata.ListFields.Where(x => x.Cascade >= cascade))
            {
                var entityCollection = (IEntityCollection)ReflectionHelper.GetProperty(entityType, listField.Name).GetValue(entity);
                var subEntities      = entityCollection.GetCollectionItems();
                var removedEntities  = entityCollection.GetRemovedCollectionItems();

                foreach (var subEntity in subEntities)
                {
                    if (subEntity != null)
                    {
                        GetChildEntities(subEntity, cascade, entities);
                    }
                }

                foreach (var subEntity in removedEntities)
                {
                    if (subEntity != null)
                    {
                        GetChildEntities(subEntity, cascade, entities);
                    }
                }
            }
        }
Example #29
0
        public async Task <ActionResult <GetResult> > Get([FromQuery] ChannelRequest request)
        {
            if (!await _authManager.HasSitePermissionsAsync(request.SiteId,
                                                            MenuUtils.SitePermissions.SettingsStyleContent))
            {
                return(Unauthorized());
            }

            var site = await _siteRepository.GetAsync(request.SiteId);

            if (site == null)
            {
                return(NotFound());
            }

            var channel = await _channelRepository.GetAsync(request.ChannelId);

            var tableName         = _channelRepository.GetTableName(site, channel);
            var relatedIdentities = _tableStyleRepository.GetRelatedIdentities(channel);
            var styles            = await _tableStyleRepository.GetTableStylesAsync(tableName, relatedIdentities);

            foreach (var style in styles)
            {
                style.IsSystem = style.RelatedIdentity != request.ChannelId;
            }

            Cascade <int> cascade = null;

            if (request.ChannelId == request.SiteId)
            {
                cascade = await _channelRepository.GetCascadeAsync(site, channel, async summary =>
                {
                    var count = await _contentRepository.GetCountAsync(site, summary);
                    return(new
                    {
                        Count = count
                    });
                });
            }

            var inputTypes = ListUtils.GetSelects <InputType>();

            return(new GetResult
            {
                TableName = tableName,
                RelatedIdentities = ListUtils.ToString(relatedIdentities),
                Styles = styles,
                InputTypes = inputTypes,
                Channels = cascade
            });
        }
        public void LongPropertyPathAccess_DlrVsClr()
        {
            const string scriptFunctionSourceCode =
                @"
import clr
def PropertyPathAccess(cascade) :
  if cascade.Child.Child.Child.Child.Child.Child.Child.Child.Child.Name == 'C0' :
    return cascade.Child.Child.Child.Child.Child.Child.Child.Name
  return 'FAILED'
";

            const string expressionScriptSourceCode =
                "IIf( GLOBAL_cascade.Child.Child.Child.Child.Child.Child.Child.Child.Child.Name == 'C0',GLOBAL_cascade.Child.Child.Child.Child.Child.Child.Child.Name,'FAILED')";


            var cascade = new Cascade(10);

            var privateScriptEnvironment = ScriptEnvironment.Create();

            privateScriptEnvironment.ImportIifHelperFunctions();
            privateScriptEnvironment.SetVariable("GLOBAL_cascade", cascade);

            privateScriptEnvironment.Import(typeof(Cascade).Assembly.GetName().Name, typeof(Cascade).Namespace, typeof(Cascade).Name);

            var propertyPathAccessScript = new ScriptFunction <Cascade, string> (
                _scriptContext,
                ScriptLanguageType.Python,
                scriptFunctionSourceCode,
                privateScriptEnvironment,
                "PropertyPathAccess"
                );

            var propertyPathAccessExpressionScript = new ExpressionScript <string> (
                _scriptContext, ScriptLanguageType.Python, expressionScriptSourceCode, privateScriptEnvironment
                );

            var nrLoopsArray = new[] { 1, 1, 10, 100, 1000, 10000, 100000, 1000000 };

            //var nrLoopsArray = new[] { 1, 1, 10, 100, 1000, 10000};
            ScriptingHelper.ExecuteAndTime("C# method", nrLoopsArray, delegate
            {
                if (cascade.Child.Child.Child.Child.Child.Child.Child.Child.Child.Name == "C0")
                {
                    return(cascade.Child.Child.Child.Child.Child.Child.Child.Name);
                }
                return("FAILED");
            });
            ScriptingHelper.ExecuteAndTime("script function", nrLoopsArray, () => propertyPathAccessScript.Execute(cascade));
            ScriptingHelper.ExecuteAndTime("expression script", nrLoopsArray, propertyPathAccessExpressionScript.Execute);
        }
Example #31
0
        private static Cascade Cleanup(Cascade cascade)
        {
            bool hasAll = cascade.Has(Cascade.All) || cascade.Has(AnyButOrphans);

            if (hasAll && cascade.Has(Cascade.DeleteOrphans))
            {
                return(Cascade.All | Cascade.DeleteOrphans);
            }
            if (hasAll)
            {
                return(Cascade.All);
            }
            return(cascade);
        }
        public void ProcessCurrentEvents()
        {
            //_plugin.PluginEditor.Log("ProcessCurrentEvents");

            // a plugin must implement IVstPluginMidiSource or this call will throw an exception.
            var midiHost = _plugin.Host.GetInstance <IVstMidiProcessor>();

            // always expect some hosts not to support this.
            if (midiHost != null)
            {
                var outEvents = new VstEventCollection();

                var someCommands = _plugin.Host.GetInstance <IVstHostCommands20>();
                var timeInfo     = someCommands.GetTimeInfo(
                    VstTimeInfoFlags.PpqPositionValid | VstTimeInfoFlags.BarStartPositionValid | VstTimeInfoFlags.TempoValid);
                if (CurrentEvents != null)
                {
                    // NOTE: other types of events could be in the collection!
                    foreach (VstEvent evnt in CurrentEvents)
                    {
                        switch (evnt.EventType)
                        {
                        case VstEventTypes.MidiEvent:
                            var midiEvent = (VstMidiEvent)evnt;

                            midiEvent = Cascade.ProcessEvent(midiEvent, timeInfo);

                            //_plugin.PluginEditor.Log("tempo" + x.Tempo);

                            outEvents.Add(midiEvent);
                            break;

                        default:
                            // non VstMidiEvent
                            outEvents.Add(evnt);
                            break;
                        }
                    }
                }

                outEvents.AddRange(Cascade.CreateNotes(timeInfo));

                midiHost.Process(outEvents);
            }

            // Clear the cache, we've processed the events.
            CurrentEvents = null;
        }
Example #33
0
        public CascadeTests()
        {
            var smsRu = new Account()
            {
                Type    = "sms",
                Service = "smsru",
                Login   = "******",
                Balance = 0
            };

            this._cascade = new Cascade(new List <Validator>
            {
                new BalanceValidator(smsRu),
                new MobilePhoneValidator(new Phone("78123333333"))
            });
        }
Example #34
0
        protected override Message ReceiveAuthenticatedMessage(AuthenticatedMessage message)
        {
            if (message is Bytes)
            {
                var bytesMessage       = message as Bytes;
                var bitsAsBytesPayload = bytesMessage.Payload as BitsAsBytes;

                if (bytesMessage.Demand == Demand.Estimation)
                {
                    var bobBits       = new BitArray(bitsAsBytesPayload.GetBytes().ToList().Skip(8).ToArray());
                    var aliceBits     = new BitArray(DestilationBuffer.GetBytes(bitsAsBytesPayload.Index, bitsAsBytesPayload.Length));
                    var estimatedQBER = Cascade.EstimateQBER(aliceBits, bobBits);
                    DestilationBuffer.SetEstimatedQBER(estimatedQBER);
                }
                if (bytesMessage.Demand == Demand.Confirmation)
                {
                }
            }
            if (message is AddingKeyAck)
            {
                var addingKeyAckMessage = message as AddingKeyAck;

                if (DoesAckCorrespondsToLastSentKeyIndex(addingKeyAckMessage.Payload as BlockIdAndKeyAllocation))
                {
                    _lastReceivedKeyIndexAck = _lastSendKeyIndex;

                    var key = LocalKeyStore.GetKey();
                    CommonKeyStore.AddNewKey(key, (addingKeyAckMessage.Payload as BlockIdAndKeyAllocation).KeyAllocation);

                    if (!LocalKeyStore.IsEmpty())
                    {
                        _lastSendKeyIndex += 1;
                        return(PrepareMessageForNewKeyChunk(_lastSendKeyIndex));
                    }
                    else
                    {
                        return(new NOP());
                    }
                }
                else
                {
                    throw new UnexpectedMessageException();
                }
            }
            return(new NOP());
        }
Example #35
0
    public void Apply(Card card)
    {
        bool    success = false;
        Cascade aph     = (Cascade)card.parentPlaceholder;

        if (FilterPlaceholders(ArcanaCardRank, card))
        {
            return;
        }
        switch (ArcanaCardRank)
        {
        case 0:
            success = aph.ReverseCards(card);
            aph.ReverseArrows();
            aph.behaviour = Behaviour.ReverseAll;
            break;

        case 1:
            success = aph.SortNumericalDescending(card);
            break;

        case 2:
            success = aph.SortByZodiac(card);
            break;

        case 3:
            success = aph.SortBySuit(card);
            break;

        case 4:
            success = aph.RevealOneUp();
            break;

        case 5:
            success = aph.MoveToBottom(card);
            break;

        case 6:
            success = aph.MoveRowToBottom(card);
            break;
        }
        if (success)
        {
            Done();
        }
    }
Example #36
0
		/// <summary>Creates a new instance of the <see cref="ConfigurationBuilder"/>.</summary>
		public ConfigurationBuilder(IDefinitionProvider[] definitionProviders, ClassMappingGenerator generator, IWebContext webContext, ConfigurationBuilderParticipator[] participators, DatabaseSection config, ConnectionStringsSection connectionStrings)
		{
			this.definitionProviders = definitionProviders;
			this.generator = generator;
			this.webContext = webContext;
			this.participators = participators;

			if (config == null) config = new DatabaseSection();
			TryLocatingHbmResources = config.TryLocatingHbmResources;
			tablePrefix = config.TablePrefix;
			batchSize = config.BatchSize;
			childrenLaziness = config.Children.Laziness;
			childrenCascade = config.Children.Cascade;
			cacheRegion = config.CacheRegion;

			SetupProperties(config, connectionStrings);
			SetupMappings(config);
		}
        public MyShadowsSettings()
        {
            m_shadowCascadeSmallSkipThresholds = new float[] { 1000, 5000, 200, 1000, 1000, 1000 };
            m_shadowCascadeFrozen = new bool[6];
            m_cascades = new Cascade[8];

            // no stabilization, csm resolution 2048, hard shadows:
            float baseCoef = 5.0f;
            float cascadePow = 5.0f;
            float extMult = 2;
            float snoPart = 758.0f;
            float skippingSmallObjectsThreshold = 0.0f;
            for (int i = 0; i < 8; i++)
            {
                float cascadeDepth = baseCoef * (float)Math.Pow(cascadePow, i);
                m_cascades[i].FullCoverageDepth = cascadeDepth;
                m_cascades[i].ExtendedCoverageDepth = cascadeDepth * extMult;
                m_cascades[i].ShadowNormalOffset = (cascadeDepth + extMult) / snoPart;
                m_cascades[i].SkippingSmallObjectThreshold = skippingSmallObjectsThreshold;
            };
        }
Example #38
0
		public void Cascade(Cascade cascadeStyle)
		{
			oneToOne.cascade = (cascadeStyle.Exclude(ByCode.Cascade.DeleteOrphans)).ToCascadeString();
		}
Example #39
0
 public void Cascade(Cascade cascadeStyle)
 {
     // not supported by HbmKeyManyToOne
 }
 public bool Equals(Cascade other)
 {
     return Equals(other.value, value);
 }
Example #41
0
        /// <summary>
        /// Checks to see if it is possible to move the specified <see cref="Card"/> to the specified <see cref="Cascade"/>.
        /// </summary>
        /// <param name="tableaux">The tableaux to try to move to the cascade.</param>
        /// <param name="cascade">The <see cref="Cascade"/> that will be holding the specified <see cref="Card"/></param>
        /// <returns><c>true</c> if the specified <see cref="Card"/> can be moved to the specified <see cref="Stack"/>; otherwise <c>false</c></returns>
        public virtual bool CanMoveToCascade(List<Card> tableaux, Cascade cascade, Game game)
        {
            if (!EnforceRules)
                return true;

            if (cascade.Count == 0)
                return true;

            Card landingCard = cascade.Last();

            if (tableaux.Count == 1)
            {
                // MOVING ONE CARD
                if (this.CanMoveToCascade(tableaux.Last(), cascade))
                {
                    return true;
                }
                else
                {
                    return false;
                }
            }
            else
            {
                // MOVING MULTIPLE CARDS... FIND THE MAXIMUM NUMBER OF MOVES AVAILABLE.
                int maxMoves = Utility.GetMaximumMovesForGame(game, (cascade.Count == 0));
                int level = 1;
                // WALK BACKWARDS OVER TABLEAUX TRYING EACH CARD AS A LINK TO LANDING CARD.
                for (int i = (tableaux.Count - 1); i >= 0; i--)
                {
                    // CHECK FOR THE LINK BETWEEN CURRENT TABLEAUX CARD AND LANDING CARD.
                    if (this.DoCardsLinkInCascade(tableaux[i], landingCard))
                    {
                        // CARDS LINK, CHECK TO SEE IF WE'VE EXCEEDED OUT MAX NUMBER OF MOVES ALLOWED.
                        if (level > maxMoves)
                        {
                            // MAX NUMBER OF MOVES EXCEEDED, MOVE FAILS
                            return false;
                        }
                        else
                        {
                            // MOVE SUCCESSFUL
                            return true;
                        }
                    }
                    else
                    {
                        // CARDS DO NOT LINK, CONTINUE ONTO THE NEXT TABLEAUX CARD.
                        if (i == 0)
                        {
                            // THIS IS THE LAST CARD IN THE TABLEAUX, MOVE FAILS BECAUSE NO LINKING CARDS FOUND IN STACK.
                            return false;
                        }
                    }
                    level++;
                }
            }

            return false;
        }
 public void Cascade(Cascade cascadeStyle)
 {
     manyToOne.cascade = (cascadeStyle & ~ConfOrm.Cascade.DeleteOrphans).ToCascadeString();
 }
Example #43
0
 /// <summary>
 /// Gets a tableaux from cascade of cards.
 /// </summary>
 /// <param name="cascade">The cascade to get tableaux from.</param>
 /// <param name="rules">The rules to use when determining what makes a tableaux.</param>
 /// <returns>
 /// A list of linking cards from the top of a cascade
 /// </returns>
 public static List<Card> GetTableauxFromCascade(Cascade cascade, IRules rules)
 {
     List<Card> tableaux = new List<Card>();
     for (int i = (cascade.Count - 1); i > 0; i--)
     {
         tableaux.Add(cascade[i]);
         if (!rules.DoCardsLinkInCascade(cascade[i], cascade[i - 1]))
             break;
     }
     tableaux.Reverse();
     return tableaux;
 }
Example #44
0
 /// <summary>
 /// Initializes a new instance of the <see cref="CascadeGridColumnDefinition"/> class.
 /// </summary>
 public CascadeGridColumnDefinition(Cascade cascade, int index)
 {
     ColumnIndex = index;
     Cascade = cascade;
 }
		public static bool Has(this Cascade source, Cascade value)
		{
			return (source & value) == value;
		}
Example #46
0
 /// <summary>
 /// Initializes a new instance of the <see cref="CascadeEventArgs"/> class.
 /// </summary>
 /// <param name="cascade">The cascade.</param>
 public CascadeEventArgs(Cascade cascade)
 {
     Cascade = cascade;
 }
		public void Cascade(Cascade cascadeStyle)
		{
			_manyToOne.cascade = cascadeStyle.ToCascadeString();
		}
		public static Cascade Include(this Cascade source, Cascade value)
		{
			return Cleanup(source | value);
		}