Exemplo n.º 1
0
        public TypeDescriptor(Authentication authentication, IType type, DescriptorTypes descriptorTypes, object owner)
            : base(authentication, type, descriptorTypes)
        {
            this.type  = type;
            this.owner = owner ?? this;
            this.type.Dispatcher.VerifyAccess();
            this.typeInfo  = type.TypeInfo;
            this.typeState = type.TypeState;
            if (this.type.TypeInfo.IsFlag == true)
            {
                this.typeAttribute |= TypeAttribute.IsFlag;
            }
            this.lockInfo           = type.LockInfo;
            this.accessInfo         = type.AccessInfo;
            this.accessType         = type.GetAccessType(this.authentication);
            this.templateDescriptor = new TypeTemplateDescriptor(authentication, type.Template, descriptorTypes);

            if (this.descriptorTypes.HasFlag(DescriptorTypes.IsSubscriptable) == true)
            {
                this.type.Deleted          += Type_Deleted;
                this.type.LockChanged      += Type_LockChanged;
                this.type.AccessChanged    += Type_AccessChanged;
                this.type.TypeInfoChanged  += Type_TypeInfoChanged;
                this.type.TypeStateChanged += Type_TypeStateChanged;
            }
        }
Exemplo n.º 2
0
 public void Start(TypeState typeState, DateTime dateTime)
 {
     OnTypeStart(new TyInfo(typeState), dateTime);
     TypeData.Instance.TypeState = TypeState.Typing;
     TypeData.Instance.StartTime = dateTime;
     TypeData.Instance.GetTypeAchievement().AchievementDic["字数"].TypeData.关连值 = TypeData.Instance.TypeText.Length;
 }
Exemplo n.º 3
0
        protected override TypeAttributeHandlerResult TryMap(AttributeMap item, TypeState s, TypeArgsValue a, RuntimeTypeModel model)
        {
            if (a.HasFamily(MetaType.AttributeFamily.Aqla) && CheckAqlaModelId(item, model))
            {
                var attr = item.GetRuntimeAttribute <SerializableTypeAttribute>(model);
                s.SettingsValue = attr.TypeSettings;

                s.ImplicitOnlyWriteable = attr.ImplicitOnlyWriteable;
                s.DataMemberOffset      = attr.DataMemberOffset;
                if (attr.InferTagFromNameHasValue)
                {
                    s.InferTagByName = attr.InferTagFromName;
                }
                s.ImplicitFields = attr.ImplicitFields;
                if (attr.ImplicitFirstTag != 0)
                {
                    s.ImplicitFirstTag = attr.ImplicitFirstTag;
                }

                if (s.ImplicitFields != ImplicitFieldsMode.None)
                {
                    s.ImplicitAqla = true;
                }

                return(TypeAttributeHandlerResult.Done);
            }
            return(TypeAttributeHandlerResult.Continue);
        }
Exemplo n.º 4
0
 private void Change(TypeState typeState)
 {
     foreach (var proxyMethod in typeState.ProxyMethods)
     {
         ChangeProxyMethod((BuildType)typeState.Type, proxyMethod);
     }
 }
Exemplo n.º 5
0
        /// <summary>
        /// Gets the specified type.
        /// </summary>
        /// <param name="typeReference">The type reference.</param>
        /// <returns></returns>
        Type GetType(TypeReference typeReference, TypeState state)
        {
            Type type;

            if (!types.TryGetValue(typeReference, out type))
            {
                type = BuildType(typeReference);
            }

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

            if ((state >= TypeState.StackComplete && type.StackType == StackValueType.Value) ||
                state >= TypeState.TypeComplete)
            {
                CompleteType(type);
            }

            if (state >= TypeState.VTableEmitted)
            {
                GetClass(type);
            }

            return(type);
        }
Exemplo n.º 6
0
        public ICreationContext MoveTo <TNewState>()
            where TNewState : IStateDefinition <TSignal>
        {
            TypeState newTypeState = typeof(TNewState);

            if (!CreationContext.States.TryGetValue(newTypeState, out var newState))
            {
                newState = CreationContext.Agent.CreateState <TNewState>();

                CreationContext.States.Add(newTypeState, newState);
            }

            State.Transitions = (State.Transitions ?? new Transition <TypeState, TypeState> [0])
                                .Concat(new[]
            {
                new Transition <TypeState, TypeState>
                {
                    Input          = Input,
                    ResultantState = newTypeState,
                    Precondition   = Precondition
                }
            }).ToArray();

            return(CreationContext);
        }
        public TypeAttributeHandlerResult TryMap(AttributeMap item, TypeState s)
        {
            RuntimeTypeModel model = s.Model;
            object           tmp;
            int tag = 0;

            if (item.TryGet("tag", out tmp))
            {
                tag = (int)tmp;
            }
            Type knownType = null;

            try
            {
                if (item.TryGet("knownTypeName", out tmp))
                {
                    knownType = model.GetType((string)tmp, Helpers.GetAssembly(s.Type));
                }
                else if (item.TryGet("knownType", out tmp))
                {
                    knownType = (Type)tmp;
                }
            }
            catch (Exception ex)
            {
                throw new InvalidOperationException("Unable to resolve sub-type of: " + s.Type.FullName, ex);
            }
            if (knownType == null)
            {
                throw new InvalidOperationException("Unable to resolve sub-type of: " + s.Type.FullName);
            }
            s.DerivedTypes.Add(new DerivedTypeCandidate(tag, knownType));
            return(TypeAttributeHandlerResult.Done);
        }
Exemplo n.º 8
0
 protected override TypeAttributeHandlerResult TryMap(AttributeMap item, TypeState s, TypeArgsValue a, RuntimeTypeModel model)
 {
     if (a.CanUse(AttributeType.Aqla) && CheckAqlaModelId(item, model))
     {
         s.PartialMembers.Add(item);
     }
     return(TypeAttributeHandlerResult.Done);
 }
 protected override TypeAttributeHandlerResult TryMap(AttributeMap item, TypeState s, TypeArgsValue a, RuntimeTypeModel model)
 {
     if (a.CanUse(AttributeType.Aqla) && CheckAqlaModelId(item, model))
     {
         return(_derivedTypeStrategy.TryMap(item, s));
     }
     return(TypeAttributeHandlerResult.Continue);
 }
Exemplo n.º 10
0
        public static State <TypeState, TypeState> CreateState <TState>()
            where TState : IStateDefinition
        {
            var       type      = typeof(TState);
            TypeState typeState = type;

            var state = new State <TypeState, TypeState>
            {
                Value = typeState
            };

            var description = typeof(TState).GetCustomAttribute <DescriptionAttribute>(false)?.Description;

            state.Description = description;

            if (typeState.IsActionable() || typeState.IsPrecondition())
            {
                if (typeState.IsActionable())
                {
                    string actionDescription = null;

                    var naturalActionInterface = type.GetInterfaces()
                                                 .FirstOrDefault(i => i.IsGenericType &&
                                                                 i.GetGenericTypeDefinition() ==
                                                                 typeof(INaturalAction <>));

                    if (naturalActionInterface != null)
                    {
                        var invokeMethodInfo = type.GetMethod(nameof(INaturalAction <object> .InvokeAsync),
                                                              new[]
                        {
                            typeof(ConnectorContext),
                            naturalActionInterface.GenericTypeArguments[0],
                            typeof(CancellationToken)
                        });

                        actionDescription = invokeMethodInfo?.GetCustomAttribute <DescriptionAttribute>()?.Description;
                    }

                    state.Action = new REstate.Schematics.Action <TypeState>
                    {
                        ConnectorKey = typeState.GetConnectorKey(),
                        Description  = actionDescription
                    };
                }

                if (typeState.IsPrecondition())
                {
                    state.Precondition = new Precondition
                    {
                        ConnectorKey = typeState.GetConnectorKey()
                    }
                }
                ;
            }

            return(state);
        }
Exemplo n.º 11
0
        public static ResultState <TItem> GetResultState(ISchemaStore schemas, TableIdentity heading)
        {
            return((ResultState <TItem>)factoryMap.GetOrAdd(heading, _ =>
            {
                TypeState state = GetTypeState(schemas);

                return new ResultCompiler(state).Compile <TItem>(heading);
            }));
        }
Exemplo n.º 12
0
 public void ToggleUnit()
 {
     if (!UIToggle.current.value)
         return;
     _stateCont.GetController<SelectController>().Deselect();
     _stateCont.GetController<SelectController>().ControllerSelectType = SelectController.SelectState.Mob;
     _stateCont.ControllerState = ControllerState.Selection;
     _typeState = TypeState.Mob;
 }
Exemplo n.º 13
0
        internal void StartsIn <TState>()
            where TState : IStateDefinition
        {
            TypeState typeState = typeof(TState);

            var state = Agent.CreateState <TState>();

            States.Add(typeState, state);

            _schematic.InitialState = typeState;
        }
Exemplo n.º 14
0
        private void txtType_TextChanged(object sender, TextChangedEventArgs e)
        {
            if (_state == TypeState.Restarted)
            {
                _state = TypeState.Playing;
                _stopWatch.Restart();
            }

            ColorWord();
            UpdateStats();
        }
 protected override TypeAttributeHandlerResult TryMap(AttributeMap item, TypeState s, TypeArgsValue a, RuntimeTypeModel model)
 {
     // we check CanUse everywhere but not family because GetContractFamily is based on CanUse
     // and CanUse is based on the settings
     // except is for SerializableAttribute which family is not returned if other families are present
     if (a.HasFamily(MetaType.AttributeFamily.SystemSerializable))
     {
         s.ImplicitFields = ImplicitFieldsMode.AllFields;
         s.ImplicitAqla   = true;
     }
     return(TypeAttributeHandlerResult.Done);
 }
Exemplo n.º 16
0
        public GrpcStateEngine(
            IStateMachineService stateMachineService,
            IEnumerable <IEventListener> listeners)
        {
            _stateMachineService = stateMachineService
                                   .WithHeaders(new Metadata
            {
                { "Status-Type", TypeState.FromType(typeof(TState)).GetFullName() },
                { "Input-Type", TypeState.FromType(typeof(TInput)).GetFullName() }
            });

            _listeners = listeners.ToList();
        }
Exemplo n.º 17
0
            internal TypeState GetType(IType type)
            {
                type = type.DeclaringType;

                TypeState state;

                if (!_types.TryGetValue(type, out state))
                {
                    state = new TypeState(type);
                    _types.Add(type, state);
                }

                return(state);
            }
        TypeState CreateTypeState(DmdType type, DbgLanguage language)
        {
            var info = GetDisplayParts(type);

            if (info.nameParts.Length == 0 && info.valueParts.Length == 0 && info.typeParts.Length == 0)
            {
                return(TypeState.Empty);
            }

            var context = language.CreateContext(evalInfo.Runtime, null);
            var state   = new TypeState(context, info.nameParts, info.valueParts, info.typeParts);

            context.Runtime.CloseOnExit(state);
            return(state);
        }
Exemplo n.º 19
0
        TypeState CreateTypeState(DmdType type, DbgLanguage language)
        {
            var parts = GetDisplayParts(type) ?? Array.Empty <DisplayPart>();

            if (parts.Length == 0)
            {
                return(TypeState.Empty);
            }

            var context = language.CreateContext(frame.Runtime, null, cancellationToken: cancellationToken);
            var state   = new TypeState(context, parts);

            context.Runtime.CloseOnExit(state);
            return(state);
        }
Exemplo n.º 20
0
 protected override TypeAttributeHandlerResult TryMap(AttributeMap item, TypeState s, TypeArgsValue a, RuntimeTypeModel model)
 {
     if (a.HasFamily(MetaType.AttributeFamily.DataContractSerialier))
     {
         var    main = s.SettingsValue;
         object tmp;
         if (main.Name == null && item.TryGet("Name", out tmp))
         {
             main.Name = (string)tmp;
         }
         s.SettingsValue = main;
         return(TypeAttributeHandlerResult.Done);
     }
     return(TypeAttributeHandlerResult.Continue);
 }
 public TypeTreeViewItemViewModel(CremaDataType dataType, ISelector selector)
 {
     this.Target   = dataType;
     this.dataType = dataType;
     this.dataType.ExtendedProperties[selector] = this;
     this.selector                  = selector;
     this.typeInfo                  = dataType.TypeInfo;
     this.typeAttribute             = TypeAttribute.None;
     this.typeState                 = TypeState.None;
     this.renameCommand             = new DelegateCommand(async() => await this.RenameAsync());
     this.deleteCommand             = new DelegateCommand(async() => await this.DeleteAsync());
     this.viewCommand               = new DelegateCommand(async() => await this.ViewContentAsync());
     this.dataType.PropertyChanged += DataType_PropertyChanged;
     this.Items.CollectionChanged  += Items_CollectionChanged;
 }
        bool Format(DbgDotNetValue value, TypeState typeState, DisplayPart[] displayParts)
        {
            if (displayParts.Length == 0)
            {
                return(false);
            }

            var evaluator = evalInfo.Context.GetDebuggerDisplayAttributeEvaluator();

            foreach (var part in displayParts)
            {
                if ((part.Flags & DisplayPartFlags.EvaluateText) == 0)
                {
                    output.Write(DbgTextColor.DebuggerDisplayAttributeEval, part.Text);
                }
                else
                {
                    var eeState = typeState.GetExpressionEvaluatorState(evalInfo.Context.Language.ExpressionEvaluator, part.Text);
                    DbgDotNetEvalResult evalRes = default;
                    try {
                        var evalInfo2 = new DbgEvaluationInfo(typeState.TypeContext !, evalInfo.Frame, evalInfo.CancellationToken);
                        evalRes = evaluator.Evaluate(evalInfo2, value, part.Text, DbgEvaluationOptions.Expression, eeState);
                        if (evalRes.Error is not null)
                        {
                            output.Write(DbgTextColor.Error, "<<<");
                            output.Write(DbgTextColor.Error, evalRes.Error);
                            output.Write(DbgTextColor.Error, ">>>");
                        }
                        else
                        {
                            // Prevent recursive calls
                            var options = this.options | DbgValueFormatterOptions.NoDebuggerDisplay;
                            options &= ~DbgValueFormatterOptions.NoStringQuotes;
                            options  = PredefinedFormatSpecifiers.GetValueFormatterOptions(evalRes.FormatSpecifiers, options);
                            languageFormatter.FormatValue(evalInfo, output, evalRes.Value !, options, cultureInfo);
                        }
                    }
                    finally {
                        if (evalRes.Value != value)
                        {
                            evalRes.Value?.Dispose();
                        }
                    }
                }
            }

            return(true);
        }
Exemplo n.º 23
0
        public IForStateContext <TState> For <TState>()
            where TState : IStateDefinition
        {
            TypeState typeState = typeof(TState);

            if (!States.TryGetValue(typeState, out var state))
            {
                state = Agent.CreateState <TState>();

                States.Add(typeState, state);
            }

            return(new ForStateContext <TState> {
                CreationContext = this, State = state
            });
        }
Exemplo n.º 24
0
            public IWhenContext <TState, TSignal> When <TPrecondition>()
                where TPrecondition : INaturalPrecondition <TSignal>
            {
                TypeState preconditionTypeState = typeof(TPrecondition);

                return(new WhenContext <TState, TSignal>
                {
                    CreationContext = CreationContext,
                    State = State,
                    Input = Input,
                    Precondition = new Precondition
                    {
                        ConnectorKey = preconditionTypeState.GetConnectorKey()
                    }
                });
            }
Exemplo n.º 25
0
        /// <summary>
        /// Gets the specified type.
        /// </summary>
        /// <param name="typeReference">The type reference.</param>
        /// <returns></returns>
        Type GetType(TypeReference typeReference, TypeState state)
        {
            Type type;
            if (!types.TryGetValue(typeReference, out type))
                type = BuildType(typeReference);

            if (type == null)
                return null;

            if ((state >= TypeState.StackComplete && type.StackType == StackValueType.Value)
                || state >= TypeState.TypeComplete)
                CompleteType(type);

            if (state >= TypeState.VTableEmitted)
                GetClass(type);

            return type;
        }
Exemplo n.º 26
0
    public IConsume(IConsume item)
    {
        RemoveAllState = item.RemoveAllState;

        AddState    = item.AddState;
        RemoveState = item.RemoveState;
        AddTrait    = item.AddTrait;
        RemoveTrait = item.RemoveTrait;

        Stats   = item.Stats;
        Recover = item.Recover;

        Name        = item.Name;
        Icon        = item.Icon;
        Category    = item.Category;
        Description = item.Description;
        Value       = item.Value;
        Stack       = item.Stack;
    }
Exemplo n.º 27
0
        public IWhenContext <TState, TSignal> When <TPrecondition>()
            where TPrecondition : INaturalPrecondition <TSignal>
        {
            TypeState preconditionTypeState = typeof(TPrecondition);

            CreationContext.Agent.Configuration.Register(registrar =>
                                                         registrar.RegisterConnector(preconditionTypeState)
                                                         .WithConfiguration(new ConnectorConfiguration(preconditionTypeState.GetConnectorKey())));

            return(new WhenContext <TState, TSignal>
            {
                CreationContext = CreationContext,
                State = State,
                Input = Input,
                Precondition = new Precondition
                {
                    ConnectorKey = preconditionTypeState.GetConnectorKey()
                }
            });
        }
    // void Start()
    // {
    //     // game_variables.Instance.IsSave;
    //     // _isSave = PlayerPrefs.GetInt("save", 0) == 0 ? false : true;
    // }
    public void Save(string id, base_state state, TypeState type)
    {
        //
        FileStream file = new FileStream(Application.persistentDataPath + "/" + type.ToString() + "/" + id + ".dot", FileMode.OpenOrCreate);

        try
        {
            BinaryFormatter formatter = new BinaryFormatter();
            formatter.Serialize(file, state);
        }
        catch (SerializationException e)
        {
            feedback_toaster.Instance.RegisterMessage(gameObject.name + " : " + e.Message, game_variables.Instance.ColorDefault);
        }
        finally
        {
            file.Close();
            game_variables.Instance.Save();
        }
    }
Exemplo n.º 29
0
    public IThrow(IThrow item)
    {
        Battle           = item.Battle;
        Piercing         = item.Piercing;
        Piercing_Precent = item.Piercing_Precent;
        AttackElement    = item.AttackElement;
        AtkState         = item.AtkState;
        RemoveState      = item.RemoveState;
        RemoveAllState   = item.RemoveAllState;
        MissileFlight    = item.MissileFlight;
        AreaRange        = item.AreaRange;
        AreaAttack       = item.AreaAttack;
        IgnoreObstacle   = item.IgnoreObstacle;

        Name        = item.Name;
        Icon        = item.Icon;
        Category    = item.Category;
        Description = item.Description;
        Value       = item.Value;
        Stack       = item.Stack;
    }
Exemplo n.º 30
0
        private static TypeState GetTypeState(ISchemaStore schemas)
        {
            if (typeState != null)
            {
                return(typeState);
            }

            lock (typeLock)
            {
                if (typeState != null)
                {
                    return(typeState);
                }

                Type listType = typeof(IList <>).MakeGenericType(typeof(TItem));

                ISchema schema = schemas.GetSchema(listType);

                return(typeState = new TypeState(schema));
            }
        }
Exemplo n.º 31
0
        /// <summary>
        /// Registers an <see cref="IAction{TState,TInput}"/> or <see cref="IPrecondition{TState,TInput}"/>.
        /// </summary>
        /// <param name="registrar"></param>
        /// <param name="connectorType">
        /// The unbound generic type of the connector aka generic type definition. e.g.
        /// <c>typeof(LoggingAction&lt;,&gt;)</c>
        /// </param>
        /// <param name="registrationName">
        /// The name to register the type as in the <see cref="IComponentContainer"/>.
        /// <para />
        /// Registration names should ALWAYS be unique, overriding is NOT supported for safety/clarity reasons.
        /// <para />
        /// The default is the assembly qualified name of the type.
        /// </param>
        /// <returns>A <see cref="IConnectorRegistration"/> that allows the caller to
        /// register an <see cref="IConnectorConfiguration"/> that includes an Identifier
        /// that can be resolved using a <see cref="Schematics.ConnectorKey"/> in a <see cref="Schematics.ISchematic{TState,TInput}"/>.
        /// </returns>
        /// <remarks>
        /// Connectors are available for use by a <see cref="IStateMachine{TState,TInput}"/> when a <see cref="Schematics.ConnectorKey"/>
        /// in its <see cref="Schematics.ISchematic{TState,TInput}"/> matches a <see cref="IConnectorConfiguration"/>,
        /// that has been registered in a <see cref="IConnectorRegistration"/>'s <c>WithConfiguration</c> method.
        /// </remarks>
        public static IConnectorRegistration RegisterConnector(
            this IRegistrar registrar,
            Type connectorType,
            string registrationName = null)
        {
            var registrationKey = registrationName ?? TypeState.FromType(connectorType).GetConnectorKey();

            var interfaces = connectorType
                             .GetInterfaces()
                             .Where(type => type.IsConstructedGenericType)
                             .Select(type => type.GetGenericTypeDefinition())
                             .ToList();

            var registered = false;

            if (interfaces.Any(type => type == typeof(IAction <,>)))
            {
                registrar.Register(typeof(IAction <,>), connectorType, registrationKey);

                registered = true;
            }

            if (interfaces.Any(type => type == typeof(IPrecondition <,>)))
            {
                registrar.Register(typeof(IPrecondition <,>), connectorType, registrationKey);

                registered = true;
            }

            if (!registered)
            {
                throw new ArgumentException(
                          message: "Type must be either IAction<,> or IPrecondition<,> to be registered.",
                          paramName: nameof(connectorType));
            }

            return(new ConnectorRegistration(registrar, connectorType));
        }
Exemplo n.º 32
0
        private void Restart()
        {
            txtType.IsReadOnly = false;
            _state             = TypeState.Restarted;
            _wordIndex         = 0;

            var words = _text.Split(' ');

            _words.Clear();
            var position = 0;

            for (int i = 0; i < words.Length; i++)
            {
                _words.Add(new Word(words[i], position));
                position += words[i].Length + 1;
            }

            txtText.Text = _text;
            txtType.Text = string.Empty;
            txtType.Focus();

            ColorWord();
        }
Exemplo n.º 33
0
 public State(Program handle,TypeState type, int timerIntervalMilliseconds=100)
 {
     _MainHandle = handle;
     _typeState = type;
     _timerIntervalMilliseconds = timerIntervalMilliseconds;
 }
Exemplo n.º 34
0
 public State(TypeState type)
 {
     _typeState = type;
 }