Exemplo n.º 1
0
        internal new static PolicyRangePartition CreateFromMetadata(Table parent, TOM.Partition metadataObject)
        {
            var obj = new PolicyRangePartition(metadataObject);

            parent.Partitions.Add(obj);

            obj.Init();

            return(obj);
        }
Exemplo n.º 2
0
        public new static PolicyRangePartition CreateNew(Table parent, string name = null)
        {
            if (!parent.Handler.PowerBIGovernance.AllowCreate(typeof(PolicyRangePartition)))
            {
                throw new InvalidOperationException(string.Format(Messages.CannotCreatePowerBIObject, typeof(PolicyRangePartition).GetTypeName()));
            }

            var metadataObject = new TOM.Partition();

            metadataObject.Name   = parent.Partitions.GetNewName(string.IsNullOrWhiteSpace(name) ? "New " + typeof(PolicyRangePartition).GetTypeName() : name);
            metadataObject.Source = new TOM.PolicyRangePartitionSource();

            var obj = new PolicyRangePartition(metadataObject);

            parent.Partitions.Add(obj);

            obj.Init();

            return(obj);
        }
Exemplo n.º 3
0
        public override Partition Clone(string newName = null, Table newParent = null)
        {
            if (!Handler.PowerBIGovernance.AllowCreate(typeof(Partition)))
            {
                throw new InvalidOperationException(string.Format(Messages.CannotCreatePowerBIObject, typeof(Partition).GetTypeName()));
            }

            Handler.BeginUpdate("Clone Partition");

            // Create a clone of the underlying metadataobject:
            var tom = MetadataObject.Clone() as TOM.Partition;


            // Assign a new, unique name:
            tom.Name = Parent.Partitions.GetNewName(string.IsNullOrEmpty(newName) ? tom.Name + " copy" : newName);

            // Create the TOM Wrapper object, representing the metadataobject
            PolicyRangePartition obj = CreateFromMetadata(newParent ?? Parent, tom);

            Handler.EndUpdate();

            return(obj);
        }