コード例 #1
0
        public CodeInspectionSetting GetSetting(Type inspection)
        {
            var proto    = Convert.ChangeType(Activator.CreateInstance(inspection), inspection);
            var existing = CodeInspections.FirstOrDefault(s => s.Name.Equals(proto.GetType().ToString()));

            if (existing != null)
            {
                return(existing);
            }
            var setting = new CodeInspectionSetting(proto as IInspectionModel);

            CodeInspections.Add(setting);
            return(setting);
        }
コード例 #2
0
 public CodeInspectionSetting GetSetting(Type inspectionType)
 {
     try
     {
         var existing = CodeInspections.FirstOrDefault(s => inspectionType.ToString().Equals(s.Name));
         if (existing != null)
         {
             return(existing);
         }
         var proto   = Convert.ChangeType(Activator.CreateInstance(inspectionType, new object[] { null }), inspectionType);
         var setting = new CodeInspectionSetting(proto as IInspectionModel);
         CodeInspections.Add(setting);
         return(setting);
     }
     catch (Exception)
     {
         return(null);
     }
 }