Esempio n. 1
0
        public static void Run()
        {
            Console.WriteLine(nameof(TestAttributeExpressions));

            TypeAttribute attr1 = typeof(Holder1).GetCustomAttribute <TypeAttribute>();

            if (attr1.SomeType.ToString() != "ReflectionTest+TestAttributeExpressions+FirstNeverUsedType*[,]")
            {
                throw new Exception();
            }

            TypeAttribute attr2 = typeof(Holder2).GetCustomAttribute <TypeAttribute>();

            if (attr2.SomeType.ToString() != "ReflectionTest+TestAttributeExpressions+Gen`1[ReflectionTest+TestAttributeExpressions+SecondNeverUsedType]")
            {
                throw new Exception();
            }

            EnumArrayAttribute attr3 = typeof(Holder3).GetCustomAttribute <EnumArrayAttribute>();

            if (attr3.EnumArray[0] != 0)
            {
                throw new Exception();
            }
        }
Esempio n. 2
0
        static UserDefinedTypeCache()
        {
            TypeAttribute typeAttribute = typeof(T).GetCustomAttribute(typeof(TypeAttribute)) as TypeAttribute;

            if (typeAttribute == null)
            {
                throw new TypeLoadException($"Unable to cache type {typeof(T).Name} as it does not have a 'Type' attribute");
            }

            Dictionary <string, PropertyInfo> properties = new Dictionary <string, PropertyInfo>();
            Dictionary <string, string>       aliases    = new Dictionary <string, string>();

            foreach (PropertyInfo property in typeof(T).GetProperties())
            {
                if (Attribute.IsDefined(property, typeof(IgnoreAttribute)))
                {
                    continue;
                }

                ColumnAttribute column     = property.GetCustomAttribute(typeof(ColumnAttribute)) as ColumnAttribute;
                string          columnName = column?.Name ?? property.Name;

                properties.Add(columnName, property);
                aliases.Add(property.Name, columnName);
            }

            CachedType = new UserDefinedType()
            {
                Columns      = properties,
                KeyspaceName = typeAttribute.KeyspaceName,
                TypeName     = typeAttribute.TypeName ?? typeof(T).Name,
                Aliases      = aliases
            };
        }
 public ActionResult Create(TypeAttribute typeAttribute)
 {
     if (ModelState.IsValid)
     {
         var user = Session["User"] as User;
         typeAttribute.CreateAt = DateTime.Now;
         typeAttribute.Status   = true;
         typeAttribute.CreateBy = user.Id;
         if (_typeAttribute.GetAll().FirstOrDefault(x => x.TypeName == typeAttribute.TypeName) != null)
         {
             ModelState.AddModelError("TypeName", "Category already exists");
             return(View(typeAttribute));
         }
         try
         {
             if (_typeAttribute.Create(typeAttribute))
             {
                 TempData["CreateSuccess"] = "Create Success";
                 return(RedirectToAction("Index"));
             }
             else
             {
                 return(View(typeAttribute));
             }
         }
         catch (Exception)
         {
             return(View(typeAttribute));
         }
     }
     return(View());
 }
Esempio n. 4
0
        static Column()
        {
            Type type = typeof(valueType);

            if (type.IsEnum || !type.IsValueType)
            {
                AutoCSer.LogHelper.Error(type.fullName() + " 非值类型,不能用作数据列", LogLevel.Error | LogLevel.AutoCSer);
                return;
            }
            attribute = TypeAttribute.GetAttribute <ColumnAttribute>(type, true) ?? ColumnAttribute.Default;
            foreach (MethodInfo method in type.GetMethods(System.Reflection.BindingFlags.Static | System.Reflection.BindingFlags.Public | System.Reflection.BindingFlags.NonPublic))
            {
#if NOJIT
                if (typeof(ICustom).IsAssignableFrom(method.ReturnType)
#else
                if (typeof(ICustom <valueType>).IsAssignableFrom(method.ReturnType)
#endif
                    && method.GetParameters().Length == 0 && method.IsDefined(typeof(ColumnAttribute), false))
                {
                    object customValue = method.Invoke(null, null);
                    if (customValue != null)
                    {
#if NOJIT
                        custom = (ICustom)customValue;
#else
                        custom = (ICustom <valueType>)customValue;
#endif
                        return;
                    }
                }
            }
            Fields      = Field.Get(MemberIndexGroup <valueType> .GetFields(attribute.MemberFilters), true).ToArray();
            dataColumns = new AutoCSer.Threading.LockDictionary <HashString, KeyValue <string, Type>[]>();
            AutoCSer.Memory.Common.AddClearCache(dataColumns.Clear, typeof(Column <valueType>), 60 * 60);
        }
Esempio n. 5
0
        public virtual void TestCaptureState()
        {
            // init a first instance
            AttributeSource src     = new AttributeSource();
            TermAttribute   termAtt = (TermAttribute)src.AddAttribute(typeof(TermAttribute));
            TypeAttribute   typeAtt = (TypeAttribute)src.AddAttribute(typeof(TypeAttribute));

            termAtt.SetTermBuffer("TestTerm");
            typeAtt.SetType("TestType");
            int hashCode = src.GetHashCode();

            AttributeSource.State state = src.CaptureState();

            // modify the attributes
            termAtt.SetTermBuffer("AnotherTestTerm");
            typeAtt.SetType("AnotherTestType");
            Assert.IsTrue(hashCode != src.GetHashCode(), "Hash code should be different");

            src.RestoreState(state);
            Assert.AreEqual("TestTerm", termAtt.Term());
            Assert.AreEqual("TestType", typeAtt.Type());
            Assert.AreEqual(hashCode, src.GetHashCode(), "Hash code should be equal after restore");

            // restore into an exact configured copy
            AttributeSource copy = new AttributeSource();

            copy.AddAttribute(typeof(TermAttribute));
            copy.AddAttribute(typeof(TypeAttribute));
            copy.RestoreState(state);
            Assert.AreEqual(src.GetHashCode(), copy.GetHashCode(), "Both AttributeSources should have same hashCode after restore");
            Assert.AreEqual(src, copy, "Both AttributeSources should be equal after restore");

            // init a second instance (with attributes in different order and one additional attribute)
            AttributeSource src2 = new AttributeSource();

            typeAtt = (TypeAttribute)src2.AddAttribute(typeof(TypeAttribute));
            Lucene.Net.Analysis.Tokenattributes.FlagsAttribute flagsAtt = (Lucene.Net.Analysis.Tokenattributes.FlagsAttribute)src2.AddAttribute(typeof(Lucene.Net.Analysis.Tokenattributes.FlagsAttribute));
            termAtt = (TermAttribute)src2.AddAttribute(typeof(TermAttribute));
            flagsAtt.SetFlags(12345);

            src2.RestoreState(state);
            Assert.AreEqual("TestTerm", termAtt.Term());
            Assert.AreEqual("TestType", typeAtt.Type());
            Assert.AreEqual(12345, flagsAtt.GetFlags(), "FlagsAttribute should not be touched");

            // init a third instance missing one Attribute
            AttributeSource src3 = new AttributeSource();

            termAtt = (TermAttribute)src3.AddAttribute(typeof(TermAttribute));
            try
            {
                src3.RestoreState(state);
                Assert.Fail("The third instance is missing the TypeAttribute, so restoreState() should throw IllegalArgumentException");
            }
            catch (System.ArgumentException iae)
            {
                // pass
            }
        }
        public ActionResult DeleteConfirmed(int id)
        {
            TypeAttribute typeAttribute = db.TypeAttributes.Find(id);

            db.TypeAttributes.Remove(typeAttribute);
            db.SaveChanges();
            return(RedirectToAction("Index"));
        }
Esempio n. 7
0
        public void ParseTypeAttributeTest()
        {
            //Parse tokens
            MarkupParser  markupParser        = new MarkupParser(Init("type1"));
            TypeAttribute parsedTypeAttribute = markupParser.ParseTypeAttribute();

            //Check Id Attribute
            Assert.AreEqual("type1", parsedTypeAttribute.GetType());
        }
Esempio n. 8
0
        /// <summary>
        /// 成员信息转换为数据列
        /// </summary>
        /// <param name="name">成员名称</param>
        /// <param name="type">成员类型</param>
        /// <param name="memberAttribute">SQL成员信息</param>
        /// <returns>数据列</returns>
        internal Column GetColumn(string name, Type type, MemberAttribute memberAttribute)
        {
            Column column = TypeAttribute.GetAttribute <ColumnAttribute>(type, false) == null?GetColumn(type, memberAttribute) : new Column
            {
                SqlColumnType = type
            };

            column.Name = name;
            return(column);
        }
        public static string GetStringName(TypeAttribute ta)
        {
            string result;

            if (typeAttribute.TryGetValue(ta, out result))
            {
                return(result);
            }
            return(null);
        }
 public ActionResult Edit(TypeAttribute typeAttribute)
 {
     if (_typeAttribute.Update(typeAttribute))
     {
         TempData["UpdateSuccess"] = "Update Success";
         return(RedirectToAction("Index"));
     }
     TempData["UpdateFalse"] = "Update False!";
     return(View(typeAttribute));
 }
Esempio n. 11
0
        /// <summary>
        /// Parser for TypeAttribute
        /// </summary>
        /// <returns>Parsed TypeAttribute</returns>
        public TypeAttribute ParseTypeAttribute()
        {
            TypeAttribute typeAttribute = new TypeAttribute();

            //Get type token
            CurrentToken = TokenStream.NextToken();
            typeAttribute.SetType(CurrentToken.GetValue().ToString());

            return(typeAttribute);
        }
        public void ApplyChanges()
        {
            if (HasChanged)
            {
                var serviceProperties = new Dictionary <SystemServiceProperty, object>();

                foreach (KeyValuePair <SystemServiceProperty, object> property in GetServiceProperties())
                {
                    TypeAttribute typeAttribute = property.Key.GetEnumAttribute <TypeAttribute>();

                    switch (property.Key)
                    {
                    case SystemServiceProperty.DesktopInteract:
                        if (InteractWithDesktop != (bool)Convert.ChangeType(property.Value, typeAttribute.Type))
                        {
                        }
                        break;

                    case SystemServiceProperty.DisplayName:
                        if (DisplayName != Convert.ChangeType(property.Value, typeAttribute.Type).ToString())
                        {
                        }
                        break;

                    case SystemServiceProperty.PathName:
                        if (ServiceAssemblyPath != Convert.ChangeType(property.Value, typeAttribute.Type).ToString())
                        {
                            serviceProperties.Add(SystemServiceProperty.PathName, ServiceAssemblyPath);
                        }
                        break;

                    case SystemServiceProperty.StartMode:
                        if (ServiceStartMode != (ServiceStartMode)Convert.ChangeType(property.Value, typeAttribute.Type))
                        {
                            serviceProperties.Add(SystemServiceProperty.StartMode, ServiceStartMode);
                        }
                        break;

                    case SystemServiceProperty.StartName:
                        if (UserName != Convert.ChangeType(property.Value, typeAttribute.Type).ToString())
                        {
                            serviceProperties.Add(SystemServiceProperty.StartName, ServiceStartMode);
                        }
                        break;

                    default:
                        break;
                    }
                }



                ;
            }
        }
Esempio n. 13
0
        public StringParser()
        {
            Type t = GetType();

            ParseMethods = t.GetMethods().Where(x => TypeAttribute.HasAttribute(x)).ToDictionary(
                (m) => TypeAttribute.GetAttribute(m).Type,
                (m) => new Func <string, object>((str) =>
                                                 Try.Func <object>(
                                                     () => m.Invoke(this, new object[] { str }),
                                                     (ex) => { throw ex.InnerException; }
                                                     )));
        }
Esempio n. 14
0
 //FIXME raise an assertion failure  if setExplicitType(String) and setExplicitType(Type) are use at the same time
 public void SetExplicitType(TypeAttribute typeAnn)
 {
     if (typeAnn != null)
     {
         explicitType = typeAnn.Type;
         typeParameters.Clear();
         foreach (ParameterAttribute param in typeAnn.Parameters)
         {
             typeParameters.Add(param.Name, param.Value);
         }
     }
 }
 public ActionResult Edit([Bind(Include = "Id,TypeId,AttributeId")] TypeAttribute typeAttribute)
 {
     if (ModelState.IsValid)
     {
         db.Entry(typeAttribute).State = EntityState.Modified;
         db.SaveChanges();
         return(RedirectToAction("Index"));
     }
     ViewBag.AttributeId = new SelectList(db.Attributes, "Id", "Name", typeAttribute.AttributeId);
     ViewBag.TypeId      = new SelectList(db.Types, "Id", "Name", typeAttribute.TypeId);
     return(View(typeAttribute));
 }
		//FIXME raise an assertion failure  if setExplicitType(String) and setExplicitType(Type) are use at the same time
		public void SetExplicitType(TypeAttribute typeAnn)
		{
			if (typeAnn != null)
			{
				explicitType = typeAnn.Type;
				typeParameters.Clear();
				foreach (ParameterAttribute param in typeAnn.Parameters)
				{
					typeParameters.Add( param.Name, param.Value);
				}
			}
		}
Esempio n. 17
0
 private async void Type_TypeInfoChanged(object sender, EventArgs e)
 {
     this.typeInfo = this.type.TypeInfo;
     if (this.typeInfo.IsFlag == true)
     {
         this.typeAttribute |= TypeAttribute.IsFlag;
     }
     else
     {
         this.typeAttribute &= ~TypeAttribute.IsFlag;
     }
     await this.RefreshAsync();
 }
Esempio n. 18
0
    static void Main(string[] args)
    {
        var input         = Console.ReadLine();
        var typeAttribute = new TypeAttribute(input);

        Console.WriteLine(typeAttribute);


        //var type = typeof(TypeAttribute);
        // var fielType = type.GetFields(BindingFlags.Instance | BindingFlags.Public | BindingFlags.NonPublic)
        //     .Where(f => f.Name == "Type");
        // Console.WriteLine(fielType.GetType());
    }
Esempio n. 19
0
        public void Load_ShouldNotLoadType_RegularCtor(string xml)
        {
            mSut = new TypeAttribute(new ReadOnlyCollection <IProperty>(new List <IProperty>()));

            XmlDocument xmlDoc = new XmlDocument();

            xmlDoc.LoadXml($"<appender name=\"ColoredConsoleAppender\" {xml}>\r\n" +
                           "</appender>");

            mSut.Load(xmlDoc.FirstChild);

            Assert.IsNull(mSut.Value);
        }
        void init()
        {
            TypeAttribute att = fieldInfo.GetCustomAttributes(typeof(TypeAttribute), false).FirstOrDefault(e => { return(e is TypeAttribute); }) as TypeAttribute;

            if (att != null)
            {
                _refType = att.type;
            }
            else
            {
                _refType = typeof(GameObject);
            }
        }
        public ActionResult Create([Bind(Include = "Id,TypeId,AttributeId")] TypeAttribute typeAttribute)
        {
            if (ModelState.IsValid)
            {
                db.TypeAttributes.Add(typeAttribute);
                db.SaveChanges();
                return(RedirectToAction("Index"));
            }

            ViewBag.AttributeId = new SelectList(db.Attributes, "Id", "Name", typeAttribute.AttributeId);
            ViewBag.TypeId      = new SelectList(db.Types, "Id", "Name", typeAttribute.TypeId);
            return(View(typeAttribute));
        }
Esempio n. 22
0
        public void TestCdmFolderToDataTypeAttribute()
        {
            CdmCorpusDefinition corpus = new CdmCorpusDefinition();

            corpus.SetEventCallback(new EventCallback {
                Invoke = CommonDataModelLoader.ConsoleStatusReport
            }, CdmStatusLevel.Warning);
            corpus.Storage.Mount("local", new LocalAdapter("C:\\Root\\Path"));
            corpus.Storage.DefaultNamespace = "local";

            var cdmTypeAttributeDefinition = corpus.MakeObject <CdmTypeAttributeDefinition>(CdmObjectType.TypeAttributeDef, "TestSavingTraitAttribute", false);

            List <string> englishConstantsList = new List <string>()
            {
                "en", "Some description in English language"
            };
            List <string> serbianConstantsList = new List <string>()
            {
                "sr", "Opis na srpskom jeziku"
            };
            List <string> chineseConstantsList = new List <string>()
            {
                "cn", "一些中文描述"
            };
            List <List <string> > listOfConstLists = new List <List <string> > {
                englishConstantsList, serbianConstantsList, chineseConstantsList
            };

            var constEntDef = corpus.MakeObject <CdmConstantEntityDefinition>(CdmObjectType.ConstantEntityDef, "localizedDescriptions", false);

            constEntDef.ConstantValues = listOfConstLists;
            constEntDef.EntityShape    = corpus.MakeRef <CdmEntityReference>(CdmObjectType.EntityRef, "localizedTable", true);
            var traitReference2 = corpus.MakeObject <CdmTraitReference>(CdmObjectType.TraitRef, "is.localized.describedAs", false);

            traitReference2.Arguments.Add("localizedDisplayText", corpus.MakeRef <CdmEntityReference>(CdmObjectType.EntityRef, constEntDef, true));
            cdmTypeAttributeDefinition.AppliedTraits.Add(traitReference2);

            TypeAttribute result = PersistenceLayer.ToData <CdmTypeAttributeDefinition, TypeAttribute>(cdmTypeAttributeDefinition, null, null, PersistenceLayer.CdmFolder);

            Assert.IsNotNull(result.AppliedTraits);

            var argument = result.AppliedTraits[0].ToObject <TraitReferenceDefinition>().Arguments[0].ToObject <Argument>();
            List <List <string> > constantValues = argument.Value.ToObject <EntityReferenceDefinition>().EntityReference.ToObject <ConstantEntity>().ConstantValues;

            Assert.AreEqual("en", constantValues[0][0]);
            Assert.AreEqual("Some description in English language", constantValues[0][1]);
            Assert.AreEqual("sr", constantValues[1][0]);
            Assert.AreEqual("Opis na srpskom jeziku", constantValues[1][1]);
            Assert.AreEqual("cn", constantValues[2][0]);
            Assert.AreEqual("一些中文描述", constantValues[2][1]);
        }
Esempio n. 23
0
        public async Task <EntityEntry <TypeAttribute> > AddOrUpdateAsync(TypeAttribute entity)
        {
            var exists = await FindAsync <TypeAttribute>(entity.TypeId, entity.AttributeId);

            if (exists == null)
            {
                return(Add(entity));
            }
            else
            {
                Entry(exists).CurrentValues.SetValues(entity);
                return(Entry(entity));
            }
        }
Esempio n. 24
0
        public static void InjectAttributeInfo(MethodInfo methodInfo, Method method)
        {
            CommandAttribute commandAttribute = methodInfo.GetCustomAttribute <CommandAttribute>();

            if (commandAttribute != null)
            {
                method.Command   = commandAttribute.CommandName;
                method.IsCommand = true;
            }

            TypeAttribute typeAttribute = methodInfo.GetCustomAttribute <TypeAttribute>();

            method.Type = typeAttribute == null ? DispatcherType.Any : typeAttribute.Type;
        }
        // GET: TypeAttribute/Delete/5
        public ActionResult Delete(int?id)
        {
            if (id == null)
            {
                return(new HttpStatusCodeResult(HttpStatusCode.BadRequest));
            }
            TypeAttribute typeAttribute = db.TypeAttributes.Find(id);

            if (typeAttribute == null)
            {
                return(HttpNotFound());
            }
            return(View(typeAttribute));
        }
Esempio n. 26
0
        /// <summary>
        /// 获取数据库表格操作工具
        /// </summary>
        /// <returns>数据库表格操作工具</returns>
        /// <param name="isCreateCacheWait">是否等待创建缓存</param>
        public static ModelTable <modelType> Get(bool isCreateCacheWait = false)
        {
            Type           type      = typeof(modelType);
            TableAttribute attribute = TypeAttribute.GetAttribute <TableAttribute>(type, false);

            if (attribute != null)// && Array.IndexOf(ConfigLoader.Config.CheckConnectionNames, attribute.ConnectionType) != -1
            {
                ModelTable <modelType> table = new ModelTable <modelType>(attribute, isCreateCacheWait);
                if (!table.IsError)
                {
                    return(table);
                }
            }
            return(null);
        }
 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;
 }
Esempio n. 28
0
        static Model()
        {
            Type type = typeof(valueType);

            attribute   = TypeAttribute.GetAttribute <ModelAttribute>(type, true) ?? ModelAttribute.Default;
            Fields      = Field.Get(MemberIndexGroup <valueType> .GetFields(attribute.MemberFilters), false).ToArray();
            Identity    = Field.GetIdentity(Fields);
            PrimaryKeys = Field.GetPrimaryKeys(Fields).ToArray();
            MemberMap   = new MemberMap <valueType>();
            foreach (Field field in Fields)
            {
                MemberMap.SetMember(field.MemberMapIndex);
            }
            if (Identity != null)
            {
                IdentitySqlName = Identity.SqlFieldName;
#if NOJIT
                new identity(Identity.Field).Get(out GetIdentity, out SetIdentity);
                Action <valueType, int> setter32;
                new identity32(Identity.Field).Get(out GetIdentity32, out setter32);
#else
                DynamicMethod dynamicMethod = new DynamicMethod("GetSqlIdentity", typeof(long), new Type[] { type }, type, true);
                ILGenerator   generator     = dynamicMethod.GetILGenerator();
                generator.Emit(OpCodes.Ldarg_0);
                generator.Emit(OpCodes.Ldfld, Identity.FieldInfo);
                if (Identity.FieldInfo.FieldType != typeof(long) && Identity.FieldInfo.FieldType != typeof(ulong))
                {
                    generator.Emit(OpCodes.Conv_I8);
                }
                generator.Emit(OpCodes.Ret);
                GetIdentity = (Func <valueType, long>)dynamicMethod.CreateDelegate(typeof(Func <valueType, long>));

                dynamicMethod = new DynamicMethod("SetSqlIdentity", null, new Type[] { type, typeof(long) }, type, true);
                generator     = dynamicMethod.GetILGenerator();
                generator.Emit(OpCodes.Ldarg_0);
                generator.Emit(OpCodes.Ldarg_1);
                if (Identity.FieldInfo.FieldType != typeof(long) && Identity.FieldInfo.FieldType != typeof(ulong))
                {
                    generator.Emit(OpCodes.Conv_I4);
                }
                generator.Emit(OpCodes.Stfld, Identity.FieldInfo);
                generator.Emit(OpCodes.Ret);
                SetIdentity = (Action <valueType, long>)dynamicMethod.CreateDelegate(typeof(Action <valueType, long>));

                GetIdentity32 = getIdentityGetter32("GetSqlIdentity32", Identity.FieldInfo);
#endif
            }
        }
        // GET: TypeAttribute/Edit/5
        public ActionResult Edit(int?id)
        {
            if (id == null)
            {
                return(new HttpStatusCodeResult(HttpStatusCode.BadRequest));
            }
            TypeAttribute typeAttribute = db.TypeAttributes.Find(id);

            if (typeAttribute == null)
            {
                return(HttpNotFound());
            }
            ViewBag.AttributeId = new SelectList(db.Attributes, "Id", "Name", typeAttribute.AttributeId);
            ViewBag.TypeId      = new SelectList(db.Types, "Id", "Name", typeAttribute.TypeId);
            return(View(typeAttribute));
        }
Esempio n. 30
0
//JAVA TO C# CONVERTER WARNING: Method 'throws' clauses are not available in .NET:
//ORIGINAL LINE: private void testPositons(TypeTokenFilter stpf) throws java.io.IOException
        private void testPositons(TypeTokenFilter stpf)
        {
            TypeAttribute              typeAtt       = stpf.getAttribute(typeof(TypeAttribute));
            CharTermAttribute          termAttribute = stpf.getAttribute(typeof(CharTermAttribute));
            PositionIncrementAttribute posIncrAtt    = stpf.getAttribute(typeof(PositionIncrementAttribute));

            stpf.reset();
            bool enablePositionIncrements = stpf.EnablePositionIncrements;

            while (stpf.incrementToken())
            {
                log("Token: " + termAttribute.ToString() + ": " + typeAtt.type() + " - " + posIncrAtt.PositionIncrement);
                assertEquals("if position increment is enabled the positionIncrementAttribute value should be 3, otherwise 1", posIncrAtt.PositionIncrement, enablePositionIncrements ? 3 : 1);
            }
            stpf.end();
            stpf.close();
        }
Esempio n. 31
0
 /// <summary>
 /// 获取属性值并排序
 /// </summary>
 /// <param name="cp"></param>
 /// <returns></returns>
 public static List<FieldAttributeInfo> GetComponentField(TypeAttribute component)
 {
     List<FieldAttributeInfo> list = new List<FieldAttributeInfo>();
     IEnumerable<PropertyName> pNames = component.GetPropertyNames();
     FieldAttributeInfo info = null;
     foreach (var n in pNames)
     {
         info = new FieldAttributeInfo();
         PropertyInfo p = component.GetPropertyInfo(n.Name);
         info.Name = n.Name;
         var attrs = p.GetCustomAttributes(typeof(ComponentAttributeBase), false);
         bool hide = false;
         foreach (var a in attrs)
         {
             if (a is FieldDocumentAttribute)
             {
                 FieldDocumentAttribute att = a as FieldDocumentAttribute;
                 if (att.Order == 0)
                 {
                     info.Order = 100;
                 }
                 else
                 {
                     info.Order = att.Order;
                 }                    
                 info.Title = att.Title;
                 info.Detail = att.Detail;
                 info.Link = att.Link;
                 hide = att.Hide;
             }
         }
         if (hide)
         {
             continue;
         }
         if (attrs.Length == 0)
         {
             info.Order = 100;
         }
         list.Add(info);
     }
     List<FieldAttributeInfo> listAsc = list.OrderBy(o => o.Order).ToList();
     return listAsc;
 }
Esempio n. 32
0
        public List <DbAttribute> GetPropertyDbAtttibutes(string propertyName)
        {
            List <DbAttribute> dbAttributes = new List <DbAttribute>();

            var property = ModelType.GetProperty(propertyName);

            var attrs = System.Attribute.GetCustomAttributes(property);

            var typeAttr = System.Attribute.GetCustomAttribute(property, typeof(TypeAttribute));

            if (DbTypeMapping.TypeMapping(property.PropertyType).Equals(DbTypeMapping.UserType))
            {
                var dbType = DbTypeMapping.UserType;

                typeAttr = new TypeAttribute(dbType.TypeName, dbType.DefaultSize);
            }
            else if (DbTypeMapping.TypeMapping(property.PropertyType).Equals(DbTypeMapping.List_UserType))
            {
                var dbType = DbTypeMapping.List_UserType;

                typeAttr = new TypeAttribute(dbType.TypeName, dbType.DefaultSize);
            }
            else
            {
                if (typeAttr == null)
                {
                    var dbType = DbTypeMapping.TypeMapping(property.PropertyType);
                    typeAttr = new TypeAttribute(dbType.TypeName, dbType.DefaultSize);
                }

                //加载约束特性
                foreach (var attr in attrs)
                {
                    if (attr is ConstraintAttribute)
                    {
                        dbAttributes.Add((DbAttribute)attr);
                    }
                }
            }
            dbAttributes.Add((DbAttribute)typeAttr);
            return(dbAttributes);
        }
 public BaseAttributeConfigBean()
 {
     helper = new TypeAttribute(this);
 }
Esempio n. 34
0
        /// <summary> Write a Type XML Element from attributes in a member. </summary>
        public virtual void WriteType(System.Xml.XmlWriter writer, System.Reflection.MemberInfo member, TypeAttribute attribute, BaseAttribute parentAttribute, System.Type mappedClass)
        {
            writer.WriteStartElement( "type" );
            // Attribute: <name>
            writer.WriteAttributeString("name", attribute.Name==null ? DefaultHelper.Get_Type_Name_DefaultValue(member) : GetAttributeValue(attribute.Name, mappedClass));

            WriteUserDefinedContent(writer, member, null, attribute);

            System.Collections.ArrayList memberAttribs = GetSortedAttributes(member);
            int attribPos; // Find the position of the TypeAttribute (its <sub-element>s must be after it)
            for(attribPos=0; attribPos<memberAttribs.Count; attribPos++)
                if( memberAttribs[attribPos] is TypeAttribute
                    && ((BaseAttribute)memberAttribs[attribPos]).Position == attribute.Position )
                    break; // found
            int i = attribPos + 1;

            // Element: <param>
            for(; i<memberAttribs.Count; i++)
            {
                BaseAttribute memberAttrib = memberAttribs[i] as BaseAttribute;
                if( IsNextElement(memberAttrib, parentAttribute, attribute.GetType())
                    || IsNextElement(memberAttrib, attribute, typeof(ParamAttribute)) )
                    break; // next attributes are 'elements' of the same level OR for 'sub-elements'
                else
                {
                    if( memberAttrib is TypeAttribute )
                        break; // Following attributes are for this Type
                    if( memberAttrib is ParamAttribute )
                        WriteParam(writer, member, memberAttrib as ParamAttribute, attribute, mappedClass);
                }
            }
            WriteUserDefinedContent(writer, member, typeof(ParamAttribute), attribute);

            writer.WriteEndElement();
        }
Esempio n. 35
0
 public BaseTableComponent()
 {
     helper = new TypeAttribute(this);
 }
Esempio n. 36
0
 public BaseChartComponent()
 {
     helper = new TypeAttribute(this);
 }
 public BaseAttributeConfigBean()
 {
     helper = new TypeAttribute(this);
     UpdateLogDic = new Dictionary<string, object>();
 }