Beispiel #1
0
        /// <param name="uri">            The uri to identify the component with. </param>
        /// <param name="type">           The type to create the metadata for </param>
        /// <param name="factory">        A reflection library to provide class construction and field get/set functionality </param>
        /// <param name="copyStrategies"> A copy strategy library </param>
        /// <exception cref="NoSuchMethodException"> If the component has no default constructor </exception>
//JAVA TO C# CONVERTER WARNING: Method 'throws' clauses are not available in .NET:
//ORIGINAL LINE: public ComponentMetadata(org.terasology.engine.SimpleUri uri, Class type, org.terasology.reflection.reflect.ReflectFactory factory, org.terasology.reflection.copy.CopyStrategyLibrary copyStrategies) throws NoSuchMethodException
        public ComponentMetadata(SimpleUri uri, Type type, ReflectFactory factory, CopyStrategyLibrary copyStrategies) : base(uri, type, factory, copyStrategies, Predicates.alwaysTrue())
        {
            replicated = type.getAnnotation(typeof(Replicate)) != null;
            blockLifecycleEventsRequired = type.getAnnotation(typeof(RequiresBlockLifecycleEvents)) != null;
            ForceBlockActive forceBlockActiveAnnotation = type.getAnnotation(typeof(ForceBlockActive));

            if (forceBlockActiveAnnotation != null)
            {
                forceBlockActive             = true;
                retainUnalteredOnBlockChange = forceBlockActiveAnnotation.retainUnalteredOnBlockChange();
            }

//JAVA TO C# CONVERTER TODO TASK: Java wildcard generics are not converted to .NET:
//ORIGINAL LINE: for (ComponentFieldMetadata<T, ?> field : getFields())
            foreach (ComponentFieldMetadata <T, ?> field in Fields)
            {
                if (field.Replicated)
                {
                    replicated = true;
                    if (field.ReplicationInfo.value().ReplicateFromOwner)
                    {
                        replicatedFromOwner = true;
                    }
                }
                if (field.OwnedReference)
                {
                    referenceOwner = true;
                }
            }
        }
Beispiel #2
0
 public virtual void registerEvent(SimpleUri uri, Type eventType)
 {
     eventIdMap.put(uri, eventType);
     logger.debug("Registering event {}", eventType.Name);
     foreach (Type parent in ReflectionUtils.getAllSuperTypes(eventType, Predicates.assignableFrom(typeof(Event))))
     {
         if (!typeof(AbstractConsumableEvent).Equals(parent) && !typeof(Event).Equals(parent))
         {
             childEvents.put(parent, eventType);
         }
     }
     if (shouldAddToLibrary(eventType))
     {
         eventLibrary.register(uri, eventType);
     }
 }
Beispiel #3
0
            /// <summary>
            /// Determines whether the specified <see cref="System.Object"/> is equal to this instance.
            /// </summary>
            /// <param name="obj">The <see cref="System.Object"/> to compare with this instance.</param>
            /// <returns>
            ///     <c>true</c> if the specified <see cref="System.Object"/> is equal to this instance; otherwise, <c>false</c>.
            /// </returns>
            /// <exception cref="T:System.NullReferenceException">
            /// The <paramref name="obj"/> parameter is null.
            /// </exception>
            public override bool Equals(object obj)
            {
                SimpleUri other = obj as SimpleUri;

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

                // Note that this equality check is intentionally leaving off the Fragment part
                // to match Uri behavior, and is intentionally being case sensitive and insensitive
                // for different parts.
                return(string.Equals(this.Scheme, other.Scheme, StringComparison.OrdinalIgnoreCase) &&
                       string.Equals(this.Authority, other.Authority, StringComparison.OrdinalIgnoreCase) &&
                       string.Equals(this.Path, other.Path, StringComparison.Ordinal) &&
                       string.Equals(this.Query, other.Query, StringComparison.Ordinal));
            }
Beispiel #4
0
        private static SimpleUri ParseUri(string uri)
        {
            Regex rx = new Regex(@"((?<scheme>http[s]?)):\/\/(?<host>[^:\/\s]+)(:(?<port>(\d+)))?.*");

            var m = rx.Match(uri);

            if (m.Success)
            {
                var result = new SimpleUri()
                {
                    Scheme = m.Groups["scheme"].Value.ToUpper(),
                    Host   = m.Groups["host"].Value,
                };

                UInt16 port;
                if (UInt16.TryParse(m.Groups["port"].Value, out port))
                {
                    result.Port = port;
                }
                else
                {
                    if (result.Scheme.Equals("http", StringComparison.InvariantCultureIgnoreCase))
                    {
                        result.Port = 80;
                    }
                    if (result.Scheme.Equals("https", StringComparison.InvariantCultureIgnoreCase))
                    {
                        result.Port = 443;
                    }
                }

                return(result);
            }

            return(null);
        }
Beispiel #5
0
 public virtual void prepare(SimpleUri buttonId, ButtonState newState, float delta)
 {
     reset(delta);
     this.id    = buttonId;
     this.state = newState;
 }
Beispiel #6
0
//JAVA TO C# CONVERTER WARNING: Method 'throws' clauses are not available in .NET:
//ORIGINAL LINE: public EventMetadata(Class simpleClass, org.terasology.reflection.copy.CopyStrategyLibrary copyStrategies, org.terasology.reflection.reflect.ReflectFactory factory, org.terasology.engine.SimpleUri uri) throws NoSuchMethodException
        public EventMetadata(Type simpleClass, CopyStrategyLibrary copyStrategies, ReflectFactory factory, SimpleUri uri) : base(uri, simpleClass, factory, copyStrategies, Predicates.alwaysTrue())
        {
            if (simpleClass.getAnnotation(typeof(ServerEvent)) != null)
            {
                networkEventType = NetworkEventType.SERVER;
                lagCompensated   = simpleClass.getAnnotation(typeof(ServerEvent)).lagCompensate();
            }
            else if (simpleClass.getAnnotation(typeof(OwnerEvent)) != null)
            {
                networkEventType = NetworkEventType.OWNER;
            }
            else if (simpleClass.getAnnotation(typeof(BroadcastEvent)) != null)
            {
                networkEventType = NetworkEventType.BROADCAST;
                skipInstigator   = simpleClass.getAnnotation(typeof(BroadcastEvent)).skipInstigator();
            }
        }