本文整理汇总了C#中System.IO类的典型用法代码示例。如果您正苦于以下问题:C# System.IO类的具体用法?C# System.IO怎么用?C# System.IO使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。
System.IO类属于命名空间,在下文中一共展示了System.IO类的20个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于我们的系统推荐出更棒的C#代码示例。
示例1: Main
static void Main(string[] args)
{
const string categoryName = "Likes";
var methods = new[]
{
"likes.getList",
"likes.add",
"likes.delete",
"likes.isLiked"
};
var parser = new VkApiParser();
var generator = new VkApiGenerator();
var source = InitializeSource(categoryName);
foreach (string methodName in methods)
{
System.Console.WriteLine("*** {0} ***", methodName);
VkMethodInfo methodInfo;
try
{
methodInfo = parser.Parse(methodName);
}
catch (WebException ex)
{
System.Console.WriteLine(ex.Message);
continue;
}
System.Console.WriteLine("DESCRIPTION: {0}", methodInfo.Description);
System.Console.WriteLine("RETURN TEXT: {0}", methodInfo.ReturnText);
System.Console.WriteLine("RETURN TYPE: {0}", methodInfo.ReturnType);
System.Console.WriteLine("PAPAMETERS:");
foreach (var p in methodInfo.Params)
{
System.Console.WriteLine(" {0} - {1}", p.Name, p.Description);
}
source.Append(generator.GenerateMethod(methodInfo))
.AppendLine()
.AppendLine();
System.Console.WriteLine("\n========================================\n");
//System.Console.ReadLine();
}
source.Append("}}");
System.Console.WriteLine("Saving to disk");
string path = Path.GetDirectoryName(Assembly.GetExecutingAssembly().Location);
path = Path.Combine(path, @"..\VkNet\Categories\");
path = string.Format("{0}\\{1}Category_Generated.cs", path, categoryName);
File.WriteAllText(path, source.ToString());
System.Console.WriteLine("done.");
}
开发者ID:G-IT-ED,项目名称:vk,代码行数:59,代码来源:Program.cs
示例2: given_empty_cache_and_valid_commit_function
public void given_empty_cache_and_valid_commit_function()
{
var cache = new LockingInMemoryCache();
long? commitStoreVersion = null;
long? commitStreamVersion = null;
cache.ConcurrentAppend("stream", GetEventBytes(1), (version, storeVersion) =>
{
commitStoreVersion = storeVersion;
commitStreamVersion = version;
});
Assert.AreEqual(1, commitStoreVersion, "commitStoreVersion");
Assert.AreEqual(1, commitStreamVersion, "commitStreamVersion");
Assert.AreEqual(1, cache.StoreVersion);
var expected = new[]
{
CreateKey(1, 1, "stream"),
};
DataAssert.AreEqual(expected, cache.ReadStream("stream",0,100));
DataAssert.AreEqual(expected, cache.ReadAll(0, 100));
}
开发者ID:mojamcpds,项目名称:lokad-cqrs-1,代码行数:25,代码来源:when_doing_concurrent_append.cs
示例3: GenerateCompareOperatorCode
public static void GenerateCompareOperatorCode() {
var s = new StringBuilder();
var types = new[] {
"DynamicValue", "bool", "byte", "sbyte", "char", "decimal", "double", "float",
"int", "uint", "long", "ulong", "short", "ushort", "string"
};
var operators = new[] {"==", "!=", ">", "<", ">=", "<="};
foreach (string @operator in operators) {
foreach (string type1 in types) {
string typeName = type1;
s.AppendLine("public static bool operator " + @operator + "(DynamicValue p1, " + typeName + " p2) {");
if (typeName == "DynamicValue") {
s.AppendLine("return (p1.Value " + @operator + " (dynamic)p2.To(p1.Type));");
}
else {
s.AppendLine("return (p1.Value " + @operator + " (dynamic)DynamicConversion.To(p1.Type, p2));");
}
s.AppendLine("}");
s.AppendLine();
}
}
File.WriteAllText("code.cs", s.ToString());
}
开发者ID:MartijnB,项目名称:DynamicType.NET,代码行数:29,代码来源:CodeGen.cs
示例4: GetRunning
public bool GetRunning()
{
var json = _wc.DownloadString(URL + "?action=getStatus");
var status = new { running = false };
status = Newtonsoft.Json.JsonConvert.DeserializeAnonymousType(json, status);
return status.running;
}
开发者ID:knabbi,项目名称:GW2WBot,代码行数:7,代码来源:StatusAPI.cs
示例5: TransformToGrayscaleFromArray
public void TransformToGrayscaleFromArray()
{
foreach (var data in TestUtils.GetTestImagesData("*.jpg"))
{
Assert.DoesNotThrow(() =>
{
var transforms = new[]
{
new TJTransformDescription
{
Operation = TJTransformOperations.TJXOP_NONE,
Options = TJTransformOptions.GRAY,
Region = TJRegion.Empty
}
};
var result = _transformer.Transform(data.Item2, transforms, TJFlags.NONE);
Assert.NotNull(result);
Assert.NotNull(result.Length == 1);
var file = Path.Combine(OutDirectory, "gray_" + Path.GetFileName(data.Item1));
File.WriteAllBytes(file, result[0]);
});
}
}
开发者ID:qmfrederik,项目名称:AS.TurboJpegWrapper,代码行数:25,代码来源:TJTransformerTests.cs
示例6: SortObjectCanBeSortedByMonsterIdAndMark
public void SortObjectCanBeSortedByMonsterIdAndMark()
{
var s = new[]{
new SortedBoxObject { Mark = 0, MonsterId = 3 },
new SortedBoxObject { Mark = 0, MonsterId = 2 },
new SortedBoxObject { Mark = 0, MonsterId = 3 },
new SortedBoxObject { Mark = 0, MonsterId = 1 },
new SortedBoxObject { Mark = 1, MonsterId = 3 },
new SortedBoxObject { Mark = 1, MonsterId = 2 },
new SortedBoxObject { Mark = 2, MonsterId = 3 },
new SortedBoxObject { Mark = 1, MonsterId = 1 },
new SortedBoxObject { Mark = 0, MonsterId = 0 }
};
var r = s.OrderBy( o=> o ).ToArray();
Assert.AreSame( s[6], r[0] );
Assert.AreSame( s[7], r[1] );
Assert.AreSame( s[5], r[2] );
Assert.AreSame( s[4], r[3] );
Assert.AreSame( s[8], r[4] );
Assert.AreSame( s[3], r[5] );
Assert.AreSame( s[1], r[6] );
Assert.AreSame( s[0], r[7] );
Assert.AreSame( s[2], r[8] );
}
开发者ID:Zazcallabah,项目名称:PokeSave,代码行数:26,代码来源:PcBufferTests.cs
示例7: IsSupported
private static bool IsSupported(string fileName)
{
string extension = Path.GetExtension(fileName).ToLowerInvariant();
string[] allowed = new[] { ".js", ".css", ".html", ".htm", ".less", ".scss", ".coffee", ".iced", ".config", ".cs", "vb" };
return allowed.Contains(extension);
}
开发者ID:vandro,项目名称:FileNesting,代码行数:7,代码来源:PathSegmentFileNester.cs
示例8: RenderTexture
public static void RenderTexture(TextureInfo textureInfo, float x, float y, float orientation = 0,
float offsetX = 0, float offsetY = 0,
LabelStyle.HorizontalAlignmentEnum horizontalAlignment = LabelStyle.HorizontalAlignmentEnum.Center,
LabelStyle.VerticalAlignmentEnum verticalAlignment = LabelStyle.VerticalAlignmentEnum.Center,
float opacity = 1f,
float scale = 1f)
{
GL.Enable(All.Texture2D);
GL.BindTexture(All.Texture2D, textureInfo.TextureId);
GL.PushMatrix();
GL.Translate(x, y, 0f);
GL.Rotate(orientation, 0, 0, 1);
GL.Scale (scale, scale, 1);
x = offsetX + DetermineHorizontalAlignmentCorrection(horizontalAlignment, textureInfo.Width);
y = -offsetY + DetermineVerticalAlignmentCorrection(verticalAlignment, textureInfo.Height);
var halfWidth = textureInfo.Width / 2;
var halfHeight = textureInfo.Height / 2;
var vertextArray = new[]
{
x - halfWidth, y - halfHeight,
x + halfWidth, y - halfHeight,
x + halfWidth, y + halfHeight,
x - halfWidth, y + halfHeight
};
RenderTextureWithoutBinding(textureInfo.TextureId, vertextArray, opacity);
GL.PopMatrix();
GL.BindTexture(All.Texture2D, 0);
GL.Disable(All.Texture2D);
}
开发者ID:pauldendulk,项目名称:Mapsui,代码行数:35,代码来源:TextureHelper.cs
示例9: FiltersEventsWithLevelExactValue
public void FiltersEventsWithLevelExactValue()
{
var expected = new[]
{
new EventExpectation
{
Level = Level.Error,
Logger = "Root.ChildA.LoggerA1",
Thread = "Thread-5",
Timestamp = 1411231353795L,
Message = "#5. Test event F.",
Throwable = null,
Id = 672
}
};
using (var sourceStream = new MemoryStream (sampleBytes))
using (var source = Log4JFile.Create (sourceStream))
using (var subject = new FilterLevel (Level.Error, Level.Error))
{
source.Encoding = Encoding.GetEncoding (1251);
var actual = source.GetEvents ().Where (subject);
Assert.That (actual, Is.EqualTo (expected));
}
}
开发者ID:MaxKot,项目名称:Log4JDash,代码行数:25,代码来源:FilterLevelTests.cs
示例10: IsSatisifedBy
public bool IsSatisifedBy(string path)
{
var fileExt = Path.GetExtension(path);
var extensions = new[] { "PNG", "PCX", "JPG", "JPEG", "GIF", "TIF", "BMP", "TGA", };
if (fileExt != null && fileExt != "") fileExt = fileExt.Substring(1).ToUpper();
return extensions.Any(extension => fileExt != null && fileExt.Equals(extension));
}
开发者ID:bsimser,项目名称:goldbox,代码行数:7,代码来源:ImagePlugin.cs
示例11: GetPrelude
private static string GetPrelude(DirectoryInfo dir)
{
var preludeFile = new[] { dir, dir.Parent }.
SelectMany(d => d.GetFiles("prelude.*", SearchOption.TopDirectoryOnly))
.FirstOrDefault(f => f.Exists);
return preludeFile == null ? "" : preludeFile.ContentAsUtf8();
}
开发者ID:andgein,项目名称:uLearn,代码行数:7,代码来源:CSharpSlideLoader.cs
示例12: ComplexTest
public void ComplexTest()
{
var source =
@"{{#each nav ~}}
<a href=""{{url}}"">
{{~#if test}}
{{~title}}
{{~else~}}
Empty
{{~/if~}}
</a>
{{~/each}}";
var template = Handlebars.Compile(source);
var data = new {
nav = new [] {
new {
url = "https://google.com",
test = true,
title = "Google"
},
new {
url = "https://bing.com",
test = false,
title = "Bing"
}
}
};
var result = template(data);
Assert.AreEqual(@"<a href=""https://google.com"">Google</a><a href=""https://bing.com"">Empty</a>", result);
}
开发者ID:amaclean,项目名称:Handlebars.Net,代码行数:30,代码来源:WhitespaceTests.cs
示例13: Parse
public TextureAtlas Parse(string dataFilePath)
{
if (!File.Exists(dataFilePath))
{
throw new FileNotFoundException(nameof(dataFilePath) + $" : {dataFilePath}");
}
var xml = XDocument.Load(dataFilePath);
var atlasDetails = new {
Width = (int)xml.Element("TextureAtlas").Attribute("width"),
Height = (int)xml.Element("TextureAtlas").Attribute("height"),
TextureRegions = from s in xml.Root.Descendants("sprite")
select new {
X = (int)s.Attribute("x"),
Y = (int)s.Attribute("y"),
Width = (int)s.Attribute("w"),
Height = (int)s.Attribute("h")
}
};
var textureAtlas = new TextureAtlas(atlasDetails.Width, atlasDetails.Height);
foreach (var region in atlasDetails.TextureRegions)
{
textureAtlas.Add(new TextureRegion(region.X, region.Y, region.Width, region.Height));
}
return textureAtlas;
}
开发者ID:rmckirby,项目名称:XogoEngine,代码行数:26,代码来源:TexturePackerParser.cs
示例14: non_dotnet_files_are_skipped
public void non_dotnet_files_are_skipped()
{
var assemblyScanner = new AssemblyScanner(Path.Combine(TestContext.CurrentContext.TestDirectory, "TestDlls"));
var results = assemblyScanner
.GetScannableAssemblies();
var skippedFiles = results.SkippedFiles;
var notProperDotNetDlls = new[]
{
"libzmq-v120-mt-3_2_3.dll",
"Tail.exe",
"some_random.dll",
"some_random.exe"
};
foreach (var notProperDll in notProperDotNetDlls)
{
var skippedFile = skippedFiles.FirstOrDefault(f => f.FilePath.Contains(notProperDll));
if (skippedFile == null)
{
throw new AssertionException($"Could not find skipped file matching {notProperDll}");
}
Assert.That(skippedFile.SkipReason, Contains.Substring("not a .NET assembly"));
}
}
开发者ID:Particular,项目名称:NServiceBus,代码行数:29,代码来源:When_directory_with_non_dot_net_dll_is_scanned.cs
示例15: TransformImpl
protected TribitPyramid TransformImpl(TribitPyramid tribitPyramid)
{
var indices = tribitPyramid.GetPyramidIndices();
var bitscnt = new[] { 0, 0 };
for (var i = 0; i < indices.Length; ++i) {
var triange = tribitPyramid[indices[i]];
var tribitPyramidRule = TribitPyramidRule.GetBy(triange);
if (tribitPyramidRule != null) {
tribitPyramid[indices[i]] = tribitPyramidRule.To;
}
else {
bitscnt[triange[0]]++;
}
}
if (bitscnt[0] + bitscnt[1] == indices.Length) {
if (bitscnt[0] == 0) return new TribitPyramid(1);
if (bitscnt[1] == 0) return new TribitPyramid(0);
var bits = new byte[tribitPyramid.Count >> 2];
for (var i = 0; i < bits.Length; ++i) {
bits[i] = tribitPyramid[indices[i]][0];
}
return new TribitPyramid(bits);
}
return tribitPyramid;
}
开发者ID:steelmaker,项目名称:interview,代码行数:26,代码来源:TribitPyramidTransformer.cs
示例16: DownloadFile
public void DownloadFile()
{
var path = packet.args.First().ToString();
if (File.Exists(path))
{
var fileName = Path.GetFileName(path);
var size = new FileInfo(path).Length;
var data = new
{
fileValid = true,
fileName,
size
};
serializator.Serialize(_client, packet.endpoint, packet.syncKey, data);
serializator.PushFile(_client, path);
}
else
{
var data = new
{
fileValid = false
};
serializator.Serialize(_client, packet.endpoint, packet.syncKey, data);
}
}
开发者ID:jakop345,项目名称:ulterius-server,代码行数:25,代码来源:FileController.cs
示例17: CreatePackage_SetContentFilesMetadata
public async Task CreatePackage_SetContentFilesMetadata()
{
var result = await Scenario.RestoreAndBuildSinglePackageAsync();
var solutionPath = Assets.GetScenarioSolutionPath();
var projectPath = Path.GetDirectoryName(solutionPath);
var nuspecFile = Path.Combine(projectPath, @"Package\obj\Debug\Package.nuspec");
Manifest manifest;
using (var stream = File.OpenRead(nuspecFile))
{
manifest = Manifest.ReadFrom(stream, false);
}
var expected = new[]
{
new ManifestContentFiles { [email protected]"any\any\1x1.png", BuildAction="EmbeddedResource", CopyToOutput="false", Flatten="false"},
new ManifestContentFiles { [email protected]"any\any\TextFile.txt", BuildAction="None", CopyToOutput="true", Flatten="false"},
new ManifestContentFiles { [email protected]"cs\any\Class.cs.pp", CopyToOutput="false", Flatten="false"},
new ManifestContentFiles { [email protected]"cs\any\Class1.cs.pp", CopyToOutput="false", Flatten="false"}
};
Assert.Equal<ManifestContentFiles>(
expected,
manifest.Metadata.ContentFiles.OrderBy(x => x.Include),
ManifestContentFilesComparer.Instance);
}
开发者ID:kovalikp,项目名称:nuproj,代码行数:25,代码来源:CreatePackageTests.cs
示例18: Main
private static void Main()
{
using (var csv = new CsvWriter(new StreamWriter("results.csv", false, Encoding.UTF8)))
{
WriteHeader(csv);
var languagesToTest = new[] {Languages.EnglishUK, Languages.GermanGermany};
foreach (var language in languagesToTest)
{
var results = new AutoCorrectTester(language).Run();
foreach (var result in results)
{
foreach (var testResult in result.Results)
{
csv.WriteField(language);
csv.WriteField(result.AutoCompleteMethod);
csv.WriteField(result.MemorySize);
csv.WriteField(testResult.Misspelling);
csv.WriteField(testResult.TargetWord);
csv.WriteField(testResult.CharactersTyped);
csv.WriteField(testResult.TargetWord.Length);
csv.WriteField(testResult.TimeTaken.Milliseconds);
csv.WriteField(testResult.CharactersTyped != -1
? (double) testResult.CharactersTyped/testResult.TargetWord.Length
: 2d);
csv.NextRecord();
}
}
}
}
}
开发者ID:EddPorter,项目名称:OptiKey,代码行数:32,代码来源:Program.cs
示例19: PackageIsCorrect
public void PackageIsCorrect()
{
this.SetupTest("ExtractXSLTWorks", isPackTest: true);
var files = new[]
{
"GenerateProject.CSharp.xslt",
"GenerateProject.CPlusPlus.MonoDevelop.xslt",
"GenerateProject.CPlusPlus.VisualStudio.xslt",
"GenerateSolution.xslt",
"GenerationFunctions.cs",
"SelectSolution.xslt",
};
foreach (var file in files)
{
if (File.Exists(this.GetPath("Build\\" + file)))
{
File.Delete(this.GetPath("Build\\" + file));
}
}
this.OtherMode("extract-xslt");
foreach (var file in files)
{
_assert.True(File.Exists(this.GetPath("Build\\" + file)));
}
}
开发者ID:marler8997,项目名称:Protobuild,代码行数:29,代码来源:ExtractXSLTWorksTest.cs
示例20: Should_Generate_HTML_References_with_pre_and_post_text
public void Should_Generate_HTML_References_with_pre_and_post_text()
{
// Arrange
var compilers = new[] { new JQueryTemplateCompiler(), };
var referencer = new LABjsScriptReference();
var package = new Package(".", compilers, referencer);
var references = new[]
{
new SystemReference(new DirectoryInfo("C:/Root/"), new FileInfo("C:/Root/Scripts/depper1.js"), "depper1.js")
{
Type = Reference.TypeEnum.App
}
};
// Act
var result = package.GenerateReferences(references, new HelperOptions { GenerateHeaderAndFooter = true });
// Assert
result.ShouldBe(
@"<script>
$LAB
.script(""/hotglue.axd/Scripts/depper1.js-app"");
</script>
");
}
开发者ID:nathanpalmer,项目名称:hotglue,代码行数:27,代码来源:GenerateReferenceTests.cs
注:本文中的System.IO类示例整理自Github/MSDocs等源码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。 |
请发表评论