Represents a set of form kinds and is used to specify the set of form kids that are allowed in a reference.
コード例 #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);
        }
コード例 #2
0
ファイル: RecordReader.cs プロジェクト: tstavrianos/patcher
        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);
        }
コード例 #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);
            }
        }
コード例 #4
0
ファイル: FormKindSet.cs プロジェクト: unforbidable/patcher
        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;
            }
        }
コード例 #5
0
 public ReferenceAttribute(string kinds)
 {
     ReferenceFormKinds = FormKindSet.FromNames(kinds);
 }
コード例 #6
0
 public ReferenceAttribute()
 {
     ReferenceFormKinds = FormKindSet.Any;
 }
コード例 #7
0
ファイル: RecordWriter.cs プロジェクト: unforbidable/patcher
        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);
        }