public ContainerContext(ContainerBasePage container, ContainerContext parentContext = null)
 {
     _containingElement = container.Container; // the iframe
     _containerPage = container;
     _containerType = container.Type;
     _containerSwitchers = new Dictionary<ContainerType, Action<IWebDriver>>() 
     { 
         { ContainerType.Frame,   driver =>
                                      {
                                          driver.SwitchTo().Frame(_containingElement.Element); Log.Info(string.Format("Switched to Frame {0}", _containingElement.Identifier));
                                      }},
         { ContainerType.Alert,   driver => driver.SwitchTo().Alert()},
         { ContainerType.Window,  driver => driver.SwitchTo().Window(_containerPage.NewestWindowHandle)},
         { ContainerType.Element, driver => driver.SwitchTo().ActiveElement() }
     };
     _containerRestorers = new Dictionary<ContainerType, Action<IWebDriver>>() 
     { 
         { ContainerType.Frame, driver =>
             {
                 if (HasParentContext(parentContext))
                     SwitchToParentContext(parentContext);
                 else
                     SwitchToDefaultContent(driver);
             }
         },
         { ContainerType.Alert,   driver => { driver.SwitchTo().DefaultContent(); Log.Info("Switched to DefaultContent"); }}, //?
         { ContainerType.Window,  driver => driver.SwitchTo().Window(_containerPage.LastKnownWindowHandle)},
         { ContainerType.Element, driver => driver.SwitchTo().ActiveElement() }  //?
     };
     Switch();
 }
Beispiel #2
0
 public MediaFileInfo(MediaType mediaType, ContainerType containerType, EncodingType encondingType, String path)
 {
     mMediaType = mediaType;
     mContainerType = containerType;
     mEncondingType = encondingType;
     mPath = path;
 }
 public ContainerBasePage(IWebDriver driver, ContainerType? containerType, string title = null, string url = null, ContainerWebElement parentContainer = null)
     : base(driver, title, url, parentContainer)
 {
     if (containerType != null) Type = containerType.Value;
     ActionsBeforeInit();
     InitContainerContext();
 }
         ContainerTypeViewModel Map(ContainerType containerType)
        {
            var vm = new ContainerTypeViewModel();
            vm.Id = containerType.Id;
            vm.Code = containerType.Code;
            vm.Name = containerType.Name;
            vm.Make = containerType.Make;
            vm.Model = containerType.Model;
            vm.Description = containerType.Description;
            vm.LoadCariage = containerType.LoadCarriage;
            vm.TareWeight = containerType.TareWeight;
            vm.Width = containerType.Width;
            vm.Height = containerType.Height;
            vm.BubbleSpace = containerType.BubbleSpace;
            vm.Volume = containerType.Volume;
            vm.FreezerTemp = containerType.FreezerTemp;
            vm.ContainerUserType = (int)containerType.ContainerUseType;
            vm.IsActive = (int)containerType._Status;

            if (containerType.CommodityGrade != null)
            {
                vm.SelectedCommodityGradeId = containerType.CommodityGrade.Id;
                vm.SelectedCommodityGradeName = containerType.CommodityGrade.Name;
                vm.SelectedCommodityId = containerType.CommodityGrade.Commodity.Id;
                vm.SelectedCommodityName = containerType.CommodityGrade.Commodity.Name;
            }
            
            return vm;
        }
 private void GetKnownContainerTypeInfo(object source, out ContainerType ct, out IDictionary dictionary, out IEnumerable enumerable)
 {
     ct = ContainerType.None;
     dictionary = null;
     enumerable = null;
     dictionary = source as IDictionary;
     if (dictionary != null)
     {
         ct = ContainerType.Dictionary;
     }
     else
     {
         if (source is Stack)
         {
             ct = ContainerType.Stack;
             enumerable = LanguagePrimitives.GetEnumerable(source);
         }
         else if (source is Queue)
         {
             ct = ContainerType.Queue;
             enumerable = LanguagePrimitives.GetEnumerable(source);
         }
         else if (source is IList)
         {
             ct = ContainerType.List;
             enumerable = LanguagePrimitives.GetEnumerable(source);
         }
         else
         {
             Type derived = source.GetType();
             if (derived.IsGenericType)
             {
                 if (DerivesFromGenericType(derived, typeof(Stack<>)))
                 {
                     ct = ContainerType.Stack;
                     enumerable = LanguagePrimitives.GetEnumerable(source);
                 }
                 else if (DerivesFromGenericType(derived, typeof(Queue<>)))
                 {
                     ct = ContainerType.Queue;
                     enumerable = LanguagePrimitives.GetEnumerable(source);
                 }
                 else if (DerivesFromGenericType(derived, typeof(List<>)))
                 {
                     ct = ContainerType.List;
                     enumerable = LanguagePrimitives.GetEnumerable(source);
                 }
             }
         }
         if (ct == ContainerType.None)
         {
             enumerable = LanguagePrimitives.GetEnumerable(source);
             if (enumerable != null)
             {
                 ct = ContainerType.Enumerable;
             }
         }
     }
 }
Beispiel #6
0
 public WebElement(string identifier, BasePage parentPage, Type nextPage = null, ContainerType? containerType = null, ContainerWebElement parentContainer = null)
 {
     Identifier = identifier;
     ParentPage = parentPage;
     NextPage = nextPage;
     ParentContainer = parentContainer;
     NextPageContainerType = containerType;
 }
Beispiel #7
0
 protected Engine(MediaType mediaType, ContainerType inputFileContainerType, EncodingType inputFileEncondingType, String inputFilePath, String outputFilePath)
     : base(mediaType, inputFileContainerType, inputFileEncondingType, inputFilePath, outputFilePath)
 {
     if (!sInitialized)
     {
         // Native initialization here
         sInitialized = true;
     }
 }
        /// <summary>
        /// Creates a new AdvancedFieldGenerator.
        /// </summary>
        /// <param name="table">The table this class generates fields for.</param>
        /// <param name="multiItemMode"><value>true</value> to indicate a multi-item control such as GridView, <value>false</value> for a single-item control such as DetailsView.</param>
        public AdvancedFieldGenerator(MetaTable table, bool multiItemMode) {
            if (table == null) {
                throw new ArgumentNullException("table");
            }

            _table = table;
            _containerType = multiItemMode ? ContainerType.List : ContainerType.Item;
            SkipList = new List<MetaColumn>();
        }
 public Container(int id, string bedrijf, Bestemming bestemming, int gewicht, ContainerType type, bool ingeplanned)
 {
     this.ID = id;
     this.Containertruckingbedrijf = bedrijf;
     this.CBestemming = bestemming;
     this.Gewicht = gewicht;
     this.Type = type;
     this.Ingeplanned = ingeplanned;
 }
        public DropdownWebElement(string identifier, BasePage parentPage, ContainerType? containerType = null, ContainerWebElement container = null)
            : base(identifier, parentPage, null, containerType, container)
        {
            Selector = new Dictionary<SelectionKind, Action<object>>
            {
					{SelectionKind.Text, x => Select.SelectByText((string) x)},
					{SelectionKind.Value, x => Select.SelectByValue((string) x)},
					{SelectionKind.Index, x => Select.SelectByIndex((int) x)}
				};
        }
Beispiel #11
0
 public static CloudEntity<ContainerRestoreState> ContainerRestore(string snapshotId, string restoreId, DateTime created, ContainerType containerType, string liveName)
 {
     return new ContainerRestoreState
            	{
            		SnapshotId = snapshotId,
            		RestoreId = restoreId,
            		Name = liveName,
            		Type = containerType,
            		Created = created
            	}.ToCloudEntity();
 }
        protected virtual DynamicField CreateField(MetaColumn column, ContainerType containerType, DataBoundControlMode mode) {            
            string headerText = (containerType == ContainerType.List ? column.ShortDisplayName : column.DisplayName);

            var field = new DynamicField() {
                DataField = column.Name,
                HeaderText = headerText
            };
            // Turn wrapping off by default so that error messages don't show up on the next line.
            field.ItemStyle.Wrap = false;

            return field;
        }
Beispiel #13
0
        protected override void Parse( BigEndianReader reader )
        {
            reader.ReadByte(); // ID
            _Serial = reader.ReadUInt32();
            _GumpID = reader.ReadInt16();

            int type = reader.ReadInt16();

            if ( type == 0 )
                _ContainerType = ContainerType.Vendor;
            else
                _ContainerType = ContainerType.ContainerOrSpellbook;
        }
        public void RestoreTaskCompleted(string accountName, string snapshotId, string restoreId, ContainerType type, CloudName name)
        {
            // State:
            var entity = _containerRestores.GetContainerRestoreEntity(restoreId, type, name.LiveName).Value;
            entity.Value.IsCompleted = true;
            _containerRestores.Update(entity);

            // Denormalization:
            if (!_containerRestores.Get(restoreId).Any(task => !task.Value.IsCompleted))
            {
                RestoreCompleted(accountName, snapshotId, restoreId);
            }
        }
Beispiel #15
0
 public static CloudEntity<ContainerState> Container(string accountName, string snapshotId, DateTime created, ContainerType containerType, PackingType packingType, string liveName, string snapshotName)
 {
     return new ContainerState
            	{
                 AccountName = accountName,
                 SnapshotId = snapshotId,
                 Created = created,
                 ContainerType = containerType,
                 PackingType = packingType,
                 LiveName = liveName,
                 SnapshotName = snapshotName
            	}.ToCloudEntity();
 }
        public ContainerHeader(Stream stream)
        {
            if (stream == null)
                throw new ArgumentNullException("stream");

            Length = readByte(stream) | (readByte(stream) << 8) | (readByte(stream) << 16) | (readByte(stream) << 24);
            ContainerType = (ContainerType) readByte(stream);
            //byte 5 skipped
            readByte(stream);
            Code = readByte(stream) | (readByte(stream) << 8);
            TransactionID = readByte(stream) | (readByte(stream) << 8) | (readByte(stream) << 16) |
                            (readByte(stream) << 24);
        }
Beispiel #17
0
 public override IEnumerable<MetaColumn> GetScaffoldColumns(DataBoundControlMode mode, ContainerType containerType)
 {
     if (_getVisibleColumns == null)
      {
           var visibleColumn = base.GetScaffoldColumns(mode, containerType);
           var secureColumns = from column in visibleColumn
                               where column.ColumnIsVisible()
                               select column;
           return secureColumns;
      }
      else
      {
           return _getVisibleColumns(base.GetScaffoldColumns(mode, containerType));
      }
 }
Beispiel #18
0
        public CalcData(long frames, decimal fps, ContainerType container, VideoCodec codec, bool bframes, AudioBitrateCalculationStream[] audios)
        {
            if (fps <= 0) throw new ArgumentException("Frames per second must be greater than zero.", "fps");
            if (frames <= 0) throw new ArgumentException("Frames must be greater than zero.", "frames");

            Frames = frames;
            FramesPerSecond = fps;
            ContainerType = container;
            VideoCodec = codec;
            HasBFrames = bframes;
            AudioStreams = audios;
            VideoOverheadRatio = 1;
            AudioOverheadRatio = 1;
            ExtraOverheadRatio = 1;
            QualityCoeffient = 0.75F;
        }
Beispiel #19
0
        internal Paragraph(DocX document, XElement xml, int startIndex, ContainerType parent = ContainerType.None)
            : base(document, xml)
        {
            ParentContainer = parent;
            this.startIndex = startIndex;
            this.endIndex = startIndex + GetElementTextLength(xml);

            RebuildDocProperties();

            // As per Unused code affecting performance (Wiki Link: [discussion:454191]) and coffeycathal suggestion no longer requeried
            //#region It's possible that a Paragraph may have pStyle references
            //// Check if this Paragraph references any pStyle elements.
            //var stylesElements = xml.Descendants(XName.Get("pStyle", DocX.w.NamespaceName));

            //// If one or more pStyles are referenced.
            //if (stylesElements.Count() > 0)
            //{
            //    Uri style_package_uri = new Uri("/word/styles.xml", UriKind.Relative);
            //    PackagePart styles_document = document.package.GetPart(style_package_uri);

            //    using (TextReader tr = new StreamReader(styles_document.GetStream()))
            //    {
            //        XDocument style_document = XDocument.Load(tr);
            //        XElement styles_element = style_document.Element(XName.Get("styles", DocX.w.NamespaceName));

            //        var styles_element_ids = stylesElements.Select(e => e.Attribute(XName.Get("val", DocX.w.NamespaceName)).Value);

            //        //foreach(string id in styles_element_ids)
            //        //{
            //        //    var style =
            //        //    (
            //        //        from d in styles_element.Descendants()
            //        //        let styleId = d.Attribute(XName.Get("styleId", DocX.w.NamespaceName))
            //        //        let type = d.Attribute(XName.Get("type", DocX.w.NamespaceName))
            //        //        where type != null && type.Value == "paragraph" && styleId != null && styleId.Value == id
            //        //        select d
            //        //    ).First();

            //        //    styles.Add(style);
            //        //}
            //    }
            //}
            //#endregion

            this.runs = Xml.Elements(XName.Get("r", DocX.w.NamespaceName)).ToList();
        }
Beispiel #20
0
 public static Container CreateInstance(ContainerType type, World level, Point3 point)
 {
     switch (type)
     {
         case ContainerType.Chest:
             return new ContainerChest(level, point);
         case ContainerType.Furnace:
             // TODO
             break;
         case ContainerType.Dispenser:
             // TODO
             break;
         case ContainerType.BrewingStand:
             // TODO
             break;
     }
     return null;
 }
        public static IInstanceProvider GetContainer(ContainerType containerType, ApplicationName application)
        {
            IInstanceProvider instanceProvider = null;

            var containerSpecification = ContainerSpecificationFactory.GetSpecification(application);
            switch (containerType)
            {
                case ContainerType.Windsor:
                    var windsorContainerResolver = new WindsorContainerResolver(containerSpecification);
                    instanceProvider = windsorContainerResolver.GetContainer();
                    break;
                case ContainerType.StructureMap:
                case ContainerType.NInject:
                    throw new NotImplementedException("No implementation for these provider types...");
            }

            return instanceProvider;
        }
        /// <summary>
        /// Gets an instance of the provider based on the container type and backup management type (optional)
        /// </summary>
        /// <param name="containerType">Type of the container</param>
        /// <param name="backupManagementType">Type of the backup management type (optional)</param>
        /// <returns></returns>
        public IPsBackupProvider GetProviderInstance
            (
            ContainerType containerType, 
            BackupManagementType? backupManagementType
            )
        {
            PsBackupProviderTypes providerType = 0;

            switch (containerType)
            {
                case ContainerType.AzureVM:
                    if (backupManagementType == BackupManagementType.AzureVM || backupManagementType == null)
                        providerType = PsBackupProviderTypes.IaasVm;
                    else
                        throw new ArgumentException(
                            String.Format(Resources.BackupManagementTypeIncorrectForContainerType, 
                            containerType)
                            );
                    break;
                case ContainerType.Windows:
                    if (backupManagementType == BackupManagementType.MARS)
                        providerType = PsBackupProviderTypes.Mab;
                    else if (backupManagementType == null)
                        throw new ArgumentException(
                            String.Format(
                            Resources.BackupManagementTypeRequiredForContainerType, 
                            containerType)
                            );
                    else
                        throw new ArgumentException(
                            String.Format(
                            Resources.BackupManagementTypeIncorrectForContainerType, 
                            containerType)
                            );
                    break;
                default:
                    throw new ArgumentException(
                        String.Format(Resources.UnsupportedContainerType, 
                        containerType.ToString())
                        );
            }

            return GetProviderInstance(providerType);
        }
        public void Save(ContainerTypeViewModel vm)
        {
            ContainerType containerType = new ContainerType(vm.Id);
            containerType.Name = vm.Name;
            containerType.Code = vm.Code;
            containerType.Make = vm.Make;
            containerType.Model = vm.Model;
            containerType.Description = vm.Description;
            containerType.LoadCarriage = vm.LoadCariage;
            containerType.TareWeight = vm.TareWeight;
            containerType.Length = vm.Length;
            containerType.Width = vm.Width;
            containerType.Height = vm.Height;
            containerType.BubbleSpace = vm.BubbleSpace;
            containerType.Volume = vm.Volume;
            containerType.FreezerTemp = vm.FreezerTemp;
            containerType._Status = EntityStatus.Active;
            containerType.ContainerUseType = (ContainerUseType)vm.ContainerUserType;
            containerType.CommodityGrade = _commodityRepository.GetGradeByGradeId(vm.SelectedCommodityGradeId);


            _containerTypeRepository.Save(containerType);
        }
 public async Task<CloudBlobContainer> GetContainer(ContainerType type)
 {
     CloudBlobContainer container;
     switch (type)
     {
         case ContainerType.Image:
             container = BlobClient.GetContainerReference("images");
             break;
         case ContainerType.ResizeImage:
             container = BlobClient.GetContainerReference("resizedimages");
             break;
         default:
             container = BlobClient.GetContainerReference("images");
             break;
     }
     if (container.CreateIfNotExists())
     {
         await container.SetPermissionsAsync(new BlobContainerPermissions()
         {
             PublicAccess = BlobContainerPublicAccessType.Blob
         });
     }
     return container;
 }
 public static unsafe void AddSmall(long fileId, ContainerType container)
 {
     TestUtils.Add(container, fileId, "small", "small", H5T.NATIVE_INT32, TestData.SmallData.AsSpan());
 }
Beispiel #26
0
        public static void HandleDebugEchoFlags(Session session, params string[] parameters)
        {
            try
            {
                string debugOutput = "";
                if (parameters?.Length == 2)
                {
                    switch (parameters[0].ToLower())
                    {
                    case "descriptionflags":
                        ObjectDescriptionFlag objectDescFlag = new ObjectDescriptionFlag();
                        objectDescFlag = (ObjectDescriptionFlag)Convert.ToUInt32(parameters[1]);

                        debugOutput = $"{objectDescFlag.GetType().Name} = {objectDescFlag.ToString()}" + " (" + (uint)objectDescFlag + ")";
                        break;

                    case "weenieflags":
                        WeenieHeaderFlag weenieHdr = new WeenieHeaderFlag();
                        weenieHdr = (WeenieHeaderFlag)Convert.ToUInt32(parameters[1]);

                        debugOutput = $"{weenieHdr.GetType().Name} = {weenieHdr.ToString()}" + " (" + (uint)weenieHdr + ")";
                        break;

                    case "weenieflags2":
                        WeenieHeaderFlag2 weenieHdr2 = new WeenieHeaderFlag2();
                        weenieHdr2 = (WeenieHeaderFlag2)Convert.ToUInt32(parameters[1]);

                        debugOutput = $"{weenieHdr2.GetType().Name} = {weenieHdr2.ToString()}" + " (" + (uint)weenieHdr2 + ")";
                        break;

                    case "positionflag":
                        UpdatePositionFlag posFlag = new UpdatePositionFlag();
                        posFlag = (UpdatePositionFlag)Convert.ToUInt32(parameters[1]);

                        debugOutput = $"{posFlag.GetType().Name} = {posFlag.ToString()}" + " (" + (uint)posFlag + ")";
                        break;

                    case "type":
                        ItemType objectType = new ItemType();
                        objectType = (ItemType)Convert.ToUInt32(parameters[1]);

                        debugOutput = $"{objectType.GetType().Name} = {objectType.ToString()}" + " (" + (uint)objectType + ")";
                        break;

                    case "containertype":
                        ContainerType contType = new ContainerType();
                        contType = (ContainerType)Convert.ToUInt32(parameters[1]);

                        debugOutput = $"{contType.GetType().Name} = {contType.ToString()}" + " (" + (uint)contType + ")";
                        break;

                    case "usable":
                        Usable usableType = new Usable();
                        usableType = (Usable)Convert.ToInt64(parameters[1]);

                        debugOutput = $"{usableType.GetType().Name} = {usableType.ToString()}" + " (" + (Int64)usableType + ")";
                        break;

                    case "radarbehavior":
                        RadarBehavior radarBeh = new RadarBehavior();
                        radarBeh = (RadarBehavior)Convert.ToUInt32(parameters[1]);

                        debugOutput = $"{radarBeh.GetType().Name} = {radarBeh.ToString()}" + " (" + (uint)radarBeh + ")";
                        break;

                    case "physicsdescriptionflags":
                        PhysicsDescriptionFlag physicsDescFlag = new PhysicsDescriptionFlag();
                        physicsDescFlag = (PhysicsDescriptionFlag)Convert.ToUInt32(parameters[1]);

                        debugOutput = $"{physicsDescFlag.GetType().Name} = {physicsDescFlag.ToString()}" + " (" + (uint)physicsDescFlag + ")";
                        break;

                    case "physicsstate":
                        PhysicsState physState = new PhysicsState();
                        physState = (PhysicsState)Convert.ToUInt32(parameters[1]);

                        debugOutput = $"{physState.GetType().Name} = {physState.ToString()}" + " (" + (uint)physState + ")";
                        break;

                    case "validlocations":
                        EquipMask locFlags = new EquipMask();
                        locFlags = (EquipMask)Convert.ToUInt32(parameters[1]);

                        debugOutput = $"{locFlags.GetType().Name} = {locFlags.ToString()}" + " (" + (uint)locFlags + ")";
                        break;

                    case "currentwieldedlocation":
                        EquipMask locFlags2 = new EquipMask();
                        locFlags2 = (EquipMask)Convert.ToUInt32(parameters[1]);

                        debugOutput = $"{locFlags2.GetType().Name} = {locFlags2.ToString()}" + " (" + (uint)locFlags2 + ")";
                        break;

                    case "priority":
                        CoverageMask covMask = new CoverageMask();
                        covMask = (CoverageMask)Convert.ToUInt32(parameters[1]);

                        debugOutput = $"{covMask.GetType().Name} = {covMask.ToString()}" + " (" + (uint)covMask + ")";
                        break;

                    case "radarcolor":
                        RadarColor radarBlipColor = new RadarColor();
                        radarBlipColor = (RadarColor)Convert.ToUInt32(parameters[1]);

                        debugOutput = $"{radarBlipColor.GetType().Name} = {radarBlipColor.ToString()}" + " (" + (uint)radarBlipColor + ")";
                        break;

                    default:
                        debugOutput = "No valid type to test";
                        break;
                    }

                    if (session == null)
                    {
                        Console.WriteLine(debugOutput.Replace(", ", " | "));
                    }
                    else
                    {
                        session.Network.EnqueueSend(new GameMessageSystemChat(debugOutput, ChatMessageType.System));
                    }
                }
            }
            catch (Exception)
            {
                string debugOutput = "Exception Error, check input and try again";
                if (session == null)
                {
                    Console.WriteLine(debugOutput.Replace(", ", " | "));
                }
                else
                {
                    session.Network.EnqueueSend(new GameMessageSystemChat(debugOutput, ChatMessageType.System));
                }
            }
        }
Beispiel #27
0
        public override bool ShouldExposeContentsToRoom(ContainerType containerType = ContainerType.In)
        {
            // Pack animals exposed in corral, even when it's closed

            return(Uid != 72 || containerType != ContainerType.In ? base.ShouldExposeContentsToRoom(containerType) : true);
        }
Beispiel #28
0
    private static ResultVoid <TaskConfigError> CheckContainer(Compare compare, long expected, ContainerType containerType, Dictionary <ContainerType, List <Container> > containers)
    {
        var actual = containers.ContainsKey(containerType) ? containers[containerType].Count : 0;

        if (!CheckVal(compare, expected, actual))
        {
            return(ResultVoid <TaskConfigError> .Error(
                       new TaskConfigError($"container type {containerType}: expected {compare} {expected}, got {actual}")));
        }

        return(ResultVoid <TaskConfigError> .Ok());
    }
Beispiel #29
0
 public ContainerContext(ContainerType containerType, string backupManagementType)
     : base(backupManagementType)
 {
     ContainerType = containerType;
 }
 /// <summary>
 /// To get provider instance using container type.
 /// </summary>
 public IPsBackupProvider GetProviderInstance(ContainerType containerType)
 {
     throw new NotImplementedException();
 }
Beispiel #31
0
        public async Task <DownloadFile> DownloadFile(Guid applicationId, int?sequenceNumber, int?sectionNumber, string pageId, string fileName, ContainerType containerType, CancellationToken cancellationToken)
        {
            var file = default(DownloadFile);

            if (!string.IsNullOrWhiteSpace(pageId) && !string.IsNullOrWhiteSpace(fileName))
            {
                var container = await BlobContainerHelpers.GetContainer(_fileStorageConfig, containerType);

                if (container != null)
                {
                    var pageDirectory = container.GetDirectory(applicationId, sequenceNumber, sectionNumber, pageId);
                    var pageFileBlob  = pageDirectory.GetBlobReference(fileName);

                    if (pageFileBlob.Exists())
                    {
                        file = await DownloadFileFromBlob(pageFileBlob, cancellationToken);
                    }
                }
            }

            return(file);
        }
        private bool HandleKnownContainerTypes(object source, string property, int depth)
        {
            Dbg.Assert(source != null, "caller should validate the parameter");

            ContainerType ct         = ContainerType.None;
            PSObject      mshSource  = source as PSObject;
            IEnumerable   enumerable = null;
            IDictionary   dictionary = null;

            // If passed in object is PSObject with no baseobject, return false.
            if (mshSource != null && mshSource.ImmediateBaseObjectIsEmpty)
            {
                return(false);
            }

            // Check if source (or baseobject in mshSource) is known container type
            GetKnownContainerTypeInfo(mshSource != null ? mshSource.ImmediateBaseObject : source, out ct,
                                      out dictionary, out enumerable);

            if (ct == ContainerType.None)
            {
                return(false);
            }

            WriteStartOfPSObject(mshSource ?? PSObject.AsPSObject(source), property, true);
            switch (ct)
            {
            case ContainerType.Dictionary:
            {
                WriteDictionary(dictionary, depth);
            }

            break;

            case ContainerType.Stack:
            case ContainerType.Queue:
            case ContainerType.List:
            case ContainerType.Enumerable:
            {
                WriteEnumerable(enumerable, depth);
            }

            break;

            default:
            {
                Dbg.Assert(false, "All containers should be handled in the switch");
            }

            break;
            }

            // An object which is original enumerable becomes an PSObject
            // with arraylist on deserialization. So on roundtrip it will show up
            // as List.
            // We serialize properties of enumerable and on deserialization mark the object
            // as Deserialized. So if object is marked deserialized, we should write properties.
            // Note: we do not serialize the properties of IEnumerable if depth is zero.
            if (depth != 0 && (ct == ContainerType.Enumerable || (mshSource != null && mshSource.IsDeserialized)))
            {
                // Note:Depth is the depth for serialization of baseObject.
                // Depth for serialization of each property is one less.
                WritePSObjectProperties(PSObject.AsPSObject(source), depth);
            }

            // If source is PSObject, serialize notes
            if (mshSource != null)
            {
                // Serialize instanceMembers
                PSMemberInfoCollection <PSMemberInfo> instanceMembers = mshSource.InstanceMembers;
                if (instanceMembers != null)
                {
                    WriteMemberInfoCollection(instanceMembers, depth, true);
                }
            }

            _writer.WriteEndElement();

            return(true);
        }
Beispiel #33
0
 public Container(int weight, ContainerType type)
 {
     SetWeight(weight);
     Type = type;
 }
        /// <summary>
        /// Trains a model and returns the associated <see cref="DisposableTrainedModel"/> instance, from which
        /// the model ID can be obtained. Upon disposal, the model will be deleted.
        /// </summary>
        /// <param name="useTrainingLabels">If <c>true</c>, use a label file created in the &lt;link-to-label-tool-doc&gt; to provide training-time labels for training a model. If <c>false</c>, the model will be trained from forms only.</param>
        /// <param name="containerType">Type of container to use to execute training.</param>
        /// <param name="modelName">Optional model name.</param>
        /// <returns>A <see cref="DisposableTrainedModel"/> instance from which the trained model ID can be obtained.</returns>
        protected async Task <DisposableTrainedModel> CreateDisposableTrainedModelAsync(bool useTrainingLabels, ContainerType containerType = default, string modelName = default)
        {
            var trainingClient = CreateFormTrainingClient();

            string trainingFiles = containerType switch
            {
                ContainerType.Singleforms => TestEnvironment.BlobContainerSasUrlV2,
                ContainerType.MultipageFiles => TestEnvironment.MultipageBlobContainerSasUrlV2,
                ContainerType.SelectionMarks => TestEnvironment.SelectionMarkBlobContainerSasUrlV2,
                ContainerType.TableVariableRows => TestEnvironment.TableDynamicRowsContainerSasUrlV2,
                ContainerType.TableFixedRows => TestEnvironment.TableFixedRowsContainerSasUrlV2,
                _ => TestEnvironment.BlobContainerSasUrlV2,
            };
            var trainingFilesUri = new Uri(trainingFiles);

            return(await DisposableTrainedModel.TrainModelAsync(trainingClient, trainingFilesUri, useTrainingLabels, modelName));
        }
        public ImageNodeViewModel(MegaSDK megaSdk, AppInformation appInformation, MNode megaNode, ContainerType parentContainerType,
                                  ObservableCollection <IMegaNode> parentCollection = null, ObservableCollection <IMegaNode> childCollection = null)
            : base(megaSdk, appInformation, megaNode, parentContainerType, parentCollection, childCollection)
        {
            // Image node downloads to the image path of the full original image
            this.Transfer = new TransferObjectModel(MegaSdk, this, MTransferType.TYPE_DOWNLOAD, LocalFilePath);

            this.DefaultImagePathData = ImageService.GetDefaultFileTypePathData(this.Name);

            // Default false for preview slide
            InViewingRange = false;
        }
Beispiel #36
0
        public async Task <bool> DeleteFile(Guid applicationId, int?sequenceNumber, int?sectionNumber, string pageId, string fileName, ContainerType containerType, CancellationToken cancellationToken)
        {
            var success = false;

            if (!string.IsNullOrWhiteSpace(pageId) && !string.IsNullOrWhiteSpace(fileName))
            {
                var container = await BlobContainerHelpers.GetContainer(_fileStorageConfig, containerType);

                if (container != null)
                {
                    var pageDirectory = container.GetDirectory(applicationId, sequenceNumber, sectionNumber, pageId);
                    var pageFileBlob  = pageDirectory.GetBlobReference(fileName);

                    success = await pageFileBlob.DeleteIfExistsAsync(cancellationToken);
                }
            }

            return(success);
        }
Beispiel #37
0
        public async Task <bool> UploadFiles(Guid applicationId, int?sequenceNumber, int?sectionNumber, string pageId, IFormFileCollection files, ContainerType containerType, CancellationToken cancellationToken)
        {
            var success = false;

            if (!string.IsNullOrWhiteSpace(pageId) && files != null)
            {
                var container = await BlobContainerHelpers.GetContainer(_fileStorageConfig, containerType);

                if (container != null)
                {
                    var questionDirectory = container.GetDirectory(applicationId, sequenceNumber, sectionNumber, pageId);

                    try
                    {
                        foreach (var file in files)
                        {
                            var blob = questionDirectory.GetBlockBlobReference(file.FileName);
                            blob.Properties.ContentType = file.ContentType;

                            var encryptedFileStream = _fileEncryptionService.Encrypt(file.OpenReadStream());

                            await blob.UploadFromStreamAsync(encryptedFileStream, cancellationToken);
                        }

                        success = true;
                    }
                    catch (Exception ex)
                    {
                        _logger.LogError($"Error uploading files to directory: {questionDirectory.Uri} || Message: {ex.Message} || Stack trace: {ex.StackTrace}");
                        success = false;
                    }
                }
            }

            return(success);
        }
Beispiel #38
0
 private object ReadDictionary(ContainerType ct)
 {
     Hashtable hashtable = new Hashtable(StringComparer.CurrentCultureIgnoreCase);
     int num = 0;
     if (this.ReadStartElementAndHandleEmpty("DCT"))
     {
         while (this._reader.NodeType == XmlNodeType.Element)
         {
             this.ReadStartElement("En");
             if (this._reader.NodeType != XmlNodeType.Element)
             {
                 throw this.NewXmlException(Serialization.DictionaryKeyNotSpecified, null, new object[0]);
             }
             if (string.Compare(this.ReadNameAttribute(), "Key", StringComparison.OrdinalIgnoreCase) != 0)
             {
                 throw this.NewXmlException(Serialization.InvalidDictionaryKeyName, null, new object[0]);
             }
             object key = this.ReadOneObject();
             if (key == null)
             {
                 throw this.NewXmlException(Serialization.NullAsDictionaryKey, null, new object[0]);
             }
             if (this._reader.NodeType != XmlNodeType.Element)
             {
                 throw this.NewXmlException(Serialization.DictionaryValueNotSpecified, null, new object[0]);
             }
             if (string.Compare(this.ReadNameAttribute(), "Value", StringComparison.OrdinalIgnoreCase) != 0)
             {
                 throw this.NewXmlException(Serialization.InvalidDictionaryValueName, null, new object[0]);
             }
             object obj3 = this.ReadOneObject();
             if (hashtable.ContainsKey(key) && (num == 0))
             {
                 num++;
                 Hashtable hashtable2 = new Hashtable();
                 foreach (DictionaryEntry entry in hashtable)
                 {
                     hashtable2.Add(entry.Key, entry.Value);
                 }
                 hashtable = hashtable2;
             }
             if (hashtable.ContainsKey(key) && (num == 1))
             {
                 num++;
                 IEqualityComparer equalityComparer = new ReferenceEqualityComparer();
                 Hashtable hashtable3 = new Hashtable(equalityComparer);
                 foreach (DictionaryEntry entry2 in hashtable)
                 {
                     hashtable3.Add(entry2.Key, entry2.Value);
                 }
                 hashtable = hashtable3;
             }
             try
             {
                 hashtable.Add(key, obj3);
             }
             catch (ArgumentException exception)
             {
                 throw this.NewXmlException(Serialization.InvalidPrimitiveType, exception, new object[] { typeof(Hashtable) });
             }
             this.ReadEndElement();
         }
         this.ReadEndElement();
     }
     return hashtable;
 }
Beispiel #39
0
 private object ReadListContainer(ContainerType ct)
 {
     ArrayList col = new ArrayList();
     if (this.ReadStartElementAndHandleEmpty(this._reader.LocalName))
     {
         while (this._reader.NodeType == XmlNodeType.Element)
         {
             col.Add(this.ReadOneObject());
         }
         this.ReadEndElement();
     }
     if (ct == ContainerType.Stack)
     {
         col.Reverse();
         return new Stack(col);
     }
     if (ct == ContainerType.Queue)
     {
         return new Queue(col);
     }
     return col;
 }
        /// <summary>
        /// Recursively gets all data from a field and appends it in string format to a StringBuilder.
        /// </summary>
        /// <typeparam name="KeyType">The key type of the field -- used only for maps</typeparam>
        /// <typeparam name="FieldType">The data type of the field for simple types and arrays</typeparam>
        /// <param name="field">The field to query</param>
        /// <param name="entity">The entity to query</param>
        /// <param name="strBuilder">The StringBuilder to append entity data to</param>
        private void GetFieldDataAsString <KeyType, FieldType>(Field field, Entity entity, StringBuilder strBuilder)
        {
            string fieldName = field.FieldName;

            System.Type   fieldType          = field.ValueType;
            ForgeTypeId   fieldUnit          = field.GetSpecTypeId();
            ContainerType fieldContainerType = field.ContainerType;

            Type[]   methodGenericParameters       = null;
            object[] invokeParams                  = null;
            Type[]   methodOverloadSelectionParams = null;
            if (field.ContainerType == ContainerType.Simple)
            {
                methodGenericParameters = new Type[] { field.ValueType }
            }
            ;
            else if (field.ContainerType == ContainerType.Array)
            {
                methodGenericParameters = new Type[] { typeof(IList <int>).GetGenericTypeDefinition().MakeGenericType(new Type[] { field.ValueType }) }
            }
            ;
            else //map
            {
                methodGenericParameters = new Type[] { typeof(IDictionary <int, int>).GetGenericTypeDefinition().MakeGenericType(new Type[] { field.KeyType, field.ValueType }) }
            };

            if (fieldUnit.Empty())
            {
                methodOverloadSelectionParams = new Type[] { typeof(Field) };
                invokeParams = new object[] { field };
            }
            else
            {
                methodOverloadSelectionParams = new Type[] { typeof(Field), typeof(ForgeTypeId) };
                invokeParams = new object[] { field, UnitTypeId.Meters };
            }

            MethodInfo instantiatedGenericGetMethod = entity.GetType().GetMethod("Get", methodOverloadSelectionParams).MakeGenericMethod(methodGenericParameters);

            if (field.ContainerType == ContainerType.Simple)
            {
                FieldType retval = (FieldType)instantiatedGenericGetMethod.Invoke(entity, invokeParams);
                if (fieldType == typeof(Entity))
                {
                    Schema subSchema = Schema.Lookup(field.SubSchemaGUID);
                    strBuilder.AppendLine("Field: " + field.FieldName + ", Type: " + field.ValueType.ToString() + ", Value: " + " {SubEntity} " + ", Unit: " + field.GetSpecTypeId().TypeId + ", ContainerType: " + field.ContainerType.ToString());
                    DumpAllSchemaEntityData <FieldType>(retval, subSchema, strBuilder);
                }
                else
                {
                    string sRetval = retval.ToString();
                    strBuilder.AppendLine("Field: " + field.FieldName + ", Type: " + field.ValueType.ToString() + ", Value: " + retval + ", Unit: " + field.GetSpecTypeId().TypeId + ", ContainerType: " + field.ContainerType.ToString());
                }
            }
            else if (field.ContainerType == ContainerType.Array)
            {
                IList <FieldType> listRetval = (IList <FieldType>)instantiatedGenericGetMethod.Invoke(entity, invokeParams);
                if (fieldType == (typeof(Entity)))
                {
                    strBuilder.AppendLine("Field: " + field.FieldName + ", Type: " + field.ValueType.ToString() + ", Value: " + " {SubEntity} " + ", Unit: " + field.GetSpecTypeId().TypeId + ", ContainerType: " + field.ContainerType.ToString());

                    foreach (FieldType fa in listRetval)
                    {
                        strBuilder.Append("  Array Value: ");
                        DumpAllSchemaEntityData <FieldType>(fa, Schema.Lookup(field.SubSchemaGUID), strBuilder);
                    }
                }
                else
                {
                    strBuilder.AppendLine("Field: " + field.FieldName + ", Type: " + field.ValueType.ToString() + ", Value: " + " {Array} " + ", Unit: " + field.GetSpecTypeId().TypeId + ", ContainerType: " + field.ContainerType.ToString());
                    foreach (FieldType fa in listRetval)
                    {
                        strBuilder.AppendLine("  Array value: " + fa.ToString());
                    }
                }
            }
            else //Map
            {
                strBuilder.AppendLine("Field: " + field.FieldName + ", Type: " + field.ValueType.ToString() + ", Value: " + " {Map} " + ", Unit: " + field.GetSpecTypeId().TypeId + ", ContainerType: " + field.ContainerType.ToString());
                IDictionary <KeyType, FieldType> mapRetval = (IDictionary <KeyType, FieldType>)instantiatedGenericGetMethod.Invoke(entity, invokeParams);
                if (fieldType == (typeof(Entity)))
                {
                    strBuilder.AppendLine("Field: " + field.FieldName + ", Type: " + field.ValueType.ToString() + ", Value: " + " {SubEntity} " + ", Unit: " + field.GetSpecTypeId().TypeId + ", ContainerType: " + field.ContainerType.ToString());
                    foreach (FieldType fa in mapRetval.Values)
                    {
                        strBuilder.Append("  Map Value: ");
                        DumpAllSchemaEntityData <FieldType>(fa, Schema.Lookup(field.SubSchemaGUID), strBuilder);
                    }
                }
                else
                {
                    strBuilder.AppendLine("Field: " + field.FieldName + ", Type: " + field.ValueType.ToString() + ", Value: " + " {Map} " + ", Unit: " + field.GetSpecTypeId().TypeId + ", ContainerType: " + field.ContainerType.ToString());
                    foreach (FieldType fa in mapRetval.Values)
                    {
                        strBuilder.AppendLine("  Map value: " + fa.ToString());
                    }
                }
            }
        }
Beispiel #41
0
        public async Task <IEnumerable <string> > GetPageFileList(Guid applicationId, int?sequenceNumber, int?sectionNumber, string pageId, ContainerType containerType, CancellationToken cancellationToken)
        {
            var fileList = new List <string>();

            if (!string.IsNullOrWhiteSpace(pageId))
            {
                var container = await BlobContainerHelpers.GetContainer(_fileStorageConfig, containerType);

                if (container != null)
                {
                    var pageDirectory = container.GetDirectory(applicationId, sequenceNumber, sectionNumber, pageId);
                    var fileBlobs     = pageDirectory.ListBlobs(useFlatBlobListing: true).ToList();

                    foreach (var blob in fileBlobs.OfType <CloudBlob>())
                    {
                        string fileName = Path.GetFileName(blob.Name);
                        fileList.Add(fileName);
                    }
                }
            }

            return(fileList);
        }
 public ZipInContainer()
 {
     ContainerDataKey = "[TargetNameWithoutExt]";
     TargetContainer  = ContainerType.InstructionSetContainer;
 }
Beispiel #43
0
 public static Container GetContainer(ContainerType containerType)
 {
     return(new Container(containerType));
 }
Beispiel #44
0
        public override bool ShouldExposeContentsToRoom(ContainerType containerType = ContainerType.In)
        {
            // Dodge Hotel basement shelves don't expose contents

            return(Uid != 58 && base.ShouldExposeContentsToRoom(containerType));
        }
Beispiel #45
0
 public ProjectDialogResult(bool createAndroid, bool createiOS, bool createUwp, ContainerType containerType)
 {
     CreateAndroid = createAndroid;
     CreateiOS     = createiOS;
     CreateUwp     = createUwp;
     ContainerType = containerType;
     Cancelled     = false;
 }
Beispiel #46
0
 private static IPropertySet GetSettingsValues(ContainerType container)
 {
     return((container == ContainerType.Local)
         ? ApplicationData.Current.LocalSettings.Values
         : ApplicationData.Current.RoamingSettings.Values);
 }
Beispiel #47
0
 protected static T GetValue <T>(ContainerType container = default(ContainerType), [CallerMemberName] string propertyName = null)
 {
     return(GetValue(default(T), container, propertyName));
 }
        public static async Task <bool> DeleteContainerAsync(ContainerType containerType)
        {
            var container = GetContainer(containerType);

            return(await container.DeleteIfExistsAsync());
        }
Beispiel #49
0
 /// <summary>
 ///    Set the ContainerType of the container
 /// </summary>
 /// <param name="container">Container for which the ContainerType should be set</param>
 /// <param name="containerType">ContainerType to set</param>
 public static TContainer WithContainerType <TContainer>(this TContainer container, ContainerType containerType) where TContainer : IContainer
 {
     container.ContainerType = containerType;
     return(container);
 }
Beispiel #50
0
 public Container(int weight, int[] xyz, ContainerType type)
 {
     this.weight = weight;
     pos         = new int[xyz[0], xyz[1], xyz[2]];
     this.type   = type;
 }
        public static unsafe void Add(ContainerType container, long fileId, string groupName, string elementName, long typeId, void *dataPtr, ulong length, long cpl = 0, long apl = 0)
        {
            var dims0 = new ulong[] { length };

            TestUtils.Add(container, fileId, groupName, elementName, typeId, dataPtr, dims0, dims0, cpl, apl);
        }
Beispiel #52
0
 public async Task <ContainerType> CreateContainerType(ContainerType entity)
 {
     return(await Channel.CreateContainerType(entity).ConfigureAwait(false));
 }
Beispiel #53
0
 private bool IsKnownContainerTag(out ContainerType ct)
 {
     if (this.IsNextElement("DCT"))
     {
         ct = ContainerType.Dictionary;
     }
     else if (this.IsNextElement("QUE"))
     {
         ct = ContainerType.Queue;
     }
     else if (this.IsNextElement("STK"))
     {
         ct = ContainerType.Stack;
     }
     else if (this.IsNextElement("LST"))
     {
         ct = ContainerType.List;
     }
     else if (this.IsNextElement("IE"))
     {
         ct = ContainerType.Enumerable;
     }
     else
     {
         ct = ContainerType.None;
     }
     return (ct != ContainerType.None);
 }
Beispiel #54
0
        /// <summary>
        /// Gets an instance of the provider based on the container type and backup management type (optional)
        /// </summary>
        /// <param name="containerType">Type of the container</param>
        /// <param name="backupManagementType">Type of the backup management type (optional)</param>
        /// <returns></returns>
        public IPsBackupProvider GetProviderInstance
        (
            ContainerType containerType,
            BackupManagementType?backupManagementType
        )
        {
            PsBackupProviderTypes providerType = 0;

            switch (containerType)
            {
            case ContainerType.AzureVM:
                if (backupManagementType == BackupManagementType.AzureVM || backupManagementType == null)
                {
                    providerType = PsBackupProviderTypes.IaasVm;
                }
                else
                {
                    throw new ArgumentException(
                              string.Format(Resources.BackupManagementTypeIncorrectForContainerType,
                                            containerType)
                              );
                }
                break;

            case ContainerType.Windows:
                if (backupManagementType == BackupManagementType.MARS)
                {
                    providerType = PsBackupProviderTypes.Mab;
                }
                else if (backupManagementType == null)
                {
                    throw new ArgumentException(
                              string.Format(
                                  Resources.BackupManagementTypeRequiredForContainerType,
                                  containerType)
                              );
                }
                else
                {
                    throw new ArgumentException(
                              string.Format(
                                  Resources.BackupManagementTypeIncorrectForContainerType,
                                  containerType)
                              );
                }
                break;

            case ContainerType.AzureSQL:
                if (backupManagementType == BackupManagementType.AzureSQL ||
                    backupManagementType == null)
                {
                    providerType = PsBackupProviderTypes.AzureSql;
                }
                else
                {
                    throw new ArgumentException(
                              string.Format(
                                  Resources.BackupManagementTypeRequiredForContainerType,
                                  containerType));
                }
                break;

            case ContainerType.AzureStorage:
                if (backupManagementType == BackupManagementType.AzureStorage ||
                    backupManagementType == null)
                {
                    providerType = PsBackupProviderTypes.AzureFiles;
                }
                else
                {
                    throw new ArgumentException(
                              string.Format(
                                  Resources.BackupManagementTypeRequiredForContainerType,
                                  containerType));
                }
                break;

            default:
                throw new ArgumentException(
                          string.Format(Resources.UnsupportedContainerType,
                                        containerType.ToString())
                          );
            }

            return(GetProviderInstance(providerType));
        }
Beispiel #55
0
        private object ReadKnownContainer(ContainerType ct)
        {
            switch (ct)
            {
                case ContainerType.Dictionary:
                    return this.ReadDictionary(ct);

                case ContainerType.Queue:
                case ContainerType.Stack:
                case ContainerType.List:
                case ContainerType.Enumerable:
                    return this.ReadListContainer(ct);
            }
            return null;
        }
Beispiel #56
0
 /// <summary>
 /// To get provider instance using container type.
 /// </summary>
 public IPsBackupProvider GetProviderInstance(ContainerType containerType)
 {
     throw new NotImplementedException();
 }
Beispiel #57
0
 /// <summary>
 /// Container variants
 /// </summary>
 /// <param name="type"></param>
 /// <param name="upward">all or only internal(deepest)</param>
 /// <returns></returns>
 private static string container(ContainerType type, bool upward)
 {
     /* PCRE:
          (
            \${1,2}
          )
          (?=
            (
              \(
                (?>
                  [^()]
                  |
                  (?2)
                )*
              \)
            )
          )           ~-> for .NET: v
      */
     return String.Format(@"({0}{1}
                              \${{{2}}}
                            )
                            (
                              \(
                                (?>
                                  {3}[^()]
                                  |
                                  \((?<R>)
                                  |
                                  \)(?<-R>)
                                )*
                                (?(R)(?!))
                              \)
                            )",
                            (type == ContainerType.Unclear)? String.Empty : "?:",
                            (type == ContainerType.Normal)? @"(?<!\$)" : String.Empty,
                            (type == ContainerType.Unclear)? "1,2" : (type == ContainerType.Normal)? "1" : "2",
                            (upward)? @"(?!\$\()" : String.Empty);
 }
Beispiel #58
0
 public GenericContainer(DataReader dataReader, ContainerType containerType)
     : base(dataReader)
 {
     MyStatus = (ContainerStatus)(Enum.Parse(typeof(ContainerStatus), dataReader.GetString(ContainerData.STATUS)));
     MyType   = containerType;
 }
        /// <summary>
        /// Checks if source is known container type and returns appropriate information.
        /// </summary>
        /// <param name="source"></param>
        /// <param name="ct"></param>
        /// <param name="dictionary"></param>
        /// <param name="enumerable"></param>
        private void GetKnownContainerTypeInfo(
            object source, out ContainerType ct, out IDictionary dictionary, out IEnumerable enumerable)
        {
            Dbg.Assert(source != null, "caller should validate the parameter");

            ct         = ContainerType.None;
            dictionary = null;
            enumerable = null;

            dictionary = source as IDictionary;
            if (dictionary != null)
            {
                ct = ContainerType.Dictionary;
                return;
            }

            if (source is Stack)
            {
                ct         = ContainerType.Stack;
                enumerable = LanguagePrimitives.GetEnumerable(source);
                Dbg.Assert(enumerable != null, "Stack is enumerable");
            }
            else if (source is Queue)
            {
                ct         = ContainerType.Queue;
                enumerable = LanguagePrimitives.GetEnumerable(source);
                Dbg.Assert(enumerable != null, "Queue is enumerable");
            }
            else if (source is IList)
            {
                ct         = ContainerType.List;
                enumerable = LanguagePrimitives.GetEnumerable(source);
                Dbg.Assert(enumerable != null, "IList is enumerable");
            }
            else
            {
                Type gt = source.GetType();
                if (gt.GetTypeInfo().IsGenericType)
                {
                    if (DerivesFromGenericType(gt, typeof(Stack <>)))
                    {
                        ct         = ContainerType.Stack;
                        enumerable = LanguagePrimitives.GetEnumerable(source);
                        Dbg.Assert(enumerable != null, "Stack is enumerable");
                    }
                    else if (DerivesFromGenericType(gt, typeof(Queue <>)))
                    {
                        ct         = ContainerType.Queue;
                        enumerable = LanguagePrimitives.GetEnumerable(source);
                        Dbg.Assert(enumerable != null, "Queue is enumerable");
                    }
                    else if (DerivesFromGenericType(gt, typeof(List <>)))
                    {
                        ct         = ContainerType.List;
                        enumerable = LanguagePrimitives.GetEnumerable(source);
                        Dbg.Assert(enumerable != null, "Queue is enumerable");
                    }
                }
            }

            // Check if type is IEnumerable
            if (ct == ContainerType.None)
            {
                enumerable = LanguagePrimitives.GetEnumerable(source);
                if (enumerable != null)
                {
                    ct = ContainerType.Enumerable;
                }
            }
        }
Beispiel #60
0
        public async Task <DownloadFile> DownloadPageFiles(Guid applicationId, int?sequenceNumber, int?sectionNumber, string pageId, ContainerType containerType, CancellationToken cancellationToken)
        {
            var zipFile = default(DownloadFile);

            if (!string.IsNullOrWhiteSpace(pageId))
            {
                var container = await BlobContainerHelpers.GetContainer(_fileStorageConfig, containerType);

                if (container != null)
                {
                    var pageDirectory = container.GetDirectory(applicationId, sequenceNumber, sectionNumber, pageId);
                    var files         = await DownloadFilesFromDirectory(pageDirectory, cancellationToken);

                    if (files.Any())
                    {
                        zipFile = ZipDownloadFiles(files, $"{pageId}_uploads.zip");
                    }
                }
            }

            return(zipFile);
        }