Exemplo n.º 1
0
    /// <summary>
    /// 创建 FormValidationResult 对象
    /// </summary>
    /// <param name="form">所验证的表单</param>
    /// <param name="errors">验证错误信息</param>
    public FormValidationResult( HtmlForm form, IEnumerable<FormValidationError> errors )
    {

      if ( form == null )
        throw new ArgumentNullException( "form" );

      
      Form = form;

      Errors = new FormValidationErrorCollection();

      if ( errors != null )
      {
        errors = errors.NotNull();

        if ( errors.Any() )
        {
          HasError = true;
          foreach ( var e in errors )
            Errors.Add( e );
        }
      }

      else
        HasError = false;
    }
Exemplo n.º 2
0
 public static ILookup<IPackageInfo, AssemblyName> InGac(IEnumerable<IPackageInfo> packages, ExecutionEnvironment environment = null)
 {
     var domain = TempDomain();
     try
     {
         var loader = ((Loader)domain.CreateInstanceFromAndUnwrap(
                 typeof(Loader).Assembly.Location,
                 typeof(Loader).FullName));
         return (from package in packages.NotNull().Select(x => x.Load()).NotNull()
                 let export = package.GetExport("bin", environment)
                 where export != null
                 from assembly in export.Items.OfType<IAssemblyReferenceExportItem>()
                 let inGac = loader.InGAC(assembly.AssemblyName)
                 where inGac
                 select new { package, assembly.AssemblyName })
                 .ToLookup(x => (IPackageInfo)x.package, x => x.AssemblyName);
     }
     catch
     {
         return (new AssemblyName[0]).ToLookup(x => (IPackageInfo)null);
     }
     finally
     {
         AppDomain.Unload(domain);
     }
 }
Exemplo n.º 3
0
 public SchemaStore(IMetadataNotation notation, IEnumerable <IMetadataBuilder> builders)
     : this(notation)
 {
     foreach (IMetadataBuilder builder in builders?.NotNull() ?? Array.Empty <IMetadataBuilder>())
     {
         this.Add(builder);
     }
 }
Exemplo n.º 4
0
 static ILookup<string, string> Files(IEnumerable<ITaskItem> specs)
 {
     return specs == null
                ? Lookup<string, string>.Empty
                : specs.NotNull()
                      .Select(x => new { target = GetTarget(x), path = Path.GetFullPath(x.ItemSpec) })
                      .ToLookup(_ => _.target, _ => _.path);
 }
Exemplo n.º 5
0
 static IEnumerable<IAssemblyReferenceExportItem> GetAssemblyReferencesFromPackages(IEnumerable<IPackageInfo> packages, ExecutionEnvironment exec)
 {
     return from package in packages.NotNull()
                    .GroupBy(x => x.Name)
                    .Select(x => x.OrderByDescending(y => y.Version).Select(y=>y.Load()).NotNull().First())
            from assembly in package.Load().GetExport("bin", exec).Items.Cast<IAssemblyReferenceExportItem>()
            where MatchesReferenceSection(package, assembly)
            select assembly;
 }
 static IEnumerable<IAssemblyReferenceExportItem> GetAssemblyReferencesFromPackages(IEnumerable<IPackageInfo> packages, ExecutionEnvironment exec)
 {
     return packages
             .NotNull()
             .GroupBy(x=>x.Name)
             .Select(x=>x.OrderByDescending(y=>y.Version).First())
             .NotNull()
             .SelectMany(x => x.Load().GetExport("bin", exec).Items)
             .Cast<IAssemblyReferenceExportItem>();
 }
Exemplo n.º 7
0
        /// <inheritdoc />
        protected override void InternalReopenDiscussionThreads(IEnumerable <IPullRequestDiscussionThread> threads)
        {
            // ReSharper disable once PossibleMultipleEnumeration
            threads.NotNull(nameof(threads));

            // ReSharper disable once PossibleMultipleEnumeration
            foreach (var thread in threads)
            {
                this.PullRequestSystem.AzureDevOpsPullRequest.ActivateCommentThread(thread.Id);
            }
        }
Exemplo n.º 8
0
        public static void NotNullOrEmptyElement <T>(this IEnumerable <T> value, string parameterName)
        {
            // ReSharper disable once PossibleMultipleEnumeration
            value.NotNull(parameterName);

            // ReSharper disable once PossibleMultipleEnumeration
            if (value.Any(x => x == null))
            {
                throw new ArgumentOutOfRangeException(parameterName, "List contains.");
            }
        }
        public static IEnumerable <FileNameCombiner> ChangeExtension(this IEnumerable <FileNameCombiner> combiners, string newExtension)
        {
            combiners.NotNull(nameof(combiners));

            foreach (var combiner in combiners)
            {
                combiner?.ChangeExtension(newExtension);
            }

            return(combiners);
        }
Exemplo n.º 10
0
        public static void SerializeIssuesToJsonFile(
            this ICakeContext context,
            IEnumerable <IIssue> issues,
            FilePath filePath)
        {
            context.NotNull(nameof(context));
            issues.NotNull(nameof(issues));
            filePath.NotNull(nameof(filePath));

            issues.SerializeToJsonFile(filePath);
        }
Exemplo n.º 11
0
        ///// <summary>
        ///// <see cref="IEnumerable{T}"/>扩展根据返回指定键的列表信息
        ///// </summary>
        ///// <typeparam name="T">类型</typeparam>
        ///// <typeparam name="Key">键类型</typeparam>
        ///// <param name="list">所有值</param>
        ///// <param name="key">指定键</param>
        ///// <returns></returns>
        //public static IEnumerable<Key> ToKeys<T, Key>(this IEnumerable<T> list, Expression<Func<T, Key>> key)
        //{
        //    foreach (var item in list)
        //    {
        //    }
        //}
        /// <summary>
        /// <see cref="IEnumerable{T}"/>扩展转换全部类型
        /// </summary>
        /// <typeparam name="T"></typeparam>
        /// <typeparam name="TResult"></typeparam>
        /// <param name="list"></param>
        /// <returns></returns>
        public static IEnumerable <TResult> AsToAll <T, TResult>(this IEnumerable <T> list)
        {
            list.NotNull(nameof(IEnumerable <T>));
            var result = list as IEnumerable <TResult>;

            if (result.IsNotNull())
            {
                return(result);
            }
            return(YieldAsTo <T, TResult>(list));
        }
Exemplo n.º 12
0
        /// <summary>
        /// <see cref="IEnumerable{T}"/>扩展根据指定字符以及分隔符获取拼接字符串
        /// </summary>
        /// <typeparam name="T">类型</typeparam>
        /// <param name="list">值</param>
        /// <param name="left">左侧符号</param>
        /// <param name="right">右侧符号</param>
        /// <param name="split">分割符</param>
        /// <returns></returns>
        public static string ToSqlIn <T>(this IEnumerable <T> list, string left = "'", string right = "'", string split = ",")
        {
            list.NotNull(nameof(IEnumerable <T>));
            StringBuilder builder = new StringBuilder();

            list.ForEach(x =>
            {
                builder.Append(left + x + right + split);
            });
            return(builder.ToString().Substring(0, builder.Length - 1));
        }
Exemplo n.º 13
0
        public static IEnumerable <FilePathCombiner> ChangeBasePath(this IEnumerable <FilePathCombiner> combiners, string newBasePath)
        {
            combiners.NotNull(nameof(combiners));

            foreach (var combiner in combiners)
            {
                combiner?.ChangeBasePath(newBasePath);
            }

            return(combiners);
        }
Exemplo n.º 14
0
        /// <summary>
        /// Serializes an <see cref="IEnumerable{IIssue}"/> to a JSON file.
        /// </summary>
        /// <param name="issues">Issues which should be serialized.</param>
        /// <param name="filePath">Path to the file.</param>
        public static void SerializeToJsonFile(this IEnumerable <IIssue> issues, FilePath filePath)
        {
            issues.NotNull(nameof(issues));
            filePath.NotNull(nameof(filePath));

            using (var stream = File.Open(filePath.FullPath, FileMode.Create))
                using (var writer = new StreamWriter(stream))
                {
                    JsonMapper.ToJson(issues.Select(x => x.ToSerializableIssue()).ToArray(), new JsonWriter(writer));
                }
        }
Exemplo n.º 15
0
        public static void NotNullOrEmpty <T>(this IEnumerable <T> value, string parameterName)
        {
            // ReSharper disable once PossibleMultipleEnumeration
            value.NotNull(parameterName);

            // ReSharper disable once PossibleMultipleEnumeration
            if (!value.Any())
            {
                throw new ArgumentException("Empty list.", parameterName);
            }
        }
Exemplo n.º 16
0
 /// <summary>
 /// 创建一个迭代器带有索引的
 /// </summary>
 /// <typeparam name="T"></typeparam>
 /// <param name="source"></param>
 /// <returns></returns>
 public static IEnumerable <Tuple <int, T> > ForeachIndex <T>(this IEnumerable <T> source)
 {
     if (source.NotNull())
     {
         for (int i = 0; i < source.Count(); i++)
         {
             var souTemp = source.ElementAt(i);
             yield return(new Tuple <int, T>(i, souTemp));
         }
     }
 }
        /// <summary>
        /// Serializes an <see cref="IEnumerable{ExpandoObject}"/> to a JSON string.
        /// </summary>
        /// <param name="expandoObjects">Objects which should be serialized.</param>
        /// <returns>Serialized objects.</returns>
        public static string SerializeToJsonString(this IEnumerable <ExpandoObject> expandoObjects)
        {
            expandoObjects.NotNull(nameof(expandoObjects));

            return
                (JsonMapper
                 .ToJson(
                     expandoObjects
                     .Select(x => new Dictionary <string, object>(x))
                     .ToArray()));
        }
Exemplo n.º 18
0
        /// <summary>
        /// 把集合的元素转成指定的类型
        /// </summary>
        /// <typeparam name="TTarget">要转换的类型</typeparam>
        /// <param name="source">转换的数据源</param>
        /// <returns>返回转换后的集合</returns>
        public static IEnumerable <TTarget> AsToAll <TTarget>(this IEnumerable source)
        {
            source.NotNull(nameof(source));
            IEnumerable <TTarget> enumerable = source as IEnumerable <TTarget>;

            if (enumerable != null)
            {
                return(enumerable);
            }
            return(CastIterator <TTarget>(source));
        }
Exemplo n.º 19
0
 /// <summary>
 /// 检查list是否含有值,判null和any
 /// </summary>
 /// <typeparam name="T"></typeparam>
 /// <param name="self"></param>
 /// <returns></returns>
 public static bool HasItem <T>(this IEnumerable <T> self)
 {
     if (self.NotNull() && self.Any())
     {
         return(true);
     }
     else
     {
         return(false);
     }
 }
    public void Can_Use_NotNull_On_Null_Enumerable_To_Work_With_Null_Easily()
    {
        // Arrange
        IEnumerable <string>?input = null;

        // Act
        var actual = input.NotNull();

        // Assert
        actual.Should().BeEmpty();
    }
Exemplo n.º 21
0
        private bool AddThreadProperties(
            AzureDevOpsPullRequestCommentThread thread,
            IEnumerable <AzureDevOpsPullRequestIterationChange> changes,
            IIssue issue,
            int iterationId,
            string commentSource)
        {
            thread.NotNull(nameof(thread));
            changes.NotNull(nameof(changes));
            issue.NotNull(nameof(issue));

            var properties = new Dictionary <string, object>();

            if (issue.AffectedFileRelativePath != null)
            {
                if (this.azureDevOpsPullRequest.CodeReviewId > 0)
                {
                    var changeTrackingId =
                        this.TryGetCodeFlowChangeTrackingId(changes, issue.AffectedFileRelativePath);
                    if (changeTrackingId < 0)
                    {
                        // Don't post comment if we couldn't determine the change.
                        return(false);
                    }

                    AddCodeFlowProperties(issue, iterationId, changeTrackingId, properties);
                }
                else
                {
                    throw new NotSupportedException("Legacy code reviews are not supported.");
                }
            }

            // An Azure DevOps UI extension will recognize this and format the comments differently.
            properties.Add("CodeAnalysisThreadType", "CodeAnalysisIssue");

            thread.Properties = properties;

            // Add a custom property to be able to distinguish all comments created this way.
            thread.SetCommentSource(commentSource);

            // Add custom property for identifying the comment for subsequent runs
            thread.SetCommentIdentifier(issue.Identifier);

            // Add a custom property to be able to distinguish all comments by provider type later on
            thread.SetProviderType(issue.ProviderType);

            // Add a custom property to be able to return issue message from existing threads,
            // without any formatting done by this addin, back to Cake.Issues.PullRequests.
            thread.SetIssueMessage(issue.MessageText);

            return(true);
        }
Exemplo n.º 22
0
        public static IEnumerable <TSource> Catch <TSource, TException>(
            this IEnumerable <TSource> source, Action <TException> handler = null)
            where TException : Exception
        {
            source.NotNull(nameof(source));

            return(source.Catch <TSource, TException>(exception =>
            {
                handler?.Invoke(exception);
                return false;
            }));
        }
        /// <summary>
        /// Serializes an <see cref="IEnumerable{IIssue}"/> to a JSON string.
        /// </summary>
        /// <param name="issues">Issues which should be serialized.</param>
        /// <returns>Serialized issues.</returns>
        public static string SerializeToJsonString(this IEnumerable <IIssue> issues)
        {
            issues.NotNull(nameof(issues));

            var serializer = new DataContractJsonSerializer(typeof(IEnumerable <SerializableIssue>));

            using (var stream = new MemoryStream())
            {
                serializer.WriteObject(stream, issues.Select(x => x.ToSerializableIssue()));
                return(Encoding.UTF8.GetString(stream.ToArray()));
            }
        }
        /// <summary>
        /// Serializes an <see cref="IEnumerable{IIssue}"/> to a JSON file.
        /// </summary>
        /// <param name="issues">Issues which should be serialized.</param>
        /// <param name="filePath">Path to the file.</param>
        public static void SerializeToJsonFile(this IEnumerable <IIssue> issues, FilePath filePath)
        {
            issues.NotNull(nameof(issues));
            filePath.NotNull(nameof(filePath));

            var serializer = new DataContractJsonSerializer(typeof(IEnumerable <SerializableIssue>));

            using (var stream = File.Open(filePath.FullPath, FileMode.Create))
            {
                serializer.WriteObject(stream, issues.Select(x => x.ToSerializableIssue()));
            }
        }
Exemplo n.º 25
0
        /// <summary>
        /// Initializes a new instance of the <see cref="FakeFilteringByModifiedFilesCapability"/> class.
        /// </summary>
        /// <param name="log">The Cake log context.</param>
        /// <param name="pullRequestSystem">Pull request system to which this capability belongs.</param>
        /// <param name="modifiedFiles">List of modified files which the pull request system capability should return.</param>
        public FakeFilteringByModifiedFilesCapability(
            ICakeLog log,
            FakePullRequestSystem pullRequestSystem,
            IEnumerable <FilePath> modifiedFiles)
            : base(log, pullRequestSystem)
        {
            // ReSharper disable once PossibleMultipleEnumeration
            modifiedFiles.NotNull(nameof(modifiedFiles));

            // ReSharper disable once PossibleMultipleEnumeration
            this.modifiedFiles.AddRange(modifiedFiles);
        }
        /// <summary>
        /// Initializes a new instance of the <see cref="FakeConfigurableIssueProvider"/> class.
        /// </summary>
        /// <param name="log">The Cake log instance.</param>
        /// <param name="settings">The issue provider settings.</param>
        /// <param name="issues">Issues which should be returned by the issue provider.</param>
        public FakeConfigurableIssueProvider(
            ICakeLog log,
            IssueProviderSettings settings,
            IEnumerable <IIssue> issues)
            : base(log, settings)
        {
            // ReSharper disable once PossibleMultipleEnumeration
            issues.NotNull(nameof(issues));

            // ReSharper disable once PossibleMultipleEnumeration
            this.issues.AddRange(issues);
        }
Exemplo n.º 27
0
        private static IEnumerable <string> ParseNames(IEnumerable <string> tokens)
        {
            var names =
                from token in tokens.NotNull()
                from name in token.Split(',', ';', '|').NotNullOrWhitespace()
                select name;

            foreach (var name in names)
            {
                yield return(name.Trim());
            }
        }
Exemplo n.º 28
0
        /// <summary>
        /// Initializes a new instance of the <see cref="FakeDiscussionThreadsCapability"/> class.
        /// </summary>
        /// <param name="log">The Cake log context.</param>
        /// <param name="pullRequestSystem">Pull request system to which this capability belongs.</param>
        /// <param name="discussionThreads">Discussion threads which the pull request system capability should return.</param>
        public FakeDiscussionThreadsCapability(
            ICakeLog log,
            FakePullRequestSystem pullRequestSystem,
            IEnumerable <IPullRequestDiscussionThread> discussionThreads)
            : base(log, pullRequestSystem)
        {
            // ReSharper disable once PossibleMultipleEnumeration
            discussionThreads.NotNull(nameof(discussionThreads));

            // ReSharper disable once PossibleMultipleEnumeration
            this.discussionThreads.AddRange(discussionThreads);
        }
        public static decimal AverageOrZero(this IEnumerable <decimal> values)
        {
            var sum   = 0m;
            var count = 0;

            foreach (var v in values.NotNull(nameof(values)))
            {
                sum += v;
                count++;
            }
            return(count == 0 ? 0 : sum / count);
        }
Exemplo n.º 30
0
        /// <summary>
        /// 存储依赖项描述符。
        /// </summary>
        /// <param name="dependencyDescriptors">依赖项描述符集合。</param>
        public void StoreDescriptors(IEnumerable <DependencyDescriptor> dependencyDescriptors)
        {
            dependencyDescriptors = dependencyDescriptors.NotNull("dependencyDescriptors").ToArray();

            var existingDescriptors = LoadDescriptors().OrderBy(d => d.Name);
            var newDescriptors      = dependencyDescriptors.OrderBy(d => d.Name);

            if (!newDescriptors.SequenceEqual(existingDescriptors, new DependencyDescriptorComparer()))
            {
                WriteDependencies(_persistencePath, dependencyDescriptors);
            }
        }
Exemplo n.º 31
0
        public static IEnumerable <E> SelectNotNullComponents <E>(this IEnumerable <Component> components)
        {
            var selects = new List <E>();

            foreach (var component in components.NotNull())
            {
                if (component && component.TryGetComponent <E>(out var eComponent))
                {
                    selects.Add(eComponent);
                }
            }
            return(selects);
        }
Exemplo n.º 32
0
        public static void ForEach <T>(this IEnumerable <T> items, Action <T, int> action)
        {
            items.NotNull(nameof(items));
            action.NotNull(nameof(action));

            int i = 0;

            foreach (var item in items)
            {
                action.Invoke(item, i);
                i++;
            }
        }
Exemplo n.º 33
0
        /// <inheritdoc />
        protected override void InternalPostDiscussionThreads(IEnumerable <IIssue> issues, string commentSource)
        {
            issues.NotNull(nameof(issues));

            if (this.settings.GroupIssues)
            {
                this.WriteGroupedIssues(issues);
            }
            else
            {
                this.WriteIssues(issues);
            }
        }
Exemplo n.º 34
0
        public static IEnumerable <E> SelectNotNullComponents <E>(this IEnumerable <GameObject> gameObjects)
        {
            var selects = new List <E>();

            foreach (var gameObject in gameObjects.NotNull())
            {
                if (gameObject && gameObject.TryGetComponent <E>(out var component))
                {
                    selects.Add(component);
                }
            }
            return(selects);
        }
Exemplo n.º 35
0
        /// <summary>
        ///   Like string.Join. However also will escape the seperator and escape charachter so this is reversable using Split
        /// </summary>
        public static string Join <T>(this IEnumerable <T> items, string separator, Func <T, string> format = null, char?escapeCharacter = null)
        {
            format = format ?? (s => s.ToString());
            var escapeFormat = format;

            if (escapeCharacter != null)
            {
                escapeFormat = s =>
                               format(s).Replace(escapeCharacter.Value.ToString(), escapeCharacter.ToString() + escapeCharacter)
                               .Replace(separator, escapeCharacter.ToString() + separator);
            }
            return(string.Join(separator, items.NotNull().Select(escapeFormat)));
        }
Exemplo n.º 36
0
 public static ILookup<IPackageInfo, AssemblyName> InGac(this IPackageExporter exporter, IEnumerable<IPackageInfo> packages)
 {
     var domain = TempDomain();
     try
     {
         var loader = ((Loader)domain.CreateInstanceFromAndUnwrap(
                 typeof(Loader).Assembly.Location,
                 typeof(Loader).FullName));
         return (from package in packages.NotNull().Select(x => x.Load()).NotNull()
                 from assembly in exporter.Assemblies(package, ExecutionEnvironment.Any)
                 where loader.InGAC(assembly.AssemblyName)
                 select new { package, assembly.AssemblyName }
                ).ToLookup(x => (IPackageInfo)x.package, x => x.AssemblyName);
     }
     catch
     {
         return (new AssemblyName[0]).ToLookup(x => (IPackageInfo)null);
     }
     finally
     {
         AppDomain.Unload(domain);
     }
 }
		public DeleteSoundEmitterSourceAction(IEnumerable<SoundEmitter> parent, IEnumerable<SoundEmitter.Source> obj) : base(obj)
		{
			this.targetParentObj = parent.NotNull().ToArray();
		}
Exemplo n.º 38
0
    /// <summary>
    /// 合并多个缓存标记
    /// </summary>
    /// <param name="tokens">要合并的缓存标记列表</param>
    /// <returns>合并后的缓存标记</returns>
    public static CacheToken Combine( IEnumerable<CacheToken> tokens )
    {

      if ( tokens.IsNullOrEmpty() )
        return null;

      tokens = tokens.NotNull();

      CacheToken result;
      if ( tokens.IsSingle( out result ) )
        return result;

      return new CacheToken( tokens.SelectMany( t => t._tokens ).ToArray() );

    }
Exemplo n.º 39
0
		private static void OnDiscardPluginData(IEnumerable<CorePlugin> oldPlugins)
		{
			oldPlugins = oldPlugins.NotNull().Distinct();
			if (!oldPlugins.Any()) oldPlugins = null;

			if (DiscardPluginData != null)
				DiscardPluginData(null, EventArgs.Empty);

			// Clean globally cached type values
			availTypeDict.Clear();
			ReflectionHelper.ClearTypeCache();
			Component.ClearTypeCache();

			// Dispose any existing Resources that could reference plugin data
			if (!Scene.Current.IsEmpty)
				Scene.Current.Dispose();
			foreach (Resource r in ContentProvider.EnumeratePluginContent().ToArray())
				ContentProvider.RemoveContent(r.Path);
			
			// Clean input sources that a disposed Assembly forgot to unregister.
			if (oldPlugins != null)
			{
				foreach (CorePlugin plugin in oldPlugins)
					CleanInputSources(plugin.PluginAssembly);
			}
			// Clean event bindings that are still linked to the disposed Assembly.
			if (oldPlugins != null)
			{
				foreach (CorePlugin plugin in oldPlugins)
					CleanEventBindings(plugin.PluginAssembly);
			}
		}
Exemplo n.º 40
0
 public void SelectNodes(IEnumerable<NodeBase> nodes, bool select = true)
 {
     this.objectView.BeginUpdate();
     TreeNodeAdv viewNode = null;
     foreach (NodeBase node in nodes.NotNull())
     {
         viewNode = this.objectView.FindNode(this.objectModel.GetPath(node));
         if (viewNode != null) viewNode.IsSelected = select;
     }
     this.objectView.EndUpdate();
     if (select && viewNode != null) this.objectView.EnsureVisible(viewNode);
 }
Exemplo n.º 41
0
 static List<string> Files(IEnumerable<ITaskItem> specs)
 {
     return specs == null
         ? new List<string>(0)
         : specs.NotNull()
                .Select(x=>System.IO.Path.GetFullPath(x.ItemSpec))
                .ToList();
 }
Exemplo n.º 42
0
 public SoundEmitterSourceAction(IEnumerable<SoundEmitter.Source> obj)
 {
     if (obj == null) throw new ArgumentNullException("obj");
     this.targetObj = obj.NotNull().ToArray();
 }
 /// <summary>
 /// 获取可用的服务类型。
 /// </summary>
 /// <param name="types">类型集合。</param>
 /// <returns>可用的服务类型。</returns>
 public Type[] GeTypes(IEnumerable<Type> types)
 {
     types = types.NotNull("types").ToArray();
     return types.Where(i => i.IsClass && !i.IsAbstract).ToArray();
 }
Exemplo n.º 44
0
        /// <summary>
        /// Constructor
        /// </summary>
        /// <param name="components">Collection of components to monitor in your system</param>
        public MonitorRequest(IEnumerable<ComponentDto> components)
        {
            components.NotNull(nameof(components));

            Components = components.ToList();
        }
Exemplo n.º 45
0
        public BadRequest(IEnumerable<SerializableValidationError> validationErrors)
        {
            validationErrors.NotNull(nameof(validationErrors));

            ValidationErrors = validationErrors;
        }
Exemplo n.º 46
0
		private static void CleanupAfterPlugins(IEnumerable<CorePlugin> oldPlugins)
		{
			oldPlugins = oldPlugins.NotNull().Distinct();
			if (!oldPlugins.Any()) oldPlugins = null;

			// Clean globally cached type values
			availTypeDict.Clear();
			ReflectionHelper.ClearTypeCache();
			Component.ClearTypeCache();
			Formatter.ClearTypeCache();
			CloneProvider.ClearTypeCache();
			
			// Clean input sources that a disposed Assembly forgot to unregister.
			if (oldPlugins != null)
			{
				foreach (CorePlugin plugin in oldPlugins)
					CleanInputSources(plugin.PluginAssembly);
			}
			// Clean event bindings that are still linked to the disposed Assembly.
			if (oldPlugins != null)
			{
				foreach (CorePlugin plugin in oldPlugins)
					CleanEventBindings(plugin.PluginAssembly);
			}
		}
Exemplo n.º 47
0
        IEnumerable<PackageOperationResult> CopyPackagesToRepositories(IEnumerable<IPackageRepository> sourceRepositories,
            DependencyResolutionResult resolvedPackages,
            IEnumerable<IPackageRepository> destinationRepositories)
        {
            var publishingRepos = destinationRepositories.NotNull().OfType<ISupportPublishing>().ToList();
            foreach (var foundPackage in resolvedPackages.SuccessfulPackages)
            {
                foreach (var destinationRepository in publishingRepos)
                {
                    var existingUpToDateVersion = GetExistingPackage(destinationRepository, foundPackage, x => x >= foundPackage.Identifier.Version);
                    if (existingUpToDateVersion == null)
                    {
                        var sourcePackage = GetBestSourcePackage(sourceRepositories, foundPackage.Packages);

                        _deployer.DeployDependency(sourcePackage, destinationRepository);
                        var existingVersion = GetExistingPackage(destinationRepository, foundPackage, x => x < foundPackage.Identifier.Version);

                        yield return existingVersion == null
                            ? new PackageAddedResult(sourcePackage, destinationRepository)
                            : new PackageUpdatedResult(existingVersion, sourcePackage, destinationRepository);
                    }
                    else
                    {
                        yield return new PackageUpToDateResult(existingUpToDateVersion, destinationRepository);
                    }
                }
            }
            foreach (var repo in publishingRepos)
                repo.PublishCompleted();
        }
		public RigidBodyShapeAction(IEnumerable<ShapeInfo> obj)
		{
			if (obj == null) throw new ArgumentNullException("obj");
			this.targetObj = obj.NotNull().ToArray();
		}