/// <summary>Initializes a new instance of the RestrictParentsAttribute which is used to restrict which types of items may be added below which.</summary>
 /// <param name="allowedTypes">Defines wether all types of items are allowed as parent items.</param>
 public AllowedParentsAttribute(AllowedTypes allowedTypes)
 {
     if (allowedTypes == AllowedTypes.All)
         Types = null;
     else
         Types = new Type[0];
 }
 /// <summary>Initializes a new instance of the RestrictParentsAttribute which is used to restrict which types of items may be added below which.</summary>
 /// <param name="allowedTypes">Defines wether all types of items are allowed as parent items.</param>
 public RestrictParentsAttribute(AllowedTypes allowedTypes)
     : this()
 {
     if (allowedTypes == AllowedTypes.All)
         Types = null;
     else
         Types = new Type[0];
 }
        public static void RegisterControllersIn(Assembly assembly, string @namespace, string areaName)
        {
            var types = assembly.GetTypes().Where(IsControllerType).Where(a => a.Namespace == @namespace || a.Namespace.StartsWith(@namespace + "."));

            AllowedTypes.AddRange(types, t => t, t => areaName, "controllers");
        }
 /// <summary>Initializes a new instance of the RestrictPageTypesAttribute which is used to restrict which types of items may be added below which.</summary>
 /// <param name="allowedTypes">Defines wether all types of items are allowed as parent items.</param>
 public RestrictPageTypesAttribute(AllowedTypes allowedTypes)
     : this()
 {
     Types = allowedTypes == AllowedTypes.All ? null : new Type[0];
 }
        public Block ConvertToBlock(IImage <T> input, IEnumerable <IFitsValue> extraKeys, bool isXtension = false)
        {
            if (input is null)
            {
                throw new ArgumentNullException(nameof(input), SR.NullArgument);
            }

            AllowedTypes.ValidateDataType <T>();

            var extraKeysInst = (extraKeys ?? Enumerable.Empty <IFitsValue>()).ToList();

            // Throws if mandatory keys are present
            Extensions.CheckExtraFitsKeys(extraKeysInst);

            var bitPix = FitsCs.Extensions.ConvertTypeToBitPix <T>()
                         ?? throw new InvalidOperationException(string.Format(SR.TypeNotSupported, typeof(T)));

            var desc = new Descriptor(
                bitPix,
                new[] { input.Width, input.Height },
                isXtension ? ExtensionType.Image : ExtensionType.Primary);

            var keys = new List <IFitsValue>(extraKeysInst.Count + 10);

            keys.AddRange(desc.GenerateFitsHeader());
            keys.AddRange(extraKeysInst);
            keys.Add(FitsKey.CreateEnd());

            var block = Block <T> .CreateWithData(desc, keys, x =>
            {
                input.GetView().CopyTo(x);
            });

            return(block);
        }
Esempio n. 6
0
    public override string ToString()
    {
        var  sb      = new StringBuilder("E2EENegotiationResult(");
        bool __first = true;

        if (AllowedTypes != null && __isset.allowedTypes)
        {
            if (!__first)
            {
                sb.Append(", ");
            }
            __first = false;
            sb.Append("AllowedTypes: ");
            AllowedTypes.ToString(sb);
        }
        if (PublicKey != null && __isset.publicKey)
        {
            if (!__first)
            {
                sb.Append(", ");
            }
            __first = false;
            sb.Append("PublicKey: ");
            PublicKey.ToString(sb);
        }
        sb.Append(")");
        return(sb.ToString());
    }
Esempio n. 7
0
        //-----------------------------------------------------------------------------------
        public CNField(bool exclusive, AllowedTypes allowedType, ScopeFlag scopeType, bool addDefaultWildcard)
        {
            allowedType_ = allowedType;
            exclusive_   = exclusive;
            ScopeType    = scopeType;

            if (addDefaultWildcard)
            {
                NameSelectors.Add("*");
            }
        }
 /// <summary>Initializes a new instance of the RestrictParentsAttribute which is used to restrict which types of items may be added below which.</summary>
 /// <param name="allowedTypes">Defines wether all types of items are allowed as parent items.</param>
 public RestrictParentsAttribute(AllowedTypes allowedTypes)
     : this()
 {
     if (allowedTypes == AllowedTypes.All)
     {
         Types = null;
     }
     else
     {
         Types = new Type[0];
     }
 }
 /// <summary>
 /// An authorization information consists of a start timestamp and a
 /// list of possible values that influence this period.
 /// </summary>
 public AuthorizationInfo(AllowedTypes Allowed,
                          Token Token,
                          LocationReference?Location = null,
                          AuthorizationReference?AuthorizationReference = null,
                          DisplayText?Info = null)
 {
     this.Allowed  = Allowed;
     this.Token    = Token;
     this.Location = Location;
     this.AuthorizationReference = AuthorizationReference;
     this.Info = Info;
 }
        public BitVectorUnsigned(int bits, uint defaultvalue, SignalDirectionType st) : base(st, defaultvalue)
        {
            if (bits > 64)
            {
                throw new ArgumentException("BitVectorUnsigned has a maximum size of 64");
            }

            this.bits = bits;
            maxvalue  = (ulong)(Math.Pow(2, bits) - 1);

            AllowedTypes.Add(typeof(SignalCollection <bool>));
        }
Esempio n. 11
0
        /// <summary>
        /// Create new token statuss for an EV driver.
        /// </summary>
        /// <param name="Token">The name of the energy supplier for this token.</param>
        /// <param name="Status">The optional contract identification at the energy supplier, that belongs to the owner of this token.</param>
        /// <param name="LocationReference">A reference to location details.</param>
        public TokenStatus(Token Token,
                           AllowedTypes Status,
                           LocationReference?LocationReference = null)
        {
            if (Token is null)
            {
                throw new ArgumentNullException(nameof(Token), "The given token must not be null or empty!");
            }

            this.Token             = Token;
            this.Status            = Status;
            this.LocationReference = LocationReference;
        }
Esempio n. 12
0
 public static void CheckAllowedType(QuestType questType)
 {
     if (!AllowedTypes.Contains(questType))
     {
         AllowedTypes.Add(questType);
         // if (AllowedTypes.Count == 1) {
         //     foreach (NetworkUser networkUser in NetworkUser.readOnlyInstancesList) {
         //         Questing.Announcement announcement = new Questing.Announcement("");
         //         Networking.SendAnnouncement(announcement, networkUser.connectionToClient.connectionId);
         //     }
         // }
         timeoutStart = Run.instance.GetRunStopwatch();
     }
 }
Esempio n. 13
0
        //-----------------------------------------------------------------------------------
        private CNField(CNField original)
        {
            exclusive_   = original.exclusive_;
            allowedType_ = original.allowedType_;
            scopeType_   = original.scopeType_;

            //references to gameObject are never cloned

            foreach (CommandNode commandNode in original.lCommandNodes_)
            {
                CommandNodes.Add(commandNode);
            }

            foreach (string nameSelector in original.lNameSelector_)
            {
                NameSelectors.Add(string.Copy(nameSelector));
            }
        }
        static bool IsAllowed(Type type, out string areaName)
        {
            if (MainAssembly == null)
            {
                throw new InvalidOperationException("PortableAreaControllers.MainAssembly is not set");
            }

            areaName = null;

            if (type == null)
            {
                return(false);
            }

            if (type.Assembly == MainAssembly)
            {
                return(true);
            }

            return(AllowedTypes.TryGetValue(type, out areaName));
        }
Esempio n. 15
0
        public bool CanHaveStatefulFields(Control control)
        {
            if (control is LiteralControl)             //quickly removed the LiteralControls
            {
                return(false);
            }
            if (control is UserControl || control is Page)
            {
                if (control is IStatefulFieldsControl)
                {
                    if (((IStatefulFieldsControl)control).IgnoreStatefulFields)
                    {
                        return(false);
                    }
                }
                return(Attribute.GetCustomAttribute(control.GetType(), typeof(IgnoreStatefulFields)) == null);
            }
            Type t = control.GetType();

            LogFactory.Log.Debug("inspecting " + t + control.ID + "(" + control.UniqueID + ")");
            if (AllowedTypes.Contains(t))
            {
                return(true);
            }
            if (FilteredTypes.Contains(t))
            {
                return(false);
            }
            foreach (Type ft in FilteredBaseTypes)
            {
                if (t.IsSubclassOf(ft))
                {
                    FilteredTypes.Add(t);
                    return(false);
                }
            }
            //this line took too much resources:
            //return Attribute.GetCustomAttribute(control.GetType(), typeof (HasStatefulField)) != null;
            return(true);
        }
Esempio n. 16
0
        public void SetValue <T>(T value)
        {
            object objValue = value;

            if (objValue != null && AllowedTypes != null)
            {
                Type type = typeof(T);

                if (type == typeof(BoostVariant))
                {
                    BoostVariant boostVariant = (BoostVariant)objValue;
                    type     = boostVariant.Type;
                    objValue = boostVariant.Value;
                }

                if (type != null && !AllowedTypes.Contains(type))
                {
                    throw new ArgumentException(String.Format("This type is not allowed: {0}", type));
                }
            }

            data = objValue;
        }
Esempio n. 17
0
        /// <summary>
        /// Returns true if this port can connect to specified port
        /// </summary>
        public bool CanConnectTo(NodePort port)
        {
            // Figure out which is input and which is output
            NodePort input = null, output = null;

            if (IsInput)
            {
                input = this;
            }
            else
            {
                output = this;
            }

            if (port.IsInput)
            {
                input = port;
            }
            else
            {
                output = port;
            }
            // If there isn't one of each, they can't connect
            if (input == null || output == null)
            {
                return(false);
            }
            // Disable connection if input and output belongs to same node
            if (input.node == output.node)
            {
                return(false);
            }
            // Check input type constraints
            if (input.typeConstraint == XNode.Node.TypeConstraint.Inherited)
            {
                if (!AllowedTypes.Any(t => ((Type)t).IsAssignableFrom(output.ValueType)))
                {
                    return(false);
                }
            }

            if (input.typeConstraint == XNode.Node.TypeConstraint.Strict)
            {
                if (AllowedTypes.All(t => ((Type)t) != output.ValueType))
                {
                    return(false);
                }
            }
            // Check output type constraints
            if (output.typeConstraint == XNode.Node.TypeConstraint.Inherited)
            {
                if (!AllowedTypes.Any(t => ((Type)t).IsAssignableFrom(input.ValueType)))
                {
                    return(false);
                }
            }

            if (output.typeConstraint == XNode.Node.TypeConstraint.Strict)
            {
                if (AllowedTypes.All(t => ((Type)t) != input.ValueType))
                {
                    return(false);
                }
            }
            // Success
            return(true);
        }
Esempio n. 18
0
 //-----------------------------------------------------------------------------------
 public CNField(bool exclusive, AllowedTypes allowedType, bool addDefaultWildcard)
     : this(exclusive, allowedType, ScopeFlag.Inherited, addDefaultWildcard)
 {
 }
Esempio n. 19
0
 internal bool CanMount(Part part)
 {
     return(AllowedTypes.Intersect(part.Types).Any() && AllowedSizes.Contains(part.MySizeType));
 }
Esempio n. 20
0
 private static bool IsAllowedType(this Type t)
 {
     return(AllowedTypes.Contains(t));
 }
Esempio n. 21
0
 public static Builder <RestrictParentsAttribute> RestrictParents(this IContentRegistration registration, AllowedTypes allowedTypes)
 {
     return(registration.RegisterRefiner(new RestrictParentsAttribute(allowedTypes)));
 }
Esempio n. 22
-1
 /// <summary>Initializes a new instance of the RestrictParentsAttribute which is used to restrict which types of items may be added below which.</summary>
 /// <param name="allowedTypes">Defines wether all types of items are allowed as parent items.</param>
 public AllowedParentsAttribute(AllowedTypes allowedTypes)
 {
     if (allowedTypes == AllowedTypes.All)
     {
         Types = null;
     }
     else
     {
         Types = new Type[0];
     }
 }
Esempio n. 23
-1
 /// <summary>
 /// This attribute replace the children allowed with the types
 /// </summary>
 public static Builder <RestrictChildrenAttribute> RestrictChildren <TModel>(this IContentRegistration <TModel> registration, AllowedTypes allowedTypes)
 {
     return(registration.RegisterRefiner <RestrictChildrenAttribute>(new RestrictChildrenAttribute(allowedTypes)));
 }
 public static Builder<RestrictParentsAttribute> RestrictParents(this IContentRegistration registration, AllowedTypes allowedTypes)
 {
     return registration.RegisterRefiner<RestrictParentsAttribute>(new RestrictParentsAttribute(allowedTypes));
 }
		/// <summary>Initializes a new instance of the RestrictPageTypesAttribute which is used to restrict which types of items may be added below which.</summary>
		/// <param name="allowedTypes">Defines wether all types of items are allowed as parent items.</param>
		public RestrictPageTypesAttribute(AllowedTypes allowedTypes)
			: this()
		{
		    Types = allowedTypes == AllowedTypes.All ? null : new Type[0];
		}