Пример #1
0
        public async Task InsertOrUpdateAsync(IEnumerable <TEntity> source)
        {
            using (var connection = new SqlConnection(configuration.GetConnectionString(ConfigurationConnectionStringKey)))
            {
                using (var command = connection.CreateCommand())
                {
                    await connection.OpenAsync();

                    using (var transaction = connection.BeginTransaction())
                    {
                        try
                        {
                            command.Transaction = transaction;

                            var temporaryTableName = await CreateTemporarySqlTable();

                            await BulkInsert(source, temporaryTableName);

                            var properties = OrderAttribute.GetPropertiesOrder <TEntity>();

                            command.CommandText =
                                @$ "MERGE {SqlTableName} AS TARGET
                           USING {temporaryTableName} AS SOURCE
                            ON TARGET.Id = Source.Id
                           WHEN MATCHED AND {properties.Select(x => $" TARGET.{ x.Value } < > SOURCE.{ x.Value } ")
                                                        .Aggregate((current, previous) => $" { current } OR {
                                previous
                            } ")}
                            THEN 
                                UPDATE SET {properties.Select(x => $" TARGET.{ x.Value } = SOURCE.{ x.Value } ")
                                                        .Aggregate((current, previous) => $" { current }, { previous } ")}
                           WHEN NOT MATCHED
                            THEN
                                INSERT ({properties.Select(x => x.Value).Aggregate((current, previous) => $" { current }, { previous } ")})
                                VALUES ({properties.Select(x => $" SOURCE.{ x.Value } ").Aggregate((current, previous) => $" { current }, { previous } ")})
Пример #2
0
 public Task UpdateAsync(
     OrderAttribute attribute,
     Dictionary <string, string> headers = default,
     CancellationToken ct = default)
 {
     return(_factory.PatchAsync(_host + "/Orders/Attributes/v1/Update", null, attribute, headers, ct));
 }
Пример #3
0
        private void invokeMethod(MethodInfo method, OrderAttribute attr)
        {
            if (method.GetParameters().Count() == 0)
            {
                dynamic returnObj = method.Invoke(_tempInstance, null);
                if (isSimpleField(method.ReturnType))
                {
                    ColumnBindingAttribute colAttr = attr as ColumnBindingAttribute;
                    if (colAttr != null && colAttr.Directory == DataDirectory.Output)
                    {
                        resetColumnName(method, colAttr);
                        DataRow[] data = null;
                        if (_bindingMode.DataMode == DataType.FromShareTable)
                        {
                            data = getSharedData(colAttr);
                        }
                        else
                        {
                            data = getPrivateData(colAttr);
                        }

                        int index = _bindingMode.LoopMode == LoopType.Loop ? TypeCounts[me] : 0;
                        getSingleProperty(method, returnObj, colAttr, data, index);
                    }
                }
                else if (method.ReturnType.IsClass)
                {
                    runRecusion(returnObj);
                }
            }
        }
Пример #4
0
    /// <summary>
    ///     Get a list of valid fields this datablock can access
    /// </summary>
    /// <returns>Array of valid fields</returns>
    public static FieldInfo[] GetFields(Type datablockType)
    {
        var fields = new List <FieldInfo>();

        foreach (FieldInfo field in datablockType.GetFields(BindingFlags.Public | BindingFlags.Instance))
        {
            if (!IsValidMemberType(field))
            {
                continue;
            }

            if (!(field.DeclaringType == typeof(Datablock) || field.DeclaringType.IsSubclassOf(typeof(Datablock))))
            {
                continue;
            }

            if (field.DeclaringType == typeof(Datablock))
            {
                continue;
            }

            fields.Add(field);
        }

        return(fields.OrderBy(property => OrderAttribute.GetMemberOrder(property)).ToArray());
    }
Пример #5
0
 private void invokeSampleMethod(MethodInfo method, OrderAttribute attr)
 {
     if (method.GetParameters().Count() == 0)
     {
         dynamic returnObj = method.Invoke(_tempInstance, null);
         if (isSimpleField(method.ReturnType))
         {
             ColumnBindingAttribute colAttr = attr as ColumnBindingAttribute;
             if (colAttr != null && colAttr.Directory == DataDirectory.Output)
             {
                 resetColumnName(method, colAttr);
                 if (_sampleDic.ContainsKey(colAttr.ColNames[0]))
                 {
                     _sampleDic[colAttr.ColNames[0]] = returnObj;
                 }
                 else
                 {
                     _sampleDic.Add(colAttr.ColNames[0], returnObj);
                 }
             }
         }
         else if (method.ReturnType.IsClass)
         {
             runRecusion(returnObj);
         }
     }
 }
Пример #6
0
        public static BaseEnumItem[] enumToArray(Type source)
        {
            ArrayList <BaseEnumItem>       items        = new ArrayList <BaseEnumItem>();
            SortedList <int, BaseEnumItem> _sortedItems = new SortedList <int, BaseEnumItem>();
            int  sortIndex = 0;
            bool autoOrder = true;

            try
            {
                FieldInfo[] fields = source.GetFields(BindingFlags.Static | BindingFlags.GetField | BindingFlags.Public);
                foreach (FieldInfo field in fields)
                {
                    int    value = (int)field.GetValue(null);
                    string name  = Enum.GetName(source, value);
                    autoOrder = (field.GetCustomAttributes(typeof(OrderAttribute), false) != null);

                    foreach (Attribute attrib in field.GetCustomAttributes(true))
                    {
                        if (attrib is NameAttribute)
                        {
                            NameAttribute at = (NameAttribute)attrib;
                            name = at.Name;
                        }
                        if (attrib is OrderAttribute)
                        {
                            OrderAttribute at = (OrderAttribute)attrib;
                            sortIndex = at.Order;
                        }
                    }

                    items.put(new BaseEnumItem(value, name));

                    if (!autoOrder)
                    {
                        _sortedItems.Add(sortIndex, new BaseEnumItem(value, name));
                    }
                    else
                    {
                        _sortedItems.Add(sortIndex++, new BaseEnumItem(value, name));
                    }
                }

                if (_sortedItems.Count != 0)
                {
                    BaseEnumItem[] ret = new BaseEnumItem[_sortedItems.Count];
                    _sortedItems.Values.CopyTo(ret, 0);
                    return(ret);
                }

                return(items.toArray());
            }
            catch (Exception ex)
            {
                throw ex;
            }
            finally
            {
            }
        }
Пример #7
0
        public async Task <ActionResult <Guid> > Create(OrderAttribute attribute, CancellationToken ct = default)
        {
            attribute.AccountId = _userContext.AccountId;

            var id = await _orderAttributesService.CreateAsync(_userContext.UserId, attribute, ct);

            return(Created(nameof(Get), id));
        }
Пример #8
0
    public static int GetOrder(this Enum value)
    {
        FieldInfo      fieldInfo = value.GetType().GetField(value.ToString());
        OrderAttribute attribute =
            fieldInfo.GetCustomAttributes(typeof(OrderAttribute), false).FirstOrDefault() as OrderAttribute;

        return(attribute == null ? -1 : attribute.Order);
    }
Пример #9
0
        private void SetProperty(object instance, XElement root, IReflectionProperty property)
        {
            if (property.IsPrimitive || property.IsNullable)
            {
                if (instance != null)
                {
                    SetPrimitiveProperty(property, instance, root);
                }
            }

            if (property.IsClass)
            {
                var    type  = Reflector.Get(property.Type);
                object value = null;
                if (property.CanRead)
                {
                    value = property.Get(instance);
                }

                if (value == null)
                {
                    if (property.CanWrite)
                    {
                        value = type.CreateInstance();
                    }
                }

                if (value != null)
                {
                    var properties = type.Properties.OrderBy(
                        p =>
                    {
                        OrderAttribute priority = p.Attributes.SingleOrDefault(x => x is OrderAttribute) as OrderAttribute;

                        return(priority != null ? priority.Value : int.MaxValue);
                    }).ToList();

                    XmlPropertyAttribute attribute = (XmlPropertyAttribute)property.Attributes.SingleOrDefault(x => x is XmlPropertyAttribute);

                    var propertyName = property.Name;

                    if (attribute != null && !string.IsNullOrWhiteSpace(attribute.Name))
                    {
                        propertyName = attribute.Name;
                    }

                    var element = root.Element(propertyName);

                    if (element != null)
                    {
                        this.SetPropertiesValue(properties, value, element);
                    }
                }
            }
        }
        /// <summary>
        /// Gets the registration order based on position in sequence in <seealso cref="Employment.Web.Mvc.Infrastructure.DataAnnotations.OrderAttribute" />.
        /// </summary>
        /// <param name="registration">The registration object.</param>
        /// <returns>The position in sequence.</returns>
        public static int Order(this IRegistration registration)
        {
            var orderAttribute = registration.GetType().GetAttribute <OrderAttribute>();

            if (orderAttribute == null)
            {
                orderAttribute = new OrderAttribute();
            }

            return(orderAttribute.PositionInSequence);
        }
Пример #11
0
        private void SetRootValue(IReflectionType reflectionType, object instance, XElement root)
        {
            var properties = reflectionType.Properties.OrderBy(
                p =>
            {
                OrderAttribute priority = p.Attributes.SingleOrDefault(x => x is OrderAttribute) as OrderAttribute;

                return(priority != null ? priority.Value : int.MaxValue);
            }).ToList();

            SetPropertiesValue(properties, instance, root);
        }
        /// <summary>
        /// Gets the registration group based on first in sequence in <seealso cref="Employment.Web.Mvc.Infrastructure.DataAnnotations.OrderAttribute" />.
        /// </summary>
        /// <param name="registration">The registration object.</param>
        /// <returns>The group.</returns>
        public static int Group(this IRegistration registration)
        {
            var orderAttribute = registration.GetType().GetAttribute <OrderAttribute>();

            if (orderAttribute == null)
            {
                orderAttribute = new OrderAttribute();
            }

            // Invert bool and convert to int (true = 0, false = 1)
            return(Convert.ToInt32(!orderAttribute.FirstInSequence));
        }
        public void TestItAllowsIterationOfAttributesInOrder()
        {
            var attrs = OrderAttribute.GetSortedProperties(typeof(HasSomeAttrs));

            Assert.AreEqual("IntAttr", attrs.ElementAt(0).Name);
            Assert.AreEqual("StringAttr", attrs.ElementAt(1).Name);
            Assert.AreEqual("FloatAttr", attrs.ElementAt(2).Name);

            var thirdAttr = OrderAttribute.GetPropertyByOrder(typeof(HasSomeAttrs), 3);

            Assert.AreEqual("FloatAttr", thirdAttr.Name);
        }
Пример #14
0
 public OrderAttributeBuilder(
     IDefaultRequestHeadersService defaultRequestHeadersService,
     IOrderAttributesClient orderAttributesClient)
 {
     _orderAttributesClient        = orderAttributesClient;
     _defaultRequestHeadersService = defaultRequestHeadersService;
     _attribute = new OrderAttribute
     {
         Id        = Guid.NewGuid(),
         Type      = AttributeType.Text,
         Key       = "Test".WithGuid(),
         IsDeleted = false
     };
 }
Пример #15
0
        public async Task <ActionResult> Update(OrderAttribute attribute, CancellationToken ct = default)
        {
            var oldAttribute = await _orderAttributesService.GetAsync(attribute.Id, true, ct);

            if (oldAttribute == null)
            {
                return(NotFound(attribute.Id));
            }

            return(await ActionIfAllowed(
                       () => _orderAttributesService.UpdateAsync(_userContext.UserId, oldAttribute, attribute, ct),
                       Roles.Orders,
                       oldAttribute.AccountId));
        }
Пример #16
0
        public byte[] Serialize <T>(T input) where T : SampleData
        {
            List <byte> ret = new List <byte>();
            SortedList <int, PropertyInfo> memo = new SortedList <int, PropertyInfo>();
            Type type       = input.GetType();
            var  properties = type.GetProperties();

            if (properties != null)
            {
                foreach (var propertyInfo in properties)
                {
                    OrderAttribute orderInfo = propertyInfo.GetCustomAttribute(typeof(OrderAttribute)) as OrderAttribute;
                    if (orderInfo != null)
                    {
                        memo.Add(orderInfo.Position, propertyInfo);
                    }
                }

                foreach (var t in memo)
                {
                    var property = t.Value.GetValue(input);
                    switch (property)
                    {
                    case DateTime d:
                        ret.AddRange(DateTimeToBytes(d));
                        break;

                    case string s:
                        //get max length that specified in attribute
                        var strAtt = t.Value.GetCustomAttribute(typeof(StringLengthAttribute)) as StringLengthAttribute;
                        ret.AddRange(StrToBytes(s, strAtt.MaximumLength));
                        break;

                    case int i:
                        ret.AddRange(IntToBytes(i));
                        break;

                    case SampleFlags f:
                        ret.AddRange(FlagsToBytes(f));
                        break;
                    }
                }
            }
            if (!BitConverter.IsLittleEndian)
            {
                ret.Reverse();
            }

            return(ret.ToArray());
        }
Пример #17
0
        public IEnumerable <Book> GetBooks(string searchBy, string filterBy, string orderBy)
        {
            using (SqlConnection conn = new SqlConnection(this.DBString))
            {
                using (SqlCommand cmd = new SqlCommand("spGetBooks", conn)
                {
                    CommandType = CommandType.StoredProcedure
                })
                {
                    cmd.Parameters.AddWithValue("@search", searchBy.Trim().ToLower());
                    cmd.Parameters.AddWithValue("@filter", FilterAttribute.GetAttribute(filterBy));
                    cmd.Parameters.AddWithValue("@order", OrderAttribute.GetAttribute(orderBy));

                    try
                    {
                        conn.Open();
                        SqlDataReader rdr = cmd.ExecuteReader();
                        if (rdr.HasRows)
                        {
                            List <Book> bookList = new List <Book>();
                            while (rdr.Read())
                            {
                                bookList.Add(new Book
                                {
                                    id             = Convert.ToInt32(rdr["id"]),
                                    authorName     = rdr["auther_name"].ToString(),
                                    bookDetail     = rdr["book_detail"].ToString(),
                                    bookImageSrc   = rdr["book_image_src"].ToString(),
                                    bookName       = rdr["book_name"].ToString(),
                                    bookPrice      = Convert.ToInt32(rdr["book_price"]),
                                    isbnNumber     = rdr["isbn_number"].ToString(),
                                    noOfCopies     = Convert.ToInt32(rdr["no_of_copies"]),
                                    publishingYear = Convert.ToInt32(rdr["publishing_year"])
                                });
                            }
                            return(bookList);
                        }
                    }
                    catch
                    {
                        return(null);
                    }
                    finally
                    {
                        conn.Close();
                    }
                }
            }
            return(null);
        }
Пример #18
0
 public BaseReferenceContextProvider(ConfiguredProject configuredProject)
 {
     ConfiguredProject       = configuredProject;
     VsReferenceManagerUsers = new OrderPrecedenceImportCollection <IVsReferenceManagerUserAsync, IVsReferenceManagerUserComponentMetadataView>(projectCapabilityCheckProvider: configuredProject);
     _nextHandler            = new Lazy <Lazy <IVsReferenceManagerUserAsync, IVsReferenceManagerUserComponentMetadataView> >(() =>
     {
         Type provider        = GetType();
         OrderAttribute order = provider.GetCustomAttribute <OrderAttribute>();
         ExportIVsReferenceManagerUserAsyncAttribute user = provider.GetCustomAttribute <ExportIVsReferenceManagerUserAsyncAttribute>();
         return(VsReferenceManagerUsers.FirstOrDefault(
                    export =>
                    export.Metadata.OrderPrecedence < order.OrderPrecedence &&
                    export.Metadata.ProviderContextIdentifier == user.ProviderContextIdentifier));
     });
 }
Пример #19
0
        public static OrderAttributeChange CreateWithLog(
            this OrderAttribute attribute,
            Guid userId,
            Action <OrderAttribute> action)
        {
            action(attribute);

            return(new OrderAttributeChange
            {
                AttributeId = attribute.Id,
                ChangerUserId = userId,
                CreateDateTime = DateTime.UtcNow,
                OldValueJson = string.Empty,
                NewValueJson = attribute.ToJsonString()
            });
        }
Пример #20
0
        private static void AppendField(SortedList <uint, FieldDesc> fields, MemberInfo mi)
        {
            OrderAttribute fAttr = mi.GetAttr <OrderAttribute>();

            if (fAttr == null)
            {
                return;
            }

            if (fields.ContainsKey(fAttr.Order))
            {
                throw new InvalidOperationException("duplicate order " + fAttr.Order);
            }

            fields.Add(fAttr.Order, new FieldDesc(mi));
        }
        public static T[] SortEnum <T>()
        {
            Type myEnumType = typeof(T);
            var  enumValues = Enum.GetValues(myEnumType).Cast <T>().ToArray();
            var  enumNames  = Enum.GetNames(myEnumType);

            int[] enumPositions = Array.ConvertAll(enumNames, n =>
            {
                OrderAttribute orderAttr = (OrderAttribute)myEnumType.GetField(n)
                                           .GetCustomAttributes(typeof(OrderAttribute), false)[0];
                return(orderAttr.Order);
            });

            Array.Sort(enumPositions, enumValues);

            return(enumValues);
        }
        public virtual void UpdateOrderAttribute(OrderAttribute orderAttribute)
        {
            if (orderAttribute == null)
            {
                throw new ArgumentNullException(nameof(orderAttribute));
            }

            _orderAttributeRepository.Update(orderAttribute);

            //cache
            _cacheManager.RemoveByPattern(ORDERATTRIBUTES_PATTERN_KEY);
            _cacheManager.RemoveByPattern(ORDERATTRIBUTEMAPPINGS_PATTERN_KEY);
            _cacheManager.RemoveByPattern(ORDERATTRIBUTEVALUES_PATTERN_KEY);
            _cacheManager.RemoveByPattern(ORDERATTRIBUTECOMBINATIONS_PATTERN_KEY);

            //event notification
            _eventPublisher.EntityUpdated(orderAttribute);
        }
Пример #23
0
        /// <summary>
        /// Generates the labeled list for the enum type.
        /// </summary>
        static private NamedItemList <Enum> CreateLabeledList(Type inType, bool inbSorted = false)
        {
            NamedItemList <Enum> itemList = new NamedItemList <Enum>();

            foreach (var field in inType.GetFields(BindingFlags.Static | BindingFlags.Public | BindingFlags.DeclaredOnly))
            {
                if (field.IsDefined(typeof(HiddenAttribute)) || field.IsDefined(typeof(ObsoleteAttribute)))
                {
                    continue;
                }

                LabelAttribute labeledAttr = (LabelAttribute)field.GetCustomAttribute(typeof(LabelAttribute));
                OrderAttribute orderAttr   = (OrderAttribute)field.GetCustomAttribute(typeof(OrderAttribute));

                string name;
                int    order;
                Enum   val = (Enum)field.GetValue(null);

                if (labeledAttr != null)
                {
                    name = labeledAttr.Name;
                }
                else
                {
                    name = ObjectNames.NicifyVariableName(val.ToString());
                }

                if (orderAttr != null)
                {
                    order = orderAttr.Order;
                }
                else if (inbSorted)
                {
                    order = 100;
                }
                else
                {
                    order = Convert.ToInt32(val);
                }

                itemList.Add(val, name, order);
            }
            return(itemList);
        }
Пример #24
0
        public async Task UpdateAsync(
            Guid userId,
            OrderAttribute oldAttribute,
            OrderAttribute newAttribute,
            CancellationToken ct)
        {
            var change = oldAttribute.UpdateWithLog(userId, x =>
            {
                x.Type           = newAttribute.Type;
                x.Key            = newAttribute.Key;
                x.IsDeleted      = newAttribute.IsDeleted;
                x.ModifyDateTime = DateTime.UtcNow;
            });

            _storage.Update(oldAttribute);
            await _storage.AddAsync(change, ct);

            await _storage.SaveChangesAsync(ct);
        }
Пример #25
0
        private static XElement BuildPropertyRoot(object instance, IReflectionProperty rootProperty)
        {
            IReflectionType reflectionType = Reflector.Get(instance.GetType());
            XElement        root           = BuildElement(rootProperty);
            var             properties     = reflectionType.Properties.OrderBy(
                p =>
            {
                OrderAttribute priority = p.Attributes.SingleOrDefault(x => x is OrderAttribute) as OrderAttribute;

                return(priority != null ? priority.Value : int.MaxValue);
            }).ToList();

            foreach (var property in properties)
            {
                AddProperty(instance, root, property);
            }

            return(root);
        }
Пример #26
0
        public static void BindInstance(Type serviceType, Type implmentedType, string name, ILifetime lifetime, int?order = null)
        {
            MethodInfo bindInstanceMethod      = MakeGenericBindMethod(serviceType);
            MethodInfo implementInstanceMethod = MakeGenericToMethod(serviceType, implmentedType);

            MethodCallExpression methodCallExpression = Expression.Call(bindInstanceMethod, new Expression[] { Expression.Constant(name, typeof(string)) });

            Func <IBindingInfo> binder  = Expression.Lambda <Func <IBindingInfo> >(methodCallExpression).Compile();
            IBindingInfo        binding = binder();

            MethodInfo           containsMethod         = MakeGenericContainsMethod(serviceType);
            MethodCallExpression containsCallExpression = Expression.Call(containsMethod, new Expression[] { Expression.Constant(name, typeof(string)) });
            Func <bool>          containsFunc           = Expression.Lambda <Func <bool> >(containsCallExpression).Compile();

            if (containsFunc())
            {
                if (order == null)
                {
                    OrderAttribute priorityAttribute = implmentedType.GetCustomAttribute <OrderAttribute>();

                    int priority = priorityAttribute != null ? priorityAttribute.Value : int.MaxValue;

                    if (binding.Order.HasValue && priority < binding.Order.Value)
                    {
                        return;
                    }

                    binding.Order = priority;
                }
                else
                {
                    binding.Order = order;
                }
            }

            MethodCallExpression implementCallExpression = Expression.Call(Expression.Constant(binding), implementInstanceMethod);
            Func <IBindingInfo>  implementer             = Expression.Lambda <Func <IBindingInfo> >(implementCallExpression).Compile();

            binding = implementer();
            binding.LifetimeManager = lifetime;
        }
Пример #27
0
        public async Task <Guid> CreateAsync(Guid userId, OrderAttribute attribute, CancellationToken ct)
        {
            var newAttribute = new OrderAttribute();
            var change       = newAttribute.CreateWithLog(userId, x =>
            {
                x.Id             = attribute.Id;
                x.AccountId      = attribute.AccountId;
                x.Type           = attribute.Type;
                x.Key            = attribute.Key;
                x.IsDeleted      = attribute.IsDeleted;
                x.CreateDateTime = DateTime.UtcNow;
            });

            var entry = await _storage.AddAsync(newAttribute, ct);

            await _storage.AddAsync(change, ct);

            await _storage.SaveChangesAsync(ct);

            return(entry.Entity.Id);
        }
Пример #28
0
        private static IEnumerable <ApiControllerDefination> FindDependenciesType(IReadOnlyList <Assembly> assemblies)
        {
            List <ApiControllerDefination> list = new List <ApiControllerDefination>();

            foreach (Assembly assembly in assemblies)
            {
                foreach (var type in assembly.GetExportableLoadableTypes())
                {
                    if (IsWebController(type))
                    {
                        ApiControllerDefination defination = new ApiControllerDefination(type);

                        OrderAttribute priorityAttribute = type.GetCustomAttribute <OrderAttribute>();
                        defination.TypePriority = priorityAttribute == null ? int.MaxValue : priorityAttribute.Value;

                        list.Add(defination);
                    }
                }
            }

            return(list);
        }
Пример #29
0
        public void DataBinding(Tuple <string, BindingType> BindingMember)
        {
            dba = me.GetCustomAttributes(typeof(DataBindingAttribute), true).FirstOrDefault() as DataBindingAttribute;
            if (dba != null)
            {
                dba.TableName = string.IsNullOrEmpty(dba.TableName) ? me.Name : dba.TableName;
                MemberInfo mi = null;
                switch (BindingMember.Item2)
                {
                case BindingType.Method:
                    mi = me.GetMethod(BindingMember.Item1);
                    break;

                default:
                    mi = me.GetProperty(BindingMember.Item1);
                    break;
                }
                if (mi != null)
                {
                    OrderAttribute oa = mi.GetCustomAttributes(typeof(OrderAttribute), true).FirstOrDefault() as OrderAttribute;
                    if (oa != null)
                    {
                        List <Tuple <MemberInfo, OrderAttribute> > memberList = new List <Tuple <MemberInfo, OrderAttribute> >()
                        {
                            new Tuple <MemberInfo, OrderAttribute>(mi, oa)
                        };

                        if (IsUsingSampleData)
                        {
                            sampleDataBinding(memberList);
                        }
                        else
                        {
                            tableDataBinding(memberList);
                        }
                    }
                }
            }
        }
Пример #30
0
        static public int OrderSort(FieldInfo p_field1, FieldInfo p_field2)
        {
            OrderAttribute attribute1 = p_field1.GetCustomAttribute <OrderAttribute>();
            OrderAttribute attribute2 = p_field2.GetCustomAttribute <OrderAttribute>();

            if (attribute1 == null && attribute2 == null)
            {
                return(0);
            }

            if (attribute1 != null && attribute2 == null)
            {
                return(-1);
            }

            if (attribute1 == null && attribute2 != null)
            {
                return(1);
            }

            return(attribute1.Order.CompareTo(attribute2.Order));
        }