Example #1
0
        public ItemDefinition Clone()
        {
            var id = new ItemDefinition(ItemType);

            id.AllowedChildFilters  = AllowedChildFilters.ToList();
            id.AllowedIn            = AllowedIn;
            id.AllowedParentFilters = AllowedParentFilters.ToList();
            id.Attributes           = Attributes.ToList();
            id.AllowedZoneNames     = AllowedZoneNames.ToList();
            id.AuthorizedRoles      = AuthorizedRoles != null?AuthorizedRoles.ToArray() : AuthorizedRoles;

            id.AvailableZones      = AvailableZones.ToList();
            id.Containers          = new ContentList <IEditableContainer>(Containers.Select(ec => ec.TryClone()));
            id.ContentTransformers = ContentTransformers.ToList();
            id.Description         = Description;
            id.Discriminator       = Discriminator;
            id.Displayables        = new ContentList <IDisplayable>(Displayables.Select(d => d.TryClone()));
            id.Editables           = new ContentList <IEditable>(Editables.Select(e => e.TryClone()));
            id.Enabled             = Enabled;
            id.EditableModifiers   = EditableModifiers.ToList();
            id.IconUrl             = IconUrl;
            id.Installer           = Installer;
            id.IsDefined           = IsDefined;
            id.NumberOfItems       = 0;
            id.Metadata            = Metadata.ToDictionary(kvp => kvp.Key, kvp => kvp.Value);
            id.AdditionalFlags     = AdditionalFlags.ToList();
            id.RemovedFlags        = RemovedFlags.ToList();
            id.Properties          = Properties.ToDictionary(p => p.Key, p => p.Value.Clone());
            id.RelatedTo           = RelatedTo;
            id.SortOrder           = SortOrder;
            id.TemplateKey         = TemplateKey;
            id.Title   = Title;
            id.ToolTip = ToolTip;
            return(id);
        }
Example #2
0
        public ItemDefinition Initialize(Type type)
        {
            if (initializedTypes.Contains(type))
            {
                return(this);
            }

            // Define properties, editables, displayables, etc.
            var properties = type.GetProperties().GroupBy(p => p.Name)
                             .ToDictionary(g => g.Key, g => new PropertyDefinition(g.OrderByDescending(p => Utility.InheritanceDepth(p.DeclaringType)).First()));

            foreach (var p in properties)
            {
                Properties[p.Key] = p.Value;
            }
            AddRangeInternal(Properties.Values.SelectMany(p => p.Attributes).OfType <IUniquelyNamed>());

            // Define attributes on class, including editables defined there

            lock (Attributes)
            {
                foreach (object attribute in type.GetCustomAttributes(true))
                {
                    Attributes.Add(attribute);
                }
            }
            AddRange(GetCustomAttributes <IUniquelyNamed>().Where(un => !string.IsNullOrEmpty(un.Name)));

            // Execute refiners which modify the definition
            foreach (var refiner in GetCustomAttributes <ISimpleDefinitionRefiner>())
            {
                refiner.Refine(this);
            }

            initializedTypes.Add(type);

            foreach (var attribute in type.GetCustomAttributes(typeof(InterfaceFlagsAttribute), false)
                     .OfType <InterfaceFlagsAttribute>())
            {
                foreach (var flag in attribute.AdditionalFlags)
                {
                    AdditionalFlags.Add(flag);
                }
                if (attribute.RemovedFlags != null)
                {
                    foreach (var flag in attribute.RemovedFlags)
                    {
                        RemovedFlags.Add(flag);
                    }
                }
            }


            return(this);
        }
Example #3
0
 private static extern NativeFindFileHandle FindFirstFileExW(String lpFileName, FindExInfoLevels fInfoLevelId, out Win32FindData lpFindFileData, FindExSearchOps fSearchOp, IntPtr lpSearchFilter, AdditionalFlags dwAdditionalFlags);
        public void TestAccessPointArnVariations(string accessPointArn, string region, AdditionalFlags flags, bool useArnRegion, string host)
        {
            var request = new PutObjectRequest
            {
                BucketName  = accessPointArn,
                Key         = "foo.txt",
                ContentBody = "data"
            };

            var config = new AmazonS3Config
            {
                RegionEndpoint        = RegionEndpoint.GetBySystemName(region),
                UseArnRegion          = useArnRegion,
                UseDualstackEndpoint  = (flags & AdditionalFlags.Dualstack) != 0,
                UseAccelerateEndpoint = (flags & AdditionalFlags.Accelerate) != 0,
            };

            if (string.IsNullOrEmpty(host))
            {
                try
                {
                    S3ArnTestUtils.RunMockRequest(request, PutObjectRequestMarshaller.Instance, config);
                    Assert.Fail("Request should have failed");
                }
                catch (AmazonClientException)
                {
                }
            }
            else
            {
                var internalRequest = S3ArnTestUtils.RunMockRequest(request, PutObjectRequestMarshaller.Instance, config);
                Assert.AreEqual(new Uri($"https://{host}"), internalRequest.Endpoint);
                Assert.AreEqual("/foo.txt", internalRequest.ResourcePath);
            }
        }