Example #1
0
        /// <summary>
        /// Try to get a stored object.
        /// </summary>
        /// <typeparam name="T">Type of stored item.</typeparam>
        /// <param name="model">Key model.</param>
        /// <param name="value">Stored value.</param>
        /// <returns>Stored item as type.</returns>
        public bool TryGet <T>(KeyModel model, out T value)
        {
            // Set namespace of model
            model.Namespace = Namespace;

            // Call actual Cache Service
#if DEBUG
            var step = MiniProfiler.Current.Step(string.Format("CacheService: TryGet {0} {1} {2}", model.CacheType, model.Key, model.GetValuesKey()));

            try
            {
#endif
            return(CacheService.TryGet(model, out value));

#if DEBUG
        }
        finally
        {
            if (step != null)
            {
                step.Dispose();
            }
        }
#endif
        }
Example #2
0
        /// <summary>
        ///  Set an item into recent history storage.
        /// </summary>
        /// <param name="historyType">The type of history.</param>
        /// <param name="values">The values necessary for loading the object as a dictionary of key value pairs.</param>
        /// <param name="displayName">The object's display name.</param>
        /// <exception cref="ArgumentNullException">Thrown if <paramref name="values"/> is <c>null</c> or empty.</exception>
        /// <exception cref="ArgumentNullException">Thrown if <paramref name="displayName"/> is <c>null</c> or empty.</exception>
        public void Set(HistoryType historyType, IDictionary <string, object> values, string displayName)
        {
            if (values == null || !values.Any())
            {
                throw new ArgumentNullException("values");
            }

            if (string.IsNullOrEmpty(displayName))
            {
                throw new ArgumentNullException("displayName");
            }

            var key = new KeyModel("History").Add(historyType);

            values.ForEach(v => key.Add(v.Key.ToLower()).Add(v.Value));

            var model = new HistoryModel
            {
                HistoryType  = historyType,
                Values       = values,
                DisplayName  = displayName,
                DateAccessed = UserService.DateTime,
                IsPinned     = false,
                Username     = UserService.Username
            };

            UserService.Session.Set(key, model);
        }
Example #3
0
 public void CloseConnect()
 {
     DB.Dispose();
     Connected = DB.Pool.Get().Client.Connected;
     DataBase  = new DataModel();
     Keys      = new KeyModel();
 }
        /// <summary>
        /// Prepares the step by first checking if the current step data is valid and on a postback; otherwise, attempts to load valid saved data for the step.
        /// </summary>
        /// <typeparam name="T">The view model type.</typeparam>
        /// <param name="model">The current step data.</param>
        /// <param name="key">The key model used for retrieving the saved step data from the users session.</param>
        /// <param name="valid">Whether the step data is valid.</param>
        /// <param name="forceLoadFromSession">Force loading model from session.</param>
        /// <returns><c>true</c> if the step is valid; otherwise, <c>false</c>.</returns>
        protected T PrepareStep <T>(T model, KeyModel key, out bool valid, bool forceLoadFromSession)
        {
            valid = false;

            // If the model submitted for this step is already valid, return it as is
            if (!forceLoadFromSession && Request.HttpMethod == "POST" && ValidateModel(model).IsValid)
            {
                valid = true;

                return(model);
            }

            T m;

            // Get data saved for current step and use if valid
            if (UserService.Session.TryGet(key, out m) && ValidateModel(m).IsValid)
            {
                // Overwrite model with saved data
                model = m;

                valid = true;
            }

            return(model);
        }
 /// <summary>
 /// Try to get a stored object.
 /// </summary>
 /// <typeparam name="T">Type of stored item.</typeparam>
 /// <param name="model">Key model.</param>
 /// <param name="value">Stored value.</param>
 /// <returns>Stored item as type.</returns>
 public override bool TryGet <T>(KeyModel model, out T value)
 {
     using (MiniProfiler.Current.Step(string.Format("SessionService: TryGet {0}", model.Key)))
     {
         return(base.TryGet(model, out value));
     }
 }
 /// <summary>
 /// Checks if the item is stored in the session.
 /// </summary>
 /// <param name="model">Key model.</param>
 /// <returns><c>true</c> if the item is stored in the session; otherwise, <c>false</c>.</returns>
 public override bool Contains(KeyModel model)
 {
     using (MiniProfiler.Current.Step(string.Format("SessionService: Contains {0}", model.Key)))
     {
         return(base.Contains(model));
     }
 }
 /// <summary>
 /// Remove an item from the session.
 /// </summary>
 /// <param name="model">Key model.</param>
 public override void Remove(KeyModel model)
 {
     using (MiniProfiler.Current.Step(string.Format("SessionService: Remove {0}", model.Key)))
     {
         base.Remove(model);
     }
 }
        /// <summary>
        /// Store referring Uri in the users session if its route is different to current action. Used for returning the user to the previous action they were on when exiting a workflow.
        /// </summary>
        /// <param name="filterContext">The filter context.</param>
        public override void OnActionExecuting(ActionExecutingContext filterContext)
        {
            base.OnActionExecuting(filterContext);

            var routeData = filterContext.HttpContext.Request.UrlReferrer.ToRouteData();

            if (routeData != null)
            {
                // Referrer route details
                var referrerArea       = routeData.GetArea();
                var referrerController = routeData.GetController();
                var referrerAction     = routeData.GetAction();

                // Current route details
                var currentArea       = filterContext.RouteData.GetArea();
                var currentController = filterContext.RouteData.GetController();
                var currentAction     = filterContext.RouteData.GetAction();

                // Update the stored UrlReferrer if any of the action, controller or area route values are different
                if (string.Compare(referrerAction, currentAction, StringComparison.InvariantCultureIgnoreCase) != 0 ||
                    string.Compare(referrerController, currentController, StringComparison.InvariantCultureIgnoreCase) != 0 ||
                    string.Compare(referrerArea, currentArea, StringComparison.InvariantCultureIgnoreCase) != 0)
                {
                    // Update key with current action details
                    var keyModel = new KeyModel(SessionKey).Add(currentArea).Add(currentController).Add(currentAction);

                    UserService.Session.Set(keyModel, filterContext.HttpContext.Request.UrlReferrer);
                }
            }
        }
Example #9
0
        private static KeyModel BuildRoot()
        {
            var root = new KeyModel()
            {
                Name = "Server"
            };

            root.Keys = new List <KeyModel>();
            root.Keys.Add(new KeyModel()
            {
                Name = Microsoft.Win32.Registry.ClassesRoot.Name
            });
            root.Keys.Add(new KeyModel()
            {
                Name = Microsoft.Win32.Registry.CurrentUser.Name
            });
            root.Keys.Add(new KeyModel()
            {
                Name = Microsoft.Win32.Registry.LocalMachine.Name
            });
            root.Keys.Add(new KeyModel()
            {
                Name = Microsoft.Win32.Registry.Users.Name
            });
            root.Keys.Add(new KeyModel()
            {
                Name = Microsoft.Win32.Registry.CurrentConfig.Name
            });
            return(root);
        }
Example #10
0
        public void KeyModelConstructorTest()
        {
            const string key    = "Key";
            var          target = new KeyModel(key);

            Assert.IsNotNull(target);
        }
Example #11
0
        /// <summary>
        /// Returns the List of the property types that match the specified criteria.
        /// </summary>
        /// <param name="startCodeType">The start code.</param>
        /// <param name="startCode">The start property code.</param>
        /// <param name="listType">Indicates whether to use current codes only (default is true).</param>
        /// <param name="exactLookup">Exact lookup.</param>
        /// <param name="maxRows">Maximum number of rows to return. Default 0 indicates unlimited.</param>
        /// <returns>The list of property types.</returns>
        public IList <PropertyModel> GetPropertyTypeList(string startCode, string startProperty, char listType, bool exact = false, int max = 0)
        {
            var key = new KeyModel(CacheType.Global, "PropertyTypeList").Add(startCode).Add(startProperty).Add(listType).Add(exact).Add(max);

            IList <PropertyModel> data;

            if (!CacheService.TryGet(key, out data))
            {
                // Retrieve all Adw property data for the specified code type
                var sqlParameters = new List <SqlParameter>();

                sqlParameters.Add(new SqlParameter {
                    ParameterName = "@return_value", SqlDbType = SqlDbType.Int, Direction = ParameterDirection.ReturnValue
                });
                sqlParameters.Add(new SqlParameter {
                    ParameterName = "@CodeType", SqlDbType = SqlDbType.VarChar, Value = startCode
                });
                sqlParameters.Add(new SqlParameter {
                    ParameterName = "@PropertyType", SqlDbType = SqlDbType.VarChar, Value = startProperty
                });
                if (listType != null && listType != '\0' && listType != 'A')
                {
                    sqlParameters.Add(new SqlParameter {
                        ParameterName = "@ListType", SqlDbType = System.Data.SqlDbType.Char, Value = listType
                    });
                }
                sqlParameters.Add(new SqlParameter {
                    ParameterName = "@ExactLookup", SqlDbType = SqlDbType.Char, Value = exact ? 'y' : 'n'
                });
                sqlParameters.Add(new SqlParameter {
                    ParameterName = "@MaxRows", SqlDbType = SqlDbType.Int, Value = max
                });
                sqlParameters.Add(new SqlParameter {
                    ParameterName = "@Current_Date", SqlDbType = SqlDbType.DateTime, Value = UserService.DateTime
                });

                data = SqlService.Execute <PropertyModel>(ConnectionName, "up_ListPropertyType", sqlParameters, rdr =>
                {
                    var property          = new PropertyModel();
                    property.PropertyType = rdr[0].ToString();
                    property.CodeType     = rdr[1].ToString();
                    property.Code         = rdr[2].ToString();
                    property.StartDate    = (DateTime)rdr[3];
                    if (!rdr.IsDBNull(4))
                    {
                        property.EndDate = (DateTime)rdr[4];
                    }
                    property.Value = rdr[5].ToString();
                    return(property);
                }).ToList();

                if (data.Any())
                {
                    // Successful so add all Adw property data for the specified code type to the cache
                    CacheService.Set(key, data);
                }
            }

            return(data);
        }
Example #12
0
        public KeyIcon SetIcon(KeyModel model, KeyIcon icon)
        {
            string hash = CreateMD5(JsonSerializer.Serialize(model));

            _cache[hash] = icon;
            return(icon);
        }
Example #13
0
        public void PadKey_PaddingLengthEqualsKeyLengthReturnsUnmodifiedCuts()
        {
            KeyModel input = new KeyModel()
            {
                Cuts = "123456"
            };

            List <int?> expected = new List <int?> {
                1, 2, 3, 4, 5, 6
            };

            List <int?> output = PinningModelBase.PadKey(input, 6);

            if (output.Count != expected.Count)
            {
                Assert.Fail("Output has wrong length.");
            }

            for (int index = 0; index < output.Count; index++)
            {
                if (output[index] != expected[index])
                {
                    Assert.Fail($"Output has wrong value at index {index}");
                }
            }
        }
Example #14
0
 public HttpCacheService()
 {
     keysInUseKey = new KeyModel("KeysInUse")
     {
         Namespace = GetType().Namespace
     };
 }
Example #15
0
        public async Task <KeyModel> Put(string id, [FromBody] KeyModel model)
        {
            model.Id = id;
            var keyModel = await _manager.Update(ApiKey, model);

            return(keyModel);
        }
Example #16
0
        public void SaveContext(string widgetContext)
        {
            var    key    = new KeyModel(CacheType.User, widgetContext);
            string layout = DataContext + "," + string.Join(",", OpenWidgetNames);

            // save to db
            var sqlParameters = new List <SqlParameter>();

            sqlParameters.Add(new SqlParameter {
                ParameterName = "@return_value", SqlDbType = SqlDbType.Int, Direction = ParameterDirection.ReturnValue
            });
            sqlParameters.Add(new SqlParameter {
                ParameterName = "@UserID", SqlDbType = SqlDbType.VarChar, Value = UserService.Username
            });
            sqlParameters.Add(new SqlParameter {
                ParameterName = "@WidgetContext", SqlDbType = SqlDbType.VarChar, Value = widgetContext
            });
            sqlParameters.Add(new SqlParameter {
                ParameterName = "@WidgetLayout", SqlDbType = SqlDbType.VarChar, Value = layout
            });
            SqlService.ExecuteNonQuery(connectionName, "DashboardSetLayout", sqlParameters);

            // Set cache
            CacheService.Set <string>(key, layout);
        }
Example #17
0
        public void LoadFromContext(string widgetContext)
        {
            string context;
            var    key = new KeyModel(CacheType.User, widgetContext);

            if (!CacheService.TryGet <string>(key, out context))
            {
                // load from db
                var sqlParameters = new List <SqlParameter>();
                sqlParameters.Add(new SqlParameter {
                    ParameterName = "@return_value", SqlDbType = SqlDbType.Int, Direction = ParameterDirection.ReturnValue
                });
                sqlParameters.Add(new SqlParameter {
                    ParameterName = "@UserID", SqlDbType = SqlDbType.VarChar, Value = UserService.Username
                });
                sqlParameters.Add(new SqlParameter {
                    ParameterName = "@WidgetContext", SqlDbType = SqlDbType.VarChar, Value = widgetContext
                });
                IEnumerable <string> data = SqlService.Execute <string>(connectionName, "DashboardGet", sqlParameters,
                                                                        reader =>
                {
                    return(reader[2] as string);
                }
                                                                        );

                context = data.Any() ? data.First() : ",";

                // Set cache
                CacheService.Set <string>(key, context);
            }

            OpenWidgetNames = context.Split(',').ToList();
            DataContext     = OpenWidgetNames[0];
            OpenWidgetNames.RemoveAt(0);
        }
Example #18
0
        public void PadKey_EndStoppedRightPadsLeft()
        {
            KeyModel input = new KeyModel()
            {
                Cuts = "123456"
            };

            List <int?> expected = new List <int?> {
                null, null, null, 1, 2, 3, 4, 5, 6
            };

            List <int?> output = PinningModelBase.PadKey(input, 9, false);

            if (output.Count != expected.Count)
            {
                Assert.Fail("Output has wrong length.");
            }

            for (int index = 0; index < output.Count; index++)
            {
                if (output[index] != expected[index])
                {
                    Assert.Fail($"Output has wrong value at index {index}");
                }
            }
        }
Example #19
0
 private void DefaultNamespace(ref KeyModel model)
 {
     if (model != null && string.IsNullOrEmpty(model.Namespace))
     {
         model.Namespace = GetType().Namespace;
     }
 }
        public ResponseModel ShareSessionKeys([FromBody] SessionKeyRequestModel _clientInfo)
        {
            if (_clientInfo.IsValid())
            {
                using (SqlProvider sqlOp = new SqlProvider())
                    using (RSAOperations keyOp = new RSAOperations())
                    {
                        KeyModel sessionParameters = sqlOp.GetSessionKeys(new Guid(_clientInfo.SessionId));

                        if (sessionParameters != null && !string.IsNullOrEmpty(sessionParameters.PrivateKey) && !string.IsNullOrEmpty(sessionParameters.EncKey) && !string.IsNullOrEmpty(sessionParameters.IVKey))
                        {
                            string clientPublicKey = string.Empty;

                            foreach (string chunk in _clientInfo.ClientPublic.Split('≡'))
                            {
                                clientPublicKey += keyOp.Decrypt(sessionParameters.PrivateKey, chunk);
                            }

                            if (!string.IsNullOrEmpty(clientPublicKey))
                            {
                                string encryptedEKey = keyOp.Encrypt(clientPublicKey, sessionParameters.EncKey);
                                string encryptedIKey = keyOp.Encrypt(clientPublicKey, sessionParameters.IVKey);

                                return(new ResponseModel()
                                {
                                    EKey = encryptedEKey, IKey = encryptedIKey
                                });
                            }
                        }
                    }
            }

            return(null);
        }
Example #21
0
        public async Task ClientSecretKeyTest()
        {
            var validator = GetKeySecretValidator();
            var keyData   = GetKeyData();
            var ownerKey  = await GetRootKey();

            var key = new KeyModel
            {
                OwnerKeyId = ownerKey.Id,
                PublicKey  = ModelHelper.GeneratePublicKey(),
                Type       = ApiKeyTypes.ClientSecret
            };

            var secret = "Supper secret string";

            key.Properties.Add(ApiKeyPropertyNames.ClientSecret1, secret);

            // Save key
            await keyData.Create(key);

            // Validate key
            var result = await validator.IsValid(key.PublicKey, secret);

            Assert.True(result.IsValid);
        }
        public MessageModel GetServerMessage([FromBody] MessageModel _clientMessage)
        {
            if (_clientMessage.IsValid())
            {
                try
                {
                    using (SqlProvider sqlOp = new SqlProvider())
                        using (AESOperations aesOp = new AESOperations())
                        {
                            KeyModel sessionParameters = sqlOp.GetSessionKeys(new Guid(_clientMessage.SessionId));

                            if (sessionParameters != null && !string.IsNullOrEmpty(sessionParameters.PrivateKey) && !string.IsNullOrEmpty(sessionParameters.EncKey) && !string.IsNullOrEmpty(sessionParameters.IVKey))
                            {
                                string clientMessage = aesOp.Decrypt(_clientMessage.Message, Encoding.ASCII.GetBytes(sessionParameters.EncKey), Encoding.ASCII.GetBytes(sessionParameters.IVKey));

                                if (clientMessage.Equals("MESSAGE FROM CLIENT"))
                                {
                                    return(new MessageModel()
                                    {
                                        Message = aesOp.Encrypt("LEGIT CLIENT", Encoding.ASCII.GetBytes(sessionParameters.EncKey), Encoding.ASCII.GetBytes(sessionParameters.IVKey))
                                    });
                                }
                            }
                        }
                }
                catch
                { }
            }

            return(null);
        }
        public void Overrides_Send_Email_Throws_Validation_Error_When_No_Criteria()
        {
            var inModel = new OverrideModel();

            inModel.Id = 1234;
            var           getRequest = MappingEngine.Map <OscOverrideReadUESRequest>(inModel);
            var           key        = new KeyModel("OverrideModel").Add(inModel.Id);
            OverrideModel cacheModel;

            mockCacheService.Setup(x => x.TryGet(key, out cacheModel)).Returns(true);
            mockMappingEngine.Setup(x => x.Map <OscOverrideReadUESRequest>(inModel)).Returns(getRequest);

            var response = new OscOverrideReadUESResponse {
                JobseekerId = 111111
            };
            var outModel = MappingEngine.Map <OverrideModel>(response);

            mockMappingEngine.Setup(x => x.Map <OscOverrideReadUESRequest>(inModel)).Returns(getRequest);
            mockOverridesWcf.Setup(x => x.LoadOverride(getRequest)).Returns(response);
            mockMappingEngine.Setup(m => m.Map <OverrideModel>(response)).Returns(outModel);

            var request = MappingEngine.Map <MessageRequest>(inModel);

            mockMappingEngine.Setup(x => x.Map <MessageRequest>(inModel)).Returns(request);
            mockAdwService.Setup(x => x.GetListCodeDescriptionShort("OVA", "FORW")).Returns("Forward");
            mockAdwService.Setup(x => x.GetListCodeDescriptionShort("ORS", inModel.Status)).Returns("Approved");
            SystemUnderTest().SendEmail(0, EmailAction.Forward, string.Empty, string.Empty);
        }
 /// <summary>
 /// Set an item in the session under a unique key.
 /// </summary>
 /// <typeparam name="T">Type of item.</typeparam>
 /// <param name="model">Key model.</param>
 /// <param name="o">Item to be stored in session.</param>
 /// <exception cref="TypeMismatchException">Thrown if the session already has an object set with the key and its actual type does not match the expected type.</exception>
 public override void Set <T>(KeyModel model, T o)
 {
     using (MiniProfiler.Current.Step(string.Format("SessionService: Set {0}", model.Key)))
     {
         base.Set(model, o);
     }
 }
        public void Overrides_Get_Request_Valid_Input()
        {
            OverrideModel cacheModel;
            var           inModel = new OverrideModel();

            inModel.Id = 1234;
            var request = MappingEngine.Map <OscOverrideReadUESRequest>(inModel);
            var key     = new KeyModel("OverrideModel").Add(inModel.Id);

            mockCacheService.Setup(x => x.TryGet(key, out cacheModel)).Returns(true);
            mockMappingEngine.Setup(x => x.Map <OscOverrideReadUESRequest>(inModel)).Returns(request);

            var response = new OscOverrideReadUESResponse {
                JobseekerId = 111111
            };
            var outModel = MappingEngine.Map <OverrideModel>(response);

            mockMappingEngine.Setup(x => x.Map <OscOverrideReadUESRequest>(inModel)).Returns(request);
            mockOverridesWcf.Setup(x => x.LoadOverride(request)).Returns(response);
            mockMappingEngine.Setup(m => m.Map <OverrideModel>(response)).Returns(outModel);

            var result = SystemUnderTest().Get(inModel);

            Assert.IsNotNull(result);
            Assert.AreEqual(outModel.JobSeekerId, result.JobSeekerId);
        }
Example #26
0
        private short GetSiteID()
        {
            KeyModel key    = new KeyModel(CacheType.Global, "BulletinSiteId");
            short    siteID = 0;

            if (!CacheService.TryGet(key, out siteID))
            {
                List <SqlParameter> sqlParameters = new List <SqlParameter>();

                SqlParameter siteIdParameter = new SqlParameter {
                    ParameterName = "@SiteId", Direction = ParameterDirection.Output, Value = 0
                };

                sqlParameters.Add(siteIdParameter);
                sqlParameters.Add(new SqlParameter {
                    ParameterName = "@SiteCode", SqlDbType = SqlDbType.VarChar, Value = SiteCode
                });

                SqlService.ExecuteNonQuery(connectionName, "AjsCmsSiteGet", sqlParameters);

                if (siteIdParameter.Value == null)
                {
                    throw new Exception(string.Format("Could not find Site ID for {0}", SiteCode));
                }

                short.TryParse(siteIdParameter.Value.ToString(), out siteID);

                if (siteID > 0)
                {
                    CacheService.Set(key, siteID, defaultTimeSpan);
                }
            }
            return(siteID);
        }
Example #27
0
        public IActionResult RenderLayerIcon(string deviceId, string layerId, int keyId)
        {
            Bitmap icon;

            try
            {
                DeviceModel device = _deviceManager.GetDevice(deviceId);
                KeyMap      keyMap = device.Layers.GetLayerById(layerId).Keys;


                if (keyMap.ContainsKey(keyId))
                {
                    KeyModel key = keyMap[keyId];
                    icon = _deviceManager.GenerateKeyIcon(key, deviceId);
                }
                else
                {
                    icon = IconHelpers.DrawBlankKeyIcon(244, 244);
                }
            }
            catch (Exception e)
            {
                icon = IconHelpers.DrawBlankKeyIcon(244, 244);
            }

            return(File(icon.ToMemoryStream(), "image/png", "key.png"));
        }
Example #28
0
        public async Task <KeyModel> CreateRootKey()
        {
            var existingKeyCount = await _keyData.Count();

            if (existingKeyCount > 0)
            {
                var msg = _localizer["Root key can only be created for empty database"];
                throw new InvalidOperationException(msg);
            }

            var model = new KeyModel
            {
                Type       = ApiKeyTypes.ClientSecret,
                PublicKey  = "rootkey",
                Properties =
                {
                    [ApiKeyPropertyNames.ClientSecret1] = ModelHelper.GenerateSecret(),
                    [ApiKeyPropertyNames.ClientSecret2] = ModelHelper.GenerateSecret()
                }
            };


            var saved = await _keyData.Create(model);

            return(saved);
        }
Example #29
0
 public KeyEdit(KeyModel km)
 {
     InitializeComponent();
     if (km.KeyCodeNormal != null && km.KeycodeModifier != null)
     {
         _keyModel = km;
     }
 }
Example #30
0
    // Use this for initialization
    void Awake()
    {
        // Set initial values
        _keyModel = null;

        // Get required components
        _handler = GetComponent<LetterHandler> ();
    }
Example #31
0
        /// <summary>
        /// Remove an item from the session.
        /// </summary>
        /// <param name="model">Key model.</param>
        public virtual void Remove(KeyModel model)
        {
            DefaultNamespace(ref model);

            var key = model.GetKey();

            HttpContext.Current.Session.Remove(key);
        }
Example #32
0
    void Awake()
    {
        // Set initial values
        _occupied = false;
        _index = 0;
        _keyModel = null;

        // Get required components
        _handler = GetComponent<EntryBoxHandler> ();
    }
Example #33
0
    public GameObject BuildWordGuess(KeyModel[] word, int letterCount)
    {
        if (word.Length != 4) {
            return null;
        }

        Transform wordGuess = Instantiate (guessWordPrefab);
        wordGuess.name = "";

        for (int i = 0; i < word.Length; i++) {
            int index = i + 1;
            BuildLetter(word[i]).transform.SetParent(wordGuess.Find("Letter " + index), false);

            wordGuess.name += word[i].Text;
        }

        BuildLetterCount(letterCount).transform.SetParent(wordGuess.Find("Number"), false);

        return wordGuess.gameObject;
    }
Example #34
0
    public GameObject BuildLetter(KeyModel keyModel)
    {
        // Build the letter
        Transform letter = Instantiate (letterPrefab);

        LetterHandler handler = letter.GetComponent<LetterHandler> ();
        LetterController controller = letter.GetComponent<LetterController> ();
        LetterModel model = letter.GetComponent<LetterModel> ();

        // MUST BE HOOKED IN THIS ORDER
        // Hooks controller to handler
        controller.ConnectEvents ();
        // Updates model and triggers color update to keymodel from handler
        model.KeyModel = keyModel;
        // Hooks to keymodel letter state changes
        handler.ConnectEvents ();

        letter.name = keyModel.Text;
        Text buttonText = letter.GetComponentInChildren<Text> ();
        buttonText.text = keyModel.Text;

        return letter.gameObject;
    }
Example #35
0
 private void OnKeyTextChanged(KeyModel model)
 {
     _keyText.text = model.Text;
 }
    // Use this for initialization
    void Awake()
    {
        // Set initial values
        _letter1 = null;
        _letter2 = null;
        _letter3 = null;
        _letter4 = null;
        _isFull = false;
        _isEmpty = true;
        _nextIndex = 0;

        // Get required components
        _handler = GetComponent<EntryFieldHandler> ();
    }
    private void OnNewKeyModel(KeyModel keyModel)
    {
        if (_indexOrder.Count > 0 && keyModel.Visible == false) {
            switch (_indexOrder [0]) {
            case 0:
                _model.Letter1 = keyModel;
                break;
            case 1:
                _model.Letter2 = keyModel;
                break;
            case 2:
                _model.Letter3 = keyModel;
                break;
            case 3:
                _model.Letter4 = keyModel;
                break;
            default:
                break;
            }

            RemoveIndex (0);
        }
    }
Example #38
0
 private void OnKeyVisibilityChanged(KeyModel model)
 {
     _animateHide = !model.Visible;
     _animateShow = model.Visible;
 }
Example #39
0
    // Use this for initialization
    void Start()
    {
        // Set initial values
        _animateHide = false;
        _animateShow = false;

        // Get required components
        _keyTransform = GetComponent<RectTransform> ();
        _keyImage = GetComponent<Image> ();
        _keyText = GetComponentInChildren<Text> ();
        _model = GetComponent<KeyModel> ();
        _handler = GetComponent<KeyHandler> ();

        // Hook event handlers
        ConnectEvents ();
    }
Example #40
0
 // Use this for initialization
 void Start()
 {
     // Get required components
     _model = GetComponent<KeyModel> ();
 }
Example #41
0
 private void OnKeyColorChanged(KeyModel model)
 {
     _keyImage.color = model.Color;
 }
Example #42
0
 private void OnKeyLetterStateChanged(KeyModel model)
 {
     PaintLetterByState(model.LetterState);
 }