本文整理汇总了C#中System.Union方法的典型用法代码示例。如果您正苦于以下问题:C# System.Union方法的具体用法?C# System.Union怎么用?C# System.Union使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类System
的用法示例。
在下文中一共展示了System.Union方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。
示例1: ThemedRazorViewEngine
public ThemedRazorViewEngine(string theme)
{
var additionalViewLocations = new[]{
String.Format("~/Assets/themes/{0}/html/{{1}}/{{0}}.cshtml", theme),
String.Format("~/Assets/themes/{0}/html/Shared/{{0}}.cshtml", theme)
};
ViewLocationFormats = additionalViewLocations.Union(ViewLocationFormats).ToArray();
MasterLocationFormats = additionalViewLocations.Union(MasterLocationFormats).ToArray();
PartialViewLocationFormats = additionalViewLocations.Union(PartialViewLocationFormats).ToArray();
}
示例2: Application_Start
protected void Application_Start()
{
System.Web.Mvc.RazorViewEngine rve = (RazorViewEngine)ViewEngines.Engines
.Where(e => e.GetType() == typeof(RazorViewEngine))
.FirstOrDefault();
string[] customViewLocations = new[] {
"~/Custom/Views/{1}/{0}.cshtml",
"~/Custom/Views/Shared/{0}.cshtml"
};
if (rve != null)
{
rve.PartialViewLocationFormats = customViewLocations
.Union(rve.PartialViewLocationFormats)
.ToArray();
rve.MasterLocationFormats = customViewLocations
.Union(rve.MasterLocationFormats)
.ToArray();
rve.ViewLocationFormats = customViewLocations
.Union(rve.ViewLocationFormats)
.ToArray();
}
/*
ViewEngines.Engines.Clear();
var razorEngine = new RazorViewEngine();
razorEngine.MasterLocationFormats = razorEngine.MasterLocationFormats
.Concat(new[] {
"~/Custom/Views/{1}/{0}.cshtml", // {1} = controller name
"~/Custom/Views/Shared/{0}.cshtml"
}).ToArray();
razorEngine.PartialViewLocationFormats = razorEngine.PartialViewLocationFormats
.Concat(new[] {
"~/Custom/Views/{1}/{0}.cshtml", // {1} = controller name
"~/Custom/Views/Shared/{0}.cshtml"
}).ToArray();
ViewEngines.Engines.Add(razorEngine);
*/
AreaRegistration.RegisterAllAreas();
FilterConfig.RegisterGlobalFilters(GlobalFilters.Filters);
RouteConfig.RegisterRoutes(RouteTable.Routes);
BundleConfig.RegisterBundles(BundleTable.Bundles);
}
示例3: Compile
public static Assembly Compile(SyntaxTree tree, string dllName)
{
var myRefs =
new[] {
"System", "System.Core", "mscorlib", "System.Runtime"
}.Select(MetadataReference.CreateAssemblyReference);
var obsRef = new MetadataFileReference(typeof(Observable).Assembly.Location);
var synRef = new MetadataFileReference(typeof(CommonSyntaxTree).Assembly.Location);
var comRef = new MetadataFileReference(typeof(CompilationOptions).Assembly.Location);
myRefs = myRefs.Union(new[] { obsRef, synRef, comRef });
var compiledCode = Compilation.Create(
outputName: dllName,
options: new CompilationOptions(OutputKind.DynamicallyLinkedLibrary),
syntaxTrees: new[] { tree },
references: myRefs);
using (var stream = new MemoryStream())
{
var emitResult = compiledCode.Emit(stream);
if (!emitResult.Success)
{
var message = string.Join("\r\n", emitResult.Diagnostics);
throw new ApplicationException(message);
}
return Assembly.Load(stream.GetBuffer());
}
}
示例4: Thumbnail
public static void Thumbnail(FileStoreInfo originalImageFileInfo, ThumbnailProperty thumbnailProperty, IThumbnailNameProvider thumbnailWriteProvider = null, params ThumbnailProperty[] thumbnailProperties)
{
var defaultThumbnailWriteProvider = thumbnailWriteProvider;
if (originalImageFileInfo == null)
throw new ArgumentNullException("originalImageFileInfo");
if (string.IsNullOrEmpty(originalImageFileInfo.FileNameWithExtension))
throw new ArgumentException("originalImageFileInfo.FileNameWithExtension不能为空");
if (thumbnailProperty == null)
throw new ArgumentNullException("thumbnailProperty");
if (!File.Exists(originalImageFileInfo.FullFileName))
throw new FileNotFoundException(string.Format("路径:{0}的不存在", originalImageFileInfo.FullFileName));
if (thumbnailWriteProvider == null)
defaultThumbnailWriteProvider = new DefaultThumbnailNameProvider();
var unionThumbnailPropertyies = new[] { thumbnailProperty };
if (thumbnailProperties != null)
{
unionThumbnailPropertyies = unionThumbnailPropertyies.Union(thumbnailProperties).ToArray();
}
var originalImage = System.Drawing.Image.FromFile(originalImageFileInfo.FullFileName);
foreach (var property in unionThumbnailPropertyies)
{
var fileInfo = defaultThumbnailWriteProvider.GetThumbnailFileInfo(originalImageFileInfo, thumbnailProperty);
var thumbnailImage = CreateThumbnailImage(originalImage, property);
thumbnailImage.Save(fileInfo.FullFileName);
}
}
示例5: EventSourceMock
public void When_getting_all_event_from_an_existing_event_source_the_result_should_be_all_events_stored_for_that_event_source()
{
var eventSourceId = Guid.NewGuid();
var mock = new EventSourceMock();
mock.EventSourceId = eventSourceId;
var store = new InMemoryEventStore();
var events1 = new[]{
new SomethingDoneEvent(eventSourceId), new SomethingDoneEvent(eventSourceId),
};
var events2 = new[]{
new SomethingDoneEvent(eventSourceId), new SomethingDoneEvent(eventSourceId), new SomethingDoneEvent(eventSourceId)
};
mock.GetUncommittedEventsStub = () => events1;
store.Save(mock);
mock.GetUncommittedEventsStub = () => events2;
store.Save(mock);
var events = store.GetAllEvents(eventSourceId);
var unionOfStoredEvents = events1.Union(events2);
events.Count().Should().Be(unionOfStoredEvents.Count());
events.Should().BeEquivalentTo(unionOfStoredEvents);
}
示例6: GetFieldNames
public override IEnumerable<string> GetFieldNames()
{
var hardcodedAttributes = new[] {"name", "schema-name", "schema-id"};
var elementAttributes = _source.Attributes().Select(xAttribute => xAttribute.Name.LocalName);
var childAttributes = _source.Elements().Where(x=>x.Attribute("isDoc") == null).Select(xChild => xChild.Name.LocalName);
return hardcodedAttributes.Union(elementAttributes).Union(childAttributes);
}
示例7: Set
public void Set(object target, object value, params object[] index)
{
IEnumerable<object> args = new[] { value };
if (index != null) args = args.Union(index);
if (target != null && !target.GetType().CanAssign(InternalMember.DeclaringType))
throw new TargetException("Expected {0}".AsFormat(InternalMember.DeclaringType.GetRealClassName()));
Cache.GetSetter(InternalMember)(target, args.ToArray());
}
示例8: Sign
/// <summary>
/// Usefull for testing encryption refactoring so that I can generate the same signature twice
/// </summary>
/// <param name="nonce"> </param>
/// <param name="localtime"> </param>
/// <param name="kvp"> </param>
/// <returns> </returns>
public string Sign(string nonce, DateTime localtime, IEnumerable<KeyValuePair<string, string>> kvp)
{
var timestamp = LocalTimeToUnixTimestampSeconds(localtime);
// ReSharper disable SpecifyACultureInStringConversionExplicitly
var otherSignature = new[]{new KeyValuePair<string, string>("nonce", nonce), new KeyValuePair<string, string>("timestamp", timestamp.ToString())};
// ReSharper restore SpecifyACultureInStringConversionExplicitly
var urlEncoded = string.Join("&", otherSignature.Union(kvp).Select(item => HttpUtility.UrlEncode(item.Key) + "=" + HttpUtility.UrlEncode(item.Value)));
return string.Format("{0}|{1}", Sign(urlEncoded), urlEncoded);
}
示例9: Can_union_two_lists
public void Can_union_two_lists()
{
// Arrange
var first = new[] {new TestObject("a", "a"), new TestObject("a", "b")};
var second = new[] {new TestObject("a", "b"), new TestObject("b", "a")};
// Act
var result = first.Union(second, (x, y) => x.One == y.One && x.Two == y.Two, x => (x.One ?? "").GetHashCode() ^ (x.Two ?? "").GetHashCode()).ToArray();
// Assert
Assert.AreEqual(3, result.Length);
}
示例10: Can_union_two_lists_with_overriden_gethashcode
public void Can_union_two_lists_with_overriden_gethashcode()
{
// Arrange
var first = new[] {new Test2Object("a", "a"), new Test2Object("a", "b")};
var second = new[] {new Test2Object("a", "b"), new Test2Object("b", "a")};
// Act
var result = first.Union(second, (x, y) => x.One == y.One && x.Two == y.Two).ToArray();
// Assert
Assert.AreEqual(3, result.Length);
}
示例11: ShouldGetAllLogFiles
public void ShouldGetAllLogFiles()
{
var fileSystem = new Moq.Mock<IFileSystem>();
var logFiles = new[] { @"C:\Path\backup-1234567890.csv" };
var nonLogFiles = new[] { @"C:\Path\no-match.csv" };
fileSystem.Setup(x => x.GetCommonApplicationDataPath()).Returns(@"C:\Path");
fileSystem.Setup(x => x.GetFiles(@"C:\Path\cache\logs")).Returns(logFiles.Union(nonLogFiles));
var target = new JungleDiskLogFilesProvider(fileSystem.Object, new AutomaticLogFilePath(fileSystem.Object));
var result = target.GetAllLogFiles();
result.Should().Have.SameSequenceAs(logFiles);
}
示例12: Initialize
public static void Initialize(string path)
{
var dll = new[]
{
"HtmlAgilityPack.dll",
"lnE.dll",
};
var references = ConfigurationManager.AppSettings["references"];
if (!String.IsNullOrWhiteSpace(references))
{
dll = dll.Union(references.Split(new[] { "," }, StringSplitOptions.RemoveEmptyEntries)).ToArray();
}
assembly = AssemblyHelper.GetAssembly(dll, path);
dishes = AssemblyHelper.GetTypes<DishAttribute>(assembly);
}
示例13: CollectionMath_Test
public static void CollectionMath_Test()
{
var arr1 = new[] {1, 2, 3, 4, 5, 6};
var arr2 = new[] {2, 9};
var test1 = arr1.Intersect(arr2);
var test2 = arr1.Union(arr2);
var test3 = arr1.Except(arr2);
Console.WriteLine(arr1.Select(x => x.ToString()).Aggregate((x, y) => x + "," + y));
Console.WriteLine(arr2.Select(x => x.ToString()).Aggregate((x, y) => x + "," + y));
Console.WriteLine("--------------------------------------------------------------");
Console.WriteLine(test1.Select(x => x.ToString()).Aggregate((x, y) => x + "," + y));
Console.WriteLine(test2.Select(x => x.ToString()).Aggregate((x, y) => x + "," + y));
Console.WriteLine(test3.Select(x => x.ToString()).Aggregate((x, y) => x + "," + y));
}
示例14: CollectionsAreUnioned
public void CollectionsAreUnioned()
{
var typeMapper = Mapper.CreateMapper<T1, T2>();
typeMapper.Collection(t => t.IntCollection, () => new List<int>(), null).MapsTo(t => t.LongCollection, () => new List<long>(), null);
var ints = new[] { 1, 2, 3 };
var longs = new[] { 1L, 2L, 4L };
T1 t1 = new T1() { IntCollection = ints };
T2 t2 = new T2() { LongCollection = longs };
Mapper.Map(t1, t2);
var longUnion = longs.Union(ints.Select(i => (long)i));
Assert.IsTrue(t2.LongCollection.SequenceEqual(longUnion));
}
示例15: InterfacesContainedInClassesNameAreBound
public void InterfacesContainedInClassesNameAreBound()
{
var type = typeof(MultipleInterfaceCrazyService);
var expectedInterfaces = new[]
{
typeof(ICrazyService),
typeof(IMultipleInterfaceCrazyService),
typeof(IService),
typeof(IService<int>),
};
var unexpectedInterfaces = new[] { typeof(IFoo), typeof(IBar) };
var allInterfaces = expectedInterfaces.Union(unexpectedInterfaces).OrderBy(t => t.Name);
this.bindableInterfaceSelectorMock.Setup(s => s.GetBindableInterfaces(type)).Returns(allInterfaces);
this.testee.CreateBindings(type, this.kernelMock.Object).ToList();
this.multiBindingCreatorMock.Verify(mbc => mbc.CreateBindings(
this.kernelMock.Object,
It.Is<IEnumerable<Type>>(t => t.SequenceEqual(expectedInterfaces)),
type));
}
开发者ID:EstevaoLuis,项目名称:ninject.extensions.conventions,代码行数:21,代码来源:DefaultInterfacesBindingGeneratorTests.cs