internal NonscalarTypeHeader(OutGridViewCommand parentCmd, PSObject input) : base(parentCmd)
            {
                TableView tableView = new TableView();

                tableView.Initialize(parentCmd.expressionFactory, parentCmd.typeInfoDataBase);
                ViewDefinition definition = DisplayDataQuery.GetViewByShapeAndType(parentCmd.expressionFactory, parentCmd.typeInfoDataBase, FormatShape.Table, input.TypeNames, null);

                if (definition != null)
                {
                    parentCmd.windowProxy.AddColumnsAndItem(input, tableView, (TableControlBody)definition.mainControl);
                    this.appliesTo = definition.appliesTo;
                }
                else
                {
                    parentCmd.windowProxy.AddColumnsAndItem(input, tableView);
                    this.appliesTo = new AppliesTo();
                    int num = 0;
                    foreach (string str in input.TypeNames)
                    {
                        if ((num > 0) && (str.Equals(typeof(object).FullName, StringComparison.OrdinalIgnoreCase) || str.Equals(typeof(MarshalByRefObject).FullName, StringComparison.OrdinalIgnoreCase)))
                        {
                            break;
                        }
                        this.appliesTo.AddAppliesToType(str);
                        num++;
                    }
                }
            }
Exemple #2
0
        // Constructor used for Move and Delete
        public FolderAction(IXenObject obj, Folder folder, Kind kind)
            : base(obj.Connection, GetTitle(obj, folder, kind))
        {
            System.Diagnostics.Trace.Assert(kind == Kind.Move || kind == Kind.Delete);

            this.obj    = obj;
            this.folder = folder;
            this.kind   = kind;

            if (obj.GetType() != typeof(Folder))
            {
                ApiMethodsToRoleCheck.Add(obj.GetType().Name.ToLowerInvariant() + ".remove_from_other_config",
                                          Folders.FOLDER);
                ApiMethodsToRoleCheck.Add(obj.GetType().Name.ToLowerInvariant() + ".add_to_other_config",
                                          Folders.FOLDER);
            }

            ApiMethodsToRoleCheck.Add("pool.remove_from_other_config", Folders.EMPTY_FOLDERS);
            ApiMethodsToRoleCheck.Add("pool.add_to_other_config", Folders.EMPTY_FOLDERS);

            AppliesTo.Add(obj.opaque_ref);
            if (folder != null)
            {
                AppliesTo.Add(folder.opaque_ref);
            }
        }
Exemple #3
0
 public DelegateInstallationMiddleware(
     AppliesTo <InstallationContext> appliesTo,
     InvokeAsync <InstallationContext> invokeAsync)
 {
     _appliesTo   = appliesTo ?? throw new ArgumentNullException(nameof(appliesTo));
     _invokeAsync = invokeAsync ?? throw new ArgumentNullException(nameof(invokeAsync));
 }
 public override int GetHashCode()
 {
     unchecked
     {
         var hashCode = Id.GetHashCode();
         hashCode = (hashCode * 397) ^ (Code != null ? Code.GetHashCode() : 0);
         hashCode = (hashCode * 397) ^ Value.GetHashCode();
         hashCode = (hashCode * 397) ^ EndsAt.GetHashCode();
         hashCode = (hashCode * 397) ^ StartsAt.GetHashCode();
         hashCode = (hashCode * 397) ^ (Status != null ? Status.GetHashCode() : 0);
         hashCode = (hashCode * 397) ^ UsageLimit.GetHashCode();
         hashCode = (hashCode * 397) ^ AppliesToId.GetHashCode();
         hashCode = (hashCode * 397) ^ (DiscountType != null ? DiscountType.GetHashCode() : 0);
         hashCode = (hashCode * 397) ^ (AppliesTo != null ? AppliesTo.GetHashCode() : 0);
         hashCode = (hashCode * 397) ^ (AppliesToResource != null ? AppliesToResource.GetHashCode() : 0);
         hashCode = (hashCode * 397) ^ TimesUsed.GetHashCode();
         hashCode = (hashCode * 397) ^ (Duration != null ? Duration.GetHashCode() : 0);
         hashCode = (hashCode * 397) ^ DurationUsageLimit.GetHashCode();
         hashCode = (hashCode * 397) ^ (AppliesToProductType != null ? AppliesToProductType.GetHashCode() : 0);
         hashCode = (hashCode * 397) ^ CreatedAt.GetHashCode();
         hashCode = (hashCode * 397) ^ UpdatedAt.GetHashCode();
         hashCode = (hashCode * 397) ^ OncePerCustomer.GetHashCode();
         return(hashCode);
     }
 }
        /// <summary>
        ///
        /// </summary>
        /// <param name="connection"></param>
        /// <param name="pool">May be null, in which case we're acting on a single host basis.</param>
        /// <param name="host">If pool is set, then host should be the pool master.</param>
        /// <param name="newPIFs">New PIF instances that are to be created on the server.</param>
        /// <param name="downPIFs"></param>
        /// <param name="newManagement">May be null, in which case the management network will not be disturbed.
        /// Note that it is still possible for the management interface to receive a new IP address even if this
        /// parameter is null, because it may be in newPIFs.  You only need to use this parameter if the management
        /// interface is switching onto a different PIF.</param>
        /// <param name="downManagement">May be null iff newManagement is null.</param>
        public ChangeNetworkingAction(IXenConnection connection, Pool pool, Host host, List <PIF> newPIFs, List <PIF> downPIFs,
                                      PIF newManagement, PIF downManagement, bool managementIPChanged)
            : base(connection, Messages.ACTION_CHANGE_NETWORKING_TITLE)
        {
            Pool = pool;
            Host = host;

            this.newPIFs             = newPIFs;
            this.downPIFs            = downPIFs;
            this.newManagement       = newManagement;
            this.downManagement      = downManagement;
            this.managementIPChanged = managementIPChanged;

            if (pool != null)
            {
                // If we're going to compute address ranges, then we need a sorted list of hosts (to keep the addresses stable).
                Hosts = Connection.Cache.Hosts;
                Array.Sort(Hosts);
                foreach (Host h in Hosts)
                {
                    AppliesTo.Add(h.opaque_ref);
                }
            }
            #region RBAC Dependencies
            ApiMethodsToRoleCheck.Add("vm.set_memory_limits");
            ApiMethodsToRoleCheck.Add("host.management_reconfigure");
            ApiMethodsToRoleCheck.Add("pif.reconfigure_ip");
            ApiMethodsToRoleCheck.Add("pif.plug");
            ApiMethodsToRoleCheck.AddRange(XenAPI.Role.CommonSessionApiList);
            ApiMethodsToRoleCheck.AddRange(XenAPI.Role.CommonTaskApiList);
            #endregion
        }
        public SetCslgCredentialsAction(IEnumerable <IXenConnection> connections, string host, string username, string password)
            : base(null, Messages.SET_STORAGELINK_CREDS_ACTION_TITLE, Messages.SET_STORAGELINK_CREDS_ACTION_DESCRIPTION)
        {
            Util.ThrowIfEnumerableParameterNullOrEmpty(connections, "connections");

            _connections = Util.GetList(connections).FindAll(c => c.IsConnected && Helpers.GetPoolOfOne(c) != null && Helpers.MidnightRideOrGreater(c) && !Helpers.FeatureForbidden(c, XenAPI.Host.RestrictStorageChoices));
            _host        = host;
            _username    = username;
            _password    = password;

            foreach (IXenConnection c in connections)
            {
                XenAPI.Pool pool = Helpers.GetPool(c);

                if (pool != null)
                {
                    AppliesTo.Add(pool.opaque_ref);
                }
                else
                {
                    XenAPI.Host master = Helpers.GetMaster(c);

                    if (master != null)
                    {
                        AppliesTo.Add(master.opaque_ref);
                    }
                }
            }
        }
Exemple #7
0
 public RenameFolderAction(Folder folder, String name)
     : base(folder.Connection, string.Format(Messages.RENAMING_FOLDER, Helpers.GetName(folder), name))
 {
     obj  = folder;
     path = Folders.AppendPath(obj.Path, name);
     AppliesTo.Add(obj.opaque_ref);
     AppliesTo.Add(path);
 }
Exemple #8
0
 /// <summary>
 /// Initializes a new instance of the <see cref="HintAttribute" /> class.
 /// </summary>
 /// <param name="value">The value.</param>
 /// <param name="model">The model.</param>
 /// <param name="applies">What this hint applies to.</param>
 public HintAttribute(
     string value = "",
     string model = "",
     AppliesTo applies = AppliesTo.UNDEFINED)
 {
     Value = value;
     Model = model;
     Applies = applies;
 }
Exemple #9
0
 // Constructor used for moving multiple objects, across multiple connections
 public MoveToFolderAction(List <IXenObject> objs, Folder folder)
     : base(null, string.Format(Messages.MOVE_OBJECTS_TO_FOLDER, folder.Name()))
 {
     this.objs.AddRange(objs);
     this.folder = folder;
     if (this.folder != null)
     {
         AppliesTo.Add(this.folder.opaque_ref);
     }
 }
Exemple #10
0
        public CreateFolderAction(IXenConnection connection, params string[] paths)
            : base(connection, GetTitle(paths))
        {
            this.paths = paths;

            foreach (string path in paths)
            {
                AppliesTo.Add(path);
            }
        }
 /// <summary>Assumes a 1x1x1 <see cref="Block"/> for a <see cref="Face"/>.</summary>
 /// <param name="face">Which <see cref="Block.Face"/> is this attribute describing?</param>
 /// <param name="posX">The 'x' component of the relative position of this face. (ie. the location of this face)</param>
 /// <param name="posY">The 'y' component of the relative position of this face. (ie. the location of this face)</param>
 /// <param name="posZ">The 'z' component of the relative position of this face. (ie. the location of this face)</param>
 /// <param name="rotX">The 'x' component of the relative rotation of this face. (ie. the spin around the x-axis)</param>
 /// <param name="rotY">The 'y' component of the relative rotation of this face. (ie. the spin around the y-axis)</param>
 /// <param name="rotZ">The 'z' component of the relative rotation of this face. (ie. the spin around the z-axis)</param>
 /// <param name="objPath">File path the the '.obj' file for the mesh of this block face.</param>
 /// <param name="targets">Does this attribute apply to just the preview, just the original, or both?</param>
 public Face(Block.Face face,
             float posX, float posY, float posZ,
             float rotX, float rotY, float rotZ,
             string objPath, int identifier = 0, AppliesTo targets = AppliesTo.Both)
     : base(identifier, targets)
 {
     this.face = face;
     Position  = new Vector3(posX, posY, posZ);
     Rotation  = Quaternion.Euler(rotX, rotY, rotZ);
     MeshPath  = objPath;
 }
Exemple #12
0
        // Constructor used for Rename
        public FolderAction(Folder obj, String name, Kind kind)
            : base(obj.Connection, String.Format(Messages.RENAMING_FOLDER, Helpers.GetName(obj), name))
        {
            System.Diagnostics.Trace.Assert(kind == Kind.Rename);

            this.kind = kind;
            this.obj  = obj;
            this.path = Folders.AppendPath(obj.Path, name);
            AppliesTo.Add(obj.opaque_ref);
            AppliesTo.Add(path);
        }
Exemple #13
0
        /// <param name="name_label">The name for the new network.</param>
        /// <param name="PIFs_on_master">The PIFs on the master representing the physical NICs that are to be bonded together.</param>
        /// <param name="autoplug">Whether the new network is marked AutoPlug.</param>
        /// <param name="mtu">The MTU for the Bond, ignored for pre cowley</param>
        /// <param name="bondMode">The bond mode, ignored for pre-Boston</param>
        public CreateBondAction(IXenConnection connection, string name_label, List <PIF> PIFs_on_master, bool autoplug, long mtu, bond_mode bondMode,
                                Bond.hashing_algoritm hashingAlgoritm)
            : base(connection, string.Format(Messages.ACTION_CREATE_BOND_TITLE, name_label),
                   string.Format(Messages.ACTION_CREATE_BOND_DESCRIPTION, name_label))
        {
            this.name_label      = name_label;
            this.autoplug        = autoplug;
            this.mtu             = mtu;
            this.bondMode        = bondMode;
            this.hashingAlgoritm = hashingAlgoritm;

            Pool = Helpers.GetPoolOfOne(Connection);
            if (Pool == null)
            {
                throw new Failure(Failure.INTERNAL_ERROR, "Pool has gone away");
            }

            Master = Connection.Resolve(Pool.master);
            if (Master == null)
            {
                throw new Failure(Failure.INTERNAL_ERROR, "Pool master has gone away");
            }

            bostonOrGreater = Helpers.BostonOrGreater(connection);
            tampaOrGreater  = Helpers.TampaOrGreater(connection);

            foreach (Host host in Connection.Cache.Hosts)
            {
                AppliesTo.Add(host.opaque_ref);
            }

            #region RBAC Dependencies
            ApiMethodsToRoleCheck.Add("host.management_reconfigure");
            ApiMethodsToRoleCheck.Add("network.create");
            ApiMethodsToRoleCheck.Add("network.destroy");
            ApiMethodsToRoleCheck.Add("network.remove_from_other_config");
            ApiMethodsToRoleCheck.Add("pif.reconfigure_ip");
            ApiMethodsToRoleCheck.Add("pif.plug");
            ApiMethodsToRoleCheck.Add("bond.create");
            ApiMethodsToRoleCheck.Add("bond.destroy");
            ApiMethodsToRoleCheck.AddRange(XenAPI.Role.CommonSessionApiList);
            ApiMethodsToRoleCheck.AddRange(XenAPI.Role.CommonTaskApiList);
            #endregion

            PIFs = NetworkingHelper.PIFsOnAllHosts(PIFs_on_master);
            // these locks will be cleared in clean()
            foreach (List <PIF> pifs in PIFs.Values)
            {
                foreach (PIF pif in pifs)
                {
                    pif.Locked = true;
                }
            }
        }
        public RemoveStorageLinkSystemAction(StorageLinkSystem system)
            : base(null,
                   string.Format(Messages.REMOVE_STORAGE_LINK_SYSTEM_ACTION_TITLE, system.Name),
                   string.Format(Messages.REMOVE_STORAGE_LINK_SYSTEM_ACTION_START_DESCRIPTION, system.Name))
        {
            Util.ThrowIfParameterNull(system, "system");
            _system = system;

            AppliesTo.Add(system.StorageLinkServer.opaque_ref);
            AppliesTo.Add(system.opaque_ref);
        }
Exemple #15
0
 private void SetAppliesTo(IXenConnection connection)
 {
     foreach (Pool pool in connection.Cache.Pools)
     {
         AppliesTo.Add(pool.opaque_ref);
     }
     foreach (Host host in connection.Cache.Hosts)
     {
         AppliesTo.Add(host.opaque_ref);
     }
 }
Exemple #16
0
        protected override void Run()
        {
            bool   succeeded = false;
            string name      = Helpers.GetName(Host);

            XenAPI.Host master = Helpers.GetMaster(Connection);
            AppliesTo.Add(master.opaque_ref);
            Title       = string.Format(Messages.ACTION_HOST_START_TITLE, name);
            Description = Messages.ACTION_HOST_STARTING;
            try
            {
                XenAPI.Host.power_on(Session, Host.opaque_ref);
                Description = Messages.ACTION_HOST_STARTED;
                succeeded   = true;

                /* WLB: Below code doesn't work, becasue RelatedTask is not set.
                 *      Need to explore other option when enabling set poweron task value for wlb reporting
                 * if (Helpers.IsWLBEnabled(this.Connection)
                 *  && Host.other_config.ContainsKey(WlbOptimizePoolAction.OPTIMIZINGPOOL))
                 * {
                 *  // set host poweroff task key values for wlb reporting purpose
                 *  Task.add_to_other_config(this.Session, this.RelatedTask.opaque_ref, "wlb_advised", Host.other_config[WlbOptimizePoolAction.OPTIMIZINGPOOL]);
                 *  Task.add_to_other_config(this.Session, this.RelatedTask.opaque_ref, "wlb_action", "host_poweron");
                 *  Task.add_to_other_config(this.Session, this.RelatedTask.opaque_ref, "wlb_action_obj_ref", Host.opaque_ref);
                 *  Task.add_to_other_config(this.Session, this.RelatedTask.opaque_ref, "wlb_action_obj_type", "host");
                 * }
                 */
            }
            catch (Exception e)
            {
                Failure f = e as Failure;
                if (f != null)
                {
                    string msg = f.ErrorDescription.Count > 2 ? Messages.ResourceManager.GetString(f.ErrorDescription[2]) : null;
                    if (msg != null)
                    {
                        throw new Exception(msg);
                    }
                    else
                    {
                        throw new Exception(string.Format(Messages.POWER_ON_REQUEST_FAILED, this.Host));
                    }
                }
                throw;
            }
            finally
            {
                if (Helpers.WlbConfigured(this.Connection) && Helpers.WlbEnabledAndConfigured(this.Connection))
                {
                    UpdateHostLastPowerOnSucceeded(succeeded, Host);
                }
            }
        }
Exemple #17
0
        public CreateVMAction(IXenConnection connection, VM template, Host copyBiosStringsFrom, string name, string description, InstallMethod installMethod,
                              string pvArgs, VDI cd, string url, Host homeServer, long vcpus, long memoryDynamicMin, long memoryDynamicMax, long memoryStaticMax,
                              List <DiskDescription> disks, SR fullCopySR, List <VIF> vifs, bool startAfter, Action <VM, bool> warningDialogHAInvalidConfig, Action <VMStartAbstractAction, Failure> startDiagnosisForm)
            : base(connection, string.Format(Messages.CREATE_VM, name), string.Format(Messages.CREATE_VM_FROM_TEMPLATE, name, Helpers.GetName(template)))
        {
            Template            = template;
            CopyBiosStringsFrom = copyBiosStringsFrom;
            FullCopySR          = fullCopySR;
            NameLabel           = name;
            NameDescription     = description;
            InsMethod           = installMethod;
            PvArgs           = pvArgs;
            Cd               = cd;
            Url              = url;
            HomeServer       = homeServer;
            Vcpus            = vcpus;
            MemoryDynamicMin = memoryDynamicMin;
            MemoryDynamicMax = memoryDynamicMax;
            MemoryStaticMax  = memoryStaticMax;
            Disks            = disks;
            Vifs             = vifs;
            StartAfter       = startAfter;
            _warningDialogHAInvalidConfig = warningDialogHAInvalidConfig;
            _startDiagnosisForm           = startDiagnosisForm;

            Pool pool_of_one = Helpers.GetPoolOfOne(Connection);

            if (HomeServer != null || pool_of_one != null) // otherwise we have no where to put the action
            {
                AppliesTo.Add(HomeServer != null ? HomeServer.opaque_ref : pool_of_one.opaque_ref);
            }

            #region RBAC Dependencies

            if (StartAfter)
            {
                ApiMethodsToRoleCheck.Add("vm.start");
            }
            if (HomeServerChanged())
            {
                ApiMethodsToRoleCheck.Add("vm.set_affinity");
            }
            if (Template.memory_dynamic_min != MemoryDynamicMin || Template.memory_dynamic_max != MemoryDynamicMax || Template.memory_static_max != MemoryStaticMax)
            {
                ApiMethodsToRoleCheck.Add("vm.set_memory_limits");
            }

            ApiMethodsToRoleCheck.AddRange(StaticRBACDependencies);

            ApiMethodsToRoleCheck.AddRange(Role.CommonTaskApiList);
            ApiMethodsToRoleCheck.AddRange(Role.CommonSessionApiList);
            #endregion
        }
Exemple #18
0
        public override object GetParameter(int index)
        {
            switch (index)
            {
            case 0:
                return(AppliesTo == null ? Property : AppliesTo.Save() + "." + Property);

            case 1:
                return(GetValue());

            default:
                throw new ArgumentOutOfRangeException();
            }
        }
Exemple #19
0
        public DeleteFolderAction(IXenObject obj)
            : base(obj.Connection, Messages.DELETING_FOLDER)
        {
            objs.Add(obj);
            if (obj.GetType() != typeof(Folder))
            {
                ApiMethodsToRoleCheck.Add(obj.GetType().Name.ToLowerInvariant() + ".remove_from_other_config",
                                          Folders.FOLDER);
                ApiMethodsToRoleCheck.Add(obj.GetType().Name.ToLowerInvariant() + ".add_to_other_config",
                                          Folders.FOLDER);
            }

            AppliesTo.Add(obj.opaque_ref);
        }
Exemple #20
0
        // Constructor used for New
        public FolderAction(IXenConnection connection, Kind kind, params string[] paths)
            : base(connection, GetTitleForNew(paths))
        {
            System.Diagnostics.Trace.Assert(kind == Kind.New);
            this.kind  = kind;
            this.paths = paths;

            ApiMethodsToRoleCheck.Add("pool.remove_from_other_config", Folders.EMPTY_FOLDERS);
            ApiMethodsToRoleCheck.Add("pool.add_to_other_config", Folders.EMPTY_FOLDERS);

            foreach (string path in paths)
            {
                AppliesTo.Add(path);
            }
        }
            /// <summary>Assumes a 1x1x1 <see cref="Block"/> for a <see cref="FlatFace"/>.</summary>
            /// <param name="face">Which <see cref="Block.Face"/> is this attribute describing?</param>
            /// <param name="targets">Does this attribute apply to just the preview, just the original, or both?</param>
            public FlatFace(Block.Face face, int identifier = 0, AppliesTo targets = AppliesTo.Both)
                : this(face,

                       posX: (int)face == +1 ? +0.5f : (int)face == -1 ? -0.5f : 0,
                       posY: (int)face == +2 ? +0.5f : (int)face == -2 ? -0.5f : 0,
                       posZ: (int)face == +3 ? +0.5f : (int)face == -3 ? -0.5f : 0,

                       rotX: (int)face == +3 ? +90f : (int)face == -3 ? -90f
                          : (int)face == +2 ? 000f : (int)face == -2 ? 180f : 0,
                       rotY: 0,
                       rotZ: (int)face == +1 ? -90f : (int)face == -1 ? +90f : 0,

                       identifier, targets)
            {
            }
Exemple #22
0
        public override void Execute(Context c)
        {
            object result = GetResult(c);

            if (AppliesTo != null)
            {
                // we're setting an object property
                Element obj = AppliesTo.Execute(c);
                obj.Fields.Set(Property, result);
            }
            else
            {
                // we're setting a local variable
                c.Parameters[Property] = result;
            }
        }
Exemple #23
0
        public MoveToFolderAction(IXenObject obj, Folder folder)
            : base(obj.Connection, string.Format(Messages.MOVE_OBJECT_TO_FOLDER, Helpers.GetName(obj), folder.Name()))
        {
            this.objs.Add(obj);
            this.folder = folder;
            if (obj.GetType() != typeof(Folder))
            {
                ApiMethodsToRoleCheck.Add(obj.GetType().Name.ToLowerInvariant() + ".remove_from_other_config",
                                          Folders.FOLDER);
                ApiMethodsToRoleCheck.Add(obj.GetType().Name.ToLowerInvariant() + ".add_to_other_config",
                                          Folders.FOLDER);
            }

            AppliesTo.Add(obj.opaque_ref);
            AppliesTo.Add(folder.opaque_ref);
        }
Exemple #24
0
        /// <summary>
        /// Initializes a new instance of the <see cref="ChangeStorageLinkPasswordAction"/> class.
        ///
        /// You need to be a pool-operator or higher to even get access to the password for the storagelink service.
        ///
        /// </summary>
        /// <param name="storageLinkConnection">The storage link connection.</param>
        /// <param name="username">The username.</param>
        /// <param name="oldPassword">The old password.</param>
        /// <param name="newPassword">The new password.</param>
        public ChangeStorageLinkPasswordAction(IEnumerable <IXenConnection> xenConnections, StorageLinkConnection storageLinkConnection, string username, string oldPassword, string newPassword)
            : base(null, Messages.CHANGE_SL_SERVER_PASSWORD_ACTION_TITLE, Messages.CHANGE_SL_SERVER_PASSWORD_ACTION_DES_START)
        {
            Util.ThrowIfParameterNull(storageLinkConnection, "storageLinkConnection");
            Util.ThrowIfStringParameterNullOrEmpty(username, "username");
            Util.ThrowIfParameterNull(oldPassword, "oldPassword");
            Util.ThrowIfParameterNull(newPassword, "newPassword");

            _storageLinkConnection = storageLinkConnection;
            _username       = username;
            _oldPassword    = oldPassword;
            _newPassword    = newPassword;
            _xenConnections = xenConnections;

            AppliesTo.Add(storageLinkConnection.Cache.Server.opaque_ref);
            AppliesTo.AddRange(GetPoolsToCheck().ConvertAll(p => p.opaque_ref));
        }
        protected virtual async ValueTask <IRelyingParty> GetRelyingPartyAsync(AppliesTo appliesTo, CancellationToken cancellationToken)
        {
            if (appliesTo == null)
            {
                return(null);
            }
            var id = appliesTo.EndpointReference.Uri;

            if (_cache.TryGetValue(id, out var party))
            {
                return(party);
            }
            var p = await RelyingParties.GetRelyingPartyAsync(appliesTo.EndpointReference.Uri);

            _cache.Add(id, p);
            return(p);
        }
Exemple #26
0
        public override string Save()
        {
            string result;

            if (AppliesTo != null)
            {
                result = AppliesTo.Save() + "." + Property;
            }
            else
            {
                result = Property;
            }

            result += GetEqualsString + GetSaveString();

            return(result);
        }
        public override string Save(Context c)
        {
            string result = string.Empty;

            if (AppliesTo != null)
            {
                result = string.Format("set({0}, \"{1}\", {2});", AppliesTo.Save(c), Property, GetSaveString(c));
            }
            else
            {
                string varName = Utility.ReplaceReservedVariableNames(Property);
                result  = "var " + varName;
                result += " = " + GetSaveString(c) + ";";
                c.AddLocalVariable(varName);
            }

            return(result);
        }
Exemple #28
0
        private void SetAppliesToData(Task task)
        {
            List <string> applies_to = task.AppliesTo();

            if (applies_to != null)
            {
                AppliesTo.AddRange(applies_to);
            }
            else
            {
                // A non-aware client has created this task.  We'll create a new action for this, and place it under
                // the task.resident_on host, or if that doesn't resolve, the pool master.
                Host host = task.Connection.Resolve(task.resident_on) ?? Helpers.GetMaster(task.Connection);
                if (host != null)
                {
                    AppliesTo.Add(host.opaque_ref);
                }
            }
        }
Exemple #29
0
            internal NonscalarTypeHeader(OutGridViewCommand parentCmd, PSObject input) : base(parentCmd)
            {
                // Prepare a table view.
                TableView tableView = new TableView();

                tableView.Initialize(parentCmd._expressionFactory, parentCmd._typeInfoDataBase);

                // Request a view definition from the type database.
                ViewDefinition viewDefinition = DisplayDataQuery.GetViewByShapeAndType(parentCmd._expressionFactory, parentCmd._typeInfoDataBase, FormatShape.Table, input.TypeNames, null);

                if (viewDefinition != null)
                {
                    // Create a header using a view definition provided by the types database.
                    parentCmd._windowProxy.AddColumnsAndItem(input, tableView, (TableControlBody)viewDefinition.mainControl);

                    // Remember all type names and type groups the current view applies to.
                    _appliesTo = viewDefinition.appliesTo;
                }
                else
                {
                    // Create a header using only the input object's properties.
                    parentCmd._windowProxy.AddColumnsAndItem(input, tableView);
                    _appliesTo = new AppliesTo();

                    // Add all type names except for Object and MarshalByRefObject types because they are too generic.
                    // Leave the Object type name if it is the only type name.
                    int index = 0;
                    foreach (string typeName in input.TypeNames)
                    {
                        if (index > 0 && (typeName.Equals(typeof(Object).FullName, StringComparison.OrdinalIgnoreCase) ||
                                          typeName.Equals(typeof(MarshalByRefObject).FullName, StringComparison.OrdinalIgnoreCase)))
                        {
                            break;
                        }

                        _appliesTo.AddAppliesToType(typeName);
                        index++;
                    }
                }
            }
        /// <summary>
        /// Tries to parse a user-input text to an <see cref="AppliesTo"/> enum.
        /// </summary>
        /// <param name="text">Input from user.</param>
        /// <param name="appliesTo">Result if successful.</param>
        /// <returns>True if parsed successfully.</returns>
        public static bool TryParseAppliesTo(string text, out AppliesTo appliesTo)
        {
            if (string.IsNullOrEmpty(text) || string.Equals(ConfigFilter.GlobalAppliesTo, text, StringComparison.OrdinalIgnoreCase))
            {
                appliesTo = AppliesTo.Az;
                return(true);
            }

            if (PSNamingUtilities.IsModuleName(text))
            {
                appliesTo = AppliesTo.Module;
                return(true);
            }

            if (PSNamingUtilities.IsCmdletName(text))
            {
                appliesTo = AppliesTo.Cmdlet;
                return(true);
            }

            appliesTo = AppliesTo.Az;
            return(false);
        }
		public WindowsUIPermission(AppliesTo appliesTo)
		{
			_appliesTo = appliesTo;
		}