Beispiel #1
0
            public static bool GetOrCreateValue(
                TTextView textView,
                object key,
                Func <TTextView, TProperty> valueCreator,
                out TProperty value
                )
            {
                Contract.ThrowIfTrue(textView.IsClosed);

                var properties = textView.Properties.GetOrCreateSingletonProperty(
                    () => new AutoClosingViewProperty <TProperty, TTextView>(textView)
                    );

                if (!properties.TryGetValue(key, out var priorValue))
                {
                    // Need to create it.
                    value = valueCreator(textView);
                    properties.Add(key, value);
                    return(true);
                }

                // Already there.
                value = priorValue;
                return(false);
            }
Beispiel #2
0
        public static T Transformation(U u)
        {
            if (u == null)
            {
                return(null);
            }

            PropertyInfo[] TProperties = TType.GetProperties();
            PropertyInfo[] UProperties = UType.GetProperties();

            T t = new T();

            foreach (PropertyInfo TProperty in TProperties)
            {
                PropertyInfo UProperty =
                    UProperties.FirstOrDefault(x => x.Name == TProperty.Name && x.PropertyType == TProperty.PropertyType);

                if (UProperty != null)
                {
                    TProperty.SetValue(t, UProperty.GetValue(u));
                }
            }

            return(t);
        }
Beispiel #3
0
        public static void GenerateAOTFunctions <TProperty, TContainer, TValue>()
            where TProperty : IProperty <TContainer, TValue>
        {
            TProperty     property      = default(TProperty);
            TContainer    container     = default(TContainer);
            TValue        value         = default(TValue);
            ChangeTracker changeTracker = default(ChangeTracker);

            PropertyVisitor propertyVisitor = new PropertyVisitor();

            propertyVisitor.TryVisitContainerWithAdapters(property, ref container, ref value, ref changeTracker);
            propertyVisitor.TryVisitValueWithAdapters(property, ref container, ref value, ref changeTracker);
            PropertyVisitorAdapterExtensions.TryVisitContainer(null, null, property, ref container, ref value, ref changeTracker);
            PropertyVisitorAdapterExtensions.TryVisitValue(null, null, property, ref container, ref value, ref changeTracker);

            Actions.GetCollectionCountGetter <TContainer> getCollectionCountGetter       = new Actions.GetCollectionCountGetter <TContainer>();
            Actions.GetCountFromActualTypeCallback        getCountFromActualTypeCallback = new Actions.GetCountFromActualTypeCallback();
            getCountFromActualTypeCallback.Invoke <TContainer>();
            getCountFromActualTypeCallback.Invoke <TValue>();
            Actions.GetCountAtPathGetter <TContainer> getCountAtPathGetter = new Actions.GetCountAtPathGetter <TContainer>();
            Actions.VisitAtPathCallback visitAtPathCallback = default;
            visitAtPathCallback.Invoke <TContainer>();
            visitAtPathCallback.Invoke <TValue>();
            Actions.SetCountCallback setCountCallback = default;
            setCountCallback.Invoke <TContainer>();
            setCountCallback.Invoke <TValue>();

            Actions.TryGetCount(ref container, new PropertyPath(), 0, ref changeTracker, out var count);
            Actions.TryGetCountImpl(ref container, new PropertyPath(), 0, ref changeTracker, out var otherCount);
            Actions.GetCount(ref container, new PropertyPath(), 0, ref changeTracker);
        }
Beispiel #4
0
            public void Execute(ArchetypeChunk chunk, int chunkIndex, int firstEntityIndex)
            {
                if (!chunk.DidChange(SpriteAnimationTimeSpeedStateType, LastSystemVersion))
                {
                    return;
                }
                var states             = chunk.GetNativeArray(SpriteAnimationTimeSpeedStateType);
                var playingStates      = chunk.GetNativeArray(SpriteAnimationPlayingStateType);
                var propertyComponents = chunk.GetNativeArray(PropertyType);

                if (propertyComponents.Length > 0)
                {
                    var clipSet = ClipSetFromEntity[Filter.ClipSetEntity][Filter.ClipIndex];
                    for (var i = 0; i < propertyComponents.Length; ++i)
                    {
                        var isPlaying = clipSet.Loop || clipSet.ComputeNormalizedTime(states[i].Time) > clipSet.ComputeNormalizedTime(states[i].PrevioutTime);
                        propertyComponents[i] = new TProperty {
                            Value = clipSet.GetValue(states[i].Time)
                        };
                        if (isPlaying)
                        {
                            playingStates[i] = new SpriteAnimationPlayingState {
                                Value = true
                            }
                        }
                        ;
                    }
                }
            }
        }
Beispiel #5
0
            public static void AddValue(TTextView textView, object key, TProperty value)
            {
                Contract.ThrowIfTrue(textView.IsClosed);

                var properties = textView.Properties.GetOrCreateSingletonProperty(
                    () => new AutoClosingViewProperty <TProperty, TTextView>(textView)
                    );

                properties.Add(key, value);
            }
            // Local function
            static TProperty FallbackAccessor(T instance, TProperty fallbackResult)
            {
                if (instance is null)
                {
                    // Unlike an extension method which would throw ArgumentNullException here, the light-up
                    // behavior needs to match behavior of the underlying property.
                    throw new NullReferenceException();
                }

                return(fallbackResult);
            }
            public static bool TryGetValue(
                TTextView textView,
                object key,
                [MaybeNullWhen(false)] out TProperty value)
            {
                Contract.ThrowIfTrue(textView.IsClosed);

                var properties = textView.Properties.GetOrCreateSingletonProperty(() => new AutoClosingViewProperty <TProperty, TTextView>(textView));

                return(properties.TryGetValue(key, out value));
            }
Beispiel #8
0
 public string GetValue(Property property)
 {
     using (GeneralContext database = new GeneralContext())
     {
         TProperty match = database.Properties.FirstOrDefault(x => x.Name.Equals(property.Name));
         if (match != null)
         {
             return(match.Value);
         }
     }
     throw new NotExistingException();
 }
Beispiel #9
0
        public static void GenerateAOTCollectionFunctions <TProperty, TContainer, TValue>()
            where TProperty : ICollectionProperty <TContainer, TValue>
        {
            TProperty     property      = default(TProperty);
            TContainer    container     = default(TContainer);
            TValue        value         = default(TValue);
            ChangeTracker changeTracker = default(ChangeTracker);
            var           getter        = new VisitCollectionElementCallback <TContainer>();

            PropertyVisitor propertyVisitor = new PropertyVisitor();

            propertyVisitor.TryVisitContainerWithAdapters(property, ref container, ref value, ref changeTracker);
            propertyVisitor.TryVisitCollectionWithAdapters(property, ref container, ref value, ref changeTracker);
            propertyVisitor.TryVisitValueWithAdapters(property, ref container, ref value, ref changeTracker);
            PropertyVisitorAdapterExtensions.TryVisitCollection(null, null, property, ref container, ref value, ref changeTracker);
            PropertyVisitorAdapterExtensions.TryVisitContainer(null, null, property, ref container, ref value, ref changeTracker);
            PropertyVisitorAdapterExtensions.TryVisitValue(null, null, property, ref container, ref value, ref changeTracker);

            var arrayProperty = new ArrayProperty <TContainer, TValue>();

            arrayProperty.GetPropertyAtIndex(ref container, 0, ref changeTracker, ref getter);
            var arrayCollectionElementProperty = new ArrayProperty <TContainer, TValue> .CollectionElementProperty();

            arrayCollectionElementProperty.GetValue(ref container);
            arrayCollectionElementProperty.SetValue(ref container, value);
            propertyVisitor.VisitProperty <ArrayProperty <TContainer, TValue> .CollectionElementProperty, TContainer, TValue>(arrayCollectionElementProperty, ref container, ref changeTracker);

            var listProperty = new ListProperty <TContainer, TValue>();

            listProperty.GetPropertyAtIndex(ref container, 0, ref changeTracker, ref getter);
            var listCollectionElementProperty = new ListProperty <TContainer, TValue> .CollectionElementProperty();

            listCollectionElementProperty.GetValue(ref container);
            listCollectionElementProperty.SetValue(ref container, value);
            propertyVisitor.VisitProperty <ListProperty <TContainer, TValue> .CollectionElementProperty, TContainer, TValue>(listCollectionElementProperty, ref container, ref changeTracker);

            Actions.GetCollectionCountGetter <TContainer> getCollectionCountGetter       = new Actions.GetCollectionCountGetter <TContainer>();
            Actions.GetCountFromActualTypeCallback        getCountFromActualTypeCallback = new Actions.GetCountFromActualTypeCallback();
            getCountFromActualTypeCallback.Invoke <TContainer>();
            getCountFromActualTypeCallback.Invoke <TValue>();
            Actions.GetCountAtPathGetter <TContainer> getCountAtPathGetter = new Actions.GetCountAtPathGetter <TContainer>();
            Actions.VisitAtPathCallback visitAtPathCallback = default;
            visitAtPathCallback.Invoke <TContainer>();
            visitAtPathCallback.Invoke <TValue>();
            Actions.SetCountCallback setCountCallback = default;
            setCountCallback.Invoke <TContainer>();
            setCountCallback.Invoke <TValue>();

            Actions.TryGetCount(ref container, new PropertyPath(), 0, ref changeTracker, out var count);
            Actions.TryGetCountImpl(ref container, new PropertyPath(), 0, ref changeTracker, out var otherCount);
            Actions.GetCount(ref container, new PropertyPath(), 0, ref changeTracker);
        }
        // ====================================================================
        // public 関数
        // ====================================================================

        // --------------------------------------------------------------------
        // データベースファイル生成(既存がある場合は作成しない)
        // --------------------------------------------------------------------
        public override void CreateDatabaseIfNeeded()
        {
            if (Properties != null && DbCommon.ValidPropertyExists(Properties))
            {
                TProperty property = DbCommon.Property(Properties);
                if (Common.CompareVersionString(property.AppVer, "Ver 1.18 α") >= 0)
                {
                    // 既存のデータベースがあり、キャッシュデータの互換性がある場合はクリアしない
                    return;
                }
            }
            CreateDatabase();
        }
Beispiel #11
0
 public void SetValue(Property property)
 {
     using (GeneralContext database = new GeneralContext())
     {
         TProperty dbProperty = database.Properties.FirstOrDefault(x => x.Name.Equals(property.Name));
         if (dbProperty == null)
         {
             dbProperty = new TProperty
             {
                 Name = property.Name
             };
             database.Properties.Add(dbProperty);
         }
         dbProperty.Value = property.Value;
         database.SaveChanges();
     }
 }
Beispiel #12
0
        public static unsafe void GenerateAOTFunctions <TProperty, TContainer, TValue>()
            where TProperty : IProperty <TContainer, TValue>
        {
            TProperty     property      = default(TProperty);
            TContainer    container     = default(TContainer);
            ChangeTracker changeTracker = default(ChangeTracker);

            UnsafeAppendBuffer.Reader *reader = null;
            var propertyReader = new PropertiesBinaryReader(reader, null);

            propertyReader.VisitProperty <TProperty, TContainer, TValue>(property, ref container, ref changeTracker);
            propertyReader.IsExcluded <TProperty, TContainer, TValue>(property, ref container);
            Properties.AOTFunctionGenerator.GenerateAOTContainerFunctions <DictionaryContainer <object, object> >();
            Properties.AOTFunctionGenerator.GenerateAOTContainerFunctions <PolymorphicTypeName>();
            Properties.AOTFunctionGenerator.GenerateAOTContainerFunctions <PolymorphicTypeContainer <TContainer> >();
            Properties.AOTFunctionGenerator.GenerateAOTContainerFunctions <PolymorphicTypeContainer <TValue> >();
        }
Beispiel #13
0
        public static T MergeProperties(T t, U u)
        {
            PropertyInfo[] TProperties = TType.GetProperties();
            PropertyInfo[] UProperties = UType.GetProperties();

            foreach (PropertyInfo TProperty in TProperties)
            {
                PropertyInfo UProperty =
                    UProperties.FirstOrDefault(x => x.Name == TProperty.Name && x.GetType() == TProperty.GetType());

                if (UProperty != null)
                {
                    TProperty.SetValue(t, UProperty.GetValue(u));
                }
            }

            return(t);
        }
Beispiel #14
0
            public void Execute(ArchetypeChunk chunk, int chunkIndex, int firstEntityIndex)
            {
                if (!chunk.DidChange(SpriteAnimationStateType, LastSystemVersion))
                {
                    return;
                }
                var states             = chunk.GetNativeArray(SpriteAnimationStateType);
                var propertyComponents = chunk.GetNativeArray(PropertyType);

                if (propertyComponents.Length > 0)
                {
                    ref var clipSet = ref ClipSetFromEntity[Filter.ClipSetEntity][Filter.ClipIndex].Value.Value;
                    for (var i = 0; i < propertyComponents.Length; ++i)
                    {
                        propertyComponents[i] = new TProperty {
                            Value = clipSet.GetValue(states[i].Time)
                        }
                    }
                    ;
                }
            }
 public void Add(object key, TProperty value)
 => _map[key] = value;
 public bool TryGetValue(object key, [MaybeNullWhen(false)] out TProperty value)
 => _map.TryGetValue(key, out value);
Beispiel #17
0
        private TMember readMember()
        {
            bool vStatic = false;
            bool vConst = false;
            bool vFinal = false;
            bool vReadonly = false;
            bool vAttribute = false;
            TType type = null;
            string name = "";
            TMember mem = null;
            var attrList = new TAttributeList();
            while (true)
            {
                switch (currentToken.token)
                {
                    case ECodeToken.brSmallBraceBegin:
                        attrList = readAttributes();
                        break;
                    case ECodeToken.kwStatic:
                        vStatic = true;
                        getNextToken();
                        break;
                    case ECodeToken.kwConst:
                        vConst = true;
                        getNextToken();
                        break;
                    case ECodeToken.kwAttribute:
                        vAttribute = true;
                        getNextToken();
                        break;
                    case ECodeToken.kwReadonly:
                        vReadonly = true;
                        getNextToken();
                        break;
                    //case ECodeToken.kwFinal:
                    //  vFinal = true;
                    //  break;
                    case ECodeToken.ltString:
                        type = readType();
                        name = currentToken.value;

                        getNextToken();
                        if (currentToken.token == ECodeToken.brBraceBegin)
                        {
                            mem = new TMethod(currentInterfaceType);
                            mem.name = name;
                            mem.resultType = type;
                            mem.attributes = attrList;
                            readParameters((TMethod)mem);
                            checkGotoEndOfStatement();
                        }
                        else
                        {
                            if (vAttribute)
                            {
                                mem = new TProperty(currentInterfaceType);
                                mem.name = name;
                                mem.resultType = type;
                                mem.attributes = attrList;
                                checkGotoEndOfStatement();
                                return mem;
                            }
                            else
                            {
                                mem = new TField(currentInterfaceType);
                                mem.name = name;
                                mem.resultType = type;
                                mem.attributes = attrList;
                                if (currentToken.token == ECodeToken.blEquals)
                                {
                                    getNextToken();
                                    string Value = currentToken.value;
                                    getNextToken();
                                    if (currentToken.token == ECodeToken.ltString)
                                    {
                                        Value += currentToken.value;
                                        if (Value.ToLower() == "0xffffffff")
                                        {
                                            Value = "0xFFFFFFF";
                                        }
                                    }
                                    ((TField)mem).value = Value;
                                }
                                return mem;
                            }
                        }
                        break;
                    default:
                        getNextToken();
                        break;
                }
                if (currentToken.token == ECodeToken.syEndOfCommand)
                {
                    break;
                }
            }
            return mem;
        }
 public IValidator GetValidator(ValidationContext <T> context, TProperty value)
 {
     return(_factory?.Invoke(context, value) ?? _innerValidator);
 }
Beispiel #19
0
        // --------------------------------------------------------------------
        // データベース中に有効なプロパティー情報が存在するか
        // --------------------------------------------------------------------
        public static Boolean ValidPropertyExists(DbSet <TProperty> properties)
        {
            TProperty property = Property(properties);

            return(property.AppId == YlConstants.APP_ID && property.AppVer.Contains(YlConstants.APP_GENERATION));
        }
 /// <summary>
 /// Sets the value of the property.
 /// </summary>
 /// <param name="container">The container of the <see cref="DependencyProperty"/>.</param>
 /// <param name="value">The value to set.</param>
 public override void SetValue(DependencyObjectContainer container, TProperty value) => _Property.SetValue(container, ref _ChangeCount, ref _ChangeHandler, ref _Expression, ref _BaseValue, ref _Value, value);
Beispiel #21
0
 public bool TryGetValue(object key, out TProperty value)
 => _map.TryGetValue(key, out value);