private static void AddUnCodedAttribute(IDataStructureMutableObject dsdMutableObject, string conceptId)
 {
     var attributeMutableObject =
         dsdMutableObject.AddAttribute(new StructureReferenceImpl(agencyId: dsdMutableObject.AgencyId, maintainableId: "TEST_CS", version: "1.0", targetStructureEnum: SdmxStructureEnumType.Concept, identfiableIds: conceptId), null);
     attributeMutableObject.AttachmentLevel = AttributeAttachmentLevel.Group;
     attributeMutableObject.AttachmentGroup = "Sibling";
     attributeMutableObject.AssignmentStatus = "Conditional";
 }
        private IDataStructureMutableObject ReOrderAttribute(IDataStructureMutableObject dsMut, IAttributeMutableObject attMut, int inputOrder)
        {
            var sortedAttributes = dsMut.AttributeList.Attributes.OrderBy(
            o =>
            {
                var corder = o.Annotations.FirstOrDefault(mutableObject => string.Equals(mutableObject.Type, "@ORDER@"));
                return corder != null ? int.Parse(corder.Text[0].Value) : 0;
            }).ToArray();

            dsMut.Attributes.Clear();

            int orderID = 1;

            IAnnotationMutableObject annOrder;

            foreach (IAttributeMutableObject att in sortedAttributes)
            {
                if (orderID == inputOrder)
                {
                    annOrder = attMut.Annotations.Where(a => a.Type == "@ORDER@").FirstOrDefault();

                    if (annOrder != null)
                        attMut.Annotations.Remove(annOrder);

                    attMut.Annotations.Add(CreateAnnotation("order" + orderID.ToString(),
                                                        "",
                                                        "@ORDER@",
                                                        "", new List<ITextTypeWrapperMutableObject>(){
                                                            new TextTypeWrapperMutableCore("en",orderID.ToString()) }
                                                         )
                                        );
                    dsMut.AddAttribute(attMut);

                    ++orderID;
                }

                annOrder = att.Annotations.Where(a => a.Type == "@ORDER@").FirstOrDefault();

                if (annOrder != null)
                    att.Annotations.Remove(annOrder);

                att.Annotations.Add(CreateAnnotation("order" + orderID.ToString(),
                                                    "",
                                                    "@ORDER@",
                                                    "", new List<ITextTypeWrapperMutableObject>(){
                                                            new TextTypeWrapperMutableCore("en",orderID.ToString()) }
                                                     )
                                    );
                dsMut.AddAttribute(att);

                ++orderID;
            }

            if (orderID <= inputOrder)
            {
                annOrder = attMut.Annotations.Where(a => a.Type == "@ORDER@").FirstOrDefault();

                if (annOrder != null)
                    attMut.Annotations.Remove(annOrder);

                attMut.Annotations.Add(CreateAnnotation("order" + orderID.ToString(),
                                                    "",
                                                    "@ORDER@",
                                                    "", new List<ITextTypeWrapperMutableObject>(){
                                                            new TextTypeWrapperMutableCore("en",orderID.ToString()) }
                                                     )
                                    );
                dsMut.AddAttribute(attMut);
            }

            return dsMut;
        }