Represents a set of form kinds and is used to specify the set of form kids that are allowed in a reference.
Esempio n. 1
0
        public void WriteReference(uint formId, FormKindSet referencedFormKinds)
        {
            // All fields should write references via this method so problems can be detected
            if (formId == 0)
            {
                // Null references are normal, do not warn
                //Log.Warning("Writting null reference 0x{0:X8}.", formId);
            }
            else if (!context.Forms.Contains(formId))
            {
                Log.Warning("Writting unresolved form reference 0x{0:X8}.", formId);
            }
            else if (!referencedFormKinds.IsAny)
            {
                // Verify correct reference type
                // if specified reference type is not FormType.None
                var form = context.Forms[formId];
                if (!referencedFormKinds.Contains(form.FormKind))
                {
                    Log.Warning("Writting reference to {0} used where olny references to forms of following types should be: {1}", form, referencedFormKinds);
                }
            }

            var localFormId = ReferenceMapper.ContexToLocal(formId);

            Write(localFormId);
        }
Esempio n. 2
0
        public uint ReadReference(FormKindSet referencedFormKinds)
        {
            uint formId = ReadUInt32();

            formId = ReferenceMapper.LocalToContext(formId);

            if (formId > 0 && !context.Forms.Contains(formId))
            {
                //Log.Warning("Reading unresolved form referenced 0x{0:X8}.", formId);
            }

            // TODO: Verify reference type

            return(formId);
        }
Esempio n. 3
0
        public static FormKindSet FromNames(string names)
        {
            if (string.IsNullOrEmpty(names))
            {
                return(Any);
            }

            lock (cache)
            {
                // Find predefined ro cached set
                if (cache.ContainsKey(names))
                {
                    return(cache[names]);
                }

                // Create new one and add to cache
                var set = new FormKindSet(names);
                cache.Add(names, set);
                return(set);
            }
        }
Esempio n. 4
0
        public static FormKindSet FromNames(string names)
        {
            if (string.IsNullOrEmpty(names))
                return Any;

            lock (cache)
            {
                // Find predefined ro cached set
                if (cache.ContainsKey(names))
                    return cache[names];

                // Create new one and add to cache
                var set = new FormKindSet(names);
                cache.Add(names, set);
                return set;
            }
        }
Esempio n. 5
0
 public ReferenceAttribute(string kinds)
 {
     ReferenceFormKinds = FormKindSet.FromNames(kinds);
 }
Esempio n. 6
0
 public ReferenceAttribute()
 {
     ReferenceFormKinds = FormKindSet.Any;
 }
Esempio n. 7
0
        public void WriteReference(uint formId, FormKindSet referencedFormKinds)
        {
            // All fields should write references via this method so problems can be detected
            if (formId == 0)
            {
                // Null references are normal, do not warn
                //Log.Warning("Writting null reference 0x{0:X8}.", formId);
            }
            else if (!context.Forms.Contains(formId))
            {
                Log.Warning("Writting unresolved form reference 0x{0:X8}.", formId);
            }
            else if (!referencedFormKinds.IsAny)
            {
                // Verify correct reference type
                // if specified reference type is not FormType.None
                var form = context.Forms[formId];
                if (!referencedFormKinds.Contains(form.FormKind))
                {
                    Log.Warning("Writting reference to {0} used where olny references to forms of following types should be: {1}", form, referencedFormKinds);
                }
            }

            var localFormId = ReferenceMapper.ContexToLocal(formId);
            Write(localFormId);
        }