Ejemplo n.º 1
0
        //---------------------------------------------------------------------------------------------------------------------

        /// <summary>Returns an instance of a ComputingResource subclass representing the computing resource with the specified identifier.</summary>
        /// <param name="context">The execution environment context.</param>
        /// <param name="identifier">The unique identifier of the computing resource.</param>
        /// <returns>The created ComputingResource subclass instance.</returns>
        public static ComputingResource FromIdentifier(IfyContext context, string identifier)
        {
            EntityType        entityType = EntityType.GetEntityType(typeof(ComputingResource));
            ComputingResource result     = (ComputingResource)entityType.GetEntityInstanceFromIdentifier(context, identifier);

            result.Identifier = identifier;
            result.Load();
            return(result);
        }
Ejemplo n.º 2
0
        //---------------------------------------------------------------------------------------------------------------------

        /// <summary>Returns an instance of a ComputingResource subclass representing the computing resource with the specified database ID.</summary>
        /// <param name="context">The execution environment context.</param>
        /// <param name="id">The database ID of the computing resource.</param>
        /// <returns>The created ComputingResource subclass instance.</returns>
        public static ComputingResource FromId(IfyContext context, int id)
        {
            EntityType        entityType = EntityType.GetEntityType(typeof(ComputingResource));
            ComputingResource result     = (ComputingResource)entityType.GetEntityInstanceFromId(context, id);

            result.Id = id;
            result.Load();
            return(result);
        }
Ejemplo n.º 3
0
        //---------------------------------------------------------------------------------------------------------------------

        /// <summary>Returns an instance of a ComputingResource subclass representing the computing resource with the specified ID, address or caption.</summary>
        /// <param name="context">The execution environment context.</param>
        /// <param name="s">A search value that must match the database ID (preferred) of the computing resource, or its unique identifier.</param>
        /// <returns>The created ComputingResource subclass instance.</returns>
        public static ComputingResource FromString(IfyContext context, string s)
        {
            int id = 0;

            Int32.TryParse(s, out id);
            EntityType        entityType = EntityType.GetEntityType(typeof(ComputingResource));
            ComputingResource result     = (ComputingResource)entityType.GetEntityInstanceFromCondition(context, String.Format("t.name={0} OR t.id={1}", StringUtils.EscapeSql(s), id), String.Format("t.id!={0}", id));

            result.Id   = id;
            result.Name = s;
            result.Load();
            return(result);
        }