Example #1
0
 private void applyUnnamedCPatch <TAttributes, TWrapper>(
     EntityTypeAttributes entityType, SubsystemPatch patch, Func <TAttributes, TWrapper> createWrapper)
     where TAttributes : class
     where TWrapper : TAttributes
 {
     if (patch != null)
     {
         applyCPatch(entityType, patch, createWrapper);
     }
 }
Example #2
0
        private void applyCPatch <TAttributes, TWrapper>(
            EntityTypeAttributes entityType, SubsystemPatch patch, Func <TAttributes, TWrapper> createWrapper, string name = null)
            where TAttributes : class
            where TWrapper : TAttributes
        {
            var attributes = name != null?entityType.Get <TAttributes>(name) : entityType.Get <TAttributes>();

            if (attributes == null)
            {
                if (notFoundErrors)
                {
                    logger.Log($"ERROR: {typeof(TAttributes).Name}" + (name != null ? $": {name}" : "") + " not found");
                }
                return;
            }
            using (logger.BeginScope($"{typeof(TAttributes).Name}: {name}"))
            {
                var wrapper = createWrapper(attributes);
                patch.Apply(this, wrapper, entityType);
                entityType.Replace(attributes, wrapper);
            }
        }