예제 #1
0
        public BaseFormParent InstanceOf <T>() where T : BaseFormParent
        {
            BaseFormParent result = null;
            var            type   = typeof(T);

            //if typeInstance dict contains form with specific type
            if (typeInstanceDict.ContainsKey(type))
            {
                //Get Instance Key by Type
                if (typeInstanceDict.TryGetValue(type, out var instanceKey))
                {
                    //Get Frm by InstanceKey
                    if (ActiveForms.ContainsKey(instanceKey))
                    {
                        result = ActiveForms[instanceKey];
                    }
                    else
                    {
                        throw new Exception("Форма отсутствует в списке активных форм, хотя тип и ключ формы зарегистрирован");
                    }
                }
                else
                {
                    throw new Exception("Ключ формы не зарегистрирован");
                }
            }
            //If typeInstance dict doesn't contains InstanceKey of Form with Specific Type
            //Create Element in typeInstance dict
            else
            {
                //Instance of Form
                var form        = (T)Activator.CreateInstance(type);
                var instanceKey = InstanceKey.Generate(form);
                typeInstanceDict.Add(type, instanceKey);

                if (ActiveForms.ContainsKey(instanceKey))
                {
                    ActiveForms[instanceKey] = form;
                }
                else
                {
                    ActiveForms.Add(instanceKey, form);
                }
                result = ActiveForms[instanceKey];
            }

            return(result);
        }
예제 #2
0
 public void SendData(object data, PerformOptions options)
 {
     BaseFormParent.SendInternalData(data, options);
 }
예제 #3
0
 protected void Invoke(BaseFormParent form, Action action)
 {
     form?.Invoke(action);
 }