Beispiel #1
0
        public ActionResult CreateNew()
        {
            var model = new TypeCategory();

            model.Status = true;
            return(View(model));
        }
        public async Task <IActionResult> PutTypeCategory([FromRoute] int id, [FromBody] TypeCategory typeCategory)
        {
            if (!ModelState.IsValid)
            {
                return(BadRequest(ModelState));
            }

            if (id != typeCategory.Id_type)
            {
                return(BadRequest());
            }

            _context.Entry(typeCategory).State = EntityState.Modified;

            try
            {
                await _context.SaveChangesAsync();
            }
            catch (DbUpdateConcurrencyException)
            {
                if (!TypeCategoryExists(id))
                {
                    return(NotFound());
                }
                else
                {
                    throw;
                }
            }

            return(NoContent());
        }
        private object ProcessEnumValue()
        {
            object val = null;

            var useAlternateXml = Cache.GetAttribute <TypeLookupAttribute>()?.Class == typeof(XmlEnumAlternateName);

            if (useAlternateXml)
            {
                val = ParseEnumValue <XmlEnumAlternateName>();
            }
            else
            {
                val = ParseEnumValue <XmlEnumAttribute>();
            }

            if (val == null)
            {
                throw GetEnumArgumentException();
            }
            else
            {
                Type = TypeCategory.Enum;
            }

            return(val);
        }
Beispiel #4
0
        public void InsertTypeDigest(TypeDigest type)
        {
            ResetTypeCache(type);

            if (type.TypeCategoryId == GetRootCategoryTypeDigest().Match(() => - 1, t => t.Id))
            {
                Connect(
                    ctx => {
                    ctx.TypeDigests.Add(type);
                    ctx.SaveChanges();

                    TypeCategory newCategory = new TypeCategory()
                    {
                        Id          = type.Id,
                        TypeTableId = type.TypeTableId
                    };
                    ctx.TypeCategories.Add(newCategory);
                    ctx.SaveChanges();

                    return(Unit());
                }
                    );
            }
            else
            {
                Connect(
                    ctx => {
                    ctx.TypeDigests.Add(type);
                    ctx.SaveChanges();
                    return(Unit());
                }
                    );
            }
        }
 public static string GetTypeCategoryDisplayString(TypeCategory type)
 {
     if (type == TypeCategory.StaticClass)
     {
         return "static class";
     }
     else if (type == TypeCategory.AbstractClass)
     {
         return "abstract class";
     }
     else if (type == TypeCategory.Class)
     {
         return "class";
     }
     else if (type == TypeCategory.Enum)
     {
         return "enum";
     }
     else if (type == TypeCategory.Interface)
     {
         return "interface";
     }
     else if (type == TypeCategory.Struct)
     {
         return "struct";
     }
     else
     {
         return "";
     }
 }
        private object ParseBoolValue()
        {
            object val = null;

            //If ValueType is bool, we must be serialize mode as in DeserializeMode we would have shortcut out of ParseValue
            //immediately due to PropertyType and ValueType both being bool
            if (ValueType == typeof(bool))
            {
                Type = TypeCategory.Boolean;

                val = Convert.ToInt32((bool)OriginalValue);
            }
            else
            {
                bool boolVal;

                //OriginalValue is implicitly not null because if it were ProcessNonNullable would have escaped
                //to ValueConversionWithNullCheck
                if (TryParseBool(OriginalValue.ToString(), out boolVal))
                {
                    Type = TypeCategory.Boolean;

                    if (Mode == SerializationMode.Deserialize)
                    {
                        val = boolVal;
                    }
                    else
                    {
                        val = Convert.ToInt32(boolVal);
                    }
                }
            }

            return(val);
        }
        private ConversionState DeserializeISerializable()
        {
            var expectedTypeAttribute = Property.GetEnumAttribute <TypeAttribute>();

            if (expectedTypeAttribute != null)
            {
                if (!typeof(ISerializable).IsAssignableFrom(expectedTypeAttribute.Class))
                {
                    throw new InvalidOperationException($"Property '{Property}' has a {nameof(TypeAttribute)} of type '{expectedTypeAttribute.Class}' which does not implement '{typeof(ISerializable)}'. This represents an internal bug that must be corrected.");
                }

                if (OriginalValue != null)
                {
                    //If someone specifies the ACTUALLY serialized form of a value, we don't actually support deserializing that
                    //(e.g. "3 days" for a ScanningInterval, however as currently designed we don't actually use deserialization
                    //in DynamicPropertyTypeParser for anything but transforming "normal" user input
                    if (expectedTypeAttribute.Class.IsAssignableFrom(ValueType))
                    {
                        Type     = TypeCategory.Other;
                        NewValue = OriginalValue;
                        return(ConversionState.ValueConversion);
                    }
                    else
                    {
                        throw new InvalidTypeException($"Expected a value of type '{expectedTypeAttribute.Class}' while parsing property '{Property}' however received a value of type '{ValueType}'.");
                    }
                }
                else
                {
                    return(ConversionState.ValueConversionWithNullCheck);
                }
            }

            return(MoveNext());
        }
Beispiel #8
0
 public ComponentType(Type type, int size, TypeCategory category, FastEquality.Layout[] layout)
 {
     Type               = type;
     SizeInChunk        = size;
     Category           = category;
     FastEqualityLayout = layout;
 }
Beispiel #9
0
 private string GetChangeManagedNameActionResult(TypeInfo typeInfo,
                                                 ConvType convType, string oldName)
 {
     if (Settings.m_ruleSet != null)
     {
         ICategory           category = TypeCategory.GetInstance();
         TypeInfoMatchTarget target   = null;
         using (TypeAttr attr = typeInfo.GetTypeAttr())
         {
             TypeLibTypes.Interop.TYPEKIND kind = attr.typekind;
             target = new TypeInfoMatchTarget(typeInfo.GetContainingTypeLib(), typeInfo, kind);
         }
         AbstractActionManager actionManager   = RuleEngine.GetActionManager();
         List <Rule>           changeNameRules = Settings.m_ruleSet.GetRule(
             category, ChangeManagedNameActionDef.GetInstance(), target);
         if (changeNameRules.Count != 0)
         {
             if (changeNameRules.Count > 1)
             {
                 Output.WriteWarning(Resource.FormatString("Wrn_RuleMultipleMatch",
                                                           ChangeManagedNameActionDef.GetInstance()),
                                     WarningCode.Wrn_RuleMultipleMatch);
             }
             Rule   changeNameRule = changeNameRules[changeNameRules.Count - 1];
             int    namespaceSplit = oldName.LastIndexOf('.');
             string oldNamespace   = "";
             if (namespaceSplit != -1)
             {
                 oldNamespace = oldName.Substring(0, namespaceSplit + 1);
             }
             return(oldNamespace + (changeNameRule.Action as ChangeManagedNameAction).NewName);
         }
     }
     return(oldName);
 }
Beispiel #10
0
 public static string GetTypeCategoryDisplayString(TypeCategory type)
 {
     if (type == TypeCategory.StaticClass)
     {
         return("static class");
     }
     else if (type == TypeCategory.AbstractClass)
     {
         return("abstract class");
     }
     else if (type == TypeCategory.Class)
     {
         return("class");
     }
     else if (type == TypeCategory.Enum)
     {
         return("enum");
     }
     else if (type == TypeCategory.Interface)
     {
         return("interface");
     }
     else if (type == TypeCategory.Struct)
     {
         return("struct");
     }
     else
     {
         return(string.Empty);
     }
 }
Beispiel #11
0
        public static TypePattern MapToPattern(this TypeCategory category)
        {
            switch (category)
            {
            case TypeCategory.@struct:
                return(TypePattern.NonMarshalledStruct);

            case TypeCategory.@enum:
            case TypeCategory.bitmask:
                return(TypePattern.Enum);

            case TypeCategory.funcpointer:
                return(TypePattern.Delegate);

            case TypeCategory.None:
            case TypeCategory.basetype:
                return(TypePattern.Primitive);

            case TypeCategory.handle:
                return(TypePattern.Handle);

            case TypeCategory.union:
                return(TypePattern.Union);

            default:
                throw new NotSupportedException();
            }
        }
Beispiel #12
0
 private Info(string name, NanoLocation location, TypeCategory category, Type[] genericArgs)
 {
     Name        = name;
     Location    = location;
     Category    = category;
     GenericArgs = genericArgs;
 }
Beispiel #13
0
 public SimpleType(TypeCategory category, string fullname, IEnumerable <string> attributes, IEnumerable <SimpleType> methods)
 {
     Category   = category;
     Fullname   = fullname;
     Attributes = attributes;
     Methods    = methods;
 }
Beispiel #14
0
        private void InitializeTypeReferenceGroup(PersonalDataContext ctx)
        {
            TypeReferenceGroup = new TypeDigest()
            {
                ParentType = TypeRootCategory,
                Category   = TypeCategoryRootCategory,

                Code      = "ReferenceGroup",
                BCode     = "ReferenceGroup",
                Name      = "Категория хранения типов указателей на данные (указатели на типы, данные по действиям, константы или другие типы, наследуемые от указателей)",
                TypeTable = TypeTableRootCategory,
                Note      = null,
                Edit      = _defaultOpen,
                Open      = _defaultOpen,
                Close     = _defaultClose,
                Order     = 1
            };
            ctx.TypeDigests.Add(TypeReferenceGroup);
            ctx.SaveChanges();

            TypeCategoryReferenceGroup = new TypeCategory()
            {
                Id        = TypeReferenceGroup.Id,
                TypeTable = null
            };
            ctx.TypeCategories.Add(TypeCategoryReferenceGroup);
            ctx.SaveChanges();

            TypeReferenceType = new TypeDigest()
            {
                ParentType = null,
                Category   = TypeCategoryReferenceGroup,
                Code       = "TypeReference",
                BCode      = "TypeReference",
                Name       = "Указатель на типы из drType",
                TypeTable  = null,
                Note       = null,
                Edit       = _defaultOpen,
                Open       = _defaultOpen,
                Close      = _defaultClose,
                Order      = 1
            };
            TypeReferenceConst = new TypeDigest()
            {
                ParentType = null,
                Category   = TypeCategoryReferenceGroup,
                Code       = "ConstReference",
                BCode      = "ConstReference",
                Name       = "Указатель на константу",
                TypeTable  = null,
                Note       = null,
                Edit       = _defaultOpen,
                Open       = _defaultOpen,
                Close      = _defaultClose,
                Order      = 3
            };
            ctx.TypeDigests.AddRange(new[] { TypeReferenceType, TypeReferenceConst });
            ctx.SaveChanges();
        }
Beispiel #15
0
        private void InitializeTypeExpressionNode(PersonalDataContext ctx)
        {
            TypeExpressionNodeCategory = new TypeDigest()
            {
                ParentType = TypeRootCategory,
                Category   = TypeCategoryRootCategory,

                Code      = "ExpressionNodeTypeCategory",
                BCode     = "ExpressionNodeTypeCategory",
                Name      = "Категория для типов узлов выражений",
                TypeTable = TypeTableRootCategory,
                Note      = null,
                Edit      = _defaultOpen,
                Open      = _defaultOpen,
                Close     = _defaultClose,
                Order     = 1
            };
            ctx.TypeDigests.Add(TypeExpressionNodeCategory);
            ctx.SaveChanges();

            TypeCategoryExpressionNode = new TypeCategory()
            {
                Id        = TypeExpressionNodeCategory.Id,
                TypeTable = null
            };
            ctx.TypeCategories.Add(TypeCategoryExpressionNode);
            ctx.SaveChanges();

            TypeExpressionNodeReference = new TypeDigest()
            {
                ParentType = null,
                Category   = TypeCategoryExpressionNode,
                Code       = "ReferenceExpressionNode",
                BCode      = "ReferenceExpressionNode",
                Name       = "Узел хранит указатель на значение",
                TypeTable  = null,
                Note       = null,
                Edit       = _defaultOpen,
                Open       = _defaultOpen,
                Close      = _defaultClose,
                Order      = 1
            };
            TypeExpressionNodeOperator = new TypeDigest()
            {
                ParentType = null,
                Category   = TypeCategoryExpressionNode,
                Code       = "OperatorExpressionNode",
                BCode      = "OperatorExpressionNode",
                Name       = "Указатель на оператор",
                TypeTable  = null,
                Note       = null,
                Edit       = _defaultOpen,
                Open       = _defaultOpen,
                Close      = _defaultClose,
                Order      = 2
            };
            ctx.TypeDigests.AddRange(new[] { TypeExpressionNodeReference, TypeExpressionNodeOperator });
            ctx.SaveChanges();
        }
            public TypeInfo(Type type, int typeIndex, int size, TypeCategory category, FastEquality.TypeInfo typeInfo, EntityOffsetInfo[] entityOffsets, EntityOffsetInfo[] blobAssetRefOffsets, ulong memoryOrdering, int bufferCapacity, int elementSize, int alignmentInBytes, ulong stableTypeHash, int *writeGroups, int writeGroupCount, int maximumChunkCapacity)
            {
                Type                    = type;
                TypeIndex               = typeIndex;
                SizeInChunk             = size;
                Category                = category;
                FastEqualityTypeInfo    = typeInfo;
                EntityOffsetCount       = entityOffsets?.Length ?? 0;
                EntityOffsets           = entityOffsets;
                BlobAssetRefOffsetCount = blobAssetRefOffsets?.Length ?? 0;
                BlobAssetRefOffsets     = blobAssetRefOffsets;
                MemoryOrdering          = memoryOrdering;
                BufferCapacity          = bufferCapacity;
                ElementSize             = elementSize;
                AlignmentInBytes        = alignmentInBytes;
                StableTypeHash          = stableTypeHash;
                WriteGroups             = writeGroups;
                WriteGroupCount         = writeGroupCount;
                MaximumChunkCapacity    = maximumChunkCapacity;
                // System state shared components are also considered system state components
                bool isSystemStateSharedComponent = typeof(ISystemStateSharedComponentData).IsAssignableFrom(type);
                bool isSystemStateBufferElement   = typeof(ISystemStateBufferElementData).IsAssignableFrom(type);
                bool isSystemStateComponent       = isSystemStateSharedComponent || isSystemStateBufferElement || typeof(ISystemStateComponentData).IsAssignableFrom(type);

                if (typeIndex != 0)
                {
                    if (SizeInChunk == 0)
                    {
                        TypeIndex |= ZeroSizeTypeFlag;
                    }

                    if (Category == TypeCategory.ISharedComponentData)
                    {
                        TypeIndex |= SharedComponentTypeFlag;
                    }

                    if (isSystemStateComponent)
                    {
                        TypeIndex |= SystemStateTypeFlag;
                    }

                    if (isSystemStateSharedComponent)
                    {
                        TypeIndex |= SystemStateSharedComponentTypeFlag;
                    }

                    if (BufferCapacity >= 0)
                    {
                        TypeIndex |= BufferComponentTypeFlag;
                    }

                    if (EntityOffsetCount == 0)
                    {
                        TypeIndex |= HasNoEntityReferencesFlag;
                    }
                }
            }
Beispiel #17
0
        private void SerializeSubValue(Type type, object value, IDataAdapter data, Type[] genericArgs)
        {
            int objId;

            if (settings.EnableObjectCache && type.IsClass && objectsCache.TryGetValue(value, out objId))
            {
                data.AddIntValue(objId, ATTRIBUTE_OBJID, true);
                haveReferences = true;
                return;
            }

            Type targetType = value.GetType();

            if (targetType != type)
            {
                int typeId;
                if (!typesCache.TryGetValue(targetType, out typeId))
                {
                    typesCache.Add(targetType, typeId = typesCache.Count + 1);
                }

                if (settings.EnableTypeMarkers)
                {
                    data.AddIntValue(typeId, ATTRIBUTE_TYPE, true);
                }
                type        = targetType;
                genericArgs = type.GetGenericArguments();
            }

            TypeCategory category = GetTypeCategory(type);

            switch (category)
            {
            case TypeCategory.Primitive:
                data.SetStringValue(value.ToString());
                break;

            case TypeCategory.Enum:
                if (settings.EnumsAsValue)
                {
                    data.SetIntValue(((IConvertible)value).ToInt64(null));
                }
                else
                {
                    data.SetStringValue(value.ToString());
                }
                break;

            case TypeCategory.Unknown:
                SerializeValue(data, value);
                break;

            default:
                SerializeContainer(value, data, category, genericArgs);
                break;
            }
        }
Beispiel #18
0
 public ComponentType(Type type, int size, TypeCategory category, FastEquality.Layout[] layout, EntityOffsetInfo[] entityOffsets, UInt64 memoryOrdering)
 {
     Type               = type;
     SizeInChunk        = size;
     Category           = category;
     FastEqualityLayout = layout;
     EntityOffsets      = entityOffsets;
     MemoryOrdering     = memoryOrdering;
 }
        private object ParseNumericValue()
        {
            object val = null;

            //If the value is convertable to a double, it is either an int or a double
            if (!string.IsNullOrEmpty(OriginalValue?.ToString()))
            {
                double doubleResult;

                //If the value is a double. Implicitly not null due to !string.IsNullOrEmpty check above
                if (double.TryParse(OriginalValue.ToString(), out doubleResult))
                {
                    //If we're actually looking for an int, see if this double is actually an integer
                    if (PropertyType == typeof(int))
                    {
                        if (Convert.ToInt32(doubleResult) == doubleResult)
                        {
                            //If so, that's cool. When we ToString, we'll get an integer value anyway
                            Type = TypeCategory.Number;

                            if (Mode == SerializationMode.Deserialize)
                            {
                                val = (int)doubleResult;
                            }
                            else
                            {
                                val = doubleResult.ToString(CultureInfo.CurrentCulture);
                            }
                        }

                        //Else: someone tried to assign an actual double to our integer. An exception will be thrown below
                    }
                    else
                    {
                        Type = TypeCategory.Number;

                        if (Mode == SerializationMode.Deserialize)
                        {
                            val = doubleResult;
                        }
                        else
                        {
                            val = doubleResult.ToString(CultureInfo.CurrentCulture);
                        }
                    }
                }

                //If we still don't have a value, since we already verified our value is not null or empty we must have a value of an invalid type
                if (val == null)
                {
                    throw GetInvalidTypeException();
                }
            }

            return(val);
        }
Beispiel #20
0
        public static Type GetType(string typeName, TypeCategory typeCategory)
        {
            string strFullName = "SMT.FB.UI.Common.";

            if (typeCategory == TypeCategory.EntityObject)
            {
                strFullName = "SMT.FB.UI.FBCommonWS.";
            }
            return(Type.GetType(strFullName + typeName));
        }
Beispiel #21
0
 public ComponentType(Type type, int size, TypeCategory category, FastEquality.TypeInfo typeInfo, EntityOffsetInfo[] entityOffsets, UInt64 memoryOrdering, int bufferCapacity, int elementSize)
 {
     Type                 = type;
     SizeInChunk          = size;
     Category             = category;
     FastEqualityTypeInfo = typeInfo;
     EntityOffsets        = entityOffsets;
     MemoryOrdering       = memoryOrdering;
     BufferCapacity       = bufferCapacity;
     ElementSize          = elementSize;
 }
        public async Task <IActionResult> PostTypeCategory([FromBody] TypeCategory typeCategory)
        {
            if (!ModelState.IsValid)
            {
                return(BadRequest(ModelState));
            }

            _context.TypeCategories.Add(typeCategory);
            await _context.SaveChangesAsync();

            return(CreatedAtAction("GetTypeCategory", new { id = typeCategory.Id_type }, typeCategory));
        }
Beispiel #23
0
 public TypeInfo(Type type, int size, TypeCategory category, FastEquality.TypeInfo typeInfo, EntityOffsetInfo[] entityOffsets, UInt64 memoryOrdering, int bufferCapacity, int elementSize)
 {
     Type                         = type;
     SizeInChunk                  = size;
     Category                     = category;
     FastEqualityTypeInfo         = typeInfo;
     EntityOffsets                = entityOffsets;
     MemoryOrdering               = memoryOrdering;
     BufferCapacity               = bufferCapacity;
     ElementSize                  = elementSize;
     IsSystemStateSharedComponent = typeof(ISystemStateSharedComponentData).IsAssignableFrom(type);
     IsSystemStateComponent       = typeof(ISystemStateComponentData).IsAssignableFrom(type);
 }
Beispiel #24
0
        TypeMetadata([NotNull] Type contractType)
        {
            Category = SerializationUtil.CategorizeType(contractType);
            if (Category == TypeCategory.ConvertibleByProperties) {
                Properties =
                    contractType.GetProperties()
                                .Where(p => !Attribute.GetCustomAttributes(p, typeof(NbtIgnoreAttribute)).Any())
                                .ToArray();
                PropertyTagNames = new Dictionary<PropertyInfo, string>();

                foreach (PropertyInfo property in Properties) {
                    // read [TagName] attributes
                    Attribute[] nameAttributes = Attribute.GetCustomAttributes(property, typeof(TagNameAttribute));
                    string tagName;
                    if (nameAttributes.Length != 0) {
                        tagName = ((TagNameAttribute)nameAttributes[0]).Name;
                    } else {
                        tagName = property.Name;
                    }
                    PropertyTagNames.Add(property, tagName);

                    // read [NullPolicy] attributes
                    var nullPolicyAttr =
                        Attribute.GetCustomAttribute(property, typeof(NullPolicyAttribute)) as NullPolicyAttribute;
                    if (nullPolicyAttr != null) {
                        if (nullPolicyAttr.SelfPolicy != NullPolicy.Default) {
                            if (NullPolicies == null) {
                                NullPolicies = new Dictionary<PropertyInfo, NullPolicy>();
                            }
                            NullPolicies.Add(property, nullPolicyAttr.SelfPolicy);
                        }
                        if (nullPolicyAttr.ElementPolicy != NullPolicy.Default) {
                            if (ElementNullPolicies == null) {
                                ElementNullPolicies = new Dictionary<PropertyInfo, NullPolicy>();
                            }
                            ElementNullPolicies.Add(property, nullPolicyAttr.ElementPolicy);
                        }
                    }

                    // check for presence of [NonSerialized] and [NbtIgnore] attributes
                    if (Attribute.IsDefined(property, typeof(NonSerializedAttribute)) ||
                        Attribute.IsDefined(property, typeof(NbtIgnoreAttribute))) {
                        if (IgnoredProperties == null) {
                            IgnoredProperties = new HashSet<PropertyInfo>();
                        }
                        IgnoredProperties.Add(property);
                    }
                }
            }
        }
            public TypeInfo(int typeIndex, TypeCategory category, int entityOffsetCount, int entityOffsetStartIndex, ulong memoryOrdering, ulong stableTypeHash, int bufferCapacity, int typeSize, int elementSize, int alignmentInBytes, bool isSystemStateComponent, bool isSystemStateSharedComponent)
            {
                TypeIndex              = typeIndex;
                Category               = category;
                EntityOffsetCount      = entityOffsetCount;
                EntityOffsetStartIndex = entityOffsetStartIndex;
                //TODO: add BlobAssetRefOffset support to the static type registry
                BlobAssetRefOffsetCount      = 0;
                BlobAssetRefOffsetStartIndex = 0;
                MemoryOrdering   = memoryOrdering;
                StableTypeHash   = stableTypeHash;
                BufferCapacity   = bufferCapacity;
                SizeInChunk      = typeSize;
                AlignmentInBytes = alignmentInBytes;
                ElementSize      = elementSize;

                if (typeIndex != 0)
                {
                    if (SizeInChunk == 0)
                    {
                        TypeIndex |= ZeroSizeTypeFlag;
                    }

                    if (Category == TypeCategory.ISharedComponentData)
                    {
                        TypeIndex |= SharedComponentTypeFlag;
                    }

                    //System state shared components are also considered system state components
                    if (isSystemStateComponent || isSystemStateSharedComponent)
                    {
                        TypeIndex |= SystemStateTypeFlag;
                    }

                    if (isSystemStateSharedComponent)
                    {
                        TypeIndex |= SystemStateSharedComponentTypeFlag;
                    }

                    if (Category == TypeCategory.BufferData)
                    {
                        TypeIndex |= BufferComponentTypeFlag;
                    }

                    if (EntityOffsetCount == 0)
                    {
                        TypeIndex |= HasNoEntityReferencesFlag;
                    }
                }
            }
Beispiel #26
0
 public TypeInfo(int typeIndex, TypeCategory category, int entityOffsetCount, int entityOffsetStartIndex, ulong memoryOrdering, ulong stableTypeHash, int bufferCapacity, int typeSize, int elementSize, int alignmentInBytes, bool isSystemStateComponent, bool isSystemStateSharedComponent)
 {
     TypeIndex                    = typeIndex;
     Category                     = category;
     EntityOffsetCount            = entityOffsetCount;
     EntityOffsetStartIndex       = entityOffsetStartIndex;
     MemoryOrdering               = memoryOrdering;
     StableTypeHash               = stableTypeHash;
     BufferCapacity               = bufferCapacity;
     SizeInChunk                  = typeSize;
     AlignmentInBytes             = alignmentInBytes;
     ElementSize                  = elementSize;
     IsSystemStateComponent       = isSystemStateComponent;
     IsSystemStateSharedComponent = isSystemStateSharedComponent;
 }
Beispiel #27
0
 public TypeInfo(Type type, int size, TypeCategory category, FastEquality.TypeInfo typeInfo, EntityOffsetInfo[] entityOffsets, ulong memoryOrdering, int bufferCapacity, int elementSize, int alignmentInBytes, ulong stableTypeHash)
 {
     Type                         = type;
     SizeInChunk                  = size;
     Category                     = category;
     FastEqualityTypeInfo         = typeInfo;
     EntityOffsetCount            = entityOffsets != null ? entityOffsets.Length : 0;
     EntityOffsets                = entityOffsets;
     MemoryOrdering               = memoryOrdering;
     BufferCapacity               = bufferCapacity;
     ElementSize                  = elementSize;
     AlignmentInBytes             = alignmentInBytes;
     IsSystemStateSharedComponent = typeof(ISystemStateSharedComponentData).IsAssignableFrom(type);
     IsSystemStateComponent       = typeof(ISystemStateComponentData).IsAssignableFrom(type);
     StableTypeHash               = stableTypeHash;
 }
        private bool RuleEngineResolveRedirection(RuleSet ruleSet, TypeInfo typeInfo,
                                                  out Type convertedType)
        {
            convertedType = null;
            if (ruleSet != null)
            {
                ICategory category = TypeCategory.GetInstance();
                TypeLibTypes.Interop.TYPEKIND typeKind;
                using (TypeAttr attr = typeInfo.GetTypeAttr())
                {
                    typeKind = attr.typekind;
                }
                TypeInfoMatchTarget target = new TypeInfoMatchTarget(typeInfo.GetContainingTypeLib(),
                                                                     typeInfo, typeKind);
                AbstractActionManager actionManager  = RuleEngine.GetActionManager();
                List <Rule>           resolveToRules = ruleSet.GetRule(
                    category, ResolveToActionDef.GetInstance(), target);
                if (resolveToRules.Count != 0)
                {
                    if (resolveToRules.Count > 1)
                    {
                        Output.WriteWarning(Resource.FormatString("Wrn_RuleMultipleMatch",
                                                                  ResolveToActionDef.GetInstance().GetActionName()),
                                            WarningCode.Wrn_RuleMultipleMatch);
                    }
                    Rule resolveToRule =
                        resolveToRules[resolveToRules.Count - 1];

                    ResolveToAction action =
                        resolveToRule.Action as ResolveToAction;
                    try
                    {
                        Assembly assembly = Assembly.ReflectionOnlyLoad(action.AssemblyName);
                        convertedType = assembly.GetType(action.ManagedTypeFullName);
                        return(true);
                    }
                    catch (Exception)
                    {
                        Output.WriteWarning(Resource.FormatString("Wrn_CannotLoadResolveToType",
                                                                  action.ManagedTypeFullName, action.AssemblyName),
                                            WarningCode.Wrn_CannotLoadResolveToType);
                    }
                }
            }
            return(false);
        }
Beispiel #29
0
 public ActionResult Update(TypeCategory model)
 {
     try
     {
         model.URL        = "/" + StringUtil.UnsignToString(model.Name);
         model.UpdateBy   = CurrentInstance.Instance.CurrentUser.UserName;
         model.UpdateDate = DateTime.Now;
         _typeCatSrv.Update(model);
         _typeCatSrv.CommitChange();
         AlertSuccess(InfoString.UPDATE_SUCCESSFULL);
         return(RedirectToAction("Index"));
     }
     catch (Exception ex)
     {
         LogError(ex);
         AlertError(InfoString.ERROR_SYSTEM);
         return(View(model));
     }
 }
        /// <summary>
        /// Ensure Dispose(bool disposing) calls
        ///  - WriteLineIf(!disposing, MESSAGE) (if a first generation IDisposable in our code) and
        ///  - base.Dispose(disposing) (if a second-plus generation IDisposable of any kind)
        /// </summary>
        public void InspectDisposeBool(MethodBase disposeBool, Type baseType, TypeCategory baseCategory)
        {
            var bodyParts = new ILReader(disposeBool).ToArray();
            var module    = disposeBool.Module;

            // If the base is any kind of Disposable, we'd better call base.Dispose()!
            if (baseCategory != TypeCategory.Object && !MethodCallsBaseDispose(baseType, bodyParts, module))
            {
                Log.LogError(disposeBool.DeclaringType?.FullName + ".Dispose(bool disposing) should call base.Dispose(disposing);");
            }

            // If the base is not one of our Disposables, it is this method's responsibility to warn on missing Dispose() calls;
            // make sure the Dispose(bool) method starts with a WriteLineIf
            if (baseCategory != TypeCategory.Disposable &&
                !MethodBeginningsMatch(WriteLineIf, bodyParts, module) && !MethodBeginningsMatch(WriteLineIf2, bodyParts, module))
            {
                Log.LogError(disposeBool.DeclaringType?.FullName + ".Dispose(bool disposing) should call " + MissingDisposeMsgCmd);
            }
        }
        private ConversionState ProcessNullable()
        {
            //String, Int and Double can be used as is
            if (PropertyType == typeof(string))
            {
                Type = TypeCategory.String;

                NewValue = OriginalValue?.ToString();

                return(ValueConversionWithMaybeNullCheck);
            }
            else if (PropertyType == typeof(double) || PropertyType == typeof(int))
            {
                NewValue = ParseNumericValue();

                return(ValueConversionWithMaybeNullCheck);
            }

            return(MoveNext());
        }
Beispiel #32
0
        private void InitializeRootCatalog(PersonalDataContext ctx)
        {
            TypeTableRootCategory = new TypeTable()
            {
                Table         = "drTypeCategory",
                Name          = "TypeCategory",
                Note          = "Категории",
                PK            = "idTypeCategory",
                TableObjectId = null
            };
            ctx.TypeTables.Add(TypeTableRootCategory);
            ctx.SaveChanges();

            TypeRootCategory = new TypeDigest()
            {
                Code      = "TypeCategory",
                BCode     = "TypeCategory",
                Name      = "Типы справочников (Категории)",
                TypeTable = TypeTableRootCategory,
                Note      = null,
                Edit      = _defaultOpen,
                Open      = _defaultOpen,
                Close     = _defaultClose,
                Order     = 0
            };
            ctx.TypeDigests.Add(TypeRootCategory);
            ctx.SaveChanges();;

            TypeCategoryRootCategory = new TypeCategory()
            {
                Id        = TypeRootCategory.Id,
                TypeTable = TypeTableRootCategory
            };
            ctx.TypeCategories.Add(TypeCategoryRootCategory);
            ctx.SaveChanges();

            TypeRootCategory.Category = TypeCategoryRootCategory;

            ctx.SaveChanges();
        }
Beispiel #33
0
        internal static string ToSwaggerType(this Type type, out TypeCategory category, out Type containedType, IDictionary<string, string> customTypeMappings = null)
        {
            if (type == typeof (HttpResponseMessage))
            {
                category = TypeCategory.Unkown;
                containedType = null;
                return null;
            }

            if (type == null)
            {
                category = TypeCategory.Primitive;
                containedType = null;
                return "void";
            }

            var primitiveTypeMap = new Dictionary<string, string>
                {
                    {"Byte", "byte"},
                    {"Boolean", "boolean"},
                    {"Int32", "int"},
                    {"Int64", "long"},
                    {"Single", "float"},
                    {"Double", "double"},
                    {"Decimal", "double"},
                    {"String", "string"},
                    {"DateTime", "date"}
                };
            if (customTypeMappings != null)
                primitiveTypeMap = primitiveTypeMap.Concat(customTypeMappings).ToDictionary(m => m.Key, m => m.Value);

            if (primitiveTypeMap.ContainsKey(type.Name))
            {
                category = TypeCategory.Primitive;
                containedType = null;
                return primitiveTypeMap[type.Name];
            }

            Type innerTypeOfNullable;
            if (type.IsNullableType(out innerTypeOfNullable))
            {
                return innerTypeOfNullable.ToSwaggerType(out category, out containedType);
            }

            if (type.IsEnum)
            {
                category = TypeCategory.Primitive;
                containedType = null;
                return "string";
            }

            var enumerable = type.AsGenericType(typeof(IEnumerable<>));
            if (enumerable != null)
            {
                category = TypeCategory.Container;
                containedType = enumerable.GetGenericArguments().First();
                return String.Format("List[{0}]", containedType.ToSwaggerType(customTypeMappings));
            }

            category = TypeCategory.Complex;
            containedType = null;
            return type.Name;
        }
Beispiel #34
0
 private string CategoryName(TypeCategory category)
 {
     switch (category)
     {
         case TypeCategory.Interface: return "Interfaces";
         case TypeCategory.Class: return "Classes";
         case TypeCategory.Delegate: return "Delegates";
         case TypeCategory.Enum: return "Enums";
         default:
             throw new ArgumentException("Invalid category", "category");
     }
 }
Beispiel #35
0
 private int IntVal(TypeCategory category)
 {
     switch (category)
     {
         case TypeCategory.Class: return 0;
         case TypeCategory.Interface: return 1;
         case TypeCategory.Enum: return 2;
         case TypeCategory.Delegate: return 3;
         default:
             throw new ArgumentException("Invalid category", "category");
     }
 }