예제 #1
0
        public string GetCodebehind(bool isEdit)
        {
            string template  = isEdit ? Resources.PageEdit_cs:Resources.PageView_cs;
            string className = ClassName.Split('.').LastOrDefault();

            return(template.Replace(Templates.ShortClassName, className));
        }
예제 #2
0
        public virtual void SetProperty(string property, object value)
        {
            switch (property)
            {
            case "name":
                Element.name = value?.ToString();
                return;

            case "focusable":
                Element.focusable = Convert.ToBoolean(value);
                return;

            case "className":
                foreach (var cls in ClassList)
                {
                    Element.RemoveFromClassList(cls);
                }

                ClassName = value?.ToString();
                ClassList = string.IsNullOrWhiteSpace(ClassName) ? EmptyClassList :
                            new HashSet <string>(ClassName.Split(new char[] { ' ' }, StringSplitOptions.RemoveEmptyEntries));

                foreach (var cls in ClassList)
                {
                    Element.AddToClassList(cls);
                    ResolveStyle(true);
                }
                return;

            default:
                throw new Exception($"Unknown property name specified, '{property}'");
            }
        }
예제 #3
0
        /// <summary>
        ///     This is not used, but is intended to be completed and solve the problem regarding
        ///     the recorder using multiple class names in the By.ClassName selector.
        /// </summary>
        public void ResolveMultipleClassNames()
        {
            string[] classNames = ClassName.Split(new[] { ' ' });
            if (Id == "null" && Name == "null")
            {
                if (classNames.Length > 0)
                {
//                    MessageBox.Show("The clicked element has more than one class name ascribed to it. You must select one to use!", "Selector Selector", new MessageBoxButtons())
                }
            }
        }
        public bool HasClass(string className)
        {
            if (className == null)
            {
                throw new ArgumentNullException("className");
            }

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

            return(ClassName.Split(' ').Any(n => n.Equals(className, StringComparison.CurrentCultureIgnoreCase) || ("." + n).Equals(className, StringComparison.CurrentCultureIgnoreCase)));
        }
예제 #5
0
        /// <summary>
        /// Returns a <see cref="System.String"/> that represents this instance.
        /// </summary>
        /// <param name="full">if set to <c>true</c> includes full information
        /// about generic parameters and assembly properties.</param>
        /// <param name="includeAssembly">if set to <c>true</c> include assembly properties and generic parameters.</param>
        /// <returns>
        /// A <see cref="System.String"/> that represents this instance.
        /// </returns>
        public string ToString(bool full, bool includeAssembly)
        {
            var sb = new StringBuilder();

            if (!string.IsNullOrEmpty(Namespace))
            {
                sb.Append(Namespace).Append('.');
            }
            if (GenericArgCounts != null)
            {
                sb.Append(string.Join("+",
                                      ClassName
                                      .Split('+')
                                      .Zip(GenericArgCounts, (n, c) =>
                                           c > 0 ? String.Format("{0}`{1}", n, c) : n)));
            }
            else
            {
                sb.Append(ClassName);
                if (IsGeneric)
                {
                    sb.Append('`').Append(GenericArgs.Count);
                }
            }
            if (IsGeneric)
            {
                sb.Append('[');
                sb.Append(String.Join(",", GenericArgs.Select(a =>
                                                              string.Format("[{0}]", a.ToString(full)))));
                sb.Append(']');
            }
            sb.Append(MemoryMagic);
            if (includeAssembly && AssemblyName != null)
            {
                sb.Append(", ").Append(AssemblyName);
                if (full)
                {
                    foreach (var property in AssemblyAttribues)
                    {
                        sb.Append(", ").Append(property.Key).Append('=').Append(property.Value);
                    }
                }
            }
            return(sb.ToString());
        }
예제 #6
0
        private IEnumerable <string> GetNestedClassesInCode(HashSet <string> omitNamespaces, bool includeAllNamespaces)
        {
            var i = 0;

            foreach (var pair in ClassName.Split('+').Zip(GenericArgCounts, (n, c) => new { n, c }))
            {
                if (pair.c == 0)
                {
                    yield return(pair.n);
                }
                else
                {
                    yield return(string.Format("{0}<{1}>",
                                               pair.n,
                                               string.Join(",",
                                                           GenericArgs
                                                           .GetRange(i, pair.c)
                                                           .Select(a => a.GetTypeNameInCode(omitNamespaces, includeAllNamespaces)))));

                    i += pair.c;
                }
            }
        }
예제 #7
0
        private void AssignToClassField()
        {
            var className  = ClassName.Split("^").Last();
            var value      = Expression.Eval();
            var expression = new ValueExpression(value);

            // TODO: Проверить класс-параметр
            if (GetRoot().Module.VariableStorage.IsExist(ClassName))
            {
                var classVariable = GetRoot().Module.VariableStorage.At(ClassName);
                var classValue    = (ClassValue)classVariable.Calculate();

                var field = classValue.Class.Fields.FirstOrDefault(x => x.Name == FieldName);
                if (field == null)
                {
                    throw new Exception($"В классе {className} не объявлено поле {FieldName}");
                }

                field.Expression = expression;
                return;
            }

            throw new Exception($"Переменная {className} не объявлена!");
        }
예제 #8
0
        public CodeModel(string theType)
        {
            Type type = Type.GetType(theType);

            NamespaceName = type.Namespace;
            ClassName     = type.Name;
            IsAbstract    = type.IsAbstract;
            if (type.IsGenericType)
            {
                var gas = type.GetGenericArguments();
                for (var i = 0; i < gas.Length; i++)
                {
                    GenericTypeArguments.Add(gas[i].Name);
                }
                ClassName = $"{ClassName.Split('`')[0]}<{string.Join(",",GenericTypeArguments.ToArray())}>";
            }
            var cons = type.GetConstructors(BindingFlags.Public | BindingFlags.Instance);

            foreach (var con in cons)
            {
                CodeFunctionInfo func_info = new CodeFunctionInfo();
                var pars = con.GetParameters();
                func_info.ParamList.AddRange(pars.Select(it => new CodeParamInfo()
                {
                    Name = it.Name, TypeName = GetTypeName(it.ParameterType)
                }));
                CodeConstructorList.Add(func_info);
            }
            var methods = type.GetMethods(BindingFlags.Public | BindingFlags.Instance | BindingFlags.Static);

            foreach (var method in methods)
            {
                if (method.IsSpecialName)
                {
                    continue;
                }
                CodeFunctionInfo func_info = new CodeFunctionInfo();
                func_info.ReturnTypeName = GetTypeName(method.ReturnType);
                func_info.Name           = method.Name;
                if (method.IsGenericMethod)
                {
                    var gas = method.GetGenericArguments().Select(it => it.Name).ToArray();
                    func_info.Name = $"{method.Name}<{string.Join(",",gas)}>";
                }
                func_info.ShortName  = method.Name;
                func_info.IsStatic   = method.IsStatic;
                func_info.IsAbstract = method.IsAbstract;
                func_info.IsVirtual  = method.IsVirtual;
                var ps = method.GetParameters();
                func_info.ParamList.AddRange(ps.Select(it => new CodeParamInfo()
                {
                    Name = it.Name, TypeName = GetTypeName(it.ParameterType)
                }));
                CodeFunctionList.Add(func_info);
            }
            var pros = type.GetProperties(BindingFlags.Public | BindingFlags.Instance);

            CodePropertyList.AddRange(pros.Select(it => new CodePropertyInfo()
            {
                Name = it.Name, TypeName = GetTypeName(it.PropertyType), HasGet = it.GetGetMethod(false) != null, HasSet = it.GetSetMethod(false) != null, IsStatic = it.GetGetMethod().IsStatic, IsVirtual = it.GetGetMethod().IsVirtual, IsAbstract = it.GetGetMethod().IsAbstract
            }));
            var events = type.GetEvents(BindingFlags.Public | BindingFlags.Static);

            CodeEventList.AddRange(events.Select(it => new CodeEventInfo()
            {
                Name = it.Name, TypeName = GetTypeName(it.EventHandlerType), IsStatic = true
            }));
            events = type.GetEvents(BindingFlags.Public | BindingFlags.Instance);
            CodeEventList.AddRange(events.Select(it => new CodeEventInfo()
            {
                Name = it.Name, TypeName = GetTypeName(it.EventHandlerType), IsStatic = false
            }));
        }
예제 #9
0
 public override string ToString()
 {
     return($"{MethodName} - {ClassName.Split('.').Last()} - Result: {Result}");
 }